Skip to content

Commit

Permalink
Anjay-esp32-client 22.06
Browse files Browse the repository at this point in the history
- Updated Anjay to version 3.0.0
- Added support for certificates and TCP socket
- Added non-secure connection option
- Added support for Send operation
  • Loading branch information
JZimnol authored and Mateusz Kwiatkowski committed Jun 27, 2022
1 parent 13cea95 commit 279194c
Show file tree
Hide file tree
Showing 13 changed files with 276 additions and 135 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.6)


include($ENV{IDF_PATH}/tools/cmake/project.cmake)
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ config,namespace,,
wifi_ssid,data,string,[wifi_ssid]
wifi_pswd,data,string,[wifi_password]
wifi_inter_en,data,u8,1
endpoint_name,data,string,[endpoint_name]
identity,data,string,[identity]
psk,data,string,[psk]
uri,data,string,[lwm2m_server_uri]
Expand All @@ -62,7 +63,7 @@ wifi_ssid,data,string,[wifi_ssid]
wifi_pswd,data,string,[wifi_password]
wifi_inter_en,data,u8,0
```
And fill proper values for `[wifi_ssid]`, `[wifi_password]`, `[identity]`, `[psk]`, `[lwm2m_server_uri]`.
And fill proper values for `[wifi_ssid]`, `[wifi_password]`, `[endpoint_name]`, `[identity]`, `[psk]`, `[lwm2m_server_uri]`.
After that create config partition by running:
```
python3 $IDF_PATH/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py generate nvs_config.csv nvs_config.bin 0x4000
Expand All @@ -74,6 +75,14 @@ esptool.py -b 750000 --chip esp32 write_flash 0x0000 m5stickc-plus.bin
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.
### 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`.
### FOTA
After compilation, you can perform FOTA with Coiote DM. Required binary file location:
```
Expand Down
37 changes: 22 additions & 15 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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"
INCLUDE_DIRS ".")
"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"
INCLUDE_DIRS "."
EMBED_FILES ${Embedded_cert})

file(GLOB_RECURSE ANJAY_SOURCES
"anjay/src/*.c"
Expand Down
68 changes: 49 additions & 19 deletions main/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,42 @@ menu "anjay-esp32-client"
string "Server URI"
default "coaps://try-anjay.avsystem.com:5684"

config ANJAY_CLIENT_PSK_IDENTITY
string "PSK identity"
default ANJAY_CLIENT_ENDPOINT_NAME
choice ANJAY_CLIENT_SOCKET
prompt "Choose socket"
default ANJAY_CLIENT_SOCKET_UDP

config ANJAY_CLIENT_PSK_KEY
string "PSK key"
default "1234"
config ANJAY_CLIENT_SOCKET_UDP
bool "UDP"

config ANJAY_CLIENT_SOCKET_TCP
bool "TCP"
endchoice

choice ANJAY_SECURITY_MODE
prompt "Choose security mode"
default ANJAY_SECURITY_MODE_PSK

config ANJAY_SECURITY_MODE_NOSEC
bool "Non-secure connection"

config ANJAY_SECURITY_MODE_PSK
bool "PSK"

config ANJAY_SECURITY_MODE_CERTIFICATES
bool "Certificates"
endchoice

menu "PSK configuration"
visible if ANJAY_SECURITY_MODE_PSK

config ANJAY_CLIENT_PSK_IDENTITY
string "PSK identity"
default ANJAY_CLIENT_ENDPOINT_NAME

config ANJAY_CLIENT_PSK_KEY
string "PSK key"
default "1234"
endmenu
endmenu

menu "Connection configuration"
Expand All @@ -168,22 +197,23 @@ menu "anjay-esp32-client"
bool "Obtain IPv6 address"
default y

choice ANJAY_WIFI_CONNECT_IPV6_PREF
depends on ANJAY_WIFI_CONNECT_IPV6
prompt "Preferred IPv6 Type"
default ANJAY_WIFI_CONNECT_IPV6_PREF_LOCAL_LINK
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_LOCAL_LINK
bool "Local Link Address"

config ANJAY_WIFI_CONNECT_IPV6_PREF_GLOBAL
bool "Global Address"
config ANJAY_WIFI_CONNECT_IPV6_PREF_GLOBAL
bool "Global Address"

config ANJAY_WIFI_CONNECT_IPV6_PREF_SITE_LOCAL
bool "Site Local Address"
config ANJAY_WIFI_CONNECT_IPV6_PREF_SITE_LOCAL
bool "Site Local Address"

config ANJAY_WIFI_CONNECT_IPV6_PREF_UNIQUE_LOCAL
bool "Unique Local Link Address"
endchoice
config ANJAY_WIFI_CONNECT_IPV6_PREF_UNIQUE_LOCAL
bool "Unique Local Link Address"
endchoice
endif
endmenu
endmenu
2 changes: 1 addition & 1 deletion main/anjay
Submodule anjay updated 731 files
Loading

0 comments on commit 279194c

Please sign in to comment.