Skip to content

Commit

Permalink
Anjay-esp32-client 22.08
Browse files Browse the repository at this point in the history
- Updated Anjay to version 3.1.1
- Added CHANGELOG.md file
- Added information about updating submodule to README.md step
- Integrated with FreeRTOS Cellular Interface
- Fixed display configuration in m5stick-plus.bin binary file
  • Loading branch information
JZimnol committed Aug 12, 2022
1 parent 279194c commit fca40be
Show file tree
Hide file tree
Showing 21 changed files with 956 additions and 94 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "main/anjay"]
path = main/anjay
url = https://github.com/AVSystem/Anjay.git
[submodule "main/FreeRTOS-Cellular-Library"]
path = main/FreeRTOS-Cellular-Interface
url = https://github.com/AVSystem/FreeRTOS-Cellular-Interface
branch = esp32-client-v1.2.0
67 changes: 67 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Changelog

## 22.08 (August 12th, 2022)

### Features

- Updated Anjay to version 3.1.1
- Added CHANGELOG.md file
- Added support for BG96
- Integrated with FreeRTOS Cellular Interface

### Bugfixes

- Fixed display configuration in m5stick-plus.bin binary file

## 22.06 (June 27th, 2022)

### Features

- Updated Anjay to version 3.0.0
- Added support for certificates and TCP socket
- Added non-secure connection option
- Added support for Send operation

## 22.04.1 (April 28th, 2022)

### Bugfixes

- Fix configuration issue regarded to improper include order.

## 22.04 (April 13th, 2022)

### Features

- added support for FOTA
- added support for changing Wi-Fi configuration while the device is
running
- added NVS for Anjay and Wi-Fi configuration

### Improvements

- all required configuration can be set from anjay-esp32-client component
config
- updated ESP-IDF and Anjay

## 22.01.1 (January 26th, 2022)

### Bugfixes

- Fixed configuration in avs_commons_config.h

## 22.01 (January 21st, 2022)

### Features

- added support for M5StickC-Plus hardware
- added generic sensors objects handling code

### Improvements

- anjay handling WiFi connection loss

## 21.10 (October 4th, 2021)

### Features

- Initial release of Anjay-esp32-client
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ if(CONFIG_PARTITION_TABLE_CUSTOM)
spiffs_create_partition_image(storage graphics FLASH_IN_PROJECT)
endif()
endif()

1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@
PROJECT_NAME := anjay-esp32-client

include $(IDF_PATH)/make/project.mk

28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ The following LwM2M Objects are supported:
## Compiling and launching
1. Install ESP-IDF and its dependencies on your computer. Please follow the instructions at https://docs.espressif.com/projects/esp-idf/en/v4.4/esp32/get-started/index.html up to and including the point where you call `. $HOME/esp/esp-idf/export.sh`
* The project has been tested with ESP-IDF v4.4, but may work with other versions as well.
2. Run `idf.py set-target esp32` in the project directory
3. Run `idf.py menuconfig`
1. Clone the repository `git clone https://github.com/AVSystem/Anjay-esp32-client.git` and navigate to project directory
1. Initialize and update submodules with `git submodule update --init --recursive`
1. Run `idf.py set-target esp32` in the project directory
1. Run `idf.py menuconfig`
* navigate to `Component config/anjay-esp32-client`:
* select one of supported boards or manually configure the board in `Board options` menu
* configure Anjay in `Client options` menu
* configure WiFi in `Connection configuration` menu
4. Run `idf.py build` to compile
5. Run `idf.py flash` to flash
1. Run `idf.py build` to compile
1. Run `idf.py flash` to flash
* NOTE: M5StickC-Plus does not support default baudrate, run `idf.py -b 750000 flash` to flash it
6. The logs will be on the same `/dev/ttyUSB<n>` port that the above used for flashing, 115200 8N1
1. The logs will be on the same `/dev/ttyUSB<n>` port that the above used for flashing, 115200 8N1
* You can use `idf.py monitor` to see logs on serial output from a connected device, or even more conveniently `idf.py flash monitor` as one command to see logs right after the device is flashed

