Skip to content

Commit

Permalink
[Module]
Browse files Browse the repository at this point in the history
1. Add EZMesh controller and library.
2. Remove cpcd and cpc library.
[Integrate]
1. Add systmed for debian.
[SDK]
1. Modify build flow.
2. Modify systemd service.
  • Loading branch information
rex authored and rex committed Jan 24, 2024
1 parent 5cf6817 commit 01d79cf
Show file tree
Hide file tree
Showing 198 changed files with 8,526 additions and 11,589 deletions.
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
cmake_minimum_required(VERSION 3.21)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
cmake_minimum_required(VERSION 3.10)
include(project.conf)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")
include(extension)
include(banner)
include(default)
include(project)
set(PROJECT_VER "")
get_git_hash(PROJECT_VER)
message("Current project git information: ${PROJECT_VER}")

project(RAFAEL_HOST_SDK LANGUAGES C CXX)
add_subdirectory(module)
ext_add_subdirectory(module)
ext_add_subdirectory_ifdef(CONFIG_GEN_SYSTEM integrate)
64 changes: 35 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
# EZMesh
## Introduction
The EZMesh Project is the Host Daemon of Rafael's CPC Dongle (Rafael Multi-protocol RCP). The EZMesh, which use a single Rafael's CPC Dongle, can support Host OS using different communication protocol at the same time. The EZMesh currently supports Bluetooth, Thread, and Matter
The EZMesh Project is the Host Daemon of Rafael's EZmesh Dongle (Rafael Multi-protocol RCP). The EZMesh, which uses a single Rafael's EZmesh Dongle, can support the Host OS using different communication protocols simultaneously.

The EZMesh Project is supported by [Rafael Micro](https://www.rafaelmicro.com/).
The EZMesh currently supports:
- **Bluetooth**
- **Sub-G**
- **Thread**
- **Matter**
- **Zigbee**

Recommend Platform:
- Ubuntu 22.04.3 LTS (Ubuntu-based)
- Raspberry Pi OS (Legacy) Lite (Debian-based)
- Release date: December 5th 2023
- System: 64-bit
- Kernel version: 6.1
- Debian version: 11 (bullseye)

**The EZMesh Project is supported by [Rafael Micro](https://www.rafaelmicro.com/).**

---
## Prepare Env
```
$ sudo apt update \
&& sudo apt install git mosquitto libsystemd-dev net-tools curl
$ sudo apt update && sudo apt install git mosquitto libsystemd-dev net-tools curl gcc
```
---
## Project setup and pre-install
### clone EZMesh
### Clone EZMesh
```
$ [email protected]:RafaelMicro/EZMesh.git
$ git clone git@github.com:RafaelMicro/EZMesh.git
```
### Install Cmake
- Ubuntu based platfrom
- Ubuntu-based platform
```
$ sudo curl -L https://github.com/Kitware/CMake/releases/download/v3.21.6/cmake-3.21.6-linux-x86_64.sh --output /tmp/cmake-3.21.6-linux-x86_64.sh \
&& sudo chmod +x /tmp/cmake*.sh \
&& sudo /tmp/cmake*.sh --prefix=/usr/local --skip-license \
&& sudo rm /tmp/cmake*
&& sudo chmod +x /tmp/cmake*.sh && sudo /tmp/cmake*.sh --prefix=/usr/local --skip-license && sudo rm /tmp/cmake*
```
- Debian based platfrom
- Debian-based platform
```
$ sudo curl -L https://github.com/Kitware/CMake/releases/download/v3.21.6/cmake-3.21.6-linux-aarch64.sh --output /tmp/cmake-3.21.6-linux-aarch64.sh \
&& sudo chmod +x /tmp/cmake*.sh \
&& sudo /tmp/cmake*.sh --prefix=/usr/local --skip-license \
&& sudo rm /tmp/cmake*
&& sudo chmod +x /tmp/cmake*.sh && sudo /tmp/cmake*.sh --prefix=/usr/local --skip-license && sudo rm /tmp/cmake*
```
### Bluetooth pre-install
Rafael's EZMesh bluetooth based on Bluez, so makesure Bluez already in your Host.
Rafael's EZMesh Bluetooth is based on Bluez, so make sure Bluez is already in your Host.
### Border Router pre-install
```
$ sudo NAT64=1 module/border_router/ot-br-posix/script/bootstrap
Expand All @@ -46,39 +56,35 @@ $ ifconfig
```
- Build project (example network interface is enp0s3)
```
$ mkdir build && cd build \
&& cmake ../ -DOTBR_INFRA_IF_NAME=enp0s3 && sudo make install && sudo ldconfig\
&& cd ..
$ mkdir build && cd build && cmake ../ -DOTBR_INFRA_IF_NAME=enp0s3 \
&& sudo make install && sudo ldconfig && cd ..
```

---
## Apply Project to system service
### Apply CPC
### Apply EZmesh controller
```
export cpc_path=build/module/cpc/cpcd-system/debconf \
&& sudo bash $cpc_path/prerm && sudo bash $cpc_path/postrm && sudo bash $cpc_path/postinst
$ sudo ./build/integrate/debian/controller/setup
```
### Apply Border Router
```
export br=build/module/border_router/cpc-otbr/debconf \
&& sudo bash $br/prerm && sudo bash $br/postinst
$ sudo ./build/integrate/debian/border_router/setup
```
### Apply Bluetooth

```
export bt=build/module/bluetooth/cpc-bluetooth/debconf \
&& sudo bash $bt/prerm && sudo bash $bt/postinst
$ sudo ./build/integrate/debian/bluetooth/setup
```
- Note: Please makesure you RCP dongle already attach on boot
- Note: All service will auto setup on boot
- Note: Please make sure your RCP dongle is already attached to the boot
- Note: All services will auto setup on boot

---
## Manage system service
### Start all service
```
$ sudo systemctl start cpc-mgmt.service
$ sudo systemctl start ez-mgmt.service
```
### Restart all service
```
$ sudo systemctl restart cpc-mgmt.service
$ sudo systemctl restart ez-mgmt.service
```
15 changes: 15 additions & 0 deletions cmake/banner.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

function(show_banner var)
message("")
message("")
message(" 8888888888 8888888888P 888b d888 888 .d8888b. 8888888b. 888 d8P ")
message(" 888 d88P 8888b d8888 888 d88P Y88b 888 \"Y88b 888 d8P ")
message(" 888 d88P 88888b.d88888 888 Y88b. 888 888 888 d8P ")
message(" 888888888 d88P 888Y88888P888 .d88b. .d8888b 88888b. \"Y888b. 888 888 888d88K ")
message(" 888 d88P 888 Y888P 888 d8P Y8b 88K 888 \"88b \"Y88b. 888 888 8888888b ")
message(" 888 d88P 888 Y8P 888 88888888 \"Y8888b. 888 888 Y88b \"888 888 888 888 Y88b ")
message(" 888 d88P 888 \" 888 Y8b. X88 888 888 Y8888888P 88888888P\" 888 Y88b ")
message(" 8888888888 d8888888888 888 888 \"Y8888 88888P' 888 888 v${var} Powered By Rafael Micro ")
message("")
message("")
endfunction()
14 changes: 14 additions & 0 deletions cmake/default.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

ext_config_ifndef(CONFIG_CONTROLLER true)
ext_config_ifndef(CONFIG_UPGRADE true)
ext_config_ifndef(CONFIG_BLUETOOTH false)
ext_config_ifndef(CONFIG_BORDER_ROUTER false)
ext_config_ifndef(CONFIG_ZIGBEE_GW_SERVICE false)
ext_config_ifndef(CONFIG_SUBG_SERVICE false)

ext_config_ifndef(CONFIG_GEN_SYSTEM false)
ext_config_ifndef(CONFIG_PLATEFROM "")

ext_config_ifndef(EZMESHD_VER "1.0.0")
ext_config_ifndef(EZMESHD_LIB "1")
ext_config_ifndef(EZMESHD_POTOCOL "3")
89 changes: 44 additions & 45 deletions cmake/extension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,29 @@ macro(get_git_hash _git_hash)
OUTPUT_VARIABLE ${_git_hash}
OUTPUT_STRIP_TRAILING_WHITESPACE
# ERROR_QUIET
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
endmacro()

function(ext_set_config_file src)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${src}.in ${CMAKE_CURRENT_BINARY_DIR}/${src})
endfunction()

function(ext_set_config_file_to_dst src dst)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${src}.in ${CMAKE_CURRENT_BINARY_DIR}/${dst})
endfunction()

function(ext_set_config_file_with_gen src)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${src}.in ${CMAKE_CURRENT_BINARY_DIR}/${src}.in)
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${src} INPUT ${CMAKE_CURRENT_BINARY_DIR}/${src}.in)
endfunction()