## Connecting to the LwM2M Server
To connect to [Coiote IoT Device Management](https://www.avsystem.com/products/coiote-iot-device-management-platform/) LwM2M Server, please register at [https://www.avsystem.com/try-anjay/](https://www.avsystem.com/try-anjay/). The default Server URI (Kconfig option `ANJAY_CLIENT_SERVER_URI`) is set to try-anjay server, but you must manually set other client configuration options.
To connect to [Coiote IoT Device Management](https://www.avsystem.com/products/coiote-iot-device-management-platform/) LwM2M Server, please register at [https://eu.iot.avsystem.cloud/](https://eu.iot.avsystem.cloud/). The default Server URI (Kconfig option `ANJAY_CLIENT_SERVER_URI`) is set to EU Cloud Coiote DM instance, but you must manually set other client configuration options.

NOTE: You may use any LwM2M Server compliant with LwM2M 1.0 TS. The server URI
can be changed in the example configuration options.
Expand All @@ -44,7 +46,7 @@ To do that, `esptool.py` is required, which can be installed running `pip instal

### Creating a merged binary for M5StickC-Plus
```
esptool.py --chip esp32 merge_bin --flash_mode dio --flash_size 4MB --flash_freq 40m 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/anjay-esp32-client.bin 0x210000 build/storage.bin --output m5stickc-plus.bin
esptool.py --chip esp32 merge_bin --flash_mode dio --flash_size 4MB --flash_freq 40m 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/anjay-esp32-client.bin 0x310000 build/storage.bin --output m5stickc-plus.bin
```
### NVS config file
To generate NVS partition, create a `nvs_config.csv` file with following content:
Expand Down Expand Up @@ -76,21 +78,29 @@ esptool.py -b 750000 --chip esp32 write_flash 0x9000 nvs_config.bin
```
Device will be reset and run with provided configuration.
### TCP socket
To switch to TCP socket instead of UDP run `idf.py menuconfig`, navigate to `Component config/anjay-esp32-client/Client options/Choose socket` and select TCP (remember that you must also provide a proper URI in the `nvs_config.csv` file, e.g. `coaps+tcp://try-anjay.avsystem.com:5684`). NOTE: Coiote DM currently only supports the Certificate mode when using TCP and TLS.
To switch to TCP socket instead of UDP run `idf.py menuconfig`, navigate to `Component config/anjay-esp32-client/Client options/Choose socket` and select TCP (remember that you must also provide a proper URI in the `nvs_config.csv` file, e.g. `coaps+tcp://eu.iot.avsystem.cloud:5684`).
### ESP32 with certificates
1. Prepare your certificates. All certificates should have a `.der` extension and should be added to the directory where this `README.md` file is located. The names of the certificates should be as follows:
* client public certificate - `client_cert.der`
* client private certificate - `client_key.der`
* server public certificate - `server_cert.der`
2. Run `idf.py menuconfig`, navigate to `Component config/anjay-esp32-client/Client options/Choose security mode` and select `Certificates`.
1. Run `idf.py menuconfig`, navigate to `Component config/anjay-esp32-client/Client options/Choose security mode` and select `Certificates`.
### FOTA
After compilation, you can perform FOTA with Coiote DM. Required binary file location:
```
$PROJECT_DIR/build/anjay-esp32-client/build/anjay-esp32-client.bin
```
### ESP32 with BG96 and FreeRTOS cellular library
1. Prepare your BG96 module, connect it to the selected ESP32 UART interface.
1. Run `idf.py menuconfig`
* navigate to `Component config/anjay-esp32-client`:
* select `External BG96 module` in `Choose an interface` menu
* configure BG96 in `BG96 module configuration` menu
* configure PDN in `Connection configuration` menu
## Links
* [Anjay source repository](https://github.com/AVSystem/Anjay)
* [Anjay documentation](https://avsystem.github.io/Anjay-doc/index.html)
* [Doxygen-generated API documentation](https://avsystem.github.io/Anjay-doc/api/index.html)
* [AVSystem IoT Devzone](https://iotdevzone.avsystem.com/)
* [AVSystem Discord server](https://discord.avsystem.com)
* [FreeRTOS cellular library](https://www.freertos.org/cellular/index.html)
66 changes: 51 additions & 15 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,40 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set(sources
"main.c"
"connect.c"
"utils.c"
"objects/device.c"
"objects/light_control.c"
"objects/push_button.c"
"objects/mpu6886.c"
"objects/sensors.c"
"st7789.c"
"fontx.c"
"lcd.c"
"axp192.c"
"i2c_wrapper.c"
"firmware_update.c")

if (CONFIG_ANJAY_SECURITY_MODE_CERTIFICATES)
set(Embedded_cert "../server_cert.der" "../client_cert.der" "../client_key.der")
else()
set(Embedded_cert "")
endif()

idf_component_register(SRCS "main.c"
"connect.c"
"utils.c"
"objects/device.c"
"objects/light_control.c"
"objects/push_button.c"
"objects/mpu6886.c"
"objects/sensors.c"
"objects/wlan.c"
"st7789.c"
"fontx.c"
"lcd.c"
"axp192.c"
"i2c_wrapper.c"
"firmware_update.c"
if (CONFIG_ANJAY_CLIENT_INTERFACE_BG96_MODULE)
list(APPEND sources
"cellular_anjay_impl/net_impl.c"
"cellular_anjay_impl/cellular_event_loop.c")
endif()

if (CONFIG_ANJAY_CLIENT_INTERFACE_ONBOARD_WIFI)
list(APPEND sources
"objects/wlan.c")
endif()

idf_component_register(SRCS ${sources}
INCLUDE_DIRS "."
EMBED_FILES ${Embedded_cert})

Expand Down Expand Up @@ -61,6 +74,25 @@ target_link_libraries(anjay PRIVATE idf::mbedtls)
# We disable assertions within anjay to work around that.
target_compile_definitions(anjay PRIVATE NDEBUG)

if (CONFIG_ANJAY_CLIENT_INTERFACE_BG96_MODULE)
file(GLOB_RECURSE FREERTOS_CELLULAR_LIBRARY_SOURCES
"FreeRTOS-Cellular-Interface/source/*.c"
"FreeRTOS-Cellular-Interface/modules/bg96/*.c"
"FreeRTOS-Cellular-Interface/modules/cellular_platform.c")

add_library(freertos_cellular_library MODULE ${FREERTOS_CELLULAR_LIBRARY_SOURCES})
target_include_directories(freertos_cellular_library PRIVATE
"FreeRTOS-Cellular-Interface/source/include/private"
"FreeRTOS-Cellular-Interface/modules/bg96")
target_include_directories(freertos_cellular_library PUBLIC
"FreeRTOS-Cellular-Interface/source/include"
"FreeRTOS-Cellular-Interface/source/include/common"
"FreeRTOS-Cellular-Interface/source/logging"
"FreeRTOS-Cellular-Interface/source/cellular_network_transport"
"FreeRTOS-Cellular-Interface/source/interface"
"FreeRTOS-Cellular-Interface/modules")
target_link_libraries(freertos_cellular_library PRIVATE anjay)
endif()

add_custom_target( configure_git_version
COMMAND ${CMAKE_COMMAND}
Expand All @@ -71,4 +103,8 @@ add_custom_target( configure_git_version
)

add_dependencies(${COMPONENT_LIB} configure_git_version)

target_link_libraries(${COMPONENT_LIB} PRIVATE anjay)
if (CONFIG_ANJAY_CLIENT_INTERFACE_BG96_MODULE)
target_link_libraries(${COMPONENT_LIB} PRIVATE freertos_cellular_library)
endif()
1 change: 1 addition & 0 deletions main/FreeRTOS-Cellular-Interface
113 changes: 90 additions & 23 deletions main/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,50 @@ menu "anjay-esp32-client"
endmenu
endmenu

choice ANJAY_CLIENT_INTERFACE
prompt "Choose an interface"
default ANJAY_CLIENT_INTERFACE_ONBOARD_WIFI

config ANJAY_CLIENT_INTERFACE_ONBOARD_WIFI
bool "Onboard WiFi"

config ANJAY_CLIENT_INTERFACE_BG96_MODULE
bool "External BG96 module"
endchoice

config ANJAY_CLIENT_CELLULAR_EVENT_LOOP
bool
default y if ANJAY_CLIENT_INTERFACE_BG96_MODULE
default n

if ANJAY_CLIENT_INTERFACE_BG96_MODULE
menu "BG96 module configuration"

config ANJAY_BG96_UART_PORT_NUMBER
int "UART port number"
default 0

config ANJAY_BG96_TX_PIN
int "UART Tx pin"
default 0

config ANJAY_BG96_RX_PIN
int "UART Rx pin"
default 0
endmenu
endif

menu "Client options"
config ANJAY_CLIENT_ENDPOINT_NAME
string "Endpoint name"
default "anjay-esp32-client"

config ANJAY_CLIENT_SERVER_URI
string "Server URI"
default "coaps://try-anjay.avsystem.com:5684"
default "coaps://eu.iot.avsystem.cloud:5684"

choice ANJAY_CLIENT_SOCKET
prompt "Choose socket"
prompt "Choose socket"
default ANJAY_CLIENT_SOCKET_UDP

config ANJAY_CLIENT_SOCKET_UDP
Expand Down Expand Up @@ -185,35 +218,69 @@ menu "anjay-esp32-client"
endmenu

menu "Connection configuration"
config ANJAY_WIFI_SSID
string "WiFi SSID"
default "myssid"
if ANJAY_CLIENT_INTERFACE_ONBOARD_WIFI
config ANJAY_WIFI_SSID
string "WiFi SSID"
default "myssid"

config ANJAY_WIFI_PASSWORD
string "WiFi Password"
default "mypassword"

config ANJAY_WIFI_CONNECT_IPV6
bool "Obtain IPv6 address"
default y

if ANJAY_WIFI_CONNECT_IPV6
choice ANJAY_WIFI_CONNECT_IPV6_PREF
prompt "Preferred IPv6 Type"
default ANJAY_WIFI_CONNECT_IPV6_PREF_LOCAL_LINK

config ANJAY_WIFI_CONNECT_IPV6_PREF_LOCAL_LINK
bool "Local Link Address"

config ANJAY_WIFI_CONNECT_IPV6_PREF_GLOBAL
bool "Global Address"

config ANJAY_WIFI_PASSWORD
string "WiFi Password"
default "mypassword"
config ANJAY_WIFI_CONNECT_IPV6_PREF_SITE_LOCAL
bool "Site Local Address"

config ANJAY_WIFI_CONNECT_IPV6
bool "Obtain IPv6 address"
default y
config ANJAY_WIFI_CONNECT_IPV6_PREF_UNIQUE_LOCAL
bool "Unique Local Link Address"
endchoice
endif
endif

if ANJAY_CLIENT_INTERFACE_BG96_MODULE
config ANJAY_CELLULAR_APN
string "APN name"
default "Cellular APN"

if ANJAY_WIFI_CONNECT_IPV6
choice ANJAY_WIFI_CONNECT_IPV6_PREF
prompt "Preferred IPv6 Type"
default ANJAY_WIFI_CONNECT_IPV6_PREF_LOCAL_LINK
choice ANJAY_CELLULAR_PDN_AUTH_TYPE
prompt "PDN authentication type"
default ANJAY_CELLULAR_PDN_AUTH_TYPE_NONE

config ANJAY_WIFI_CONNECT_IPV6_PREF_LOCAL_LINK
bool "Local Link Address"
config ANJAY_CELLULAR_PDN_AUTH_TYPE_NONE
bool "No authentication"

config ANJAY_WIFI_CONNECT_IPV6_PREF_GLOBAL
bool "Global Address"
config ANJAY_CELLULAR_PDN_AUTH_TYPE_PAP
bool "PAP"

config ANJAY_WIFI_CONNECT_IPV6_PREF_SITE_LOCAL
bool "Site Local Address"
config ANJAY_CELLULAR_PDN_AUTH_TYPE_CHAP
bool "CHAP"

config ANJAY_WIFI_CONNECT_IPV6_PREF_UNIQUE_LOCAL
bool "Unique Local Link Address"
config ANJAY_CELLULAR_PDN_AUTH_TYPE_PAP_OR_CHAP
bool "PAP or CHAP"
endchoice

config ANJAY_CELLULAR_PDN_USERNAME
string "PDN username" if !ANJAY_CELLULAR_PDN_AUTH_TYPE_NONE
default ""

config ANJAY_CELLULAR_PDN_PASSWORD
string "PDN password" if !ANJAY_CELLULAR_PDN_AUTH_TYPE_NONE
default ""

endif
endmenu
endmenu
2 changes: 1 addition & 1 deletion main/anjay
Submodule anjay updated 123 files
Loading

0 comments on commit fca40be

Please sign in to comment.