function(ext_set_config_file_to_dst_with_gen src dst)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${src}.in ${CMAKE_CURRENT_BINARY_DIR}/${dst}.in)
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${dst} INPUT ${CMAKE_CURRENT_BINARY_DIR}/${src}.in)
endfunction()

function(ext_add_subdirectory_ifdef feature dir)
if(${${feature}})
add_subdirectory(${dir})
Expand All @@ -23,58 +40,52 @@ function(ext_add_subdirectory dir)
add_subdirectory(${dir})
endfunction()

function(ext_config define val)
set(${define} ${val})
endfunction()

function(ext_config_ifndef define val)
if(NOT DEFINED ${define})
set(${define} ${val})
endif()
endfunction()

function(ext_install type src dest component)
if("${type}" STREQUAL "EXECUTE")
install(
FILES "${src}"
DESTINATION "${dest}"
PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_EXECUTE
GROUP_READ
WORLD_READ
WORLD_EXECUTE
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_EXECUTE GROUP_READ
WORLD_READ WORLD_EXECUTE
COMPONENT "${component}")
elseif("${type}" STREQUAL "TARGET_HEADER")
install(
TARGETS "${src}" PUBLIC_HEADER
DESTINATION "${dest}"
PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_EXECUTE
GROUP_READ
WORLD_READ
WORLD_EXECUTE
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
COMPONENT "${component}")
elseif("${type}" STREQUAL "TARGET_LIBRARY")
install(
TARGETS "${src}" LIBRARY
DESTINATION "${dest}"
PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_EXECUTE
GROUP_READ
WORLD_READ
WORLD_EXECUTE
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
COMPONENT "${component}")
elseif("${type}" STREQUAL "TARGET_RUNTIME")
install(
TARGETS "${src}" RUNTIME
DESTINATION "${dest}"
PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_EXECUTE
GROUP_READ
WORLD_READ
WORLD_EXECUTE
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
COMPONENT "${component}")
elseif("${type}" STREQUAL "FILE")
install(
Expand All @@ -89,20 +100,8 @@ function(ext_install type src dest component)
FILES_MATCHING
PATTERN *
PERMISSIONS
OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_EXECUTE
GROUP_READ
WORLD_READ
WORLD_EXECUTE)
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
endif()
endfunction()

macro(ext_ifndef define val)
if(NOT DEFINED ${define})
set(${define} ${val})
endif()
endmacro()


40 changes: 0 additions & 40 deletions cmake/modules/FindCPCD.cmake

This file was deleted.

40 changes: 40 additions & 0 deletions cmake/modules/FindEZMESH.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Find the Silicon Labs EZMESH location
# =============================================================================
# Usage of this module is as follows:
#
# find_package(EZMESH)
#
# cmake-format: off
# Variables used by this module:
#
# Variables defined by this module:
# * EZMESH_FOUND - True if the EZMESH sources are found.
# cmake-format: on
# =============================================================================
if(EZMESH_LOCATION)
set(FETCHCONTENT_SOURCE_DIR_EZMESH CMAKE_SOURCE_DIR "${EZMESH_LOCATION}")
message(STATUS "Found EZMESH at ${EZMESH_LOCATION}")
elseif(DEFINED ENV{EZMESH_LOCATION})
set(FETCHCONTENT_SOURCE_DIR_EZMESH "$ENV{EZMESH_LOCATION}")
message(STATUS "EZMESH - using provided EZMESH_LOCATION ($ENV{EZMESH_LOCATION})")
else()
if(NOT FETCH_EZMESH_VERSION)
# The version to fetch should ideally be the same as the version used for fetching GeckoSDK
set(FETCH_EZMESH_VERSION "v4.2.0")
endif()
message(STATUS "Fetching EZMESH ${FETCH_EZMESH_VERSION} from public repository")
endif()

# Find the version of EZMESH
file(
STRINGS ${EZMESH_SOURCE_DIR}/CMakeLists.txt _ver_line
REGEX "^ +VERSION \"([^\"]*)\""
LIMIT_COUNT 1)
string(REGEX MATCHALL "[0-9\.]+" EZMESH_VERSION "${_ver_line}")
message(STATUS "EZMESH version ${EZMESH_VERSION}")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
EZMESH
REQUIRED_VARS EZMESH_VERSION
VERSION_VAR EZMESH_VERSION)
Loading

0 comments on commit 01d79cf

Please sign in to comment.