├── drivers └── .gitignore ├── .gitignore ├── Kconfig ├── scripts └── requirements.txt ├── samples ├── mqtt_publisher_aws │ ├── overlay-socks5.conf │ ├── boards │ │ ├── pinnacle_100_dvk.conf │ │ ├── cc3220sf_launchxl.conf │ │ └── cc3235sf_launchxl.conf │ ├── overlay-tls-offload.conf │ ├── overlay-websocket.conf │ ├── overlay-sample.conf │ ├── CMakeLists.txt │ ├── overlay-tls.conf │ ├── overlay-bt.conf │ ├── src │ │ ├── certificates.h │ │ ├── config.h │ │ └── test_certs.h │ ├── sample.yaml │ ├── overlay-aws-1sc.conf │ ├── overlay-aws-9116.conf │ ├── prj.conf │ ├── Kconfig │ └── docker-test.sh ├── bluetooth │ ├── bandwidth_test │ │ ├── requirements.txt │ │ ├── prj.conf │ │ ├── CMakeLists.txt │ │ ├── bw_test.py │ │ └── src │ │ │ └── main.c │ ├── bt_test │ │ ├── prj.conf │ │ └── CMakeLists.txt │ ├── peripheral_hr │ │ ├── prj.conf │ │ ├── CMakeLists.txt │ │ ├── sample.yaml │ │ ├── README.rst │ │ └── src │ │ │ ├── bas.c │ │ │ ├── hrs.c │ │ │ └── main.c │ ├── peripheral_sc_only │ │ ├── prj.conf │ │ ├── CMakeLists.txt │ │ ├── README.rst │ │ └── src │ │ │ └── main.c │ └── sc_extensive_test │ │ ├── CMakeLists.txt │ │ └── prj.conf ├── tmo_shell │ ├── get_zephyr_init_commit_tag.sh │ ├── src │ │ ├── devcert.der │ │ ├── devkey.der │ │ ├── servercert.der │ │ ├── digicert_ca.der │ │ ├── echo-apps-cert.der │ │ ├── echo-apps-key.der │ │ ├── entrust_g2_ca.der │ │ ├── lets-encrypt-r3.der │ │ ├── ek18 │ │ │ ├── src │ │ │ │ ├── kermit_cmd.h │ │ │ │ ├── cdefs.h │ │ │ │ └── debug.h │ │ │ ├── CMakeLists.txt │ │ │ └── COPYING │ │ ├── tmo_shell_main.c │ │ ├── tmo_smp.h │ │ ├── tmo_wifi.h │ │ ├── tmo_ping.h │ │ ├── tmo_bq24250.h │ │ ├── tmo_leds.h │ │ ├── tmo_http_request.h │ │ ├── tmo_adc.h │ │ ├── dfu_rs9116w.h │ │ ├── tmo_file.h │ │ ├── tmo_certs.h │ │ ├── tmo_pm_sys.h │ │ ├── tmo_pm.h │ │ ├── tmo_dfu_download.h │ │ ├── tmo_ble_demo.h │ │ ├── tmo_tone_player.h │ │ ├── tmo_battery_ctrl.h │ │ ├── ca_certificate.h │ │ ├── tmo_web_demo.h │ │ ├── tmo_modem.h │ │ ├── tmo_gnss.h │ │ ├── tmo_modem_edrx.h │ │ ├── tmo_sntp.h │ │ ├── tmo_modem_psm.h │ │ ├── tmo_shell.h │ │ ├── buzzer_test.c │ │ ├── tmo_battery_ctrl.c │ │ ├── tmo_tone_player.c │ │ ├── tmo_buzzer.h │ │ ├── tmo_pm_sys.c │ │ ├── tmo_modem_edrx.c │ │ ├── led_test.c │ │ ├── tmo_fuel_gauge.c │ │ ├── tmo_ping.c │ │ ├── tmo_http_mock_socket.c │ │ ├── tmo_adc.c │ │ ├── tmo_sntp.c │ │ └── tmo_file.c │ ├── get_zephyr_last_rebase_tag.sh │ ├── boards │ │ ├── tmo_dev_edge.overlay │ │ ├── tmo_dev_edge_mcuboot.overlay │ │ ├── tmo_dev_edge.conf │ │ ├── tmo_dev_edge_slot_0.overlay │ │ └── tmo_dev_edge_slot_1.overlay │ ├── overlay-mbed.conf │ ├── overlay-slot.conf │ ├── overlay-bl.conf │ ├── Kconfig │ ├── README.txt │ ├── prj.conf │ └── CMakeLists.txt ├── illuminance │ ├── boards │ │ ├── tmo_dev_edge.overlay │ │ └── tmo_dev_edge.conf │ ├── CMakeLists.txt │ ├── prj.conf │ ├── Kconfig │ └── README.rst ├── wake_sleep │ ├── boards │ │ ├── tmo_dev_edge.overlay │ │ ├── tmo_dev_edge_mcuboot.overlay │ │ ├── tmo_dev_edge_slot_0.overlay │ │ ├── tmo_dev_edge_slot_1.overlay │ │ └── tmo_dev_edge.conf │ ├── Kconfig │ ├── src │ │ ├── strerror.c │ │ ├── strerror.h │ │ └── strerror_table.h │ ├── CMakeLists.txt │ ├── README.md │ └── prj.conf ├── letimer │ ├── prj.conf │ ├── CMakeLists.txt │ ├── README.rst │ └── src │ │ └── main.c ├── button_press_cb │ ├── prj.conf │ ├── CMakeLists.txt │ ├── Kconfig │ ├── src │ │ ├── button.h │ │ └── main.c │ └── README.txt ├── as6212_sample │ ├── CMakeLists.txt │ ├── sample.yaml │ ├── prj.conf │ ├── Kconfig │ └── README.rst ├── push_button_sample │ ├── CMakeLists.txt │ ├── prj.conf │ ├── Kconfig │ └── README.txt └── lis2dw12_sample │ ├── CMakeLists.txt │ ├── sample.yaml │ ├── prj.conf │ └── README.rst ├── zephyr └── module.yml ├── libs ├── dfu_rs9116w │ ├── CMakeLists.txt │ └── dfu_rs9116w.h ├── dfu_murata_1sc │ ├── CMakeLists.txt │ └── dfu_murata_1sc.h ├── dfu_gecko │ ├── CMakeLists.txt │ ├── Kconfig.dfu_gecko │ └── dfu_gecko_lib.h ├── CMakeLists.txt └── dfu_common.h ├── set-zephyr-build-env.ps1 ├── CMakeLists.txt ├── set-zephyr-build-env.bat ├── README.md ├── Trademark_Disclaimer.md ├── CODEOWNERS ├── .github └── workflows │ ├── build-tmoshell-devkit.yml │ └── build.yml └── set-zephyr-build-env /drivers/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | /.project 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /Kconfig: -------------------------------------------------------------------------------- 1 | 2 | rsource "libs/dfu_gecko/Kconfig.dfu_gecko" 3 | -------------------------------------------------------------------------------- /scripts/requirements.txt: -------------------------------------------------------------------------------- 1 | pyserial 2 | pretty_midi 3 | tqdm 4 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/overlay-socks5.conf: -------------------------------------------------------------------------------- 1 | CONFIG_SOCKS=y 2 | -------------------------------------------------------------------------------- /samples/bluetooth/bandwidth_test/requirements.txt: -------------------------------------------------------------------------------- 1 | tqdm==4.64.1 2 | bleak==0.15.1 3 | -------------------------------------------------------------------------------- /zephyr/module.yml: -------------------------------------------------------------------------------- 1 | name: Zephyr TMO SDK 2 | build: 3 | cmake: . 4 | kconfig: Kconfig 5 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/boards/pinnacle_100_dvk.conf: -------------------------------------------------------------------------------- 1 | CONFIG_MODEM=y 2 | CONFIG_MODEM_HL7800=y 3 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/overlay-tls-offload.conf: -------------------------------------------------------------------------------- 1 | CONFIG_MQTT_LIB_TLS=y 2 | CONFIG_NET_SOCKETS_SOCKOPT_TLS=y 3 | -------------------------------------------------------------------------------- /samples/tmo_shell/get_zephyr_init_commit_tag.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git log --grep "^Initial commit$" --max-count 1 --pretty="format:%H" 3 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/devcert.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK/HEAD/samples/tmo_shell/src/devcert.der -------------------------------------------------------------------------------- /samples/tmo_shell/src/devkey.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK/HEAD/samples/tmo_shell/src/devkey.der -------------------------------------------------------------------------------- /samples/tmo_shell/src/servercert.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK/HEAD/samples/tmo_shell/src/servercert.der -------------------------------------------------------------------------------- /libs/dfu_rs9116w/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(app PRIVATE dfu_rs9116w.c) 2 | target_include_directories(app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 3 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/overlay-websocket.conf: -------------------------------------------------------------------------------- 1 | CONFIG_WEBSOCKET_CLIENT=y 2 | CONFIG_MQTT_LIB_WEBSOCKET=y 3 | CONFIG_HEAP_MEM_POOL_SIZE=1500 4 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/digicert_ca.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK/HEAD/samples/tmo_shell/src/digicert_ca.der -------------------------------------------------------------------------------- /samples/tmo_shell/get_zephyr_last_rebase_tag.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git log --grep "Merge branch 'main' into tmo-main" --max-count 1 --pretty="format:%H" 3 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/echo-apps-cert.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK/HEAD/samples/tmo_shell/src/echo-apps-cert.der -------------------------------------------------------------------------------- /samples/tmo_shell/src/echo-apps-key.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK/HEAD/samples/tmo_shell/src/echo-apps-key.der -------------------------------------------------------------------------------- /samples/tmo_shell/src/entrust_g2_ca.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK/HEAD/samples/tmo_shell/src/entrust_g2_ca.der -------------------------------------------------------------------------------- /samples/tmo_shell/src/lets-encrypt-r3.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK/HEAD/samples/tmo_shell/src/lets-encrypt-r3.der -------------------------------------------------------------------------------- /libs/dfu_murata_1sc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | target_sources(app PRIVATE dfu_murata_1sc.c) 2 | target_include_directories(app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 3 | -------------------------------------------------------------------------------- /samples/illuminance/boards/tmo_dev_edge.overlay: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | -------------------------------------------------------------------------------- /samples/tmo_shell/boards/tmo_dev_edge.overlay: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | -------------------------------------------------------------------------------- /samples/wake_sleep/boards/tmo_dev_edge.overlay: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | -------------------------------------------------------------------------------- /samples/letimer/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_PM=y 2 | CONFIG_CORTEX_M_SYSTICK=n 3 | CONFIG_GECKO_LETIMER=y 4 | CONFIG_GECKO_LETIMER_USE_REP=y 5 | CONFIG_SYS_CLOCK_TICKS_PER_SEC=8192 6 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/overlay-sample.conf: -------------------------------------------------------------------------------- 1 | # Lower values used for testing 2 | CONFIG_NET_SAMPLE_APP_MAX_ITERATIONS=3 3 | CONFIG_NET_SAMPLE_APP_MAX_CONNECTIONS=3 4 | -------------------------------------------------------------------------------- /set-zephyr-build-env.ps1: -------------------------------------------------------------------------------- 1 | if (!$env:ZEPHYR_EXTRA_MODULES) { 2 | $env:ZEPHYR_EXTRA_MODULES = $PSScriptRoot 3 | } else { 4 | $env:ZEPHYR_EXTRA_MODULES += ';' + $PSScriptRoot 5 | } 6 | -------------------------------------------------------------------------------- /samples/bluetooth/bandwidth_test/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=y 2 | CONFIG_BT_CUSTOM=y 3 | CONFIG_BT_RS9116W=y 4 | CONFIG_BT_PERIPHERAL=y 5 | CONFIG_SPI=y 6 | CONFIG_BT_DEVICE_NAME="T-Mobile Devedge" 7 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/ek18/src/kermit_cmd.h: -------------------------------------------------------------------------------- 1 | #ifndef __KERMIT_CMD_H__ 2 | #define __KERMIT_CMD_H__ 3 | 4 | int cmd_ekermit(const struct shell* shell, int argc, char ** argv); 5 | 6 | #endif -------------------------------------------------------------------------------- /samples/bluetooth/bt_test/prj.conf: -------------------------------------------------------------------------------- 1 | # nothing here 2 | CONFIG_BT=y 3 | CONFIG_BT_CUSTOM=y 4 | CONFIG_BT_RS9116W=y 5 | CONFIG_BT_PERIPHERAL=y 6 | CONFIG_BT_MAX_CONN=1 7 | CONFIG_BT_DEVICE_NAME="Zephyr" 8 | CONFIG_TEST_RANDOM_GENERATOR=y -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_shell_main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include "tmo_shell.h" 8 | 9 | void main (void) { 10 | tmo_shell_main(); 11 | } 12 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/ek18/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.20.0) 4 | 5 | target_include_directories(app PRIVATE src/) 6 | target_sources(app PRIVATE src/zephyrio.c src/kermit_cmd.c src/kermit.c) -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | cmake_minimum_required(VERSION 3.20.0) 6 | 7 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 8 | 9 | add_subdirectory(libs) 10 | -------------------------------------------------------------------------------- /samples/bluetooth/bt_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.13.1) 4 | 5 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 6 | project(bt_test) 7 | 8 | target_sources(app PRIVATE src/main.c) 9 | -------------------------------------------------------------------------------- /samples/letimer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.20.0) 4 | 5 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 6 | project(gecko_letimer_test) 7 | 8 | target_sources(app PRIVATE src/main.c) 9 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_smp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_SMP_H 8 | #define TMO_SMP_H 9 | 10 | void tmo_smp_shell_init(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_wifi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_WIFI_H 8 | #define TMO_WIFI_H 9 | 10 | int tmo_wifi_connect(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /samples/button_press_cb/prj.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | # Required to disable default behavior of deep sleep on timeout 6 | CONFIG_GPIO=y 7 | 8 | # Stack sizes 9 | CONFIG_MAIN_STACK_SIZE=4096 10 | -------------------------------------------------------------------------------- /libs/dfu_gecko/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.20.0) 2 | 3 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 4 | 5 | target_include_directories(app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 6 | 7 | target_sources_ifdef(CONFIG_DFU_GECKO_LIB app PRIVATE dfu_gecko_lib.c) 8 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_hr/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=y 2 | CONFIG_BT_CUSTOM=y 3 | CONFIG_BT_RS9116W=y 4 | # CONFIG_BT_DEBUG_LOG=y 5 | # CONFIG_BT_SMP=y 6 | CONFIG_BT_PERIPHERAL=y 7 | CONFIG_SPI=y 8 | CONFIG_BT_DEVICE_NAME="Zephyr Heartrate Sensor" 9 | # CONFIG_BT_DEVICE_APPEARANCE=833 10 | -------------------------------------------------------------------------------- /libs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # libs/CMakeLists.txt 2 | 3 | target_include_directories(app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dfu_gecko) 6 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dfu_murata_1sc) 7 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dfu_rs9116w) 8 | -------------------------------------------------------------------------------- /samples/as6212_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | cmake_minimum_required(VERSION 3.20.0) 6 | 7 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 8 | project(tmp108) 9 | 10 | target_sources(app PRIVATE src/main.c) 11 | -------------------------------------------------------------------------------- /samples/illuminance/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | cmake_minimum_required(VERSION 3.20.0) 6 | 7 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 8 | project(illuminance) 9 | 10 | target_sources(app PRIVATE "src/main.c") 11 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.20.0) 4 | 5 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 6 | project(mqtt_publisher) 7 | 8 | FILE(GLOB app_sources src/*.c) 9 | target_sources(app PRIVATE ${app_sources}) 10 | -------------------------------------------------------------------------------- /samples/push_button_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | cmake_minimum_required(VERSION 3.20.0) 6 | 7 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 8 | project(push_button) 9 | 10 | target_sources(app PRIVATE src/main.c) 11 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_ping.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_PING_H 8 | #define TMO_PING_H 9 | #include 10 | 11 | int cmd_ping(const struct shell *shell, size_t argc, char **argv); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/overlay-tls.conf: -------------------------------------------------------------------------------- 1 | CONFIG_MAIN_STACK_SIZE=4096 2 | CONFIG_MQTT_LIB_TLS=y 3 | CONFIG_NET_SOCKETS_SOCKOPT_TLS=y 4 | 5 | # TLS configuration 6 | CONFIG_MBEDTLS=y 7 | CONFIG_MBEDTLS_BUILTIN=y 8 | CONFIG_MBEDTLS_ENABLE_HEAP=y 9 | CONFIG_MBEDTLS_HEAP_SIZE=30000 10 | CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=2048 11 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_bq24250.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_BATT_CHARGER_H 8 | #define TMO_BATT_CHARGER_H 9 | 10 | int get_bq24250_status(uint8_t *charging, uint8_t *vbus, uint8_t *attached, uint8_t *fault); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_leds.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_LEDS_H 8 | #define TMO_LEDS_H 9 | 10 | #include 11 | #include 12 | 13 | #define PWMLEDS device_get_binding("pwmleds") 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_http_request.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_HTTP_REQUEST_H 8 | #define TMO_HTTP_REQUEST_H 9 | 10 | void tmo_http_json(); 11 | int tmo_http_download(int devid, char url[], const char filename[], char *auth_key); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /set-zephyr-build-env.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem adds any out of tree drivers built as modules to the zephyr build path 4 | set LOCATION=%~dp0 5 | if "%ZEPHYR_EXTRA_MODULES%" == "" ( 6 | set ZEPHYR_EXTRA_MODULES=%LOCATION% 7 | ) else ( 8 | set ZEPHYR_EXTRA_MODULES=%ZEPHYR_EXTRA_MODULES%;%LOCATION% 9 | ) 10 | 11 | echo %ZEPHYR_EXTRA_MODULES% 12 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_sc_only/prj.conf: -------------------------------------------------------------------------------- 1 | # Uncomment the following two options to get thread stack usage logs 2 | #CONFIG_INIT_STACKS=y 3 | #CONFIG_THREAD_STACK_INFO=y 4 | CONFIG_BT=y 5 | CONFIG_BT_CUSTOM=y 6 | CONFIG_BT_RS9116W=y 7 | CONFIG_BT_PERIPHERAL=y 8 | CONFIG_BT_SMP=y 9 | CONFIG_BT_MAX_PAIRED=2 10 | CONFIG_BT_DEVICE_NAME="SC only peripheral" 11 | -------------------------------------------------------------------------------- /samples/as6212_sample/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | name: TMP 108 Temperature Sensor Sample 3 | tests: 4 | sample.sensor.tmp108: 5 | harness: console 6 | tags: sensors 7 | depends_on: i2c gpio 8 | filter: dt_compat_enabled("ti,tmp108") 9 | harness_config: 10 | type: multi_line 11 | regex: 12 | - "temperature is *.*C" 13 | -------------------------------------------------------------------------------- /samples/button_press_cb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | cmake_minimum_required(VERSION 3.20.0) 6 | 7 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 8 | project(button_press_cb) 9 | 10 | target_sources(app PRIVATE src/main.c) 11 | target_sources(app PRIVATE src/button.c) 12 | -------------------------------------------------------------------------------- /samples/lis2dw12_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018, Yannis Damigos 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 5 | # 6 | 7 | cmake_minimum_required(VERSION 3.20.0) 8 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 9 | project(lis2dw12_sample) 10 | 11 | FILE(GLOB app_sources src/*.c) 12 | target_sources(app PRIVATE ${app_sources}) 13 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_adc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_ADC_H 8 | #define TMO_ADC_H 9 | 10 | int read_battery_voltage(void); 11 | int read_hwid(void); 12 | bool millivolts_to_percent(uint32_t millivolts, uint8_t *bv); 13 | void initADC(); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /samples/as6212_sample/prj.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | CONFIG_SENSOR=y 6 | CONFIG_STDOUT_CONSOLE=y 7 | CONFIG_CBPRINTF_FP_SUPPORT=y 8 | CONFIG_I2C=y 9 | CONFIG_TMP108=y 10 | CONFIG_TMP108_ALERT_INTERRUPTS=y 11 | #Power Managment 12 | CONFIG_PM=y 13 | CONFIG_PM_DEVICE=y 14 | CONFIG_APP_REPORT_TEMP_ALERTS=y 15 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_sc_only/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.13.1) 4 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 5 | 6 | 7 | project(peripheral_sc_only) 8 | 9 | target_sources(app PRIVATE 10 | src/main.c 11 | ) 12 | 13 | zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth) 14 | -------------------------------------------------------------------------------- /samples/lis2dw12_sample/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | name: LIS2DW12 Accelerometer Sample 3 | tests: 4 | sample.sensor.lis2dw12: 5 | harness: console 6 | tags: samples sensor 7 | depends_on: i2c gpio 8 | filter: dt_compat_enabled("st,lis2dw12") 9 | harness_config: 10 | type: multi_line 11 | regex: 12 | - "temperature is *.*C" 13 | 14 | -------------------------------------------------------------------------------- /libs/dfu_gecko/Kconfig.dfu_gecko: -------------------------------------------------------------------------------- 1 | # DFU Gecko updagte configuration options 2 | 3 | # Copyright (c) 2021 Kim Mansfield 4 | # Copyright (c) 2022 T-Mobile USA, Inc. 5 | # SPDX-Licnse-Identifiere: Apache-2.0 6 | # 7 | 8 | config DFU_GECKO_LIB 9 | bool "DFU Gecko Update Library" 10 | help 11 | Enable DFU Gecko update library inclusion 12 | 13 | -------------------------------------------------------------------------------- /samples/bluetooth/sc_extensive_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.13.1) 4 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 5 | 6 | 7 | project(peripheral_sc_extensive) 8 | 9 | target_sources(app PRIVATE 10 | src/main.c 11 | ) 12 | 13 | zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth) 14 | -------------------------------------------------------------------------------- /libs/dfu_rs9116w/dfu_rs9116w.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef DFU_RS9116W_H 8 | #define DFU_RS9116W_H 9 | 10 | #define DFU_RS9116W_FW_VER_SIZE 20 11 | 12 | int dfu_wifi_firmware_upgrade(void); 13 | int32_t dfu_wifi_write_image(void); 14 | int dfu_wifi_get_version(char *rsi_fw_version); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /samples/bluetooth/bandwidth_test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.13.1) 4 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 5 | 6 | project(ble_bw_test) 7 | 8 | FILE(GLOB app_sources src/*.c) 9 | target_sources(app PRIVATE 10 | ${app_sources} 11 | ) 12 | 13 | zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth) 14 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_hr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | 3 | cmake_minimum_required(VERSION 3.13.1) 4 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 5 | 6 | project(peripheral_hr) 7 | 8 | FILE(GLOB app_sources src/*.c) 9 | target_sources(app PRIVATE 10 | ${app_sources} 11 | ) 12 | 13 | zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth) 14 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/dfu_rs9116w.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef DFU_RS9116W_H 8 | #define DFU_RS9116W_H 9 | 10 | #define DFU_RS9116W_FW_VER_SIZE 20 11 | 12 | int dfu_wifi_firmware_upgrade(void); 13 | int32_t dfu_wifi_write_image(void); 14 | int dfu_wifi_get_version(char *rsi_fw_version); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /samples/push_button_sample/prj.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | CONFIG_PM=y 6 | # Required to disable default behavior of deep sleep on timeout 7 | CONFIG_PM_DEVICE=y 8 | CONFIG_GPIO=y 9 | 10 | # Stack sizes 11 | CONFIG_MAIN_STACK_SIZE=4096 12 | 13 | # Pull-up circuit - additional conductance 14 | CONFIG_PUSHBUTTON_ADDITIONAL_PULL_UP=n 15 | -------------------------------------------------------------------------------- /samples/tmo_shell/overlay-mbed.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | CONFIG_MBEDTLS_HEAP_SIZE=30000 6 | CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=7168 7 | CONFIG_MBEDTLS_SERVER_NAME_INDICATION=y 8 | CONFIG_MBEDTLS_ENABLE_HEAP=y 9 | CONFIG_CTR_DRBG_CSPRNG_GENERATOR=y 10 | 11 | CONFIG_NET_SOCKETS_OFFLOAD_DISPATCHER=y 12 | 13 | CONFIG_TMO_SHELL_USE_MBED=y 14 | -------------------------------------------------------------------------------- /samples/lis2dw12_sample/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_STDOUT_CONSOLE=y 2 | CONFIG_I2C=y 3 | CONFIG_SENSOR=y 4 | CONFIG_LIS2DW12=y 5 | CONFIG_LIS2DW12_TRIGGER_GLOBAL_THREAD=y 6 | CONFIG_LIS2DW12_TAP=y 7 | CONFIG_LIS2DW12_THRESHOLD=y 8 | CONFIG_LIS2DW12_FREEFALL=y 9 | CONFIG_CBPRINTF_FP_SUPPORT=y 10 | CONFIG_ASSERT=y 11 | 12 | #Power Managment 13 | CONFIG_PM=y 14 | CONFIG_PM_DEVICE=y 15 | 16 | CONFIG_ISR_STACK_SIZE=4096 17 | 18 | -------------------------------------------------------------------------------- /samples/wake_sleep/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | mainmenu "wake_sleep application settings" 6 | 7 | config WAKE_TIMER_DURATION 8 | int "Wake timer timeout in seconds, 0 = diaabled" 9 | default 0 10 | 11 | config WAKE_TIMER_PERIOD 12 | int "Wake timer period in seconds, 0 = disabled" 13 | default 0 14 | 15 | source "Kconfig.zephyr" 16 | -------------------------------------------------------------------------------- /samples/bluetooth/sc_extensive_test/prj.conf: -------------------------------------------------------------------------------- 1 | # Uncomment the following two options to get thread stack usage logs 2 | #CONFIG_INIT_STACKS=y 3 | #CONFIG_THREAD_STACK_INFO=y 4 | CONFIG_BT=y 5 | CONFIG_BT_CUSTOM=y 6 | CONFIG_BT_RS9116W=y 7 | CONFIG_SPI=y 8 | #CONFIG_BT_DEBUG_LOG=y 9 | CONFIG_BT_PERIPHERAL=y 10 | CONFIG_BT_SMP=y 11 | #CONFIG_BT_SMP_SC_ONLY=y 12 | # CONFIG_BT_TINYCRYPT_ECC=y 13 | CONFIG_BT_MAX_PAIRED=2 14 | CONFIG_BT_DEVICE_NAME="SC Testing" 15 | CONFIG_SHELL=y -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/overlay-bt.conf: -------------------------------------------------------------------------------- 1 | CONFIG_BT=y 2 | CONFIG_BT_DEBUG_LOG=y 3 | CONFIG_BT_SMP=y 4 | CONFIG_BT_PERIPHERAL=y 5 | CONFIG_BT_CENTRAL=y 6 | CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y 7 | CONFIG_BT_DEVICE_NAME="Zephyr MQTT" 8 | CONFIG_NET_L2_BT=y 9 | CONFIG_NET_IPV4=n 10 | CONFIG_NET_IPV6=y 11 | CONFIG_NET_CONFIG_BT_NODE=y 12 | CONFIG_NET_CONFIG_NEED_IPV6=y 13 | CONFIG_NET_CONFIG_NEED_IPV4=n 14 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="" 15 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" 16 | -------------------------------------------------------------------------------- /samples/button_press_cb/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | mainmenu "Button Sample DevEdge board V04 Production" 6 | 7 | config BUTTON_DEBOUNCE_TIMEOUT_MS 8 | int "Debounce filter timeout for button press in millisec" 9 | range 0 100 10 | default 50 11 | help 12 | Set this to configure timer value in order to debounce button press 13 | and unpress. 14 | 15 | source "Kconfig.zephyr" 16 | -------------------------------------------------------------------------------- /libs/dfu_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __DFU_COMMON_H__ 8 | #define __DFU_COMMON_H__ 9 | 10 | #define DFU_DESC_LEN 64 11 | #define DFU_FILE_LEN 64 12 | #define DFU_SHA1_LEN 20 13 | #define DFU_URL_LEN 256 14 | 15 | struct dfu_file_t { 16 | char desc[DFU_DESC_LEN]; 17 | char lfile[DFU_FILE_LEN]; 18 | char rfile[DFU_FILE_LEN]; 19 | char sha1[DFU_SHA1_LEN]; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_FILE_H 8 | #define TMO_FILE_H 9 | 10 | int tmo_cp(const struct shell *shell, size_t argc, char **argv); 11 | int tmo_ll(const struct shell *shell, size_t argc, char **argv); 12 | int tmo_mv(const struct shell *shell, size_t argc, char **argv); 13 | int cmd_sha1(const struct shell *shell, size_t argc, char **argv); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/src/certificates.h: -------------------------------------------------------------------------------- 1 | static const unsigned char CA_CERT[] = { 2 | // Write results of 'cat AmazonRootCA1.pem | sed -e '1d;$d' | base64 -di - | xxd -i' here 3 | }; 4 | 5 | static const unsigned char DEV_CERT[] = { 6 | // Write results of 'cat *-certificate.pem.crt | sed -e '1d;$d' | base64 -di - | xxd -i' here 7 | }; 8 | 9 | static const unsigned char DEV_KEY[] = { 10 | // Write results of 'cat *-private.pem.key | sed -e '1d;$d' | base64 -di - | xxd -i' here 11 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![build-tmoshell-devkit](https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK/actions/workflows/build-tmoshell-devkit.yml/badge.svg)](https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK/actions/workflows/build-tmoshell-devkit.yml) 2 | 3 | # Getting Started 4 | ZephyrSDK (TMO_shell) is a Zephyr application built by T-Mobile and comes shipped on the DevEdge - IoT Developer Kit. Learn more at: https://devedge.t-mobile.com/documentation-hub/iot-developer-kit/interacting-with-the-kit-at-cli-via-tmo-shell 5 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | description: MQTT publisher sample application 3 | name: MQTT publisher 4 | common: 5 | harness: net 6 | tags: net mqtt 7 | tests: 8 | sample.net.mqtt_publisher: 9 | platform_allow: frdm_k64f qemu_x86 pinnacle_100_dvk 10 | sample.net.mqtt_publisher.userspace: 11 | platform_allow: frdm_k64f qemu_x86 12 | extra_args: CONFIG_USERSPACE=y 13 | sample.net.mqtt_publisher.bt: 14 | platform_allow: 96b_nitrogen 15 | tags: net mqtt bluetooth 16 | -------------------------------------------------------------------------------- /Trademark_Disclaimer.md: -------------------------------------------------------------------------------- 1 | # Trademark License: 2 | 3 | Nothing in these Source Code Terms gives you a right to use any of T-Mobile’s trade names, trademarks, service marks, logos, domain names or other distinctive brand features. You agree that you will not adopt, use or attempt to register, whether as a corporate name, domain name, product name, trademark, service mark or other indication of origin, any trademark of T-Mobile or any mark that is confusingly similar to or will dilute the distinctive nature of the T-Mobile trademarks. 4 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # CODEOWNERS for autoreview assigning in github 2 | 3 | # https://help.github.com/en/articles/about-code-owners#codeowners-syntax 4 | 5 | # Order is important; for each modified file, the last matching 6 | # pattern takes the most precedence. 7 | 8 | /* @johnlange2 @ryanhagen-tmo @eniolaodufuwa-tmo @jtbaumann @DRuffer-tmo @joebairdtmo @atrowbr2-tmo @wtucker6 @JLoucks4 @s-karstein @jvhutch @YHusain1 9 | /.github/workflows/ @ryanhagen-tmo @eniolaodufuwa-tmo 10 | -------------------------------------------------------------------------------- /samples/push_button_sample/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | source "Kconfig.zephyr" 6 | 7 | mainmenu "Gecko Pushbutton" 8 | 9 | config PUSHBUTTON_ADDITIONAL_PULL_UP 10 | bool "Pushbutton additional pull-up resistor" 11 | default true 12 | help 13 | The additional conductance afforded by the Gecko GPIO pull-up resistor 14 | reduces the RC time constant of the pushbutton debounce filter circuit, 15 | making switch bounce more likely. 16 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_hr/sample.yaml: -------------------------------------------------------------------------------- 1 | sample: 2 | description: TBD 3 | name: TBD 4 | tests: 5 | sample.bluetooth.peripheral_hr: 6 | harness: bluetooth 7 | platform_allow: qemu_cortex_m3 qemu_x86 8 | tags: bluetooth 9 | sample.bluetooth.peripheral_hr_rv32m1_vega_ri5cy: 10 | platform_allow: rv32m1_vega_ri5cy 11 | tags: bluetooth 12 | build_only: true 13 | sample.bluetooth.peripheral_hr.frdm_kw41z_shield: 14 | harness: bluetooth 15 | depends_on: arduino_serial 16 | tags: bluetooth 17 | extra_args: SHIELD=frdm_kw41z 18 | -------------------------------------------------------------------------------- /samples/wake_sleep/src/strerror.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /* 8 | * TODO: Replace this interim implementation with the system default, assuming it exists. 9 | */ 10 | 11 | #include "strerror.h" 12 | #include 13 | /* 14 | * Interim support for strerror 15 | */ 16 | #ifdef sys_nerr 17 | const char *strerror(int error_value) 18 | { 19 | error_value = abs(error_value); 20 | if (sys_nerr < error_value) { 21 | return ""; 22 | } else { 23 | return sys_errlist[error_value]; 24 | } 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /.github/workflows/build-tmoshell-devkit.yml: -------------------------------------------------------------------------------- 1 | name: build-tmoshell-devkit 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | # * is a special character in YAML so you have to quote this string 7 | - cron: '0 8 * * *' 8 | defaults: 9 | run: 10 | shell: bash 11 | 12 | jobs: 13 | tmoshell-devkit-build: 14 | uses: tmobile/DevEdge-IoTDevKit-ZephyrSDK/.github/workflows/build.yml@main 15 | with: 16 | ZEPHYR_APPLICATION: ../DevEdge-IoTDevKit-ZephyrSDK/samples/tmo_shell 17 | ZEPHYR_BOARD: tmo_dev_edge 18 | ZEPHYR_DBOARD_ROOT: $GITHUB_WORKSPACE/zephyrproject/DevEdge-IoTDevKit-ZephyrRTOS -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_certs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_CERTS_H 8 | #define TMO_CERTS_H 9 | 10 | extern unsigned char ca_cert[]; 11 | extern int ca_cert_sz; 12 | extern int ca_cert_idx; 13 | int cmd_tmo_cert_load(const struct shell *shell, size_t argc, char **argv); 14 | int cmd_tmo_cert_list(const struct shell *shell, size_t argc, char **argv); 15 | int cmd_tmo_cert_info(const struct shell *shell, size_t argc, char **argv); 16 | int cmd_tmo_cert_dld(const struct shell *shell, size_t argc, char **argv); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /samples/tmo_shell/boards/tmo_dev_edge_mcuboot.overlay: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /{ 8 | chosen { 9 | zephyr,code-partition = &boot_partition; 10 | }; 11 | }; 12 | 13 | &flash0 { 14 | 15 | partitions { 16 | compatible = "fixed-partitions"; 17 | boot_partition: partition@0 { 18 | reg = <0x00000000 DT_SIZE_K(64)>; 19 | }; 20 | slot0_partition: partition@10000 { 21 | reg = <0x00010000 DT_SIZE_K(448)>; 22 | }; 23 | slot1_partition: partition@80000 { 24 | reg = <0x00080000 DT_SIZE_K(448)>; 25 | }; 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /samples/wake_sleep/boards/tmo_dev_edge_mcuboot.overlay: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /{ 8 | chosen { 9 | zephyr,code-partition = &boot_partition; 10 | }; 11 | }; 12 | 13 | &flash0 { 14 | 15 | partitions { 16 | compatible = "fixed-partitions"; 17 | boot_partition: partition@0 { 18 | reg = <0x00000000 DT_SIZE_K(64)>; 19 | }; 20 | slot0_partition: partition@10000 { 21 | reg = <0x00010000 DT_SIZE_K(448)>; 22 | }; 23 | slot1_partition: partition@80000 { 24 | reg = <0x00080000 DT_SIZE_K(448)>; 25 | }; 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /libs/dfu_murata_1sc/dfu_murata_1sc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef DFU_MURATA_1SC_H 8 | #define DFU_MURATA_1SC_H 9 | 10 | #include 11 | 12 | #include "dfu_common.h" 13 | 14 | #define DFU_MODEM_FW_VER_SIZE 32 15 | #define UA_HEADER_SIZE 256 16 | 17 | uint32_t murata_1sc_crc32_update(uint32_t crc32, const uint8_t *data, size_t len); 18 | uint32_t murata_1sc_crc32_finish(uint32_t crc32, size_t len); 19 | 20 | int dfu_modem_get_version(char *dfu_murata_version_str); 21 | int dfu_modem_firmware_upgrade(const struct dfu_file_t *dfu_file); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /samples/tmo_shell/boards/tmo_dev_edge.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2023 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | CONFIG_BT_DEVICE_NAME="TMO DevEdge" 6 | CONFIG_POSIX_CLOCK=y 7 | CONFIG_DEVICE_SHELL=y 8 | CONFIG_GPIO_SHELL=y 9 | CONFIG_SOC_GECKO_EMU_DCDC=y 10 | CONFIG_SOC_GECKO_EMU_DCDC_MODE_OFF=y 11 | CONFIG_I2C=y 12 | CONFIG_REBOOT=y 13 | CONFIG_LED=y 14 | CONFIG_LED_PWM=y 15 | CONFIG_LED_SHELL=y 16 | CONFIG_PWM=y 17 | CONFIG_PWM_SHELL=y 18 | CONFIG_PWM_GECKO=y 19 | CONFIG_SENSOR=y 20 | CONFIG_SENSOR_SHELL=y 21 | CONFIG_LPS22HH=y 22 | CONFIG_LIS2DW12=y 23 | CONFIG_TSL2540=y 24 | CONFIG_TMP108=y 25 | CONFIG_CXD5605=y 26 | CONFIG_SPI_NOR_IDLE_IN_DPD=y 27 | -------------------------------------------------------------------------------- /samples/tmo_shell/boards/tmo_dev_edge_slot_0.overlay: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /{ 8 | chosen { 9 | zephyr,code-partition = &slot0_partition; 10 | }; 11 | }; 12 | 13 | &flash0 { 14 | 15 | partitions { 16 | boot_partition: partition@0 { 17 | label = "mcuboot"; 18 | reg = <0x00000000 DT_SIZE_K(64)>; 19 | }; 20 | slot0_partition: partition@10000 { 21 | label = "image-0"; 22 | reg = <0x00010000 DT_SIZE_K(448)>; 23 | }; 24 | slot1_partition: partition@80000 { 25 | label = "image-1"; 26 | reg = <0x00080000 DT_SIZE_K(448)>; 27 | }; 28 | }; 29 | }; 30 | -------------------------------------------------------------------------------- /samples/tmo_shell/boards/tmo_dev_edge_slot_1.overlay: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /{ 8 | chosen { 9 | zephyr,code-partition = &slot1_partition; 10 | }; 11 | }; 12 | 13 | &flash0 { 14 | 15 | partitions { 16 | boot_partition: partition@0 { 17 | label = "mcuboot"; 18 | reg = <0x00000000 DT_SIZE_K(64)>; 19 | }; 20 | slot0_partition: partition@10000 { 21 | label = "image-0"; 22 | reg = <0x00010000 DT_SIZE_K(448)>; 23 | }; 24 | slot1_partition: partition@80000 { 25 | label = "image-1"; 26 | reg = <0x00080000 DT_SIZE_K(448)>; 27 | }; 28 | }; 29 | }; 30 | -------------------------------------------------------------------------------- /samples/wake_sleep/boards/tmo_dev_edge_slot_0.overlay: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /{ 8 | chosen { 9 | zephyr,code-partition = &slot0_partition; 10 | }; 11 | }; 12 | 13 | &flash0 { 14 | 15 | partitions { 16 | boot_partition: partition@0 { 17 | label = "mcuboot"; 18 | reg = <0x00000000 DT_SIZE_K(64)>; 19 | }; 20 | slot0_partition: partition@10000 { 21 | label = "image-0"; 22 | reg = <0x00010000 DT_SIZE_K(448)>; 23 | }; 24 | slot1_partition: partition@80000 { 25 | label = "image-1"; 26 | reg = <0x00080000 DT_SIZE_K(448)>; 27 | }; 28 | }; 29 | }; 30 | -------------------------------------------------------------------------------- /samples/wake_sleep/boards/tmo_dev_edge_slot_1.overlay: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /{ 8 | chosen { 9 | zephyr,code-partition = &slot1_partition; 10 | }; 11 | }; 12 | 13 | &flash0 { 14 | 15 | partitions { 16 | boot_partition: partition@0 { 17 | label = "mcuboot"; 18 | reg = <0x00000000 DT_SIZE_K(64)>; 19 | }; 20 | slot0_partition: partition@10000 { 21 | label = "image-0"; 22 | reg = <0x00010000 DT_SIZE_K(448)>; 23 | }; 24 | slot1_partition: partition@80000 { 25 | label = "image-1"; 26 | reg = <0x00080000 DT_SIZE_K(448)>; 27 | }; 28 | }; 29 | }; 30 | -------------------------------------------------------------------------------- /samples/illuminance/boards/tmo_dev_edge.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | CONFIG_BT_DEVICE_NAME="TMO DevEdge" 6 | CONFIG_POSIX_CLOCK=y 7 | CONFIG_CMU_HFCLK_HFXO=y 8 | CONFIG_DEVICE_SHELL=y 9 | CONFIG_GPIO_SHELL=n 10 | CONFIG_SOC_GECKO_EMU_DCDC=y 11 | CONFIG_SOC_GECKO_EMU_DCDC_MODE_OFF=y 12 | CONFIG_I2C=y 13 | CONFIG_SPI=y 14 | CONFIG_REBOOT=y 15 | CONFIG_COUNTER=y 16 | CONFIG_LED=y 17 | CONFIG_LED_PWM=y 18 | CONFIG_LED_SHELL=y 19 | CONFIG_PWM=y 20 | CONFIG_PWM_SHELL=n 21 | CONFIG_PWM_GECKO=y 22 | CONFIG_SENSOR=y 23 | CONFIG_SENSOR_SHELL=y 24 | CONFIG_LPS22HH=n 25 | CONFIG_LIS2DW12=n 26 | CONFIG_TSL2540=y 27 | CONFIG_TMP108=n 28 | CONFIG_CXD5605=n 29 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/overlay-aws-1sc.conf: -------------------------------------------------------------------------------- 1 | CONFIG_MAIN_STACK_SIZE=4096 2 | CONFIG_MQTT_LIB_TLS=y 3 | 4 | # TLS configuration 5 | CONFIG_MBEDTLS=y 6 | CONFIG_MBEDTLS_BUILTIN=y 7 | CONFIG_MBEDTLS_ENABLE_HEAP=y 8 | CONFIG_MBEDTLS_HEAP_SIZE=70000 9 | CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=10240 10 | CONFIG_NET_SOCKETS_SOCKOPT_TLS=y 11 | 12 | CONFIG_NET_SOCKETS_OFFLOAD=y 13 | CONFIG_NET_NATIVE=n 14 | CONFIG_NET_OFFLOAD=y 15 | 16 | CONFIG_AWS_URL="a1v55hb3re5xl0-ats.iot.us-east-1.amazonaws.com" #Replace with the relevant endpoint URL 17 | 18 | CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=2048 19 | 20 | CONFIG_NET_CONFIG_SETTINGS=n 21 | CONFIG_CTR_DRBG_CSPRNG_GENERATOR=y 22 | 23 | CONFIG_MODEM=y 24 | CONFIG_MODEM_MURATA_1SC=y -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_pm_sys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_PM_SYS_H 8 | #define TMO_PM_SYS_H 9 | #include 10 | 11 | int cmd_pmsysactive(const struct shell *shell, int argc, char** argv); 12 | int cmd_pmsysidle(const struct shell *shell, int argc, char** argv); 13 | int cmd_pmsyssuspend(const struct shell *shell, int argc, char** argv); 14 | int cmd_pmsysstandby(const struct shell *shell, int argc, char** argv); 15 | int cmd_pmsysoff(const struct shell *shell, int argc, char** argv); 16 | int cmd_pmsysfulloff(const struct shell *shell, int argc, char** argv); 17 | 18 | #endif /* TMO_PM_SYS_H */ 19 | -------------------------------------------------------------------------------- /samples/wake_sleep/boards/tmo_dev_edge.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | # CONFIG_BT_DEVICE_NAME="TMO DevEdge" 6 | CONFIG_POSIX_CLOCK=y 7 | CONFIG_CMU_HFCLK_HFXO=y 8 | # CONFIG_DEVICE_SHELL=y 9 | # CONFIG_GPIO_SHELL=y 10 | CONFIG_SOC_GECKO_EMU_DCDC=y 11 | CONFIG_SOC_GECKO_EMU_DCDC_MODE_OFF=y 12 | CONFIG_I2C=y 13 | CONFIG_SPI=y 14 | CONFIG_REBOOT=y 15 | CONFIG_COUNTER=y 16 | CONFIG_LED=y 17 | CONFIG_LED_PWM=y 18 | # CONFIG_LED_SHELL=y 19 | CONFIG_PWM=y 20 | # CONFIG_PWM_SHELL=y 21 | CONFIG_PWM_GECKO=y 22 | CONFIG_SENSOR=y 23 | # CONFIG_SENSOR_SHELL=y 24 | CONFIG_LPS22HH=y 25 | CONFIG_LIS2DW12=y 26 | CONFIG_TSL2540=y 27 | CONFIG_TMP108=y 28 | CONFIG_CXD5605=y 29 | -------------------------------------------------------------------------------- /samples/wake_sleep/src/strerror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /* 8 | * TODO: Replace this interim implementation with the system default, assuming it exists. 9 | */ 10 | 11 | #ifndef STRERROR_WORKAROUND_H_ 12 | #define STRERROR_WORKAROUND_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | /* 18 | * The following is included for Zephyr's non-standard support of strerror 19 | */ 20 | #ifndef sys_nerr 21 | #include "strerror_table.h" 22 | #define strerror strerror_extended 23 | const char *strerror(int error_value); 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif /* __cplusplus */ 29 | 30 | #endif /* STRERROR_WORKAROUND_H_ */ 31 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_hr/README.rst: -------------------------------------------------------------------------------- 1 | .. _peripheral_hr: 2 | 3 | Bluetooth: Peripheral HR 4 | ######################## 5 | 6 | Overview 7 | ******** 8 | 9 | Similar to the :ref:`Peripheral ` sample, except that this 10 | application specifically exposes the HR (Heart Rate) GATT Service. Once a device 11 | connects it will generate dummy heart-rate values. 12 | 13 | 14 | Requirements 15 | ************ 16 | 17 | * BlueZ running on the host, or 18 | * A board with BLE support 19 | 20 | Building and Running 21 | ******************** 22 | 23 | This sample can be found under :zephyr_file:`samples/bluetooth/peripheral_hr` in the 24 | Zephyr tree. 25 | 26 | See :ref:`bluetooth samples section ` for details. 27 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/boards/cc3220sf_launchxl.conf: -------------------------------------------------------------------------------- 1 | # Networking Config: 2 | CONFIG_NET_IPV4=y 3 | CONFIG_NET_IPV6=n 4 | CONFIG_NET_SOCKETS=y 5 | CONFIG_NET_NATIVE=n 6 | CONFIG_TEST_RANDOM_GENERATOR=y 7 | 8 | # Enable SimpleLink WiFi Driver and Socket Offload 9 | CONFIG_WIFI=y 10 | CONFIG_WIFI_SIMPLELINK=y 11 | CONFIG_NET_SOCKETS_OFFLOAD=y 12 | 13 | # Enable TLS credential filenames for secure socket offload 14 | CONFIG_TLS_CREDENTIAL_FILENAMES=y 15 | 16 | # Disable unneeded settings from the base prj.conf: 17 | CONFIG_DNS_RESOLVER=n 18 | CONFIG_NET_CONFIG_SETTINGS=n 19 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="" 20 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" 21 | 22 | # Debugging 23 | CONFIG_NET_LOG=y 24 | CONFIG_WIFI_LOG_LEVEL_DBG=y 25 | CONFIG_DEBUG=y 26 | CONFIG_ASSERT=y 27 | -------------------------------------------------------------------------------- /set-zephyr-build-env: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # adds any out of tree drivers built as modules to the zephyr build path 4 | 5 | if [ -n "$ZSH_VERSION" ]; then 6 | SCRIPT=${(%):-%x} 7 | elif [ -n "$BASH_VERSION" ]; then 8 | SCRIPT=${BASH_SOURCE[0]} 9 | elif eval '[[ -n ${.sh.file} ]]' 2>/dev/null; then 10 | eval 'SCRIPT=${.sh.file}' 11 | fi 12 | LOCATION=$(dirname "$(readlink -f -- "$SCRIPT")") 13 | if [ -n "${ZEPHYR_EXTRA_MODULES+1}" ]; then 14 | export ZEPHYR_EXTRA_MODULES="$ZEPHYR_EXTRA_MODULES\;$LOCATION" 15 | else 16 | export ZEPHYR_EXTRA_MODULES="$LOCATION" 17 | fi 18 | #add lines as needed for each driver below 19 | 20 | #export ZEPHYR_EXTRA_MODULES=$ZEPHYR_EXTRA_MODULES\;$LOCATION/drivers/(another driver here) 21 | 22 | echo "$ZEPHYR_EXTRA_MODULES" 23 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_sc_only/README.rst: -------------------------------------------------------------------------------- 1 | .. _peripheral_sc_only: 2 | 3 | Bluetooth: Peripheral SC-only 4 | ############################# 5 | 6 | Overview 7 | ******** 8 | 9 | Similar to the :ref:`Peripheral ` sample, except that this 10 | application enables the Secure Connections Only mode, i.e. will only 11 | accept connections that are secured using security level 4 (FIPS). 12 | 13 | 14 | Requirements 15 | ************ 16 | 17 | * BlueZ running on the host, or 18 | * A board with BLE support 19 | 20 | Building and Running 21 | ******************** 22 | 23 | This sample can be found under :zephyr_file:`samples/bluetooth/peripheral_sc_only` 24 | in the Zephyr tree. 25 | 26 | See :ref:`bluetooth samples section ` for details. 27 | -------------------------------------------------------------------------------- /samples/illuminance/prj.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | # UART support 6 | CONFIG_SERIAL=y 7 | CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=1024 8 | CONFIG_RING_BUFFER=y 9 | 10 | # Sensor 11 | CONFIG_SENSOR=y 12 | CONFIG_STDOUT_CONSOLE=y 13 | CONFIG_CBPRINTF_FP_SUPPORT=y 14 | CONFIG_I2C=y 15 | 16 | # TSL2540 interrupt support 17 | # CONFIG_TSL2540_TRIGGER_NONE=y 18 | # CONFIG_TSL2540_TRIGGER_GLOBAL_THREAD=y 19 | CONFIG_TSL2540_TRIGGER_OWN_THREAD=y 20 | 21 | # Power Management 22 | CONFIG_PM=y 23 | # CONFIG_PM_DEVICE=y 24 | 25 | # GPIO 26 | CONFIG_GPIO=y 27 | CONFIG_SHELL=y 28 | CONFIG_SHELL_LOG_LEVEL_INF=y 29 | CONFIG_SHELL_CMD_BUFF_SIZE=2100 30 | 31 | # Logging 32 | CONFIG_LOG=y 33 | CONFIG_LOG_MODE_IMMEDIATE=y 34 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/boards/cc3235sf_launchxl.conf: -------------------------------------------------------------------------------- 1 | # Networking Config: 2 | CONFIG_NET_IPV4=y 3 | CONFIG_NET_IPV6=n 4 | CONFIG_NET_SOCKETS=y 5 | CONFIG_NET_NATIVE=n 6 | CONFIG_TEST_RANDOM_GENERATOR=y 7 | 8 | # Enable SimpleLink WiFi Driver and Socket Offload 9 | CONFIG_WIFI=y 10 | CONFIG_WIFI_SIMPLELINK=y 11 | CONFIG_NET_SOCKETS_OFFLOAD=y 12 | 13 | # Enable TLS credential filenames for secure socket offload 14 | CONFIG_TLS_CREDENTIAL_FILENAMES=y 15 | 16 | # Disable unneeded settings from the base prj.conf: 17 | CONFIG_DNS_RESOLVER=n 18 | CONFIG_NET_CONFIG_SETTINGS=n 19 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="" 20 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" 21 | 22 | # Debugging 23 | CONFIG_NET_LOG=y 24 | CONFIG_WIFI_LOG_LEVEL_DBG=y 25 | CONFIG_DEBUG=y 26 | CONFIG_CC3235SF_DEBUG=y 27 | CONFIG_ASSERT=y 28 | -------------------------------------------------------------------------------- /samples/letimer/README.rst: -------------------------------------------------------------------------------- 1 | .. _letimer: 2 | 3 | LETIMER 4 | ########### 5 | 6 | Overview 7 | ******** 8 | 9 | A simple sample that can be used with any silabs gecko based board and 10 | tests the LETIMER driver 11 | 12 | Building and Running 13 | ******************** 14 | 15 | This application can be built and executed on DevEdge as follows: 16 | 17 | .. zephyr-app-commands:: 18 | :zephyr-app: samples/letimer 19 | :host-os: unix 20 | :board: tmo_dev_edge 21 | :goals: run 22 | :compact: 23 | 24 | To build for another board, change "tmo_dev_edge" above to that board's name. 25 | 26 | Sample Output 27 | ============= 28 | 29 | .. code-block:: console 30 | 31 | 1 second 32 | 1 second (2) 33 | 1 second (3) 34 | 1 second (4) 35 | 1 second (5) 36 | 60 second 37 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/overlay-aws-9116.conf: -------------------------------------------------------------------------------- 1 | CONFIG_MAIN_STACK_SIZE=4096 2 | CONFIG_MQTT_LIB_TLS=y 3 | 4 | # TLS configuration 5 | CONFIG_MBEDTLS=y 6 | CONFIG_MBEDTLS_BUILTIN=y 7 | CONFIG_MBEDTLS_ENABLE_HEAP=y 8 | CONFIG_MBEDTLS_HEAP_SIZE=70000 9 | CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=10240 10 | CONFIG_NET_SOCKETS_SOCKOPT_TLS=y 11 | 12 | #RS9116 13 | CONFIG_NET_SOCKETS_OFFLOAD=y 14 | CONFIG_NET_NATIVE=n 15 | CONFIG_WIFI=y 16 | CONFIG_WIFI_RS9116W=y 17 | CONFIG_NET_L2_WIFI_SHELL=y 18 | 19 | CONFIG_AWS_URL="a1v55hb3re5xl0-ats.iot.us-east-1.amazonaws.com" #Replace with the relevant endpoint URL 20 | CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=2048 21 | 22 | CONFIG_CTR_DRBG_CSPRNG_GENERATOR=y 23 | CONFIG_NET_CONFIG_SETTINGS=n 24 | 25 | CONFIG_NET_SAMPLE_SSID="" 26 | CONFIG_NET_SAMPLE_PSK="" 27 | -------------------------------------------------------------------------------- /libs/dfu_gecko/dfu_gecko_lib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef DFU_GECKO_H 8 | #define DFU_GECKO_H 9 | 10 | #include "dfu_common.h" 11 | 12 | #define DFU_IMAGE_HDR_LEN 32 13 | #define DFU_SLOT0_FLASH_ADDR 0x10000 14 | #define DFU_SLOT1_FLASH_ADDR 0x80000 15 | #define DFU_IMAGE_MAGIC 0x96f3b83d 16 | 17 | #ifdef BOOT_SLOT 18 | int is_bootloader_running(void); 19 | int erase_image_slot(int slot); 20 | int get_gecko_fw_version(int boot_slot, char *version, int max_len); 21 | int print_gecko_slot_info(void); 22 | int get_current_slot(void); 23 | int get_unused_slot(void); 24 | int dfu_mcu_firmware_upgrade(int slot_to_upgrade, char *bin_file, char *sha_file); 25 | bool slot_is_safe_to_erase(int slot); 26 | #endif 27 | #endif 28 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_pm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_PM_H 8 | #define TMO_PM_H 9 | #include 10 | 11 | int cmd_pmresume(const struct shell *shell, int argc, char** argv); 12 | int cmd_pmsuspend(const struct shell *shell, int argc, char** argv); 13 | int cmd_pmoff(const struct shell *shell, int argc, char** argv); 14 | int cmd_pmon(const struct shell *shell, int argc, char** argv); 15 | int cmd_pmget(const struct shell *shell, int argc, char** argv); 16 | int cmd_pmlock(const struct shell *shell, int argc, char** argv); 17 | int cmd_pmunlock(const struct shell *shell, int argc, char** argv); 18 | void pm_device_name_get(size_t idx, struct shell_static_entry *entry); 19 | 20 | #endif /* TMO_PM_H */ 21 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_dfu_download.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_DFU_DOWNLOAD_H 8 | #define TMO_DFU_DOWNLOAD_H 9 | 10 | #include 11 | 12 | #include "tmo_shell.h" 13 | #include "dfu_common.h" 14 | 15 | #include "dfu_murata_1sc.h" 16 | #include "dfu_rs9116w.h" 17 | #include "dfu_gecko_lib.h" 18 | 19 | enum dfu_tgts { 20 | DFU_GECKO = 0, 21 | DFU_MODEM, 22 | DFU_9116W 23 | }; 24 | 25 | int tmo_dfu_download(const struct shell *shell, enum dfu_tgts dfu_tgt, char *filename, 26 | char *version); 27 | int set_dfu_base_url(char *base_url); 28 | int set_dfu_auth_key(char *auth_key); 29 | const char *get_dfu_base_url(void); 30 | int set_dfu_iface_type(int iface); 31 | int get_dfu_iface_type(void); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /samples/tmo_shell/overlay-slot.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | # Put BOOT LOADER config here ... 6 | CONFIG_BOOTLOADER_MCUBOOT=y 7 | 8 | # Chain-loadable image will be linked into its code partition, specified in DeviceTree. 9 | CONFIG_USE_DT_CODE_PARTITION=y 10 | 11 | # Force the initialization of the internal Cortex-M architectural state during boot 12 | # to the reset values as specified by the corresponding Arm architecture manual. 13 | CONFIG_INIT_ARCH_HW_AT_BOOT=y 14 | 15 | # chain-loadable images relocate the Cortex-M vector table by updating the VTOR register with the offset of the image vector table. 16 | # CONFIG_CPU_CORTEX_M_HAS_VTOR=y 17 | 18 | # Relay exceptions and interrupts based on a vector table pointer that is set by the chain-loadable application. 19 | CONFIG_SW_VECTOR_RELAY=y 20 | -------------------------------------------------------------------------------- /samples/wake_sleep/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | cmake_minimum_required(VERSION 3.20.0) 6 | 7 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 8 | project(wake_sleep) 9 | 10 | # TODO: Remove the following after the stderror.h workacound is addressed/removed. 11 | # 12 | # add_definitions(-include /Users/john/Work/zephyrproject-rebase/DevEdge-IoTDevKit-ZephyrSDK/samples/wake_sleep/src/stderror.h) 13 | # target_precompile_headers(app 14 | # # PUBLIC 15 | # # project_header.h 16 | # PRIVATE 17 | # [["src/stderror.h"]] 18 | # 19 | # ) 20 | 21 | # TODO: ...additionally, uncomment the following and remove the subquent two lines 22 | # target_sources(app PRIVATE "src/main.c") 23 | FILE(GLOB app_sources src/*.c) 24 | target_sources(app PRIVATE ${app_sources}) 25 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/prj.conf: -------------------------------------------------------------------------------- 1 | CONFIG_NETWORKING=y 2 | CONFIG_NET_SOCKETS=y 3 | CONFIG_NET_TCP=y 4 | CONFIG_NET_LOG=y 5 | 6 | CONFIG_NET_IPV6_RA_RDNSS=y 7 | CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3 8 | CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2 9 | 10 | CONFIG_PRINTK=y 11 | CONFIG_STDOUT_CONSOLE=y 12 | 13 | # Enable IPv6 support 14 | CONFIG_NET_IPV6=n 15 | # Enable IPv4 support 16 | CONFIG_NET_IPV4=y 17 | 18 | # Enable the MQTT Lib 19 | CONFIG_MQTT_LIB=y 20 | 21 | CONFIG_NET_CONFIG_SETTINGS=y 22 | CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1" 23 | CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2" 24 | 25 | CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1" 26 | CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2" 27 | 28 | CONFIG_MAIN_STACK_SIZE=2048 29 | 30 | # For IPv6 31 | CONFIG_NET_BUF_DATA_SIZE=256 32 | 33 | CONFIG_NET_SHELL=y 34 | 35 | CONFIG_ENTROPY_GENERATOR=y 36 | CONFIG_TEST_RANDOM_GENERATOR=y 37 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_ble_demo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_BLE_DEMO_H 8 | #define TMO_BLE_DEMO_H 9 | 10 | #include 11 | 12 | typedef struct sensor_value SENSOR_VALUE_STRUCT; 13 | int read_accelerometer( SENSOR_VALUE_STRUCT* acc_sensor_arr); 14 | bool fetch_temperature(SENSOR_VALUE_STRUCT* temp); 15 | bool fetch_light(SENSOR_VALUE_STRUCT* light); 16 | bool fetch_ir(SENSOR_VALUE_STRUCT* ir); 17 | bool fetch_pressure(SENSOR_VALUE_STRUCT* temp); 18 | 19 | int cmd_ble_adv_ebeacon(const struct shell *shell, size_t argc, char **argv); 20 | int cmd_ble_adv_ibeacon(const struct shell *shell, size_t argc, char **argv); 21 | int cmd_ble_adv_conn(const struct shell *shell, size_t argc, char **argv); 22 | int cmd_ble_conn_rssi(const struct shell *shell, size_t argc, char **argv); 23 | int cmd_ble_mac(const struct shell *shell, size_t argc, char **argv); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /samples/illuminance/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | # 5 | 6 | mainmenu "ams OSRAM TSL2540" 7 | 8 | config APP_LIGHT_ALERT_HIGH_THRESH 9 | int "High threshold for alert trigger in lux" 10 | range 0 79110 11 | default 1000 12 | help 13 | TODO: replace the following text with relevant information 14 | Set this to enable alerts for high lux 15 | although this will work with one shot enabled, 16 | it requires continuous monitoring mode to be enabled 17 | to work in real time. 18 | See spec sheet for more details. 19 | 20 | config APP_LIGHT_ALERT_LOW_THRESH 21 | int "Low threshold for alert trigger in lux" 22 | range 0 79110 23 | default 10 24 | help 25 | TODO: replace the following text with relevant information 26 | Set this to enable alerts for low temperatures 27 | although this will work with one shot enabled, 28 | it requires continuous monitoring mode to be enabled 29 | to work in real time. 30 | See spec sheet for more details. 31 | 32 | source "Kconfig.zephyr" 33 | -------------------------------------------------------------------------------- /samples/letimer/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | void main(void) 11 | { 12 | printk("Test start\n"); 13 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_SUSPEND_TO_IDLE, 0, 0}); 14 | k_msleep(1000); 15 | printk("1 second\n"); 16 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_SUSPEND_TO_IDLE, 0, 0}); 17 | k_msleep(1000); 18 | printk("1 second (2)\n"); 19 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_SUSPEND_TO_IDLE, 0, 0}); 20 | k_msleep(1000); 21 | printk("1 second (3)\n"); 22 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_SUSPEND_TO_IDLE, 0, 0}); 23 | k_msleep(1000); 24 | printk("1 second (4)\n"); 25 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_SUSPEND_TO_IDLE, 0, 0}); 26 | k_msleep(1000); 27 | printk("1 second (5)\n"); 28 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_SUSPEND_TO_IDLE, 0, 0}); 29 | k_msleep(60000); 30 | printk("60 second\n"); 31 | } 32 | -------------------------------------------------------------------------------- /samples/tmo_shell/overlay-bl.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | # mcuboot will relocate the interrupt vector to the booted application 6 | CONFIG_BOOT_INTR_VEC_RELOC=y 7 | 8 | # Chain-loadable image will be linked into its code partition, specified in DeviceTree. 9 | CONFIG_USE_DT_CODE_PARTITION=y 10 | 11 | # Force the initialization of the internal Cortex-M architectural state during boot 12 | # to the reset values as specified by the corresponding Arm architecture manual. 13 | CONFIG_INIT_ARCH_HW_AT_BOOT=y 14 | 15 | # chain-loadable images relocate the Cortex-M vector table by updating the 16 | # VTOR register with the offset of the image vector table. 17 | #CONFIG_CPU_CORTEX_M_HAS_VTOR=y 18 | 19 | # Relay exceptions and interrupts based on a vector table pointer that is set by the chain-loadable application. 20 | CONFIG_SW_VECTOR_RELAY=y 21 | 22 | # Zephyr will relocate .text, data and .bss sections from the specified files and 23 | # place it in SRAM. 24 | CONFIG_BOOT_DIRECT_XIP=y 25 | 26 | CONFIG_SPI=y 27 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_tone_player.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_TONE_PLAYER_H 8 | #define TMO_TONE_PLAYER_H 9 | 10 | /** 11 | * @brief Play a tone binary file 12 | * 13 | * @param filename Filename of the tone binary 14 | * @param finished_callback Callback function for tone sequence finish 15 | * @return 0 on sucess, negative error on failure 16 | */ 17 | int play_tone_bin(char* filename, void (*finished_callback)(void)); 18 | 19 | /** 20 | * @brief Play a single note 21 | * 22 | * @param freq Frequency of the note 23 | * @param duration Duration in milliseconds 24 | * @param finished_callback Callback function for note finish 25 | * @return 0 on sucess, negative error on failure 26 | */ 27 | int play_single_note(uint16_t freq, uint16_t duration, void (*finished_callback)(void)); 28 | 29 | /** 30 | * @brief Cancel playback of current tone sequence 31 | * 32 | * @return 0 on sucess, negative error on failure 33 | */ 34 | int cancel_playback(void); 35 | 36 | #endif /* TMO_TONE_PLAYER_H */ 37 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_battery_ctrl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_BATTERY_CTRL_H 8 | #define TMO_BATTERY_CTRL_H 9 | 10 | #include 11 | 12 | /** Uint : Percentage **/ 13 | #define FULL_CHARGED_LV 90 14 | #define HIGH_CHARGED_LV 80 15 | #define LOW_CHARGED_LV 30 16 | #define MIN_CHARGED_LV 10 17 | 18 | #define HIGH_BATTERY_LV 60 19 | #define LOW_BATTERY_LV 30 20 | 21 | #define PROTECTED_CUT_LV 6 22 | 23 | #define CHARGER_STAT_READY 0 24 | #define CHARGER_STAT_INPROG 1 25 | #define CHARGER_STAT_FULL 2 26 | #define CHARGER_STAT_FAULT 3 27 | 28 | #define CUR_STAT_UNKNOWN 0 29 | #define CUR_STAT_BATTERY 10 30 | #define CUR_STAT_INPROG 20 31 | #define CUR_STAT_FULL 30 32 | #define CUR_STAT_FAULT 40 33 | 34 | bool getBatteryPercent(uint8_t *bv); 35 | float get_remaining_capacity(float battery_voltage); 36 | bool is_battery_charging(void); 37 | int get_battery_charging_status(uint8_t *charging, uint8_t *vbus, uint8_t *attached, uint8_t *fault); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/Kconfig: -------------------------------------------------------------------------------- 1 | # Config options for mqtt_publisher sample application 2 | 3 | # Copyright (c) 2020 Intel Corporation 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | mainmenu "Networking mqtt_publisher sample application" 7 | 8 | config NET_SAMPLE_APP_MAX_ITERATIONS 9 | int "Number of times to Publish sample MQTT messages" 10 | default 500 11 | help 12 | Send sample MQTT messages this many times in a MQTT connection 13 | before exiting. A value of zero means that the messages are sent 14 | forever. 15 | 16 | config NET_SAMPLE_APP_MAX_CONNECTIONS 17 | int "Number of times to connect to the MQTT server" 18 | default 0 19 | help 20 | Number of times to connect to the MQTT server. With each connection 21 | send NET_SAMPLE_APP_MAX_ITERATIONS amount of MQTT sample messages. 22 | A value of zero means to continue forever. 23 | 24 | config NET_SAMPLE_SSID 25 | string "SSID of WiFi Network to Automatically Connect to" 26 | default "" 27 | 28 | config NET_SAMPLE_PSK 29 | string "PSK of WiFi Network to Automatically Connect to" 30 | default "" 31 | 32 | config AWS_URL 33 | string "AWS Endpoint URL" 34 | default "" 35 | 36 | source "Kconfig.zephyr" 37 | -------------------------------------------------------------------------------- /samples/illuminance/README.rst: -------------------------------------------------------------------------------- 1 | . 2 | . 3 | . 4 | ============= 5 | Sample output 6 | ============= 7 | 8 | 9 | >> *** Booting Zephyr OS build 596dd391de46 *** 10 | 11 | Welcome to T-Mobile - Internet of Things 12 | 13 | This application aims to demonstrate the Gecko's Energy Mode 2 (EM2) (Deep Sleep 14 | Mode) sleep/wake capabilities in conjunction with the high/low illuminance 15 | threshold detection circuitry of the TSL2540 light sensor integrated into the 16 | tmo_dev_edge. 17 | 18 | 19 | While observing the console output, increase the light illuminating the 20 | tmo_dev_edge's light sensor until the sensor readings at or above the high 21 | threshold are displayed. Reducing the intensity of the light source will cause 22 | the alerts to cease. Casting a shadow over the light sensor will cause sensor 23 | readings at or below the low threshold to be displayed. 24 | 25 | 26 | Awaiting TSL2540 illuminance threshold-high/threshold-low alerts 27 | 28 | [00:00:01.007,000] illuminance: Set up button at gpio@4000a030 pin 13 29 | 30 | Set SENSOR_ATTR_UPPER_THRESH (1000lx) 31 | Set SENSOR_ATTR_LOWER_THRESH (10lx) 32 | [00:00:01.259,000] tsl2540: Interrupt status(0x93): 0x10: AINT 33 | uart:~$ 34 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/ca_certificate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Nordic Semiconductor ASA 3 | * Copyright (c) 2022 T-Mobile USA, Inc. 4 | * 5 | * SPDX-License-Identifier: Apache-2.0 6 | */ 7 | 8 | #ifndef __CA_CERTIFICATE_H__ 9 | #define __CA_CERTIFICATE_H__ 10 | 11 | enum tls_tag { 12 | CA_CERTIFICATE_TAG = 1, 13 | CLIENT_CERTIFICATE_TAG, //in tls_credential.h defined as TLS_CREDENTIAL_SERVER_CERTIFICATE 14 | CLIENT_KEY_TAG, 15 | PSK_TAG 16 | }; 17 | 18 | #define TLS_PEER_HOSTNAME "" 19 | 20 | /* This is the same cert as what is found in net-tools/echo-apps-cert.pem file 21 | */ 22 | static const unsigned char dev_certificate[] = { 23 | #include "devcert.der.inc" 24 | }; 25 | 26 | static const unsigned char dtls_server_cert[] = { 27 | #include "servercert.der.inc" 28 | }; 29 | 30 | static const unsigned char entrust_g2[] = { 31 | #include "entrust_g2_ca.der.inc" 32 | }; 33 | 34 | static const unsigned char dev_private_key[] = { 35 | #include "devkey.der.inc" 36 | }; 37 | 38 | static const unsigned char digicert_ca[] = { 39 | #include "digicert_ca.der.inc" 40 | }; 41 | 42 | #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) 43 | #include CONFIG_NET_SAMPLE_PSK_HEADER_FILE 44 | #endif 45 | 46 | #endif /* __CA_CERTIFICATE_H__ */ 47 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/ek18/src/cdefs.h: -------------------------------------------------------------------------------- 1 | #ifndef __CDEFS_H__ 2 | #define __CDEFS_H__ 3 | 4 | /* 5 | By default, the internal routines of kermit.c are not static, 6 | because this is not allowed in some embedded environments. 7 | To have them declared static, define STATIC=static on the cc 8 | command line. 9 | */ 10 | #ifdef XAC /* HiTech's XAC cmd line is small */ 11 | #define STATIC static 12 | #else /* XAC */ 13 | #ifndef STATIC 14 | #define STATIC 15 | #endif /* STATIC */ 16 | #endif /* XAC */ 17 | 18 | /* 19 | By default we assume the compiler supports unsigned char and 20 | unsigned long. If not you can override these definitions on 21 | the cc command line. 22 | */ 23 | #ifndef HAVE_UCHAR 24 | typedef unsigned char UCHAR; 25 | #endif /* HAVE_UCHARE */ 26 | #ifndef HAVE_ULONG 27 | typedef unsigned long ULONG; 28 | #endif /* HAVE_ULONG */ 29 | #ifndef HAVE_USHORT 30 | typedef unsigned short USHORT; 31 | #endif /* HAVE_USHORT */ 32 | 33 | /* Unix platform.h for EK */ 34 | 35 | #ifndef IBUFLEN 36 | #define IBUFLEN 2048 /* File input buffer size */ 37 | #endif /* IBUFLEN */ 38 | 39 | #ifndef OBUFLEN 40 | #define OBUFLEN 2048 /* File output buffer size */ 41 | #endif /* OBUFLEN */ 42 | 43 | #define P_PKTLEN 2000 44 | #define P_WSLOTS 4 45 | 46 | #endif /* __CDEFS_H__ */ 47 | -------------------------------------------------------------------------------- /samples/tmo_shell/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | mainmenu "tmo_shell application settings" 6 | 7 | config TMO_SHELL_SSID 8 | string "SSID of WiFi network to automatically connect to" 9 | default "" 10 | 11 | config TMO_SHELL_PSK 12 | string "PSK of WiFi network to automatically connect to" 13 | default "" 14 | 15 | config TMO_SHELL_USE_MBED 16 | bool "Configure HTTP to use mbedTLS for TLS connections" 17 | default n 18 | 19 | config TMO_SHELL_ASYNC_SMS 20 | bool "Use asynchronous callback for SMS" 21 | select MODEM_SMS_CALLBACK 22 | default n 23 | 24 | config TMO_SHELL_BUILD_EK 25 | bool "Build in ekermit" 26 | select USE_SEGGER_RTT 27 | default n 28 | 29 | config TMO_HTTP_MOCK_SOCKET 30 | bool "Use mock socket for HTTP unit testing" 31 | default n 32 | 33 | config SEGGER_RTT_BUFFER_SIZE_DOWN 34 | int 35 | default 8192 if TMO_SHELL_BUILD_EK 36 | 37 | config TMO_FUEL_GAUGE_STATE_CHANGE_PRINT 38 | bool "Print messages on fuel guage state change" 39 | default n 40 | 41 | config TMO_TEST_MFG_CHECK_GOLDEN 42 | bool "Check modem type is golden" 43 | default y 44 | 45 | config TMO_TEST_MFG_CHECK_ACCESS_CODE 46 | bool "Check access code is present" 47 | default y 48 | 49 | source "Kconfig.zephyr" 50 | -------------------------------------------------------------------------------- /samples/as6212_sample/Kconfig: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 Jimmy Johnson 2 | # Copyright (c) 2022-2023 T-Mobile USA, Inc. 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 5 | # 6 | 7 | mainmenu "TMP108 sample application" 8 | 9 | config APP_REPORT_TEMP_ALERTS 10 | bool "Report over and under temperature alerts" 11 | default n 12 | 13 | config APP_ENABLE_ONE_SHOT 14 | bool "One shot low power mode" 15 | default n 16 | help 17 | One shot requires a callback to be invoked after the tmp108 has 18 | woken up and taken a temperature reading, calling sample_fetch 19 | starts this process. Set this to enable 1 shot mode example. 20 | 21 | config APP_TEMP_ALERT_HIGH_THRESH 22 | int "RH [%] high threshold for alert trigger in celsius" 23 | range 0 50 24 | default 44 25 | help 26 | Set this to enable alerts for high temperatures 27 | although this will work with one shot enabled, 28 | it requires continuous monitoring mode to be enabled 29 | to work in real time. 30 | See spec sheet for more details. 31 | 32 | config APP_TEMP_ALERT_LOW_THRESH 33 | int "RH [%] low threshold for alert trigger in celsius" 34 | range 0 50 35 | default 38 36 | help 37 | Set this to enable alerts for low temperatures 38 | although this will work with one shot enabled, 39 | it requires continuous monitoring mode to be enabled 40 | to work in real time. 41 | See spec sheet for more details. 42 | 43 | source "Kconfig.zephyr" 44 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_web_demo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_WEB_DEMO_H 8 | #define TMO_WEB_DEMO_H 9 | 10 | #define TRANSMIT_INTERVAL_SECS_WEB 10 11 | #define MAX_PAYLOAD_BUFFER_SIZE 400 12 | 13 | typedef struct sensor_value SENSOR_VALUE_STRUCT; 14 | struct web_demo_settings_t { 15 | bool transmit_flag; 16 | unsigned int number_http_requests; 17 | unsigned int iface_type; 18 | unsigned int transmit_interval; 19 | }; 20 | 21 | enum battery_state { 22 | battery_state_charging, 23 | battery_state_not_charging, 24 | battery_state_not_attached, 25 | battery_state_attached 26 | }; 27 | 28 | bool get_transmit_flag(); 29 | bool set_transmit_json_flag( bool user_transmit_setting); 30 | void set_transmit_interval(int secs); 31 | char* get_json_payload_pointer(); 32 | int increment_number_http_requests(); 33 | int get_web_demo_settings(struct web_demo_settings_t *ws); 34 | int set_json_iface_type (int iface_type); 35 | int get_json_iface_type(); 36 | int set_json_base_url(const char *base_url); 37 | char *get_json_base_url(); 38 | int set_json_path(const char *path); 39 | char *get_json_path(); 40 | int get_cell_strength(int *val); 41 | 42 | int create_json(); 43 | int read_accelerometer( SENSOR_VALUE_STRUCT *acc_sensor_arr); 44 | #ifdef CONFIG_DEBUG_TMO_WEB_DEMO 45 | #define printf_debug printf 46 | #else 47 | #define printf_debug if(0)printf 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/docker-test.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 Intel Corporation 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | if [ -z "$RUNNING_FROM_MAIN_SCRIPT" ]; then 5 | echo "Do not run this script directly!" 6 | echo "Run $ZEPHYR_BASE/scripts/net/run-sample-tests.sh instead." 7 | exit 1 8 | fi 9 | 10 | echo "Starting MQTT test" 11 | 12 | start_configuration || return $? 13 | start_docker \ 14 | "/usr/local/sbin/mosquitto -v -c /usr/local/etc/mosquitto/mosquitto.conf" || return $? 15 | 16 | start_zephyr -DOVERLAY_CONFIG=overlay-sample.conf "$overlay" 17 | 18 | wait_zephyr 19 | result=$? 20 | 21 | if [ $result -ne 0 ]; then 22 | return $result 23 | fi 24 | 25 | stop_docker 26 | 27 | # test TLS 28 | echo "Starting MQTT TLS test" 29 | 30 | start_docker \ 31 | "/usr/local/sbin/mosquitto -v -c /usr/local/etc/mosquitto/mosquitto-tls.conf" || return $? 32 | 33 | start_zephyr -DOVERLAY_CONFIG="overlay-tls.conf overlay-sample.conf" "$overlay" 34 | 35 | wait_zephyr 36 | result=$? 37 | 38 | if [ $result -ne 0 ]; then 39 | return $result 40 | fi 41 | 42 | stop_docker 43 | return $result 44 | 45 | # FIXME: proxy test does not work as expected 46 | 47 | # TLS and SOCKS5, mosquitto TLS is already running 48 | echo "Starting MQTT TLS + proxy test" 49 | 50 | start_docker "/usr/sbin/danted" || return $? 51 | 52 | start_zephyr -DOVERLAY_CONFIG="overlay-tls.conf overlay-sample.conf overlay-socks5.conf" "$overlay" || return $? 53 | 54 | wait_zephyr 55 | result=$? 56 | 57 | stop_docker 58 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/ek18/src/debug.h: -------------------------------------------------------------------------------- 1 | #define NODEBUG 2 | #ifndef NODEBUG /* NODEBUG inhibits debugging */ 3 | #ifndef DEBUG /* and if DEBUG not already defined */ 4 | #ifndef MINSIZE /* MINSIZE inhibits debugging */ 5 | #ifndef DEBUG 6 | #define DEBUG 7 | #endif /* DEBUG */ 8 | #endif /* MINSIZE */ 9 | #endif /* DEBUG */ 10 | #endif /* NODEBUG */ 11 | 12 | #ifdef DEBUG /* Debugging included... */ 13 | /* dodebug() function codes... */ 14 | #define DB_OPN 1 /* Open log */ 15 | #define DB_LOG 2 /* Write label+string or int to log */ 16 | #define DB_MSG 3 /* Write message to log */ 17 | #define DB_CHR 4 /* Write label + char to log */ 18 | #define DB_PKT 5 /* Record a Kermit packet in log */ 19 | #define DB_CLS 6 /* Close log */ 20 | 21 | void dodebug(int, UCHAR *, UCHAR *, long); /* Prototype */ 22 | /* 23 | dodebug() is accessed throug a macro that: 24 | . Coerces its args to the required types. 25 | . Accesses dodebug() directly or thru a pointer according to context. 26 | . Makes it disappear entirely if DEBUG not defined. 27 | */ 28 | #ifdef KERMIT_C 29 | /* In kermit.c we debug only through a function pointer */ 30 | #define debug(a,b,c,d) \ 31 | if(*(k->dbf))(*(k->dbf))(a,(UCHAR *)b,(UCHAR *)c,(long)(d)) 32 | 33 | #else /* KERMIT_C */ 34 | /* Elsewhere we can call the debug function directly */ 35 | #define debug(a,b,c,d) dodebug(a,(UCHAR *)b,(UCHAR *)c,(long)(d)) 36 | #endif /* KERMIT_C */ 37 | 38 | #else /* Debugging not included... */ 39 | 40 | #define debug(a,b,c,d) 41 | #endif /* DEBUG */ 42 | -------------------------------------------------------------------------------- /samples/bluetooth/bandwidth_test/bw_test.py: -------------------------------------------------------------------------------- 1 | import asyncio, tqdm, uuid 2 | import itertools 3 | from asyncio import sleep 4 | from bleak import BleakScanner, BleakClient 5 | from bleak.backends.scanner import AdvertisementData 6 | from bleak.backends.device import BLEDevice 7 | 8 | BWT_UUID = uuid.UUID('5432e12b-34be-4996-aafa-bdc0c7554b89') 9 | 10 | def handle_disconnect(_: BleakClient): 11 | print("Device was disconnected, goodbye.") 12 | # cancelling all tasks effectively ends the program 13 | for task in asyncio.all_tasks(): 14 | task.cancel() 15 | 16 | def match_name(device: BLEDevice, adv: AdvertisementData): 17 | if device.name: 18 | print(f"Device: {device.name}") 19 | return "T-Mobile" in (device.name or "") 20 | 21 | async def main(): 22 | device = None 23 | print("Scanning for devedge board") 24 | while not device: 25 | device = await BleakScanner.find_device_by_filter(match_name) 26 | if not device: 27 | await sleep(5) 28 | async with BleakClient(device, disconnected_callback=handle_disconnect) as client: 29 | await sleep(2) 30 | services = await client.get_services() 31 | chrcs = itertools.chain(*(i.characteristics for i in services)) 32 | chrc = None 33 | for i in chrcs: 34 | if uuid.UUID(i.uuid) == BWT_UUID: 35 | chrc = i 36 | if not i: 37 | print("Error: could not find characteristic") 38 | exit() 39 | print("Testing sending 1MB") 40 | remaining = 1000000 41 | bar = tqdm.tqdm(total=remaining, unit="B") 42 | while remaining: 43 | sz = min(228, remaining) 44 | remaining -= sz 45 | await client.write_gatt_char(chrc, bytes(sz), True) 46 | _ = bar.update(sz) 47 | bar.close() 48 | try: 49 | asyncio.run(main()) 50 | except asyncio.CancelledError: 51 | # task is cancelled on disconnect, so we ignore this error 52 | pass 53 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/src/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __CONFIG_H__ 8 | #define __CONFIG_H__ 9 | 10 | #ifdef CONFIG_NET_CONFIG_SETTINGS 11 | #ifdef CONFIG_NET_IPV6 12 | #define ZEPHYR_ADDR CONFIG_NET_CONFIG_MY_IPV6_ADDR 13 | #define SERVER_ADDR CONFIG_NET_CONFIG_PEER_IPV6_ADDR 14 | #else 15 | #define ZEPHYR_ADDR CONFIG_NET_CONFIG_MY_IPV4_ADDR 16 | #define SERVER_ADDR CONFIG_NET_CONFIG_PEER_IPV4_ADDR 17 | #endif 18 | #else 19 | #ifdef CONFIG_NET_IPV6 20 | #define ZEPHYR_ADDR "2001:db8::1" 21 | #define SERVER_ADDR "2001:db8::2" 22 | #else 23 | #define ZEPHYR_ADDR "192.168.1.101" 24 | #define SERVER_ADDR "192.168.1.10" 25 | #endif 26 | #endif 27 | 28 | #if defined(CONFIG_SOCKS) 29 | #define SOCKS5_PROXY_ADDR SERVER_ADDR 30 | #define SOCKS5_PROXY_PORT 1080 31 | #endif 32 | 33 | #ifdef CONFIG_MQTT_LIB_TLS 34 | #ifdef CONFIG_MQTT_LIB_WEBSOCKET 35 | #define SERVER_PORT 9001 36 | #else 37 | #define SERVER_PORT 8883 38 | #endif /* CONFIG_MQTT_LIB_WEBSOCKET */ 39 | #else 40 | #ifdef CONFIG_MQTT_LIB_WEBSOCKET 41 | #define SERVER_PORT 9001 42 | #else 43 | #define SERVER_PORT 1883 44 | #endif /* CONFIG_MQTT_LIB_WEBSOCKET */ 45 | #endif 46 | 47 | #define APP_CONNECT_TIMEOUT_MS 2000 48 | #define APP_SLEEP_MSECS 500 49 | 50 | #define APP_CONNECT_TRIES 10 51 | 52 | #define APP_MQTT_BUFFER_SIZE 128 53 | 54 | #define MQTT_CLIENTID "zephyr_publisher" 55 | 56 | /* Set the following to 1 to enable the Bluemix topic format */ 57 | #define APP_BLUEMIX_TOPIC 0 58 | 59 | /* These are the parameters for the Bluemix topic format */ 60 | #if APP_BLUEMIX_TOPIC 61 | #define BLUEMIX_DEVTYPE "sensor" 62 | #define BLUEMIX_DEVID "carbon" 63 | #define BLUEMIX_EVENT "status" 64 | #define BLUEMIX_FORMAT "json" 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/ek18/COPYING: -------------------------------------------------------------------------------- 1 | 2 | E-Kermit 1.8 -- Embedded Kermit version 1.8 of 25 May 2021 3 | 4 | Author: Frank da Cruz 5 | License: Revised 3-Clause BSD License 6 | 7 | Copyright (C) 1995, 2021, 8 | Trustees of Columbia University in the City of New York. 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | * Redistributions of source code must retain the above copyright notice, 15 | this list of conditions and the following disclaimer. 16 | 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | 21 | * Neither the name of Columbia University nor the names of its contributors 22 | may be used to endorse or promote products derived from this software 23 | without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_modem.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fcntl_ptr(int sock, int cmd, const void* ptr); 4 | 5 | int tmo_modem_get_atcmd_resp(enum mdmdata_e cmd); 6 | 7 | /** 8 | * @brief Wakes the modem up 9 | * 10 | * @return int 0 on success (including modem already connected), -err on failure 11 | */ 12 | int tmo_modem_wake(void); 13 | 14 | /** 15 | * @brief Puts the modem to sleep 16 | * 17 | * @return int 0 on success (including modem already asleep), -err on failure 18 | */ 19 | int tmo_modem_sleep(void); 20 | 21 | /** 22 | * @brief Gets the modem sleep state 23 | * 24 | * @return int 1 on connected, 0 on disconnected/asleep, -err on failure (or unknown state) 25 | */ 26 | int tmo_modem_get_state(void); 27 | 28 | /** 29 | * @brief Gets the IMEI from the modem. Writes the result to res as an integer in string format 30 | * 31 | * @param res A buffer to write into. Always writes 16 bytes. 32 | * @param res_len The length of the buffer 33 | * @return int 0 on success, -err on failure 34 | */ 35 | int tmo_modem_get_imei(char* res, int res_len); 36 | 37 | /** 38 | * @brief Gets the ICCID from the modem. Writes the result to res 39 | * 40 | * @param res A buffer to write into. Always writes 32 bytes. 41 | * @param res_len The length of the buffer 42 | * @return int 43 | */ 44 | int tmo_modem_get_iccid(char* res, int res_len); 45 | 46 | /** 47 | * @brief Gets the IMSI from the modem. Writes the result to res 48 | * 49 | * @param res A buffer to write into. Always writes 16 bytes. 50 | * @param res_len The length of the buffer 51 | * @return int 52 | */ 53 | int tmo_modem_get_imsi(char* res, int res_len); 54 | 55 | /** 56 | * @brief Gets the MSISDN from the modem. Writes the result to res 57 | * 58 | * @param res A buffer to write into. Always writes 16 bytes. 59 | * @param res_len The length of the buffer 60 | * @return int 61 | */ 62 | int tmo_modem_get_msisdn(char* res, int res_len); 63 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_gnss.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_GNSS_H 8 | #define TMO_GNSS_H 9 | 10 | #define GNSS_RSTn 8 11 | #define MAXFIELDS 32 12 | /* set timeout to be one second (milliseconds/10 millisecond delay) */ 13 | #define MAXTIME 100 14 | 15 | struct tmo_gnss_struct { 16 | double time; 17 | double lat; 18 | double lon; 19 | double alt; 20 | double hdop; 21 | char lonchar; 22 | char latchar; 23 | uint32_t sats; 24 | uint32_t timeToFix; 25 | uint32_t pps1Count; 26 | char version[32]; 27 | bool fix_valid; 28 | }; 29 | 30 | void setup_gnss(void); 31 | void readGNSSData(void); 32 | void ln_buf_gen(void); 33 | int gnss_version(void); 34 | 35 | #ifdef TMO_GNSS 36 | /* variables for tmo_gnss.c */ 37 | struct drv_data { 38 | struct gpio_callback gpio_cb; 39 | struct gpio_callback gpio_cb1pps; 40 | gpio_flags_t mode; 41 | int index; 42 | int aux; 43 | }; 44 | 45 | const struct device *cxd5605; 46 | 47 | struct tmo_gnss_struct gnss_values; 48 | bool running = false; 49 | bool getGNSSData = false; 50 | uint8_t rd_data[82]; 51 | //char to_send[32]; 52 | bool las_notify = false; 53 | uint8_t ln_las_buf[13]; 54 | uint8_t ln_quality_buf[6]; 55 | /* See GATT Specification Supplement V6 - page 161 */ 56 | uint32_t ln_ln_feature = BIT(2) | BIT (3) | BIT(11) | BIT(12) | BIT(15); 57 | bool restart_setup = false; 58 | #else 59 | /* variables for other files as necessary */ 60 | 61 | /** Location Service Data */ 62 | #define UUID_SERVICE_LOCATION_DATA \ 63 | uuid128(0xa4e649f4, 0x4be5, 0x11e5, 0x885d, 0xfeff819cdc9f) 64 | #define UUID_CHARACTERISTIC_ACCELERATION \ 65 | uuid128(0xc4c1f6e2, 0x4be5, 0x11e5, 0x885d, 0xfeff819cdc9f) 66 | 67 | extern struct tmo_gnss_struct gnss_values; 68 | extern bool getGNSSData; 69 | extern bool running; 70 | extern bool las_notify; 71 | extern uint8_t ln_las_buf[13]; 72 | extern uint32_t ln_ln_feature; 73 | extern uint8_t ln_quality_buf[6]; 74 | extern bool restart_setup; 75 | int cxd5605_init(void); 76 | void gnss_enable_hardware(void); 77 | #endif 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_modem_edrx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_MODEM_EDRX_H 8 | #define TMO_MODEM_EDRX_H 9 | 10 | #include 11 | #include 12 | 13 | #define MAX_EDRX_TIME 10485.76 14 | #define TMO_SUCCESS 0 15 | #define TMO_ERROR -1 16 | 17 | typedef enum edrx_mode { 18 | EDRX_DISABLED_URC_DISABLED, // 0 - eDRX mode is off 19 | EDRX_ENABLED_URC_DISABLED, // 1 - eDRX mode is on 20 | EDRX_ENABLED_URC_ENABLED // 2 - eDRX mode enabled, unsolicited messages (URC) enabled 21 | }edrx_mode_e; 22 | 23 | typedef enum edrx_act_type { 24 | EC_GSM = 1, // 1 - EC-GSM-IoT 25 | GSM = 2, // 2 - GSM 26 | THIRD_GEN = 3, // 3 - 3G 27 | LTE = 4, // 4 - LTE, LTE-M 28 | NB_IOT = 5 // 5 - NB-IoT 29 | } edrx_act_type_e; 30 | 31 | char* byte_to_binary_str(uint8_t byte); 32 | 33 | /** 34 | * converts a eDRX byte representation to seconds 35 | * 36 | * @param byte - a eDRX timer byte representation 37 | * @return - time in seconds 38 | */ 39 | int tmo_edrx_timer_byte_to_secs(uint8_t byte, double* time); 40 | 41 | /** 42 | * converts a seconds value to the closet approximation of a eDRX timer 43 | * 44 | * @param secs - the seconds to convert 45 | * @param byte - a byte representation of the eDRX timer type 46 | * @return - ERANGE - a good representation was not found, TMO_SUCCESS a representation was found 47 | */ 48 | int tmo_edrx_timer_secs_to_approx_byte(double secs, uint8_t* byte); 49 | 50 | /** 51 | * converts seconds to a approximate eDRX string 52 | * 53 | * @param secs - the seconds to convert 54 | * @return - EINVAL - could not do the conversion based on the string 55 | */ 56 | int tmo_edrx_timer_secs_to_str(double secs, char* str); 57 | 58 | /** 59 | * 60 | * @param val - a eDRX string representation 61 | * @param secs - a time_t to store the converted value in 62 | * @return - EINVAL - could not do the conversion based on the string 63 | */ 64 | int tmo_edrx_timer_str_to_secs(const char* val, double* secs); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | workflow_call: 5 | inputs: 6 | ZEPHYR_APPLICATION: 7 | required: true 8 | type: string 9 | default: ../DevEdge-IoTDevKit-ZephyrSDK/samples/tmo_shell 10 | ZEPHYR_BOARD: 11 | required: true 12 | type: string 13 | default: tmo_dev_edge 14 | ZEPHYR_DBOARD_ROOT: 15 | required: true 16 | type: string 17 | default: zephyrproject/boards 18 | 19 | defaults: 20 | run: 21 | shell: bash 22 | 23 | jobs: 24 | build: 25 | runs-on: ubuntu-latest 26 | container: 27 | image: zephyrprojectrtos/ci:latest 28 | steps: 29 | - uses: actions/checkout@v3 30 | name: Clone ${{ github.repository }} 31 | if: ${{ github.repository != 'tmobile/DevEdge-IoTDevKit-ZephyrSDK' }} 32 | - uses: actions/checkout@v3 33 | name: Clone ZephyrSDK 34 | with: 35 | repository: 'tmobile/DevEdge-IoTDevKit-ZephyrSDK' 36 | path: zephyrproject/DevEdge-IoTDevKit-ZephyrSDK 37 | - uses: actions/checkout@v3 38 | name: Clone ZephyrRTOS 39 | with: 40 | repository: 'tmobile/DevEdge-IoTDevKit-ZephyrRTOS' 41 | path: zephyrproject/DevEdge-IoTDevKit-ZephyrRTOS 42 | - name: West Init and Update 43 | working-directory: zephyrproject/DevEdge-IoTDevKit-ZephyrRTOS 44 | run: | 45 | west init -l . 46 | west update 47 | - name: West Build 48 | working-directory: zephyrproject/DevEdge-IoTDevKit-ZephyrRTOS 49 | env: 50 | ZEPHYR_BASE: ${{ github.workspace }}/zephyrproject/DevEdge-IoTDevKit-ZephyrRTOS 51 | ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/ 52 | run: | 53 | west build ${{ inputs.ZEPHYR_APPLICATION }} -p -b ${{ inputs.ZEPHYR_BOARD }} -- -DBOARD_ROOT=${{ inputs.ZEPHYR_DBOARD_ROOT }} 54 | - name: Archive firmware 55 | uses: actions/upload-artifact@v2 56 | with: 57 | name: ${{ inputs.ZEPHYR_BOARD }} 58 | path: ${{ github.workspace }}/zephyrproject/DevEdge-IoTDevKit-ZephyrRTOS/build/zephyr/zephyr.* 59 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_sntp.h: -------------------------------------------------------------------------------- 1 | #ifndef TMO_SHELL_INCLUDE_ONCE 2 | #define TMO_SHELL_INCLUDE_ONCE 3 | #include 4 | #include 5 | #ifdef CONFIG_POSIX_API 6 | #include 7 | #endif 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define SNTP_PORT 123 18 | #define NTP_TIMESTAMP_DELTA 2208988800ull 19 | 20 | // Structure that defines the 48 byte NTP packet protocol. 21 | typedef struct 22 | { 23 | 24 | uint8_t li_vn_mode; // Eight bits. li, vn, and mode. 25 | // li. Two bits. Leap indicator. 26 | // vn. Three bits. Version number of the protocol. 27 | // mode. Three bits. Client will pick mode 3 for client. 28 | 29 | uint8_t stratum; // 8 bits. Stratum level of the local clock. 30 | uint8_t poll; // 8 bits. Maximum interval between successive messages. 31 | uint8_t precision; // 8 bits. Precision of the local clock. 32 | 33 | uint32_t rootDelay; // 32 bits. Total round trip delay time. 34 | uint32_t rootDispersion; // 32 bits. Max error aloud from primary clock source. 35 | uint32_t refId; // 32 bits. Reference clock identifier. 36 | 37 | uint32_t refTm_s; // 32 bits. Reference time-stamp seconds. 38 | uint32_t refTm_f; // 32 bits. Reference time-stamp fraction of a second. 39 | 40 | uint32_t origTm_s; // 32 bits. Originate time-stamp seconds. 41 | uint32_t origTm_f; // 32 bits. Originate time-stamp fraction of a second. 42 | 43 | uint32_t rxTm_s; // 32 bits. Received time-stamp seconds. 44 | uint32_t rxTm_f; // 32 bits. Received time-stamp fraction of a second. 45 | 46 | uint32_t txTm_s; // 32 bits and the most important field the client cares about. Transmit time-stamp seconds. 47 | uint32_t txTm_f; // 32 bits. Transmit time-stamp fraction of a second. 48 | 49 | } ntp_packet; // Total: 384 bits or 48 bytes. 50 | 51 | int tmo_update_time(const struct shell *shell, char * server, int iface_idx); 52 | #endif 53 | -------------------------------------------------------------------------------- /samples/lis2dw12_sample/README.rst: -------------------------------------------------------------------------------- 1 | .. _lis2dw12: 2 | 3 | LIS2DH: Motion Sensor Monitor 4 | ############################# 5 | 6 | Sample Overview 7 | *************** 8 | 9 | This sample application periodically reads accelerometer data from the 10 | LIS2DW12 sensor and displays the sensor data on the console. 11 | 12 | Device Overview 13 | *************** 14 | 15 | The LIS2DW12 is a 3D digital accelerometer system-in-package with a digital I²C/SPI serial interface 16 | standard output, performing at 90 μA in high-resolution mode and below 1 μA in low-power mode. 17 | 18 | The device has a dynamic user-selectable full-scale acceleration range of ±2/±4/±8/±16 g and is 19 | capable of measuring accelerations with output data rates from 1.6 Hz to 1600 Hz. The LIS2DW12 can 20 | be configured to generate interrupt signals by using hardware recognition of free-fall events, 6D 21 | orientation, tap and double-tap sensing, activity or inactivity, and wake-up events. 22 | 23 | Requirements 24 | ************ 25 | 26 | This sample uses the LIS2DW12, ST MEMS system-in-package featuring a 3D 27 | digital output motion sensor. 28 | 29 | References 30 | ********** 31 | 32 | For more information about the LIS2DW12 motion sensor see 33 | http://www.st.com/en/mems-and-sensors/lis2dw12.html. 34 | 35 | Building and Running 36 | ******************** 37 | 38 | The LIS2DW12 or compatible sensors are available on a variety of boards 39 | and shields supported by Zephyr, including: 40 | 41 | * :ref:`tmo_dev_edge` 42 | 43 | See the board documentation for detailed instructions on how to flash 44 | and get access to the console where acceleration data is displayed. 45 | 46 | Building on tmo_dev_edge 47 | ======================== 48 | 49 | :ref:`tmo_dev_edge` includes an ST LIS2DW12 accelerometer which 50 | supports the LIS2DW12 interface. 51 | 52 | .. zephyr-app-commands:: 53 | :zephyr-app: samples/sensor/lis2dw12_sample 54 | :board: actinius_icarus 55 | :goals: build flash 56 | :compact: 57 | 58 | Sample Output 59 | ============= 60 | 61 | .. code-block:: console 62 | 63 | Polling at 0.5 Hz 64 | #1 @ 12 ms: x -5.387328 , y 5.578368 , z -5.463744 65 | #2 @ 2017 ms: x -5.310912 , y 5.654784 , z -5.501952 66 | #3 @ 4022 ms: x -5.349120 , y 5.692992 , z -5.463744 67 | 68 | 69 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_hr/src/bas.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief GATT Battery Service 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2018 Nordic Semiconductor ASA 7 | * Copyright (c) 2016 Intel Corporation 8 | * Copyright (c) 2021 T-Mobile USA, Inc. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #define LOG_LEVEL 0 26 | #include 27 | LOG_MODULE_REGISTER(bas); 28 | 29 | static uint8_t battery_level = 100U; 30 | 31 | static void blvl_ccc_cfg_changed(const struct bt_gatt_attr *attr, 32 | uint16_t value) 33 | { 34 | ARG_UNUSED(attr); 35 | 36 | bool notif_enabled = (value == BT_GATT_CCC_NOTIFY); 37 | 38 | LOG_INF("BAS Notifications %s", notif_enabled ? "enabled" : "disabled"); 39 | } 40 | 41 | static ssize_t read_blvl(struct bt_conn *conn, 42 | const struct bt_gatt_attr *attr, void *buf, 43 | uint16_t len, uint16_t offset) 44 | { 45 | uint8_t lvl8 = battery_level; 46 | 47 | return bt_gatt_attr_read(conn, attr, buf, len, offset, &lvl8, 48 | sizeof(lvl8)); 49 | } 50 | 51 | BT_GATT_SERVICE_DEFINE(bas, 52 | BT_GATT_PRIMARY_SERVICE(BT_UUID_BAS), 53 | BT_GATT_CHARACTERISTIC(BT_UUID_BAS_BATTERY_LEVEL, 54 | BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, 55 | BT_GATT_PERM_READ, read_blvl, NULL, 56 | &battery_level), 57 | BT_GATT_CCC(blvl_ccc_cfg_changed, 58 | BT_GATT_PERM_READ | BT_GATT_PERM_WRITE), 59 | ); 60 | 61 | static int bas_init(const struct device *dev) 62 | { 63 | ARG_UNUSED(dev); 64 | 65 | return 0; 66 | } 67 | 68 | uint8_t bt_bas_get_battery_level(void) 69 | { 70 | return battery_level; 71 | } 72 | 73 | int bt_bas_set_battery_level(uint8_t level) 74 | { 75 | int rc; 76 | 77 | if (level > 100U) { 78 | return -EINVAL; 79 | } 80 | 81 | battery_level = level; 82 | 83 | rc = bt_gatt_notify(NULL, &bas.attrs[1], &level, sizeof(level)); 84 | 85 | return rc == -ENOTCONN ? 0 : rc; 86 | } 87 | 88 | SYS_INIT(bas_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); 89 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_hr/src/hrs.c: -------------------------------------------------------------------------------- 1 | /** @file 2 | * @brief HRS Service sample 3 | */ 4 | 5 | /* 6 | * Copyright (c) 2016 Intel Corporation 7 | * Copyright (c) 2021 T-Mobile USA, Inc. 8 | * 9 | * SPDX-License-Identifier: Apache-2.0 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #define LOG_LEVEL 0 25 | #include 26 | LOG_MODULE_REGISTER(hrs); 27 | 28 | static uint8_t hrs_blsc; 29 | 30 | static void hrmc_ccc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) 31 | { 32 | ARG_UNUSED(attr); 33 | 34 | bool notif_enabled = (value == BT_GATT_CCC_NOTIFY); 35 | 36 | LOG_INF("HRS notifications %s", notif_enabled ? "enabled" : "disabled"); 37 | } 38 | 39 | static ssize_t read_blsc(struct bt_conn *conn, const struct bt_gatt_attr *attr, 40 | void *buf, uint16_t len, uint16_t offset) 41 | { 42 | return bt_gatt_attr_read(conn, attr, buf, len, offset, &hrs_blsc, 43 | sizeof(hrs_blsc)); 44 | } 45 | 46 | /* Heart Rate Service Declaration */ 47 | BT_GATT_SERVICE_DEFINE(hrs_svc, 48 | BT_GATT_PRIMARY_SERVICE(BT_UUID_HRS), 49 | BT_GATT_CHARACTERISTIC(BT_UUID_HRS_MEASUREMENT, BT_GATT_CHRC_NOTIFY, 50 | BT_GATT_PERM_NONE, NULL, NULL, NULL), 51 | BT_GATT_CCC(hrmc_ccc_cfg_changed, 52 | BT_GATT_PERM_READ | BT_GATT_PERM_WRITE), 53 | BT_GATT_CHARACTERISTIC(BT_UUID_HRS_BODY_SENSOR, BT_GATT_CHRC_READ, 54 | BT_GATT_PERM_READ, read_blsc, NULL, NULL), 55 | BT_GATT_CHARACTERISTIC(BT_UUID_HRS_CONTROL_POINT, BT_GATT_CHRC_WRITE, 56 | BT_GATT_PERM_NONE, NULL, NULL, NULL), 57 | ); 58 | 59 | static int hrs_init(const struct device *dev) 60 | { 61 | ARG_UNUSED(dev); 62 | 63 | hrs_blsc = 0x01; 64 | 65 | return 0; 66 | } 67 | 68 | int bt_hrs_notify(uint16_t heartrate) 69 | { 70 | int rc; 71 | static uint8_t hrm[2]; 72 | 73 | hrm[0] = 0x06; /* uint8, sensor contact */ 74 | hrm[1] = heartrate; 75 | 76 | rc = bt_gatt_notify(NULL, &hrs_svc.attrs[1], &hrm, sizeof(hrm)); 77 | 78 | return rc == -ENOTCONN ? 0 : rc; 79 | } 80 | 81 | SYS_INIT(hrs_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); 82 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_modem_psm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_MODEM_PSM_H 8 | #define TMO_MODEM_PSM_H 9 | 10 | #include 11 | 12 | #define str_len_nb_psm 33 13 | #define PSM_TIME_LEN 11 14 | #define EDRX_TIME_LEN 6 15 | #define MINS_TO_SECS(x) ((x) * 60) 16 | #define HOURS_TO_SECS(x) (MINS_TO_SECS(x) * 60) 17 | 18 | typedef enum Timer_T3xxx { 19 | T3312_periodic_timer, // the timer to periodically notify the availability of the MS to the network 20 | T3314_ready_timer, // the timer used in the MS and in the network per each assigned P-TMSI to control the cell updating procedure 21 | T3412_disabled_timer, // the psm 3412 disabled timer 22 | T3324_active_timer // the psm 3324 enabled timer 23 | } Timer_T3xxx_e; 24 | 25 | //add enum for enable disable mode 26 | typedef enum Psm_Mode { 27 | disable_psm, 28 | enable_psm 29 | } Psm_Mode_e; 30 | 31 | /** 32 | * converts a psm byte representation to seconds 33 | * 34 | * @param timer - an enabled or disabled psm timer 35 | * @param byte - a psm timer byte representation 36 | * @return - time in seconds 37 | */ 38 | int tmo_psm_timer_byte_to_secs(Timer_T3xxx_e timer, uint8_t byte); 39 | 40 | /** 41 | * converts a seconds value to the closet approximation of a psm timer 42 | * 43 | * @param timer - an enabled or disabled psm timer 44 | * @param secs - the seconds to convert 45 | * @param byte - a byte representation of the psm timer type 46 | * @return - ERANGE - a good representation was not found, TMO_SUCCESS a representation was found 47 | */ 48 | int tmo_psm_timer_secs_to_approx_byte(Timer_T3xxx_e timer, time_t secs, uint8_t* byte); 49 | 50 | /** 51 | * converts seconds to a approximate psm string 52 | * 53 | * @param timer - an enabled or disabled psm timer 54 | * @param secs - the seconds to convert 55 | * @return -EINVAL - could not do a conversion, or a representation string 56 | */ 57 | int tmo_psm_timer_secs_to_str(Timer_T3xxx_e timer, time_t secs, char* str); 58 | 59 | /** 60 | * 61 | * @param timer - which timer this string represents 62 | * @param val - a psm string representation 63 | * @param secs - a time_t to store the converted value in 64 | * @return - EINVAL - could not do the conversion based on the string 65 | */ 66 | int tmo_psm_timer_str_to_secs(Timer_T3xxx_e timer, const char* val, time_t* secs); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /samples/button_press_cb/src/button.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #ifndef BUTTON_H 7 | #define BUTTON_H 8 | 9 | #include 10 | 11 | typedef enum { 12 | BUTTON_PRESS_NORMAL = 0, 13 | BUTTON_PRESS_TIMEOUT = 1 14 | } button_press_type; 15 | 16 | typedef enum { 17 | BUTTON_STATE_ERROR = -1, 18 | BUTTON_STATE_DEINIT = 0, 19 | BUTTON_STATE_INIT = 1, 20 | BUTTON_STATE_DEBOUNCING = 2, 21 | BUTTON_STATE_DEBOUNCED = 3, 22 | BUTTON_STATE_TIMEOUT = 4 23 | } button_press_state; 24 | 25 | /** 26 | * @brief Button callback definition, the user will implement the callback in the application code. 27 | * It gives the timestamp of the button pressed (from system uptime in millisecs), the duration of 28 | * how long the button was pressed, and the type of button press, whether a normal or a timeout. 29 | * 30 | * The duration parameter will be the max timeout value when a timeout occurs, this won't represent 31 | * the real physical button press duration though. The callback will be invoked as soon as the 32 | * timeout reaches even if the user has not release the button. 33 | */ 34 | typedef void (*button_press_callback_t)(uint32_t timestamp, uint32_t duration, 35 | button_press_type type); 36 | 37 | /** 38 | * @brief Button press initialization. Called by user application code to configure and initialize 39 | * user button to generate callback on button presses. 40 | * 41 | * @param max_timeout [in] Max timeout value for which the user button can be pressed, after 42 | * which it is considered to be not normal operation. 43 | * @param callback [in] Function pointer to the callback that will be called when the button 44 | * has been pressed for a certain duration 45 | * @return int status code indicating success/failure. 46 | */ 47 | int button_press_module_init(uint32_t max_timeout, button_press_callback_t callback); 48 | 49 | /** 50 | * @brief De-initialize the button interrupt and callbacks if it was previously done so. Usually 51 | * performed if we want to set a new configuration on the button. 52 | * 53 | * @return int status code indicating success/failure 54 | */ 55 | int button_press_module_deinit(void); 56 | 57 | /** 58 | * @brief Get the button configured state. Handy getter function that user application code can use 59 | * to determine if existing callback is set before configuring it with new parameters. 60 | * 61 | * @return button_press_state 62 | */ 63 | button_press_state button_press_get_state(void); 64 | 65 | #endif -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_shell.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_SHELL_H 8 | #define TMO_SHELL_H 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define MAX_MODEM_SOCKS 5 16 | #define MAX_SOCK_REC 16 17 | 18 | struct test 19 | { 20 | int pass; 21 | int fail; 22 | }; 23 | 24 | enum sock_rec_flags { 25 | sock_open = 0, 26 | sock_udp, 27 | sock_dtls, 28 | sock_tcp, 29 | sock_tls, 30 | sock_connected, 31 | sock_bound, 32 | sock_v6 33 | }; 34 | 35 | typedef enum { 36 | MODEM_ID = 1, 37 | WIFI_ID, 38 | } devId_type; 39 | 40 | struct sock_rec_s { 41 | int sd; 42 | uint8_t flags; 43 | struct net_if *dev; 44 | }; 45 | 46 | static inline void gen_payload(uint8_t *buf, int len) 47 | { 48 | for (int i=0;iif_dev->offload && iface->if_dev->socket_offload != NULL){ 56 | return iface->if_dev->socket_offload(family, type, proto); 57 | } else { 58 | errno = EINVAL; 59 | return -1; 60 | } 61 | } 62 | #endif 63 | 64 | extern const struct shell *shell; 65 | 66 | int cmd_wifi_connect(const struct shell *shell, size_t argc, char *argv[]); 67 | int cmd_wifi_disconnect(const struct shell *shell, size_t argc, char *argv[]); 68 | int cmd_wifi_scan(const struct shell *shell, size_t argc, char *argv[]); 69 | int cmd_wifi_status(const struct shell *shell, size_t argc, char *argv[]); 70 | int cmd_wifi_mac(const struct shell *shell, size_t argc, char *argv[]); 71 | 72 | int toggle_keyboard(const struct shell *shell, size_t argc, char *argv[]); 73 | int toggle_confirm(const struct shell *shell, size_t argc, char *argv[]); 74 | int toggle_display(const struct shell *shell, size_t argc, char *argv[]); 75 | 76 | int send_passkey(const struct shell *shell, size_t argc, char *argv[]); 77 | int send_confirm(const struct shell *shell, size_t argc, char *argv[]); 78 | int send_cancel(const struct shell *shell, size_t argc, char *argv[]); 79 | 80 | int smp_enable(const struct shell *shell, size_t argc, char *argv[]); 81 | int smp_disable(const struct shell *shell, size_t argc, char *argv[]); 82 | int show_enabled(const struct shell *shell, size_t argc, char *argv[]); 83 | void tmo_shell_main(void); 84 | int tmo_offload_init(int devid); 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/buzzer_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "tmo_shell.h" 12 | #include "tmo_buzzer.h" 13 | 14 | int buzzer_test() 15 | { 16 | const struct device *buzzer2 = DEVICE_DT_GET(DT_ALIAS(pwm_buzzer)); 17 | int ret = 0; 18 | ret = pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_LOW); 19 | if (ret) { 20 | printf("pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_LOW) - function failed %d \n", ret); 21 | return (ret); 22 | } 23 | k_sleep(K_MSEC(130)); 24 | ret = pwm_set_frequency(buzzer2, 0, 0); 25 | if (ret) { 26 | printf("pwm_set_frequency(buzzer2, 0, 0) - function failed %d \n", ret); 27 | return (ret); 28 | } 29 | k_sleep(K_MSEC(20)); 30 | ret = pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_LOW); 31 | if (ret) { 32 | printf("pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_LOW) - function failed %d \n", ret); 33 | return (ret); 34 | } 35 | k_sleep(K_MSEC(130)); 36 | ret = pwm_set_frequency(buzzer2, 0, 0); 37 | if (ret) { 38 | printf("pwm_set_frequency(buzzer2, 0, 0) - function failed %d \n", ret); 39 | return (ret); 40 | } 41 | k_sleep(K_MSEC(20)); 42 | ret = pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_LOW); 43 | if (ret) { 44 | printf("pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_LOW) - function failed %d \n", ret); 45 | return (ret); 46 | } 47 | k_sleep(K_MSEC(130)); 48 | ret = pwm_set_frequency(buzzer2, 0, 0); 49 | if (ret) { 50 | printf("pwm_set_frequency(buzzer2, 0, 0) - function failed %d \n", ret); 51 | return (ret); 52 | } 53 | k_sleep(K_MSEC(20)); 54 | ret = pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_HIGH); 55 | if (ret) { 56 | printf("pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_HIGH) - function failed %d \n", ret); 57 | return (ret); 58 | } 59 | k_sleep(K_MSEC(130)); 60 | ret = pwm_set_frequency(buzzer2, 0, 0); 61 | if (ret) { 62 | printf("pwm_set_frequency(buzzer2, 0, 0) - function failed %d \n", ret); 63 | return (ret); 64 | } 65 | k_sleep(K_MSEC(20)); 66 | ret = pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_LOW); 67 | if (ret) { 68 | printf("pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_LOW) - function failed %d \n", ret); 69 | return (ret); 70 | } 71 | k_sleep(K_MSEC(521)); 72 | ret = pwm_set_frequency(buzzer2, 0, 0); 73 | if (ret) { 74 | printf("pwm_set_frequency(buzzer2, 0, TMO_TUNE_PITCH_LOW) - function failed %d \n", ret); 75 | return (ret); 76 | } 77 | printf("buzzer_test - function was successful\n"); 78 | return (ret); 79 | } 80 | -------------------------------------------------------------------------------- /samples/tmo_shell/README.txt: -------------------------------------------------------------------------------- 1 | Title: tmo_shell 2 | 3 | Description: 4 | 5 | A sample to demonstrate the capabilities of the T-Mobile DevEdge dev kit 6 | 7 | -------------------------------------------------------------------------------- 8 | 9 | Requirements 10 | ************ 11 | 12 | -A T-Mobile DevEdge dev kit (https://devedge.t-mobile.com/) 13 | -A Zephyr build environment (https://docs.zephyrproject.org/latest/develop/getting_started/index.html) 14 | 15 | Building and Running Project: 16 | 17 | How this project can be built: 18 | 19 | -Checkout the T-Mobile downstream zephyr repo: 20 | cd ~/zephyrproject 21 | git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrRTOS zephyr 22 | 23 | -Checkout the T-Mobile zephyr-tmo-sdk repo: 24 | cd ~/zephyrproject 25 | git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK tmo-zephyr-sdk 26 | 27 | -Run 'west update' 28 | cd ~/zephyrproject 29 | west update 30 | 31 | -Build tmo_shell: 32 | cd ~/zephyrproject 33 | west build ~/zephyrproject/tmo-zephyr-sdk/samples/tmo_shell -p -b tmo_dev_edge -- -DBOARD_ROOT=/zephyrproject/tmo-zephyr-sdk 34 | (substitute your home folder for '' in the command above) 35 | 36 | -Connect DevEdge dev kit: 37 | For DevEdge dev kits running tmo_shell built with DevEdge SDK v1.9.1 or earlier: 38 | connect BOTH USB-C ports to your computer or wall power 39 | For DevEdge dev kits running tmo_shell built with DevEdge SDK v1.10.0 or later: 40 | connect only the USB-C port furthest from the button to your computer 41 | (both USB-C ports can be connected, but only one needs to be connected) 42 | 43 | -Flash tmo_shell: 44 | cd ~/zephyrproject 45 | west flash 46 | 47 | Sample commands: 48 | 49 | tmo_shell contains a great deal of functionality. The tmo menu in tmo_shell looks like this: 50 | 51 | uart:~$ tmo 52 | tmo - TMO Shell Commands 53 | Subcommands: 54 | ble :BLE test commands 55 | buzzer :Buzzer tests 56 | certs :CA cert commands 57 | dfu :Device FW updates 58 | dns :Perform dns lookup 59 | file :File commands 60 | gnsserase :Erase GNSS chip (CXD5605) 61 | http :Get http URL 62 | ifaces :List network interfaces 63 | json :JSON data options 64 | location :Get latitude and longitude 65 | modem :Modem status and control 66 | sockets :List open sockets 67 | tcp :Send/recv TCP packets 68 | test :Run automated tests 69 | udp :Send/recv UDP packets 70 | version :Print version details 71 | wifi :WiFi status and control 72 | 73 | More details are available here for pre-release: 74 | https://github.com/tmobile/iot-developer-kit/blob/main/documentation/06-Interacting-with-the-Kit-at-CLI-via-the-tmo_shell.md 75 | or here for production: 76 | https://devedge.t-mobile.com/support/iot-documentation/iot-developer-kit/interacting-with-the-kit-at-cli-via-tmo-shell 77 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_battery_ctrl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #if DT_NODE_EXISTS(DT_NODELABEL(bq24250)) 14 | #include "tmo_bq24250.h" 15 | #endif 16 | 17 | #include "tmo_battery_ctrl.h" 18 | 19 | #define BATTERY_TABLE_LEN 15 20 | #define TABLE_VOLTAGE 0 21 | #define TABLE_PERCENT 1 22 | 23 | extern float battery_discharging_tbl [BATTERY_TABLE_LEN][2]; 24 | extern float battery_charging_tbl [BATTERY_TABLE_LEN][2]; 25 | 26 | bool is_battery_charging() 27 | { 28 | uint8_t charging; 29 | uint8_t vbus; 30 | uint8_t attached; 31 | uint8_t fault; 32 | 33 | get_battery_charging_status(&charging, &vbus, &attached, &fault); 34 | return (vbus && charging); 35 | } 36 | 37 | float get_remaining_capacity(float battery_voltage) 38 | { 39 | float (*voltage_capacity_table)[BATTERY_TABLE_LEN][2]; 40 | float high_voltage = 0.0; 41 | float low_voltage = 0.0; 42 | uint32_t i; 43 | 44 | if (is_battery_charging()) 45 | voltage_capacity_table = &battery_charging_tbl; 46 | else 47 | voltage_capacity_table = &battery_discharging_tbl; 48 | 49 | // check battery voltage limits 50 | 51 | if (battery_voltage >= (*voltage_capacity_table)[0][TABLE_VOLTAGE]) { 52 | return 100.0; 53 | } 54 | 55 | if (battery_voltage <= (*voltage_capacity_table)[BATTERY_TABLE_LEN - 1][TABLE_VOLTAGE]) { 56 | return 0.0; 57 | } 58 | 59 | // find the table percentage entries that correspond 60 | // to the voltage and interpolate between the two 61 | 62 | for (i = 1; i < BATTERY_TABLE_LEN; i++) { 63 | if (battery_voltage > (*voltage_capacity_table)[i][TABLE_VOLTAGE]) { 64 | high_voltage = (*voltage_capacity_table)[i - 1][TABLE_VOLTAGE]; 65 | low_voltage = (*voltage_capacity_table)[i][TABLE_VOLTAGE]; 66 | break; 67 | } 68 | } 69 | 70 | if ((i >= BATTERY_TABLE_LEN) || (high_voltage == low_voltage)) { 71 | return 0.0; 72 | } 73 | 74 | float pct_gap = (float) (*voltage_capacity_table)[i-1][TABLE_PERCENT] - (*voltage_capacity_table)[i][TABLE_PERCENT]; 75 | return ((battery_voltage - low_voltage) / (high_voltage - low_voltage) * pct_gap) + (*voltage_capacity_table)[i][TABLE_PERCENT]; 76 | } 77 | 78 | #if DT_NODE_EXISTS(DT_NODELABEL(pmic)) 79 | extern int get_pmic_status(uint8_t *charging, uint8_t *vbus, uint8_t *attached, uint8_t *fault, uint8_t *charge_status); 80 | #endif 81 | 82 | int get_battery_charging_status(uint8_t *charging, uint8_t *vbus, uint8_t *attached, uint8_t *fault) 83 | { 84 | #if DT_NODE_EXISTS(DT_NODELABEL(bq24250)) 85 | int status = get_bq24250_status(charging, vbus, attached, fault); 86 | #endif 87 | 88 | #if DT_NODE_EXISTS(DT_NODELABEL(pmic)) 89 | uint8_t charge_status; 90 | int status = get_pmic_status(charging, vbus, attached, fault, &charge_status); 91 | #endif 92 | 93 | return status; 94 | } 95 | -------------------------------------------------------------------------------- /samples/button_press_cb/src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include "button.h" 16 | 17 | #define FACTORY_RESET_TIMEOUT_MS (10 * 1000) 18 | 19 | static k_tid_t main_thread_id = 0; 20 | 21 | /* 22 | * User callbacks to be called when button is pressed 23 | */ 24 | 25 | static void factory_reset_callback(uint32_t timestamp, uint32_t duration, button_press_type type) 26 | { 27 | printk("%s: Button pressed: timestamp: %u; duration: %u, button press type: %s\n", __func__, 28 | timestamp, duration, 29 | type == BUTTON_PRESS_TIMEOUT ? "BUTTON_PRESS_TIMEOUT" : "BUTTON_PRESS_NORMAL"); 30 | 31 | /* Wakeup the main thread to proceed with other reinint */ 32 | k_wakeup(main_thread_id); 33 | } 34 | 35 | /* 36 | * Print greeting 37 | */ 38 | static void greeting() 39 | { 40 | puts("\n\n\t\t\tWelcome to T-Mobile DevEdge!\n\n" 41 | "This application aims to demonstrate the button press callback sample module which\n" 42 | "uses SW0 interrupt pin, which is connected to the user pushbutton switch of the\n" 43 | "DevEdge module.\n"); 44 | } 45 | 46 | /* Entry point */ 47 | void main(void) 48 | { 49 | int ret = 0; 50 | greeting(); 51 | 52 | main_thread_id = k_current_get(); 53 | 54 | /* Initialize the button with the callback and max timeout */ 55 | ret = button_press_module_init(FACTORY_RESET_TIMEOUT_MS, factory_reset_callback); 56 | if (ret != 0) { 57 | printk("Error %d: failed to configure button press module\n", ret); 58 | } 59 | 60 | /* Wait until a callback occurs atleast once */ 61 | k_sleep(K_FOREVER); 62 | 63 | /* For the purposes of demonstrating this sample application to deinit and reinit the button 64 | * callback with new parameters, adding another polled method to wait until user has release 65 | * the button only AFTER a timeout button event had occurred*/ 66 | static volatile button_press_state state; 67 | if (button_press_get_state() == BUTTON_STATE_TIMEOUT) { 68 | do { 69 | state = button_press_get_state(); 70 | } while (state != BUTTON_STATE_INIT); 71 | } 72 | 73 | /* If previously configured, deinit the button callback here to demonstrate how to change 74 | * the parameters*/ 75 | if (button_press_get_state() == BUTTON_STATE_INIT) { 76 | ret = button_press_module_deinit(); 77 | if (ret != 0) { 78 | printk("Error %d: failed to deinit button callback module\n", ret); 79 | } 80 | } 81 | 82 | /* Initialize the button callback with new parameters after successful deinit */ 83 | if (button_press_get_state() == BUTTON_STATE_DEINIT) { 84 | ret = button_press_module_init(FACTORY_RESET_TIMEOUT_MS / 2, 85 | factory_reset_callback); 86 | if (ret != 0) { 87 | printk("Error %d: failed to configure button press module\n", ret); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_tone_player.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "tmo_buzzer.h" 12 | 13 | LOG_MODULE_REGISTER(tmo_tone_player, LOG_LEVEL_DBG); 14 | 15 | struct note_s { 16 | uint16_t freq; 17 | uint16_t dur_ms; 18 | }; 19 | 20 | static struct note_s next_note; 21 | static struct fs_file_t tone_bin; 22 | static bool timer_running; 23 | static void (*song_finished_callback)(void); 24 | 25 | static void set_tone(uint16_t freq) 26 | { 27 | pwm_set_frequency(buzzer, 0, freq); 28 | } 29 | 30 | static void next_note_f(struct k_timer *timer_id) 31 | { 32 | set_tone(next_note.freq); 33 | 34 | if (next_note.dur_ms) { 35 | k_timer_start(timer_id, K_MSEC(next_note.dur_ms), K_FOREVER); 36 | } else { 37 | timer_running = false; 38 | if (song_finished_callback) 39 | song_finished_callback(); 40 | song_finished_callback = NULL; 41 | return; 42 | } 43 | 44 | if (fs_read(&tone_bin, &next_note, sizeof(next_note)) < 4) { 45 | fs_close(&tone_bin); 46 | memset(&next_note, 0, sizeof(next_note)); 47 | return; 48 | } 49 | 50 | next_note.freq = sys_be16_to_cpu(next_note.freq); 51 | next_note.dur_ms = sys_be16_to_cpu(next_note.dur_ms); 52 | } 53 | 54 | K_TIMER_DEFINE(next_tone, next_note_f, NULL); 55 | 56 | int play_tone_bin(char* filename, void (*finished_callback)(void)) 57 | { 58 | if (timer_running) { 59 | k_timer_stop(&next_tone); 60 | fs_close(&tone_bin); 61 | } 62 | 63 | song_finished_callback = finished_callback; 64 | 65 | fs_file_t_init(&tone_bin); 66 | 67 | if (fs_open(&tone_bin, filename, FS_O_READ)) { 68 | LOG_ERR("Failed to open tone file"); 69 | return -EIO; 70 | } 71 | 72 | if (fs_read(&tone_bin, &next_note, sizeof(next_note)) < 4) { 73 | LOG_ERR("Failed to read tone file"); 74 | fs_close(&tone_bin); 75 | return -EIO; 76 | } 77 | 78 | next_note.freq = sys_be16_to_cpu(next_note.freq); 79 | next_note.dur_ms = sys_be16_to_cpu(next_note.dur_ms); 80 | timer_running = true; 81 | next_note_f(&next_tone); 82 | 83 | return 0; 84 | } 85 | 86 | int play_single_note(uint16_t freq, uint16_t duration, void (*finished_callback)(void)) 87 | { 88 | if (timer_running) { 89 | return -EBUSY; 90 | } 91 | fs_close(&tone_bin); 92 | next_note.freq = 0; 93 | next_note.dur_ms = 0; 94 | 95 | song_finished_callback = finished_callback; 96 | 97 | set_tone(next_note.freq); 98 | 99 | k_timer_start(&next_tone, K_MSEC(duration), K_FOREVER); 100 | 101 | return 0; 102 | } 103 | 104 | int cancel_playback(void) 105 | { 106 | if (timer_running) { 107 | set_tone(0); 108 | k_timer_stop(&next_tone); 109 | fs_close(&tone_bin); 110 | } else { 111 | return -EALREADY; 112 | } 113 | return 0; 114 | } 115 | -------------------------------------------------------------------------------- /samples/bluetooth/bandwidth_test/src/main.c: -------------------------------------------------------------------------------- 1 | /* main.c - Application main entry point */ 2 | 3 | /* 4 | * Copyright (c) 2021 T-Mobile USA, Inc. 5 | * 6 | * SPDX-License-Identifier: Apache-2.0 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | //5432e12b-34be-4996-aafa-bdc0c7554b89 26 | #define uuid128(...) BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(__VA_ARGS__)) 27 | #define BT_UUID_BWT_CHRC uuid128(0x5432e12b, 0x34be, 0x4996, 0xaafa, 0xbdc0c7554b89) 28 | //7abd3505-2a8a-4dc6-b4ea-a4eb12fd6bf8 29 | #define BT_UUID_BWT uuid128(0x7abd3505, 0x2a8a, 0x4dc6, 0xb4ea, 0xa4eb12fd6bf8) 30 | 31 | 32 | int rcvd_len = 0; 33 | 34 | static ssize_t write_test(struct bt_conn *conn, 35 | const struct bt_gatt_attr *attr, 36 | const void *buf, uint16_t len, uint16_t offset, 37 | uint8_t flags) 38 | { 39 | rcvd_len += len; 40 | return len; 41 | } 42 | 43 | BT_GATT_SERVICE_DEFINE(bw_test_svc, 44 | BT_GATT_PRIMARY_SERVICE(BT_UUID_BWT), 45 | BT_GATT_CHARACTERISTIC(BT_UUID_BWT_CHRC, BT_GATT_CHRC_WRITE, 46 | BT_GATT_PERM_WRITE, NULL, write_test, NULL), 47 | ); 48 | 49 | static const struct bt_data ad[] = { 50 | BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), 51 | }; 52 | 53 | static const struct bt_le_conn_param fast_params = BT_LE_CONN_PARAM_INIT(6, 6, 0, 400); 54 | static void connected(struct bt_conn *conn, uint8_t err) 55 | { 56 | if (err) { 57 | printk("Connection failed (err 0x%02x)\n", err); 58 | } else { 59 | printk("Connected\n"); 60 | bt_conn_le_param_update(conn, &fast_params); 61 | } 62 | } 63 | 64 | static void disconnected(struct bt_conn *conn, uint8_t reason) 65 | { 66 | printk("Disconnected (reason 0x%02x)\n", reason); 67 | } 68 | 69 | static struct bt_conn_cb conn_callbacks = { 70 | .connected = connected, 71 | .disconnected = disconnected, 72 | }; 73 | 74 | static void bt_ready(void) 75 | { 76 | int err; 77 | 78 | printk("Bluetooth initialized\n"); 79 | 80 | err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0); 81 | if (err) { 82 | printk("Advertising failed to start (err %d)\n", err); 83 | return; 84 | } 85 | 86 | printk("Advertising successfully started\n"); 87 | } 88 | 89 | 90 | void main(void) 91 | { 92 | int err; 93 | 94 | err = bt_enable(NULL); 95 | if (err) { 96 | printk("Bluetooth init failed (err %d)\n", err); 97 | return; 98 | } 99 | 100 | bt_ready(); 101 | 102 | bt_conn_cb_register(&conn_callbacks); 103 | 104 | int last_rcvd_len = 0; 105 | int cur_rcvd_len; 106 | while (true) { 107 | k_msleep(5000); 108 | cur_rcvd_len = rcvd_len; 109 | if (last_rcvd_len != cur_rcvd_len) { 110 | printk("Total Received so far: %d\n", cur_rcvd_len); 111 | last_rcvd_len = cur_rcvd_len; 112 | } 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_buzzer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef TMO_BUZZER_H 8 | #define TMO_BUZZER_H 9 | 10 | extern const struct device *buzzer; 11 | 12 | int pwm_set_frequency(const struct device *dev, uint32_t pwm, uint16_t hz); 13 | int tmo_play_tone(int frequency_hz, int duration_msecs); 14 | void tmo_play_jingle(void); 15 | void tmo_play_ramp(void); 16 | void tmo_buzzer_set_volume(int); 17 | 18 | #define TMO_PITCH_D3 147 /* This is the lowest pitch the buzzer can play */ 19 | #define TMO_PITCH_Ds3 156 20 | #define TMO_PITCH_E3 165 21 | #define TMO_PITCH_F3 175 22 | #define TMO_PITCH_Fs3 185 23 | #define TMO_PITCH_G3 196 24 | #define TMO_PITCH_Gs3 208 25 | #define TMO_PITCH_A3 220 26 | #define TMO_PITCH_As3 233 27 | #define TMO_PITCH_B3 247 28 | 29 | #define TMO_PITCH_C4 262 30 | #define TMO_PITCH_Cs4 277 31 | #define TMO_PITCH_D4 294 32 | #define TMO_PITCH_Ds4 311 33 | #define TMO_PITCH_E4 330 34 | #define TMO_PITCH_F4 349 35 | #define TMO_PITCH_Fs4 370 36 | #define TMO_PITCH_G4 392 37 | #define TMO_PITCH_Gs4 415 38 | #define TMO_PITCH_A4 440 39 | #define TMO_PITCH_As4 466 40 | #define TMO_PITCH_B4 494 41 | 42 | #define TMO_PITCH_C5 523 43 | #define TMO_PITCH_Cs5 554 44 | #define TMO_PITCH_D5 587 45 | #define TMO_PITCH_Ds5 622 46 | #define TMO_PITCH_E5 659 47 | #define TMO_PITCH_F5 698 48 | #define TMO_PITCH_Fs5 740 49 | #define TMO_PITCH_G5 784 50 | #define TMO_PITCH_Gs5 831 51 | #define TMO_PITCH_A5 880 52 | #define TMO_PITCH_As5 932 53 | #define TMO_PITCH_B5 988 54 | 55 | #define TMO_PITCH_C6 1047 56 | #define TMO_PITCH_Cs6 1109 57 | #define TMO_PITCH_D6 1175 58 | #define TMO_PITCH_Ds6 1245 59 | #define TMO_PITCH_E6 1319 60 | #define TMO_PITCH_F6 1397 61 | #define TMO_PITCH_Fs6 1480 62 | #define TMO_PITCH_G6 1568 63 | #define TMO_PITCH_Gs6 1661 64 | #define TMO_PITCH_A6 1760 65 | #define TMO_PITCH_As6 1865 66 | #define TMO_PITCH_B6 1976 67 | 68 | #define TMO_PITCH_C7 2093 69 | #define TMO_PITCH_Cs7 2217 70 | #define TMO_PITCH_D7 2349 71 | #define TMO_PITCH_Ds7 2489 72 | #define TMO_PITCH_E7 2637 73 | #define TMO_PITCH_F7 2794 74 | #define TMO_PITCH_Fs7 2960 75 | #define TMO_PITCH_G7 3136 76 | #define TMO_PITCH_Gs7 3322 77 | #define TMO_PITCH_A7 3520 78 | #define TMO_PITCH_As7 3729 79 | #define TMO_PITCH_B7 3951 80 | 81 | #define TMO_PITCH_C8 4186 82 | #define TMO_PITCH_Cs8 4435 83 | #define TMO_PITCH_D8 4699 84 | #define TMO_PITCH_Ds8 4978 85 | #define TMO_PITCH_E8 5274 86 | #define TMO_PITCH_F8 5588 87 | #define TMO_PITCH_Fs8 5920 88 | #define TMO_PITCH_G8 6272 89 | #define TMO_PITCH_Gs8 6645 90 | #define TMO_PITCH_A8 7040 91 | #define TMO_PITCH_As8 7459 92 | #define TMO_PITCH_B8 7902 93 | 94 | #define TMO_PITCH_C9 8372 95 | #define TMO_PITCH_Cs9 8870 96 | #define TMO_PITCH_D9 9397 97 | #define TMO_PITCH_Ds9 9956 98 | #define TMO_PITCH_E9 10548 99 | #define TMO_PITCH_F9 11175 100 | #define TMO_PITCH_Fs9 11840 101 | #define TMO_PITCH_G9 12544 102 | #define TMO_PITCH_Gs9 13290 103 | #define TMO_PITCH_A9 14080 104 | #define TMO_PITCH_As9 14917 105 | #define TMO_PITCH_B9 15804 106 | 107 | #define TMO_TUNE_PITCH_LOW TMO_PITCH_C6 108 | #define TMO_TUNE_PITCH_HIGH TMO_PITCH_E6 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /samples/button_press_cb/README.txt: -------------------------------------------------------------------------------- 1 | Title: button_press_cb 2 | 3 | Description: 4 | 5 | A sample to demonstrate a callback feature of the user push button on the DevEdge kit 6 | The user will implement the Button callback function in the application code. 7 | It gives the timestamp of the button pressed (from system uptime in millisecs), the duration of 8 | how long the button was pressed (also in millisecs), and the type of button press, whether a normal or a timeout. 9 | 10 | The duration parameter will be the max timeout value when a timeout occurs, this won't represent 11 | the real physical button press duration though. The callback will be invoked as soon as the 12 | timeout reaches even if the user has not release the button. 13 | 14 | -------------------------------------------------------------------------------- 15 | 16 | Requirements 17 | ************ 18 | 19 | -A T-Mobile DevEdge dev kit (https://devedge.t-mobile.com/) 20 | -A Zephyr build environment (https://docs.zephyrproject.org/latest/develop/getting_started/index.html) 21 | 22 | Building and Running Project: 23 | 24 | How this project can be built: 25 | 26 | -Checkout the T-Mobile downstream zephyr repo: 27 | cd ~/zephyrproject 28 | git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrRTOS zephyr 29 | 30 | -Checkout the T-Mobile zephyr-tmo-sdk repo: 31 | cd ~/zephyrproject 32 | git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK tmo-zephyr-sdk 33 | 34 | -Run 'west update' 35 | cd ~/zephyrproject 36 | west update 37 | 38 | -Build button_press_cb: 39 | cd ~/zephyrproject 40 | west build ~/zephyrproject/tmo-zephyr-sdk/samples/button_press_cb -p -b tmo_dev_edge -- -DBOARD_ROOT=/zephyrproject/tmo-zephyr-sdk 41 | (substitute your home folder for '' in the command above) 42 | 43 | -Connect DevEdge dev kit: 44 | For DevEdge dev kits running tmo_shell built with DevEdge SDK v1.9.1 or earlier: 45 | connect BOTH USB-C ports to your computer or wall power 46 | For DevEdge dev kits running tmo_shell built with DevEdge SDK v1.10.0 or later: 47 | connect only the USB-C port furthest from the button to your computer 48 | (both USB-C ports can be connected, but only one needs to be connected) 49 | 50 | -Flash button_press_cb: 51 | cd ~/zephyrproject 52 | west flash 53 | 54 | Sample output: 55 | ``` 56 | *** Booting Zephyr OS build ccdf94636486 *** 57 | 58 | 59 | Welcome to T-Mobile DevEdge! 60 | 61 | This application aims to demonstrate the button press callback sample module which 62 | uses SW0 interrupt pin, which is connected to the user pushbutton switch of the 63 | DevEdge module. 64 | 65 | Set up button at gpio@4000a030 pin 13 66 | 67 | factory_reset_callback: Button pressed: timestamp: 2562; duration: 10000, button press type: BUTTON_PRESS_TIMEOUT 68 | Set up button at gpio@4000a030 pin 13 69 | 70 | factory_reset_callback: Button pressed: timestamp: 14983; duration: 159, button press type: BUTTON_PRESS_NORMAL 71 | factory_reset_callback: Button pressed: timestamp: 15920; duration: 137, button press type: BUTTON_PRESS_NORMAL 72 | factory_reset_callback: Button pressed: timestamp: 16690; duration: 5000, button press type: BUTTON_PRESS_TIMEOUT 73 | factory_reset_callback: Button pressed: timestamp: 22771; duration: 139, button press type: BUTTON_PRESS_NORMAL 74 | factory_reset_callback: Button pressed: timestamp: 23757; duration: 179, button press type: BUTTON_PRESS_NORMAL 75 | ``` 76 | 77 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_hr/src/main.c: -------------------------------------------------------------------------------- 1 | /* main.c - Application main entry point */ 2 | 3 | /* 4 | * Copyright (c) 2015-2016 Intel Corporation 5 | * Copyright (c) 2021 T-Mobile USA, Inc. 6 | * 7 | * SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | static const struct bt_data ad[] = { 27 | BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), 28 | BT_DATA_BYTES(BT_DATA_UUID16_ALL, 29 | BT_UUID_16_ENCODE(BT_UUID_HRS_VAL), 30 | BT_UUID_16_ENCODE(BT_UUID_BAS_VAL), 31 | BT_UUID_16_ENCODE(BT_UUID_DIS_VAL)) 32 | }; 33 | 34 | static void connected(struct bt_conn *conn, uint8_t err) 35 | { 36 | if (err) { 37 | printk("Connection failed (err 0x%02x)\n", err); 38 | } else { 39 | printk("Connected\n"); 40 | } 41 | } 42 | 43 | static void disconnected(struct bt_conn *conn, uint8_t reason) 44 | { 45 | printk("Disconnected (reason 0x%02x)\n", reason); 46 | } 47 | 48 | static struct bt_conn_cb conn_callbacks = { 49 | .connected = connected, 50 | .disconnected = disconnected, 51 | }; 52 | 53 | static void bt_ready(void) 54 | { 55 | int err; 56 | 57 | printk("Bluetooth initialized\n"); 58 | 59 | err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0); 60 | if (err) { 61 | printk("Advertising failed to start (err %d)\n", err); 62 | return; 63 | } 64 | 65 | printk("Advertising successfully started\n"); 66 | } 67 | 68 | static void auth_cancel(struct bt_conn *conn) 69 | { 70 | char addr[BT_ADDR_LE_STR_LEN]; 71 | 72 | bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); 73 | 74 | printk("Pairing cancelled: %s\n", addr); 75 | } 76 | 77 | // static struct bt_conn_auth_cb auth_cb_display = { 78 | // .cancel = auth_cancel, 79 | // }; 80 | 81 | static void bas_notify(void) 82 | { 83 | uint8_t battery_level = bt_bas_get_battery_level(); 84 | 85 | battery_level--; 86 | 87 | if (!battery_level) { 88 | battery_level = 100U; 89 | } 90 | 91 | bt_bas_set_battery_level(battery_level); 92 | } 93 | 94 | static void hrs_notify(void) 95 | { 96 | static uint8_t heartrate = 90U; 97 | 98 | /* Heartrate measurements simulation */ 99 | heartrate++; 100 | if (heartrate == 160U) { 101 | heartrate = 90U; 102 | } 103 | 104 | bt_hrs_notify(heartrate); 105 | } 106 | 107 | void main(void) 108 | { 109 | int err; 110 | 111 | err = bt_enable(NULL); 112 | if (err) { 113 | printk("Bluetooth init failed (err %d)\n", err); 114 | return; 115 | } 116 | 117 | bt_ready(); 118 | 119 | bt_conn_cb_register(&conn_callbacks); 120 | //bt_conn_auth_cb_register(&auth_cb_display); 121 | 122 | /* Implement notification. At the moment there is no suitable way 123 | * of starting delayed work so we do it here 124 | */ 125 | while (1) { 126 | k_sleep(K_SECONDS(1)); 127 | 128 | /* Heartrate measurements simulation */ 129 | hrs_notify(); 130 | 131 | /* Battery level simulation */ 132 | bas_notify(); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_pm_sys.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | #include 7 | #include 8 | #include "tmo_pm_sys.h" 9 | #include "tmo_leds.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef CONFIG_PM_DEVICE 16 | #include 17 | #endif 18 | 19 | int cmd_pmsysactive(const struct shell *shell, int argc, char** argv) 20 | { 21 | shell_print(shell, "Entering active state..."); 22 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_ACTIVE, 0, 0}); 23 | return 0; 24 | } 25 | 26 | int cmd_pmsysidle(const struct shell *shell, int argc, char** argv) 27 | { 28 | shell_print(shell, "Entering runtime-idle state..."); 29 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_RUNTIME_IDLE, 0, 0}); 30 | return 0; 31 | } 32 | 33 | int cmd_pmsyssuspend(const struct shell *shell, int argc, char** argv) 34 | { 35 | shell_print(shell, "Entering suspend-to-idle state..."); 36 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_SUSPEND_TO_IDLE, 0, 0}); 37 | return 0; 38 | } 39 | 40 | int cmd_pmsysstandby(const struct shell *shell, int argc, char** argv) 41 | { 42 | shell_print(shell, "Entering standby state..."); 43 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_STANDBY, 0, 0}); 44 | return 0; 45 | } 46 | 47 | int cmd_pmsysoff(const struct shell *shell, int argc, char** argv) 48 | { 49 | #if CONFIG_PM_DEVICE 50 | const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(rs9116w)); 51 | pm_device_action_run(dev, PM_DEVICE_ACTION_SUSPEND); 52 | pm_device_action_run(dev, PM_DEVICE_ACTION_TURN_OFF); 53 | dev = DEVICE_DT_GET(DT_NODELABEL(sonycxd5605)); 54 | pm_device_action_run(dev, PM_DEVICE_ACTION_SUSPEND); 55 | pm_device_action_run(dev, PM_DEVICE_ACTION_TURN_OFF); 56 | dev = DEVICE_DT_GET(DT_NODELABEL(murata_1sc)); 57 | pm_device_action_run(dev, PM_DEVICE_ACTION_SUSPEND); 58 | dev = PWMLEDS; 59 | led_off(dev, 0); 60 | led_off(dev, 1); 61 | led_off(dev, 2); 62 | led_off(dev, 3); 63 | #endif 64 | shell_print(shell, "Shutting down. Use the reset or user button to bring the board back alive"); 65 | GPIO_IntDisable(0xFFFF); 66 | GPIO_IntClear(0xFFFFFFFF); 67 | GPIO_PinModeSet(gpioPortB, 13, gpioModeInputPullFilter, 1); 68 | GPIO_EM4EnablePinWakeup(BIT(9) << _GPIO_EM4WUEN_EM4WUEN_SHIFT, 0); 69 | CRYOTIMER_EM4WakeupEnable(false); 70 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_SOFT_OFF, 1, 0}); 71 | return 0; 72 | } 73 | int cmd_pmsysfulloff(const struct shell *shell, int argc, char** argv) 74 | { 75 | #if CONFIG_PM_DEVICE 76 | const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(rs9116w)); 77 | pm_device_action_run(dev, PM_DEVICE_ACTION_SUSPEND); 78 | pm_device_action_run(dev, PM_DEVICE_ACTION_TURN_OFF); 79 | dev = DEVICE_DT_GET(DT_NODELABEL(sonycxd5605)); 80 | pm_device_action_run(dev, PM_DEVICE_ACTION_SUSPEND); 81 | pm_device_action_run(dev, PM_DEVICE_ACTION_TURN_OFF); 82 | dev = DEVICE_DT_GET(DT_NODELABEL(murata_1sc)); 83 | pm_device_action_run(dev, PM_DEVICE_ACTION_SUSPEND); 84 | dev = PWMLEDS; 85 | led_off(dev, 0); 86 | led_off(dev, 1); 87 | led_off(dev, 2); 88 | led_off(dev, 3); 89 | #endif 90 | shell_warn(shell, "Warning RTCC will be lost"); 91 | shell_print(shell, "Shutting down. Use the reset or user button to bring the board back alive"); 92 | GPIO_IntDisable(0xFFFF); 93 | GPIO_IntClear(0xFFFFFFFF); 94 | GPIO_PinModeSet(gpioPortB, 13, gpioModeInputPullFilter, 1); 95 | GPIO_EM4EnablePinWakeup(BIT(9) << _GPIO_EM4WUEN_EM4WUEN_SHIFT, 0); 96 | pm_state_force(0u, &(struct pm_state_info){PM_STATE_SOFT_OFF, 0, 0}); 97 | return 0; 98 | } 99 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_modem_edrx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #include "tmo_modem_edrx.h" 11 | 12 | // AT+CEDRXS=[mode],[AcT-type],[Requested_eDRX_value] 13 | 14 | // mode - mode: 15 | // 0 - eDRX mode is off 16 | // 1 - eDRX mode is on 17 | // 2 - eDRX mode enabled, unsolicited messages (URC) enabled 18 | 19 | // AcT-type - radio access technology: 20 | // 1 - EC-GSM-IoT 21 | // 2 - GSM 22 | // 3 - 3G 23 | // 4 - LTE, LTE-M 24 | // 5 - NB-IoT 25 | 26 | // Requested_eDRX_value in NB-IoT mode The duration of the period eDRX, edrx_time will be appended with 0 where 27 | //the bit does not represent a valid eDRX cycle length duration. 28 | // Bit 29 | // 4 3 2 1 E-UTRAN eDRX cycle length duration 30 | // 0 0 1 0 20.48 seconds 31 | // 0 0 1 1 40.96 seconds 32 | // 0 1 0 1 81.92 seconds 33 | // 1 0 0 1 163.84 seconds 34 | // 1 0 1 0 327.68 seconds 35 | // 1 0 1 1 655.36 seconds 36 | // 1 1 0 0 1310.72 seconds 37 | // 1 1 0 1 2621.44 seconds 38 | // 1 1 1 0 5242.88 seconds 39 | // 1 1 1 1 10485.76 seconds 40 | static const double edrx_time[] = { 0, 0, 20.48, 40.96, 0, 81.92, 0, 0, 0, 163.84, 327.68, 655.36, 1310.72, 2621.44, 5242.88, 10485.76, -1}; 41 | 42 | // From tmo_encoding.c 43 | char* byte_to_binary_str(uint8_t byte) 44 | { 45 | static char buf[8] = { 0 }; 46 | 47 | for (int i = 0; i < 8; i++) { 48 | buf[7 - i] = (byte & 1 << i) ? '1' : '0'; 49 | } 50 | 51 | return buf; 52 | } 53 | 54 | int tmo_edrx_timer_byte_to_secs(uint8_t byte, double* time) 55 | { 56 | char* str = byte_to_binary_str(byte); 57 | int result = TMO_ERROR; 58 | double secs = 0; 59 | 60 | result = tmo_edrx_timer_str_to_secs(str, &secs); 61 | 62 | if (result < TMO_SUCCESS) { 63 | return result; 64 | } 65 | 66 | *time = secs; 67 | return result; 68 | } 69 | 70 | int tmo_edrx_timer_secs_to_approx_byte(double secs, uint8_t* byte) 71 | { 72 | int index = 0; 73 | int index_small_val = 0; 74 | double time_val_small = 0; 75 | double time_val_large = 0; 76 | 77 | *byte = 0; 78 | 79 | //0 time is not supported 80 | if (secs == 0) { 81 | return -ERANGE; 82 | } 83 | 84 | for ( ; (edrx_time[index] != -1) && (secs != 0); index++) { 85 | if(edrx_time[index] != 0) { 86 | if(secs == edrx_time[index]) { 87 | *byte = index; 88 | break; 89 | } 90 | if(secs > edrx_time[index]) { 91 | time_val_small = edrx_time[index]; 92 | index_small_val = index; 93 | } 94 | if(secs < edrx_time[index]) { 95 | time_val_large = edrx_time[index]; 96 | break; 97 | } 98 | } 99 | } 100 | 101 | if (secs - time_val_small >= time_val_large - secs) { 102 | *byte = index; 103 | } else { 104 | *byte = index_small_val; 105 | } 106 | 107 | return TMO_SUCCESS; 108 | } 109 | 110 | int tmo_edrx_timer_secs_to_str(double secs, char* str) 111 | { 112 | int result = TMO_ERROR; 113 | uint8_t byte = 0; 114 | 115 | if (secs > MAX_EDRX_TIME) { 116 | return -EINVAL; 117 | } 118 | 119 | result = tmo_edrx_timer_secs_to_approx_byte(secs, &byte); 120 | 121 | if (result < TMO_SUCCESS) { 122 | return -EINVAL; 123 | } 124 | 125 | //get last 4 bits 126 | str = byte_to_binary_str(byte) + 4; 127 | 128 | return TMO_SUCCESS; 129 | } 130 | 131 | int tmo_edrx_timer_str_to_secs(const char* val, double* secs) 132 | { 133 | int value = 0; 134 | 135 | if (val == NULL) { 136 | return -EINVAL; 137 | } 138 | 139 | value |= (val[3] == '1') ? 0x01 : 0; 140 | value |= (val[2] == '1') ? 0x02 : 0; 141 | value |= (val[1] == '1') ? 0x04 : 0; 142 | value |= (val[0] == '1') ? 0x08 : 0; 143 | 144 | *secs = edrx_time[value]; 145 | 146 | return TMO_SUCCESS; 147 | } 148 | -------------------------------------------------------------------------------- /samples/tmo_shell/prj.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | # UART support 6 | CONFIG_SERIAL=y 7 | CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=1024 8 | 9 | CONFIG_RING_BUFFER=y 10 | CONFIG_SOC_FLASH_GECKO=y 11 | 12 | CONFIG_ADC=y 13 | CONFIG_ADC_SHELL=n 14 | # Enable support for the flash hardware. 15 | CONFIG_FLASH=y 16 | CONFIG_I2C=y 17 | 18 | CONFIG_SPI=y 19 | CONFIG_SPI_NOR=y 20 | CONFIG_SPI_GECKO=y 21 | 22 | # Murata 1SC modem support 23 | CONFIG_MODEM=y 24 | CONFIG_MODEM_SHELL=y 25 | CONFIG_MODEM_MURATA_1SC=y 26 | CONFIG_MODEM_MURATA_1SC_APN="CATM.T-MOBILE.COM" 27 | 28 | # Generic networking options 29 | CONFIG_NETWORKING=y 30 | CONFIG_NET_SHELL=n 31 | CONFIG_NET_NATIVE=n 32 | CONFIG_NET_OFFLOAD=y 33 | CONFIG_NET_IPV6_DAD=n 34 | CONFIG_NET_UDP=y 35 | CONFIG_NET_TCP=y 36 | CONFIG_NET_IPV6=n 37 | CONFIG_NET_IPV4=y 38 | CONFIG_DNS_RESOLVER=n 39 | CONFIG_POSIX_MAX_FDS=15 40 | CONFIG_HTTP_CLIENT=y 41 | 42 | # Network management events 43 | CONFIG_NET_CONNECTION_MANAGER=y 44 | CONFIG_NET_MGMT=y 45 | CONFIG_NET_MGMT_EVENT=y 46 | 47 | # Debugging 48 | # CONFIG_DEBUG_OPTIMIZATIONS=y 49 | 50 | # Logging 51 | CONFIG_LOG=y 52 | CONFIG_NET_LOG=y 53 | 54 | CONFIG_CONSOLE_SUBSYS=y 55 | CONFIG_CONSOLE_GETLINE=y 56 | 57 | # Network buffers 58 | CONFIG_NET_PKT_RX_COUNT=1 59 | CONFIG_NET_PKT_TX_COUNT=1 60 | CONFIG_NET_BUF_RX_COUNT=1 61 | CONFIG_NET_BUF_TX_COUNT=1 62 | CONFIG_NET_CONTEXT_NET_PKT_POOL=y 63 | CONFIG_NET_BUF_DATA_SIZE=60 64 | 65 | # RS9116 66 | CONFIG_WIFI=y 67 | CONFIG_WIFI_RS9116W=y 68 | CONFIG_GPIO=y 69 | 70 | #CONFIG_TEST_RANDOM_GENERATOR=y 71 | 72 | CONFIG_INIT_STACKS=y 73 | 74 | CONFIG_MBEDTLS_DTLS=y 75 | 76 | CONFIG_NET_SOCKETS=y 77 | CONFIG_NET_SOCKETS_OFFLOAD=y 78 | CONFIG_NET_SOCKETS_POSIX_NAMES=y 79 | CONFIG_NET_SOCKETS_POLL_MAX=4 80 | CONFIG_NET_SOCKETS_SOCKOPT_TLS=y 81 | CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=4 82 | CONFIG_NET_SOCKETS_ENABLE_DTLS=y 83 | 84 | 85 | # Bluetooth / BLE 86 | CONFIG_BT=y 87 | CONFIG_BT_CUSTOM=y 88 | CONFIG_BT_RS9116W=y 89 | CONFIG_BT_PERIPHERAL=y 90 | CONFIG_BT_SMP=y 91 | CONFIG_BT_MAX_PAIRED=2 92 | CONFIG_BT_DEBUG=n 93 | 94 | # Sensors 95 | CONFIG_SENSOR=y 96 | CONFIG_SENSOR_SHELL=y 97 | 98 | # Stack sizes 99 | CONFIG_MAIN_STACK_SIZE=4096 100 | CONFIG_SHELL_STACK_SIZE=4096 101 | 102 | # MBED TLS configuration 103 | CONFIG_MBEDTLS=y 104 | CONFIG_MBEDTLS_BUILTIN=y 105 | 106 | # CONFIG_NEWLIB_LIBC=y 107 | CONFIG_MINIMAL_LIBC_MALLOC=y 108 | CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=2048 109 | 110 | # Set number IPv4 network interfaces 111 | CONFIG_NET_IF_MAX_IPV4_COUNT=2 112 | # CONFIG_NET_IF_MAX_IPV6_COUNT=2 113 | 114 | #CONFIG_FS_LOG_LEVEL_DBG=y 115 | 116 | CONFIG_HEAP_MEM_POOL_SIZE=16384 117 | 118 | CONFIG_SHELL=y 119 | CONFIG_SHELL_LOG_LEVEL_INF=y 120 | CONFIG_SHELL_CMD_BUFF_SIZE=2100 121 | 122 | CONFIG_FILE_SYSTEM=y 123 | CONFIG_FILE_SYSTEM_SHELL=y 124 | CONFIG_FILE_SYSTEM_LITTLEFS=y 125 | 126 | CONFIG_FLASH_MAP=y 127 | CONFIG_FLASH_PAGE_LAYOUT=y 128 | 129 | CONFIG_RS9116W_TLS_OFFLOAD=y 130 | 131 | CONFIG_TMO_SHELL_SSID="" 132 | CONFIG_TMO_SHELL_PSK="" 133 | 134 | CONFIG_RS9116_DNS_SERVER_IP_ADDRESSES=y 135 | CONFIG_RS9116_IPV4_DNS_SERVER1="8.8.8.8" 136 | CONFIG_RS9116_IPV6_DNS_SERVER1="2001:4860:4860::8888" 137 | 138 | CONFIG_MODEM_MURATA_1SC_SOCKET_COUNT=4 139 | CONFIG_WISECONNECT_SOCKETS_COUNT=6 140 | 141 | CONFIG_SHELL_GETOPT=y 142 | CONFIG_PING=y 143 | 144 | CONFIG_MODEM_SMS_IN_MSG_MAX_LEN=200 145 | CONFIG_MODEM_SMS_OUT_MSG_MAX_LEN=200 146 | 147 | #Ekermit 148 | CONFIG_SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL=y 149 | CONFIG_LOG_BACKEND_RTT=n 150 | CONFIG_TMO_SHELL_BUILD_EK=y 151 | 152 | #Power Managment 153 | CONFIG_PM=y 154 | CONFIG_PM_DEVICE=y 155 | 156 | CONFIG_BT_DEVICE_NAME_DYNAMIC=y 157 | CONFIG_LOG_PRINTK=n 158 | 159 | #Test Configs 160 | CONFIG_TMO_TEST_MFG_CHECK_GOLDEN=y 161 | CONFIG_TMO_TEST_MFG_CHECK_ACCESS_CODE=y 162 | CONFIG_DFU_GECKO_LIB=y 163 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/led_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "tmo_shell.h" 15 | #include "tmo_leds.h" 16 | #include "board.h" 17 | 18 | int updown(int channel) 19 | { 20 | const struct device * pwm_dev = device_get_binding("pwmleds"); 21 | int ret = 0; 22 | 23 | for (int i = 0; i <= 100; i++) { 24 | if ((ret = led_set_brightness(pwm_dev, channel, i)) != 0) { 25 | printf("led_set_brightness(pwm_dev, %d, %d) - function failed %d \n", channel, i, ret); 26 | return (ret); 27 | } 28 | k_sleep(K_MSEC(10)); 29 | } 30 | for (int i = 0; i <= 100; i++) { 31 | if ((ret = led_set_brightness(pwm_dev, channel, 100-i)) != 0) { 32 | printf("led_set_brightness(pwm_dev, %d, 100-%d) - function failed %d \n", channel, i, ret); 33 | return (ret); 34 | } 35 | k_sleep(K_MSEC(10)); 36 | } 37 | return (ret); 38 | } 39 | 40 | int led_test() 41 | { 42 | const struct device * pwm_dev = device_get_binding("pwmleds"); 43 | int ret = 0; 44 | #ifdef LED_PWM_WHITE 45 | if ((ret = led_off(pwm_dev, LED_PWM_WHITE)) != 0) { 46 | printf("led_off(pwm_dev, LED_PWM_WHITE) - function failed %d \n", ret); 47 | return (ret); 48 | } 49 | #endif /* LED_PWM_WHITE */ 50 | if ((ret = led_off(pwm_dev, LED_PWM_RED)) != 0) { 51 | printf("led_off(pwm_dev, LED_PWM_RED) - function failed %d \n", ret); 52 | return (ret); 53 | } 54 | if ((ret = led_off(pwm_dev, LED_PWM_GREEN)) != 0) { 55 | printf("led_off(pwm_dev, LED_PWM_GREEN) - function failed %d \n", ret); 56 | return (ret); 57 | } 58 | if ((ret = led_on(pwm_dev, LED_PWM_BLUE)) != 0) { 59 | printf("led_on(pwm_dev, LED_PWM_BLUE) - function failed %d \n", ret); 60 | return (ret); 61 | } 62 | 63 | printf("Blue LED should be on - function was successful\n"); 64 | if ((ret = updown(LED_PWM_BLUE)) !=0) { 65 | return (ret); 66 | } 67 | 68 | if ((ret = led_off(pwm_dev, LED_PWM_BLUE)) != 0) { 69 | printf("led_off(pwm_dev, LED_PWM_BLUE) - function failed %d \n", ret); 70 | return (ret); 71 | } 72 | 73 | // This is not a great test for the white LED, but it will suffice for now 74 | #ifdef LED_PWM_WHITE 75 | if ((ret = led_on(pwm_dev, LED_PWM_WHITE)) != 0) { 76 | printf("led_on(pwm_dev, LED_PWM_WHITE) - function failed %d \n", ret); 77 | return (ret); 78 | } 79 | 80 | printf("White LED should be on - function was successful\n"); 81 | if ((ret = updown(LED_PWM_WHITE)) !=0) { 82 | return (ret); 83 | } 84 | 85 | if ((ret = led_off(pwm_dev, LED_PWM_WHITE)) != 0) { 86 | printf("led_off(pwm_dev, LED_PWM_WHITE) - function failed %d \n", ret); 87 | return (ret); 88 | } 89 | #endif /* LED_PWM_WHITE */ 90 | 91 | if ((ret = led_on(pwm_dev, LED_PWM_RED)) != 0) { 92 | printf("led_on(pwm_dev, LED_PWM_RED) - function failed %d \n", ret); 93 | return (ret); 94 | } 95 | 96 | printf("Red LED should be on - function was successful\n"); 97 | if ((ret = updown(LED_PWM_RED)) !=0) { 98 | return (ret); 99 | } 100 | 101 | if ((ret = led_off(pwm_dev, LED_PWM_RED)) != 0) { 102 | printf("led_off(pwm_dev, LED_PWM_RED) - function failed %d \n", ret); 103 | return (ret); 104 | } 105 | if ((ret = led_on(pwm_dev, LED_PWM_GREEN)) != 0) { 106 | printf("led_on(pwm_dev, LED_PWM_GREEN) - function failed %d \n", ret); 107 | return (ret); 108 | } 109 | 110 | printf("Green LED should be on - function was successful\n"); 111 | if ((ret = updown(LED_PWM_GREEN)) !=0) { 112 | return (ret); 113 | } 114 | 115 | if ((ret = led_off(pwm_dev, LED_PWM_GREEN)) != 0) { 116 | printf("led_off(pwm_dev, LED_PWM_GREEN) - function failed %d \n", ret); 117 | return (ret); 118 | } 119 | printf("led_test - function was successful\n"); 120 | 121 | return (ret); 122 | } 123 | -------------------------------------------------------------------------------- /samples/as6212_sample/README.rst: -------------------------------------------------------------------------------- 1 | Title: as6212_sample 2 | 3 | Description: 4 | 5 | An AS6212 Digital Temperature Alert sensor sample to demonstrate the 6 | capabilities of the T-Mobile DevEdge dev kit. 7 | 8 | Overview: 9 | 10 | This sample is provided as an example to demonstrate the high accuracy AS6212 11 | Digital Temperature sensor with Alert functionality. The sample uses the 12 | AS6212's temperature high/low alerting mechanism to generate interrupts that 13 | awaken threads, which report the temperature data to the console and 14 | subsequently enter EM2 sleep mode. 15 | 16 | The alert-sourced interrupts, demonstrate the AS6212's temperature High and Low 17 | threshold alerting capability. 18 | 19 | - AS6212 Digital Temperature with Alert functionality. 20 | 21 | -------------------------------------------------------------------------------- 22 | 23 | Requirements 24 | ************ 25 | 26 | -A T-Mobile DevEdge dev kit (https://devedge.t-mobile.com/) 27 | -A Zephyr build environment (https://docs.zephyrproject.org/latest/develop/getting_started/index.html) 28 | 29 | Building and Running Project: 30 | 31 | How this project can be built: 32 | 33 | -Checkout the T-Mobile downstream zephyr repo: 34 | cd ~/zephyrproject 35 | git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrRTOS zephyr 36 | 37 | -Checkout the T-Mobile zephyr-tmo-sdk repo: 38 | cd ~/zephyrproject 39 | git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK tmo-zephyr-sdk 40 | 41 | -Run 'west update' 42 | cd ~/zephyrproject 43 | west update 44 | 45 | -Build this sample: 46 | cd ~/zephyrproject 47 | west build ~/zephyrproject/DevEdge-IoTDevKit-ZephyrSDK/samples/as6212_sample -p -b tmo_dev_edge 48 | (substitute your home folder for '' in the command above) 49 | 50 | -Connect DevEdge dev kit: 51 | Connect the USB-C port furthest from the pushbutton to your computer. (The 52 | other USB-C port can be connected; however, it's not used for this sample.) 53 | 54 | -Flash as6212_sample 55 | cd ~/zephyrproject 56 | west flash 57 | 58 | Sample Output 59 | ============= 60 | 61 | .. code-block:: console 62 | *** Booting Zephyr OS build 4d07b602dd77 *** 63 | 64 | Welcome to T-Mobile DevEdge! 65 | 66 | This application aims to demonstrate the Gecko's Energy Mode 2 (EM2) (Deep Sleep 67 | Mode) and Wake capabilities in conjunction with the temperature interrupt 68 | of DevEdge's (tmo_dev_edge) AMS OSRAM AS6212 Digital Temperature Sensor. 69 | 70 | Set SENSOR_ATTR_UPPER_THRESH (44C) 71 | Set SENSOR_ATTR_LOWER_THRESH (38C) 72 | 73 | Set temperature_alert 74 | 75 | Call enable_temp_alerts 76 | get_temperature(): temperature is 29.2656C 77 | 78 | as6212_thread1(): running 79 | get_temperature(): temperature is 29.2656C 80 | 81 | as6212_thread2(): running 82 | get_temperature(): temperature is 29.2656C 83 | 84 | 85 | Awaiting the AS6212 temperature threshold-high/threshold-low (interrupt) alerts. 86 | 87 | While observing the console output, use a hair dryer (or similar forced air 88 | heat source) to momentarily raise the temperature of DevEdge board, triggering 89 | the AS6212 temperature-high alert. Remove the heat source and wait for the 90 | AS6212 temperature-low alert. 91 | 92 | 93 | as6212_intr_callback(): Received AS6212 Temperature Sensor ALERT Interrupt (1) 94 | as6212_thread1(): running 95 | get_temperature(): temperature is 44.0312C 96 | 97 | as6212_thread2(): running 98 | get_temperature(): temperature is 44.0312C 99 | 100 | 101 | as6212_intr_callback(): Received AS6212 Temperature Sensor ALERT Interrupt (2) 102 | as6212_thread1(): running 103 | get_temperature(): temperature is 37.9766C 104 | 105 | as6212_thread2(): running 106 | get_temperature(): temperature is 37.9766C 107 | 108 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_fuel_gauge.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | LOG_MODULE_REGISTER(tmo_fuel_gauge, CONFIG_LOG_DEFAULT_LEVEL); 7 | 8 | #if DT_NODE_EXISTS(DT_NODELABEL(pmic)) 9 | #define PMIC_EXIT_MODE_VALUE 0b000 10 | #define PMIC_RESET_MODE_VALUE 0b001 11 | #define PMIC_SHORT_MODE_VALUE 0b010 12 | #define PMIC_PRECOND_MODE_VALUE 0b011 13 | #define PMIC_FASTCHARGE_CC_MODE_VALUE 0b100 14 | #define PMIC_FASTCHARGE_CV_MODE_VALUE 0b101 15 | #define PMIC_END_OF_CHARGE_MODE_VALUE 0b101 16 | #define PMIC_FAULT_MODE_VALUE 0b111 17 | #include 18 | 19 | static const struct device *alpc = DEVICE_DT_GET_ANY(qorvo_act81461_alpc); 20 | 21 | int get_pmic_status(uint8_t *charging, uint8_t *vbus, uint8_t *attached, uint8_t *fault, uint8_t *charge_status) 22 | { 23 | int ret; 24 | struct fuel_gauge_get_property props[4] = {0}; 25 | 26 | props[0].property_type = FUEL_GAUGE_STATUS; 27 | props[1].property_type = FUEL_GAUGE_CONNECT_STATE; 28 | props[2].property_type = FUEL_GAUGE_PRESENT_STATE; 29 | props[3].property_type = FUEL_GAUGE_MODE; 30 | 31 | ret = fuel_gauge_get_prop(alpc, props, ARRAY_SIZE(props)); 32 | 33 | if (ret) { 34 | return ret; 35 | } 36 | 37 | if (charging) { 38 | *charging = (props[0].value.flags & FUEL_GAUGE_STATUS_FLAGS_DISCHARGING)? 0 : 1; 39 | } 40 | if (vbus) { 41 | *vbus = props[1].value.flags; 42 | } 43 | if (attached) { 44 | *attached = props[2].value.flags; 45 | } 46 | if (fault) { 47 | *fault = props[3].value.mode == PMIC_FAULT_MODE_VALUE; 48 | } 49 | if (charge_status) { 50 | *charge_status = props[3].value.mode; 51 | } 52 | 53 | return 0; 54 | } 55 | 56 | #if CONFIG_TMO_FUEL_GAUGE_STATE_CHANGE_PRINT 57 | static void print_pmic_status(const uint8_t charging, const uint8_t vbus, const uint8_t attached, 58 | const uint8_t fault, const uint8_t charge_status) 59 | { 60 | if (vbus == 1) { 61 | LOG_INF("PMIC VBUS is detected"); 62 | } 63 | else { 64 | LOG_INF("No PMIC VBUS is detected"); 65 | } 66 | 67 | /* Battery removed/inserted */ 68 | if (attached == 1) { 69 | LOG_INF("Battery has been detected"); 70 | } 71 | else { 72 | LOG_INF("No battery is detected"); 73 | } 74 | 75 | if ((attached) && (vbus)) 76 | { 77 | /* Charge condition / state change – Precondition, fast charge, top off and end of charge reached. */ 78 | switch(charge_status) 79 | { 80 | case PMIC_EXIT_MODE_VALUE: 81 | LOG_INF("Charger has exited charge mode"); 82 | break; 83 | case PMIC_RESET_MODE_VALUE: 84 | LOG_INF("Charger is in reset mode"); 85 | break; 86 | case PMIC_SHORT_MODE_VALUE: 87 | LOG_INF("Charger is in VBAT SHORT mode"); 88 | break; 89 | case PMIC_PRECOND_MODE_VALUE: 90 | LOG_INF("Charger is in VBAT PRECOND mode"); 91 | break; 92 | case PMIC_FASTCHARGE_CC_MODE_VALUE: 93 | case PMIC_FASTCHARGE_CV_MODE_VALUE: 94 | LOG_INF("Battery is in FAST charge mode - charging"); 95 | break; 96 | case PMIC_END_OF_CHARGE_MODE_VALUE: 97 | LOG_INF("Battery end of charge has been detected"); 98 | break; 99 | case PMIC_FAULT_MODE_VALUE: 100 | LOG_INF("Battery fault detected"); 101 | break; 102 | default: 103 | break; 104 | } 105 | } 106 | } 107 | 108 | void pmic_state_print(const struct device *dev) 109 | { 110 | ARG_UNUSED(dev); 111 | 112 | uint8_t charging, vbus, attached, fault, status; 113 | 114 | get_pmic_status(&charging, &vbus, &attached, &fault, &status); 115 | print_pmic_status(charging, vbus, attached, fault, status); 116 | } 117 | 118 | struct act81461_int_cb pmic_charge_cb = { 119 | cb = pmic_state_print 120 | }; 121 | 122 | static int fuel_guage_init_state_print(const struct device *unused) 123 | { 124 | ARG_UNUSED(unused); 125 | 126 | act81461_charger_int_cb_register(alpc, &pmic_charge_cb); 127 | 128 | return 0; 129 | } 130 | 131 | SYS_INIT(fuel_guage_init_state_print, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); 132 | #endif 133 | #endif 134 | 135 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_ping.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "tmo_shell.h" 14 | #include "tmo_ping.h" 15 | 16 | int ping_rxd; 17 | char host_addr[NET_IPV6_ADDR_LEN]; 18 | 19 | K_SEM_DEFINE(ping_sem, 0, 1); 20 | 21 | const static struct shell* sh; 22 | void ping_cb(uint32_t ms) 23 | { 24 | 25 | // shell_print("Request %d "); 26 | shell_print(sh, "Reply from %s; time = %dms", host_addr, ms); 27 | ping_rxd++; 28 | k_sem_give(&ping_sem); 29 | } 30 | 31 | static struct net_ping_handler ping_handler = { 32 | .handler = ping_cb 33 | }; 34 | 35 | static inline void print_usage(const struct shell *shell) 36 | { 37 | shell_print(shell, "usage: ping [-c count] [-s packetsize] [-t timeout] iface host"); 38 | } 39 | 40 | int cmd_ping(const struct shell *shell, size_t argc, char **argv) 41 | { 42 | int ping_cnt = 1, ret = 0; 43 | uint32_t timeout_ms = 5000; 44 | uint16_t sz = 64; 45 | int8_t c; 46 | ping_rxd = 0; 47 | sh = shell; 48 | net_ping_cb_register(&ping_handler); 49 | if (argc < 3) { 50 | print_usage(shell); 51 | ret = -EINVAL; 52 | goto exit; 53 | } 54 | while ((c = getopt(argc - 2, argv, "ht:s:c:")) != -1) { 55 | switch (c) { 56 | case 'h': 57 | print_usage(shell); 58 | goto exit; 59 | case 't': 60 | timeout_ms = strtol(optarg, NULL, 10); 61 | break; 62 | case 's': 63 | sz = strtol(optarg, NULL, 10); 64 | break; 65 | case 'c': 66 | ping_cnt = strtol(optarg, NULL, 10); 67 | break; 68 | case '?': 69 | shell_error(shell, "Illegal option -- %c", (char)optopt); 70 | ret = -EINVAL; 71 | print_usage(shell); 72 | goto exit; 73 | default: 74 | break; 75 | } 76 | } 77 | int if_idx = strtol(argv[argc - 2], NULL, 10); 78 | if (if_idx < 0 || if_idx > 2) { 79 | shell_error(shell, "Unknown iface %d", if_idx); 80 | print_usage(shell); 81 | goto exit; 82 | } 83 | struct net_if* iface = net_if_get_by_index(if_idx); 84 | struct sockaddr dst; 85 | char *host = argv[argc - 1]; 86 | if (ping_cnt <= 0) { 87 | shell_error(shell, "Invalid ping count %d", ping_cnt); 88 | print_usage(shell); 89 | return EINVAL; 90 | } 91 | if (!net_ipaddr_parse(host, strlen(host), &dst)) 92 | { 93 | tmo_offload_init(if_idx); 94 | struct zsock_addrinfo *res; 95 | if (zsock_getaddrinfo(host, "1", NULL, &res)){ 96 | shell_error(shell, "Cannot resolve %s: Unknown host", host); 97 | print_usage(shell); 98 | goto exit; 99 | } 100 | memcpy(&dst, res->ai_addr, sizeof(struct sockaddr)); 101 | zsock_freeaddrinfo(res); 102 | } 103 | net_addr_ntop(dst.sa_family, 104 | ((dst.sa_family == AF_INET) ? (void*)&net_sin(&dst)->sin_addr : (void*)&net_sin6(&dst)->sin6_addr), 105 | host_addr, sizeof(host_addr)); 106 | shell_print(shell, "PING %s (%s): %d data bytes", host, host_addr, sz); 107 | k_sem_reset(&ping_sem); 108 | for (int i = 0; i < ping_cnt; i++) { 109 | ret = net_ping(iface, &dst, sz); 110 | if (ret) { 111 | shell_error(shell, "Failed to initiate ping, err = %d", ret); 112 | goto exit; 113 | } 114 | if (k_sem_take(&ping_sem, K_MSEC(timeout_ms))) { 115 | shell_print(shell, "Request timeout"); 116 | } 117 | k_msleep(1000); 118 | } 119 | shell_print(shell, "%d packets transmitted, %d packets received, %.1d%% packet loss", 120 | ping_cnt, ping_rxd, (100 * (ping_cnt - ping_rxd)) / ping_cnt); 121 | exit: 122 | k_sem_give(&ping_sem); 123 | net_ping_cb_unregister(&ping_handler); 124 | return ret; 125 | } 126 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_http_mock_socket.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "sockets_internal.h" 12 | 13 | #define FAILURE_POINT 1000000 14 | #define DOWNLOAD_SIZE 2000000 15 | 16 | const char *http_resp_header = 17 | "HTTP/1.1 200 OK\r\nContent-Length: %d\r\nContent-Type: " 18 | "text/html\r\nConnection: Close\r\n\r\n"; 19 | 20 | static struct { 21 | bool header_sent; 22 | int ptr; 23 | int len; 24 | int so_rcvtimeo; 25 | } sock_data; 26 | 27 | static ssize_t s_recvfrom(void *obj, void *buf, size_t len, int flags, 28 | struct sockaddr *from, socklen_t *fromlen) 29 | { 30 | char gen_buffer[128]; 31 | if (sock_data.ptr >= FAILURE_POINT && sock_data.so_rcvtimeo) { 32 | k_msleep(sock_data.so_rcvtimeo); 33 | errno = EAGAIN; 34 | return -1; 35 | } else { 36 | k_msleep(5); 37 | } 38 | if (!sock_data.header_sent) { 39 | snprintk(gen_buffer, sizeof(gen_buffer), http_resp_header, 40 | sock_data.len); 41 | int cpl = MIN(strlen(gen_buffer + sock_data.ptr), len); 42 | memcpy(buf, gen_buffer, cpl); 43 | sock_data.ptr += cpl; 44 | if (sock_data.ptr >= strlen(gen_buffer)) { 45 | sock_data.header_sent = true; 46 | sock_data.ptr = 0; 47 | } 48 | return cpl; 49 | // sizeof(http_resp_header); 50 | } else { 51 | memset(gen_buffer, 0, sizeof(gen_buffer)); 52 | snprintk(gen_buffer, sizeof(gen_buffer), "%d", 53 | sock_data.ptr + (DOWNLOAD_SIZE - sock_data.len)); 54 | int cpl = MIN(sizeof(gen_buffer), len); 55 | cpl = MIN(cpl, sock_data.len - sock_data.ptr); 56 | memcpy(buf, gen_buffer, cpl); 57 | sock_data.ptr += cpl; 58 | return cpl; 59 | } 60 | } 61 | 62 | const char *strncasestr(const char *big, const char *little, int mxlen) 63 | { 64 | size_t count = 0; 65 | mxlen -= (strlen(little) - 1); 66 | while (count < mxlen) { 67 | if (!strncasecmp(big + count, little, strlen(little))) { 68 | return count + big; 69 | } 70 | count++; 71 | } 72 | return NULL; 73 | } 74 | 75 | static ssize_t s_sendto(void *obj, const void *buf, size_t len, int flags, 76 | const struct sockaddr *to, socklen_t tolen) 77 | { 78 | // strstr() 79 | // strncasecmp(header, "Content-Length", sizeof("Content-Length") - 1) 80 | const char *rh = strncasestr(buf, "Range: bytes=", len); 81 | 82 | if (rh) { 83 | sock_data.len = 84 | DOWNLOAD_SIZE - 85 | strtol(rh + sizeof("Range: bytes=") - 1, NULL, 10); 86 | } 87 | 88 | k_msleep(100); 89 | return len; 90 | } 91 | 92 | static int s_connect(void *obj, const struct sockaddr *addr, socklen_t addrlen) 93 | { 94 | k_msleep(100); 95 | return 0; 96 | } 97 | 98 | static ssize_t s_read(void *obj, void *buffer, size_t count) 99 | { 100 | return s_recvfrom(obj, buffer, count, 0, NULL, 0); 101 | } 102 | 103 | static ssize_t s_write(void *obj, const void *buffer, size_t count) 104 | { 105 | return s_sendto(obj, buffer, count, 0, NULL, 0); 106 | } 107 | 108 | static int s_close(void *obj) { return 0; } 109 | 110 | static int s_setsockopt(void *obj, int level, int optname, const void *optval, 111 | socklen_t optlen) 112 | { 113 | if (level != SOL_SOCKET || optname != SO_RCVTIMEO || 114 | optlen != sizeof(struct timeval)) { 115 | return -EINVAL; 116 | } 117 | const struct timeval *ptv = optval; 118 | sock_data.so_rcvtimeo = ptv->tv_sec * 1000; 119 | sock_data.so_rcvtimeo += ptv->tv_usec / 1000; 120 | return 0; 121 | } 122 | 123 | static const struct socket_op_vtable socket_fd_op_vtable = { 124 | .fd_vtable = 125 | { 126 | .read = s_read, 127 | .write = s_write, 128 | .close = s_close, 129 | }, 130 | .connect = s_connect, 131 | .sendto = s_sendto, 132 | .recvfrom = s_recvfrom, 133 | .setsockopt = s_setsockopt, 134 | }; 135 | 136 | int http_fail_unit_test_socket_create(void) 137 | { 138 | int fd = z_reserve_fd(); 139 | 140 | if (fd < 0) { 141 | return -1; 142 | } 143 | 144 | sock_data.ptr = 0; 145 | sock_data.len = DOWNLOAD_SIZE; 146 | sock_data.header_sent = 0; 147 | sock_data.so_rcvtimeo = 0; 148 | 149 | z_finalize_fd(fd, &sock_data, 150 | (const struct fd_op_vtable *)&socket_fd_op_vtable); 151 | 152 | return fd; 153 | } 154 | -------------------------------------------------------------------------------- /samples/push_button_sample/README.txt: -------------------------------------------------------------------------------- 1 | Title: push_button_sample 2 | 3 | Description: 4 | 5 | A sample to demonstrate the Push Button Interrupts (sensing edge detections + sleep wakeup) using the T-Mobile DevEdge dev kit 6 | 7 | -------------------------------------------------------------------------------- 8 | 9 | Requirements 10 | ************ 11 | 12 | -A T-Mobile DevEdge dev kit (https://devedge.t-mobile.com/) 13 | -A Zephyr build environment (https://docs.zephyrproject.org/latest/develop/getting_started/index.html) 14 | 15 | Building and Running Project: 16 | 17 | How this project can be built: 18 | 19 | -Checkout the T-Mobile downstream zephyr repo: 20 | cd ~/zephyrproject 21 | git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrRTOS zephyr 22 | 23 | -Checkout the T-Mobile zephyr-tmo-sdk repo: 24 | cd ~/zephyrproject 25 | git clone https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK tmo-zephyr-sdk 26 | 27 | -Run 'west update' 28 | cd ~/zephyrproject 29 | west update 30 | 31 | -Build this sample: 32 | cd ~/zephyrproject 33 | west build ~/zephyrproject/tmo-zephyr-sdk/samples/push_button_sample -p -b tmo_dev_edge 34 | (substitute your home folder for '' in the command above) 35 | 36 | -Connect DevEdge dev kit: 37 | Connect the USB-C port furthest from the pushbutton to your computer. (The 38 | other USB-C port can be connected; however, it's not used for this sample.) 39 | 40 | -Flash push_button_sample: 41 | cd ~/zephyrproject 42 | west flash 43 | 44 | Console output from the sample application follows: 45 | 46 | *** Booting Zephyr OS build 4d07b602dd77 *** 47 | 48 | 49 | Welcome to T-Mobile DevEdge! 50 | 51 | This application aims to demonstrate the Gecko's Energy Mode 2 (EM2) (Deep 52 | Sleep Mode) and Wake capabilities in conjunction with the SW0 interrupt pin, 53 | which is connected to the user pushbutton switch of the DevEdge module. 54 | 55 | Setting up GPIO 56 | Set up button at gpio@4000a030 pin 13 57 | 58 | Phase 1 59 | In this phase, a firmware-based debounce filter cleans up the interrupt signal 60 | generated by the user pushbutton switch. Momentarily pressing the pushbutton 61 | will display the amount of time the button was pressed. Releasing the button 62 | after holding it for more than three seconds will advance the demonstration to 63 | the next and final phase. 64 | 65 | Awaiting debounced user pushbutton interrupts... 66 | Pushbutton press-event (duration: 181ms) 67 | Pushbutton press-event (duration: 201ms) 68 | Pushbutton press-event (duration: 382ms) 69 | Pushbutton press-event (duration: 1326ms) 70 | Pushbutton press-event (duration: 100ms) 71 | Pushbutton press-event (duration: 2311ms) 72 | Pushbutton press-event (duration: 2512ms) 73 | Pushbutton press-event (duration: 2834ms) 74 | Pushbutton press-event (duration: 2533ms) 75 | Pushbutton press-event (duration: 3417ms) 76 | Exiting phase 1 77 | 78 | Phase 2 79 | In this phase, the SW0 interrupt signal temporarily wakes the Gecko from EM2 to 80 | print the signal's edge, rising or falling. 81 | 82 | Awaiting unfiltered user pushbutton interrupts... 83 | Entering EM2 sleep... 84 | 85 | gpio@4000a030 interrupt (1): rising edge 86 | Awake from EM2 sleep... 87 | Entering EM2 sleep... 88 | 89 | gpio@4000a030 interrupt (2): rising edge (bounce detected) 90 | gpio@4000a030 interrupt (3): falling edge 91 | Awake from EM2 sleep... 92 | Entering EM2 sleep... 93 | 94 | gpio@4000a030 interrupt (4): rising edge 95 | Awake from EM2 sleep... 96 | Entering EM2 sleep... 97 | 98 | gpio@4000a030 interrupt (5): falling edge 99 | Awake from EM2 sleep... 100 | Entering EM2 sleep... 101 | 102 | gpio@4000a030 interrupt (6): rising edge 103 | Awake from EM2 sleep... 104 | Entering EM2 sleep... 105 | 106 | gpio@4000a030 interrupt (7): falling edge 107 | Awake from EM2 sleep... 108 | Entering EM2 sleep... 109 | 110 | gpio@4000a030 interrupt (8): rising edge 111 | Awake from EM2 sleep... 112 | gpio@4000a030 interrupt (9): falling edge 113 | gpio@4000a030 interrupt (10): falling edge (bounce detected) 114 | ep... 115 | 116 | gpio@4000a030 interrupt (11): rising edge 117 | Awake from EM2 sleep... 118 | Entering EM2 sleep... 119 | 120 | gpio@4000a030 interrupt (12): falling edge 121 | Awake from EM2 sleep... 122 | Entering EM2 sleep... 123 | -------------------------------------------------------------------------------- /samples/wake_sleep/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | #### Example output: 4 | 5 | I: Waiting 6 secs for modem to boot... 6 | I: Max allowed PM mode: dh0 7 | I: Sleep mode: enable 8 | I: HIFC mode: A 9 | I: Setting APN to CATM.T-MOBILE.COM and IPV4 10 | I: Setting bands to 2, 4, 12 11 | I: Setting boot delay to 0 12 | I: rsi_wlan_get after rsi_wireless_init returned 0, mac: 90:35:ea:3d:0e:c8 13 | I: RS9116W WiFi driver initialized 14 | I: lps22hh@5c: int on gpio@4000a0f0.15 15 | *** Booting Zephyr OS build 0da53d0c285c *** 16 | I: Setting up GPIO and ISR structures 17 | I: Set up button at gpio@4000a030 pin 13 18 | 19 | 20 | 21 | Welcome to T-Mobile DevEdge! 22 | 23 | This application aims to demonstrate the Gecko's Energy Mode 2 (EM2) (Deep 24 | Sleep Mode) and Wake capabilities in conjunction with the SW0 interrupt pin, 25 | which is connected to the user pushbutton switch of the DevEdge module. 26 | 27 | Press and release the user pushbutton to advance from one power management 28 | mode to the next. 29 | 30 | pm_thread(): awake 31 | Turn on white LED 32 | device_action[0].value: 0, device_action[0].name: PM_DEVICE_ACTION_SUSPEND 33 | I: Suspend successful 34 | I: pm_thread(): murata_1sc call status: 0 (Success), device state: suspended 35 | I: pm_thread(): rs9116w@0 call status: 0 (Success), device state: suspended 36 | E: Cannot switch PWM 0x189f0 power state 37 | E: Cannot switch PWM 0x189f0 power state 38 | E: Cannot switch PWM 0x189f0 power state 39 | E: Cannot switch PWM 0x189f0 power state 40 | I: pm_thread(): pwmleds call status: 0 (Success), device state: suspended 41 | I: pm_thread(): sonycxd5605@24 call status: 0 (Success), device state: suspended 42 | I: pm_thread(): tsl2540@39 call status: 0 (Success), device state: suspended 43 | Turn off LEDs 44 | pm_thread(): asleep 45 | 46 | pm_thread(): awake 47 | Turn on blue LED 48 | device_action[1].value: 2, device_action[1].name: PM_DEVICE_ACTION_TURN_OFF 49 | W: pm_thread(): murata_1sc call status: -134 (Unsupported value), device state: off 50 | I: pm_thread(): rs9116w@0 call status: 0 (Success), device state: off 51 | E: Cannot switch PWM 0x189f0 power state 52 | E: Cannot switch PWM 0x189f0 power state 53 | E: Cannot switch PWM 0x189f0 power state 54 | E: Cannot switch PWM 0x189f0 power state 55 | I: pm_thread(): pwmleds call status: 0 (Success), device state: off 56 | I: pm_thread(): sonycxd5605@24 call status: 0 (Success), device state: off 57 | W: pm_thread(): tsl2540@39 call status: -134 (Unsupported value), device state: off 58 | Turn off LEDs 59 | pm_thread(): asleep 60 | 61 | pm_thread(): awake 62 | Turn on green LED 63 | device_action[2].value: 3, device_action[2].name: PM_DEVICE_ACTION_TURN_ON 64 | W: pm_thread(): murata_1sc call status: -134 (Unsupported value), device state: suspended 65 | W: pm_thread(): rs9116w@0 call status: -1 (Not owner), device state: off 66 | E: Cannot switch PWM 0x189f0 power state 67 | E: Cannot switch PWM 0x189f0 power state 68 | E: Cannot switch PWM 0x189f0 power state 69 | E: Cannot switch PWM 0x189f0 power state 70 | I: pm_thread(): pwmleds call status: 0 (Success), device state: suspended 71 | I: pm_thread(): sonycxd5605@24 call status: 0 (Success), device state: suspended 72 | W: pm_thread(): tsl2540@39 call status: -134 (Unsupported value), device state: suspended 73 | Turn off LEDs 74 | pm_thread(): asleep 75 | 76 | pm_thread(): awake 77 | Turn on red LED 78 | device_action[3].value: 1, device_action[3].name: PM_DEVICE_ACTION_RESUME 79 | I: Resume successful 80 | I: pm_thread(): murata_1sc call status: 0 (Success), device state: active 81 | W: pm_thread(): rs9116w@0 call status: -1 (Not owner), device state: off 82 | E: Cannot switch PWM 0x189f0 power state 83 | E: Cannot switch PWM 0x189f0 power state 84 | E: Cannot switch PWM 0x189f0 power state 85 | E: Cannot switch PWM 0x189f0 power state 86 | I: pm_thread(): pwmleds call status: 0 (Success), device state: active 87 | I: pm_thread(): sonycxd5605@24 call status: 0 (Success), device state: active 88 | I: pm_thread(): tsl2540@39 call status: 0 (Success), device state: active 89 | Turn off LEDs 90 | pm_thread(): asleep 91 | 92 | -------------------------------------------------------------------------------- /samples/bluetooth/peripheral_sc_only/src/main.c: -------------------------------------------------------------------------------- 1 | /* main.c - Application main entry point */ 2 | 3 | /* 4 | * Copyright (c) 2015-2016 Intel Corporation 5 | * Copyright (c) 2021 T-Mobile USA, Inc. 6 | * 7 | * SPDX-License-Identifier: Apache-2.0 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | static const struct bt_data ad[] = { 25 | BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), 26 | }; 27 | 28 | static void connected(struct bt_conn *conn, uint8_t err) 29 | { 30 | char addr[BT_ADDR_LE_STR_LEN]; 31 | 32 | bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); 33 | 34 | if (err) { 35 | printk("Failed to connect to %s (%u)\n", addr, err); 36 | return; 37 | } 38 | 39 | printk("Connected %s\n", addr); 40 | 41 | if (bt_conn_set_security(conn, BT_SECURITY_L4)) { 42 | printk("Failed to set security\n"); 43 | } 44 | } 45 | 46 | static void disconnected(struct bt_conn *conn, uint8_t reason) 47 | { 48 | char addr[BT_ADDR_LE_STR_LEN]; 49 | 50 | bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); 51 | 52 | printk("Disconnected from %s (reason 0x%02x)\n", addr, reason); 53 | } 54 | 55 | static void identity_resolved(struct bt_conn *conn, const bt_addr_le_t *rpa, 56 | const bt_addr_le_t *identity) 57 | { 58 | char addr_identity[BT_ADDR_LE_STR_LEN]; 59 | char addr_rpa[BT_ADDR_LE_STR_LEN]; 60 | 61 | bt_addr_le_to_str(identity, addr_identity, sizeof(addr_identity)); 62 | bt_addr_le_to_str(rpa, addr_rpa, sizeof(addr_rpa)); 63 | 64 | printk("Identity resolved %s -> %s\n", addr_rpa, addr_identity); 65 | } 66 | 67 | static void security_changed(struct bt_conn *conn, bt_security_t level, 68 | enum bt_security_err err) 69 | { 70 | char addr[BT_ADDR_LE_STR_LEN]; 71 | 72 | bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); 73 | 74 | if (!err) { 75 | printk("Security changed: %s level %u\n", addr, level); 76 | } else { 77 | printk("Security failed: %s level %u err %d\n", addr, level, 78 | err); 79 | } 80 | } 81 | 82 | static struct bt_conn_cb conn_callbacks = { 83 | .connected = connected, 84 | .disconnected = disconnected, 85 | .identity_resolved = identity_resolved, 86 | .security_changed = security_changed, 87 | }; 88 | 89 | static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey) 90 | { 91 | char addr[BT_ADDR_LE_STR_LEN]; 92 | 93 | bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); 94 | 95 | printk("Passkey for %s: %06u\n", addr, passkey); 96 | } 97 | 98 | static void auth_cancel(struct bt_conn *conn) 99 | { 100 | char addr[BT_ADDR_LE_STR_LEN]; 101 | 102 | bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); 103 | 104 | printk("Pairing cancelled: %s\n", addr); 105 | } 106 | 107 | static void pairing_complete(struct bt_conn *conn, bool bonded) 108 | { 109 | printk("Pairing Complete\n"); 110 | } 111 | 112 | static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason) 113 | { 114 | printk("Pairing Failed (%d). Disconnecting.\n", reason); 115 | bt_conn_disconnect(conn, BT_HCI_ERR_AUTH_FAIL); 116 | } 117 | 118 | static struct bt_conn_auth_cb auth_cb_display = { 119 | .passkey_display = auth_passkey_display, 120 | .passkey_entry = NULL, 121 | .cancel = auth_cancel, 122 | }; 123 | 124 | static struct bt_conn_auth_info_cb auth_info_cb = { 125 | .pairing_complete = pairing_complete, 126 | .pairing_failed = pairing_failed, 127 | }; 128 | 129 | void main(void) 130 | { 131 | int err; 132 | 133 | err = bt_enable(NULL); 134 | if (err) { 135 | printk("Bluetooth init failed (err %d)\n", err); 136 | return; 137 | } 138 | 139 | printk("Bluetooth initialized\n"); 140 | 141 | 142 | bt_conn_auth_cb_register(&auth_cb_display); 143 | bt_conn_auth_info_cb_register(&auth_info_cb); 144 | bt_conn_cb_register(&conn_callbacks); 145 | 146 | 147 | err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0); 148 | if (err) { 149 | printk("Advertising failed to start (err %d)\n", err); 150 | return; 151 | } 152 | 153 | printk("Advertising successfully started\n"); 154 | } 155 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_adc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * # License 3 | * Copyright 2020 Silicon Laboratories Inc. www.silabs.com 4 | * Copyright (c) 2022 T-Mobile USA, Inc. 5 | * 6 | * SPDX-License-Identifier: Apache-2.0 7 | * 8 | */ 9 | #include 10 | #include 11 | #include 12 | #include "em_device.h" 13 | #include "em_chip.h" 14 | #include "em_cmu.h" 15 | #include "em_adc.h" 16 | #include "tmo_battery_ctrl.h" 17 | #include "tmo_adc.h" 18 | #include "board.h" 19 | #include 20 | LOG_MODULE_REGISTER(tmo_adc, LOG_LEVEL_INF); 21 | 22 | #define adcFreq 16000000 23 | K_SEM_DEFINE(adc_sem, 0, 1); 24 | 25 | static ADC_InitSingle_TypeDef initSingle_bv = ADC_INITSINGLE_DEFAULT; 26 | static ADC_InitSingle_TypeDef initSingle_hwid = ADC_INITSINGLE_DEFAULT; 27 | 28 | #ifdef HWID_APORT 29 | /** 30 | * @brief Set the VBAT_SNS_EN Pin High to enable ADC readings 31 | * 32 | */ 33 | static void set_vbat_sens_en(bool enable) 34 | { 35 | // pin = 0 36 | // mode = gpioModeEnabled; 37 | // out is 1 otherwise it will be input 38 | // Set PK0/PinE2 as output so it can be 39 | #ifdef VBAT_EN_PORT 40 | GPIO_PinModeSet(VBAT_EN_PORT, VBAT_EN_PIN, gpioModePushPull, enable); 41 | #endif /* VBAT_EN_PORT */ 42 | } 43 | #endif /* HWID_APORT */ 44 | 45 | /** 46 | * @brief Initialize the Gecko ADC 47 | * 48 | */ 49 | void initADC(void) 50 | { 51 | 52 | // Enable ADC0 clock 53 | CMU_ClockEnable(cmuClock_ADC0, true); 54 | 55 | // Declare init structs 56 | ADC_Init_TypeDef init = ADC_INIT_DEFAULT; 57 | 58 | // Modify init structs and initialize 59 | init.prescale = ADC_PrescaleCalc(adcFreq, 0); // Init to max ADC clock for Series 1 60 | 61 | initSingle_bv.diff = false; // single ended 62 | initSingle_bv.reference = adcRef2V5; // internal 2.5V reference 63 | initSingle_bv.resolution = adcRes12Bit; // 12-bit resolution 64 | initSingle_bv.acqTime = adcAcqTime32; // set acquisition time to meet minimum requirement 65 | 66 | memcpy(&initSingle_hwid, &initSingle_bv, sizeof(initSingle_hwid)); 67 | 68 | // Select ADC input. See README for corresponding EXP header pin. 69 | // initSingle.posSel = adcPosSelAPORT4XCH10; 70 | #ifdef HWID_APORT 71 | initSingle_hwid.posSel = HWID_APORT; 72 | #endif /* HWID_APORT */ 73 | #ifdef VBAT_APORT 74 | initSingle_bv.posSel = VBAT_APORT; 75 | #endif /* VBAT_APORT */ 76 | 77 | init.timebase = ADC_TimebaseCalc(0); 78 | 79 | ADC_Init(ADC0, &init); 80 | 81 | int hwid = read_hwid(); 82 | 83 | LOG_INF("HWID = %d\n", hwid); 84 | } 85 | 86 | /* 87 | * @brief This function writes the amount of battery charge remaining 88 | * (to the nearest 1%) in bv. 89 | * It returns true if successful, or false if there is an issue 90 | */ 91 | bool millivolts_to_percent(uint32_t millivolts, uint8_t *percent) { 92 | float curBv = get_remaining_capacity((float) millivolts / 1000); 93 | *percent = (uint8_t) (curBv + 0.5); 94 | return true; 95 | } 96 | 97 | /** 98 | * @brief Main function 99 | */ 100 | int read_battery_voltage(void) 101 | { 102 | #ifdef VBAT_APORT 103 | uint32_t sample; 104 | uint32_t millivolts; 105 | float millivolts_f; 106 | // Start ADC conversion 107 | k_sem_take(&adc_sem, K_MSEC(500)); 108 | 109 | set_vbat_sens_en(true); 110 | k_msleep(100); 111 | 112 | ADC_InitSingle(ADC0, &initSingle_bv); 113 | ADC_Start(ADC0, adcStartSingle); 114 | 115 | // Wait for conversion to be complete 116 | while(!(ADC0->STATUS & _ADC_STATUS_SINGLEDV_MASK)); 117 | 118 | // Get ADC result 119 | sample = ADC_DataSingleGet(ADC0); 120 | 121 | set_vbat_sens_en(false); 122 | 123 | k_sem_give(&adc_sem); 124 | 125 | // Calculate input voltage in mV 126 | millivolts_f = (sample * 2500.0) / 4096.0; 127 | 128 | // On the 2nd generation dev edge, voltage on PA2 is 129 | // one third the actual battery voltage 130 | millivolts = (uint32_t) (3.0 * millivolts_f + 0.5); 131 | 132 | return (millivolts); 133 | #else 134 | return 0; 135 | #endif /* VBAT_APORT */ 136 | } 137 | 138 | /** 139 | * @brief Read HWID divider voltage 140 | * 141 | * @return int Millivolts 142 | */ 143 | int read_hwid(void) 144 | { 145 | #ifdef HWID_APORT 146 | uint32_t sample; 147 | uint32_t millivolts; 148 | float millivolts_f; 149 | // Start ADC conversion 150 | k_sem_take(&adc_sem, K_MSEC(500)); 151 | 152 | set_vbat_sens_en(true); 153 | k_msleep(100); 154 | 155 | ADC_InitSingle(ADC0, &initSingle_hwid); 156 | ADC_Start(ADC0, adcStartSingle); 157 | 158 | // Wait for conversion to be complete 159 | while(!(ADC0->STATUS & _ADC_STATUS_SINGLEDV_MASK)); 160 | 161 | // Get ADC result 162 | sample = ADC_DataSingleGet(ADC0); 163 | 164 | set_vbat_sens_en(false); 165 | 166 | k_sem_give(&adc_sem); 167 | 168 | // Calculate input voltage in mV 169 | millivolts_f = (sample * 2500.0) / 4096.0; 170 | 171 | millivolts = (uint32_t) millivolts_f; 172 | 173 | return (millivolts); 174 | #else 175 | return 0; 176 | #endif /* HWID_APORT */ 177 | } 178 | -------------------------------------------------------------------------------- /samples/wake_sleep/prj.conf: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | # UART support 6 | # CONFIG_SERIAL=y 7 | # CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=1024 8 | 9 | # CONFIG_RING_BUFFER=y 10 | # CONFIG_SOC_FLASH_GECKO=y 11 | 12 | # CONFIG_ADC=y 13 | # CONFIG_ADC_SHELL=n 14 | # Enable support for the flash hardware. 15 | # CONFIG_FLASH=y 16 | # CONFIG_I2C=y 17 | 18 | # CONFIG_SPI=y 19 | # CONFIG_SPI_NOR=y 20 | # CONFIG_SPI_GECKO=y 21 | 22 | # Murata 1SC modem support 23 | CONFIG_MODEM=y 24 | # CONFIG_MODEM_SHELL=y 25 | CONFIG_MODEM_MURATA_1SC=y 26 | CONFIG_MODEM_MURATA_1SC_APN="CATM.T-MOBILE.COM" 27 | 28 | # Generic networking options 29 | CONFIG_NETWORKING=y 30 | # CONFIG_NET_SHELL=n 31 | CONFIG_NET_NATIVE=n 32 | CONFIG_NET_OFFLOAD=y 33 | CONFIG_NET_IPV6_DAD=n 34 | CONFIG_NET_UDP=n 35 | CONFIG_NET_TCP=n 36 | CONFIG_NET_IPV6=n 37 | CONFIG_NET_IPV4=y 38 | CONFIG_DNS_RESOLVER=n 39 | CONFIG_POSIX_MAX_FDS=15 40 | CONFIG_HTTP_CLIENT=n 41 | 42 | # Network management events 43 | # CONFIG_NET_CONNECTION_MANAGER=y 44 | # CONFIG_NET_MGMT=y 45 | # CONFIG_NET_MGMT_EVENT=y 46 | 47 | # Debugging 48 | # CONFIG_DEBUG_OPTIMIZATIONS=y 49 | 50 | # Logging 51 | CONFIG_LOG=y 52 | CONFIG_LOG_MODE_MINIMAL=y 53 | # CONFIG_LOG_FUNC_NAME_PREFIX_ERR=y 54 | # CONFIG_LOG_FUNC_NAME_PREFIX_WRN=y 55 | # CONFIG_LOG_FUNC_NAME_PREFIX_INF=y 56 | # CONFIG_LOG_FUNC_NAME_PREFIX_DBG=y 57 | # CONFIG_LOG_BACKEND_SHOW_COLOR=y 58 | # CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP=y 59 | # CONFIG_LOG_TIMESTAMP_64BIT=y 60 | # CONFIG_NET_LOG=y 61 | 62 | # Required to disable default behavior of deep sleep on timeout 63 | # CONFIG_CONSOLE_SUBSYS=y 64 | # CONFIG_CONSOLE_GETLINE=y 65 | 66 | # Network buffers 67 | # CONFIG_NET_PKT_RX_COUNT=1 68 | # CONFIG_NET_PKT_TX_COUNT=1 69 | # CONFIG_NET_BUF_RX_COUNT=1 70 | # CONFIG_NET_BUF_TX_COUNT=1 71 | # CONFIG_NET_CONTEXT_NET_PKT_POOL=y 72 | # CONFIG_NET_BUF_DATA_SIZE=60 73 | 74 | # RS9116 75 | CONFIG_WIFI=y 76 | CONFIG_WIFI_RS9116W=y 77 | # CONFIG_GPIO=y 78 | 79 | #CONFIG_TEST_RANDOM_GENERATOR=y 80 | 81 | # CONFIG_INIT_STACKS=y 82 | 83 | # CONFIG_MBEDTLS_DTLS=y 84 | 85 | # CONFIG_NET_SOCKETS=y 86 | # CONFIG_NET_SOCKETS_OFFLOAD=y 87 | # CONFIG_NET_SOCKETS_POSIX_NAMES=y 88 | # CONFIG_NET_SOCKETS_POLL_MAX=4 89 | # CONFIG_NET_SOCKETS_SOCKOPT_TLS=y 90 | # CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=4 91 | # CONFIG_NET_SOCKETS_ENABLE_DTLS=y 92 | 93 | 94 | # Bluetooth / BLE 95 | # CONFIG_BT=y 96 | # CONFIG_BT_CUSTOM=y 97 | # CONFIG_BT_RS9116W=y 98 | # CONFIG_BT_PERIPHERAL=y 99 | # CONFIG_BT_SMP=y 100 | # CONFIG_BT_MAX_PAIRED=2 101 | # CONFIG_BT_DEBUG=n 102 | 103 | # Sensors 104 | # CONFIG_SENSOR=y 105 | # CONFIG_SENSOR_SHELL=y 106 | 107 | # Stack sizes 108 | # CONFIG_MAIN_STACK_SIZE=4096 109 | # CONFIG_SHELL_STACK_SIZE=4096 110 | 111 | # MBED TLS configuration 112 | # CONFIG_MBEDTLS=y 113 | # CONFIG_MBEDTLS_BUILTIN=y 114 | 115 | # CONFIG_NEWLIB_LIBC=y 116 | # CONFIG_MINIMAL_LIBC_MALLOC=y 117 | # CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=2048 118 | 119 | # Set number IPv4 network interfaces 120 | # CONFIG_NET_IF_MAX_IPV4_COUNT=2 121 | # CONFIG_NET_IF_MAX_IPV6_COUNT=2 122 | 123 | #CONFIG_FS_LOG_LEVEL_DBG=y 124 | 125 | # CONFIG_HEAP_MEM_POOL_SIZE=16384 126 | 127 | # CONFIG_SHELL=y 128 | # CONFIG_SHELL_LOG_LEVEL_INF=y 129 | # CONFIG_SHELL_CMD_BUFF_SIZE=2100 130 | 131 | # CONFIG_FILE_SYSTEM=y 132 | # CONFIG_FILE_SYSTEM_SHELL=y 133 | # CONFIG_FILE_SYSTEM_LITTLEFS=y 134 | 135 | # CONFIG_FLASH_MAP=y 136 | # CONFIG_FLASH_PAGE_LAYOUT=y 137 | 138 | # CONFIG_RS9116W_TLS_OFFLOAD=y 139 | 140 | # CONFIG_TMO_SHELL_SSID="" 141 | # CONFIG_TMO_SHELL_PSK="" 142 | 143 | # CONFIG_RS9116_DNS_SERVER_IP_ADDRESSES=y 144 | # CONFIG_RS9116_IPV4_DNS_SERVER1="8.8.8.8" 145 | # CONFIG_RS9116_IPV6_DNS_SERVER1="2001:4860:4860::8888" 146 | 147 | # CONFIG_MODEM_MURATA_1SC_SOCKET_COUNT=4 148 | # CONFIG_WISECONNECT_SOCKETS_COUNT=6 149 | 150 | # CONFIG_SHELL_GETOPT=y 151 | # CONFIG_PING=y 152 | 153 | # CONFIG_MODEM_SMS_IN_MSG_MAX_LEN=200 154 | # CONFIG_MODEM_SMS_OUT_MSG_MAX_LEN=200 155 | 156 | #Ekermit 157 | # CONFIG_SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL=y 158 | # CONFIG_LOG_BACKEND_RTT=n 159 | # CONFIG_TMO_SHELL_BUILD_EK=y 160 | 161 | #Power Managment 162 | CONFIG_PM=y 163 | CONFIG_PM_DEVICE=y 164 | 165 | # CONFIG_BT_DEVICE_NAME_DYNAMIC=y 166 | # CONFIG_LOG_PRINTK=n 167 | 168 | # CONFIG_THREAD_NAME=y 169 | # CONFIG_STATS=y 170 | # CONFIG_PM_STATS=y 171 | # CONFIG_IDLE_STACK_SIZE=640 172 | # CONFIG_ZTEST_NEW_API=y 173 | 174 | # The following is for the accelorometer 175 | # CONFIG_STDOUT_CONSOLE=y 176 | # CONFIG_I2C=y 177 | # CONFIG_SENSOR=y 178 | # CONFIG_LIS2DW12=y 179 | # CONFIG_LIS2DW12_TRIGGER_GLOBAL_THREAD=y 180 | # CONFIG_LIS2DW12_TAP=y 181 | # CONFIG_LIS2DW12_THRESHOLD=y 182 | # CONFIG_CBPRINTF_FP_SUPPORT=y 183 | # CONFIG_ASSERT=y 184 | 185 | # CONFIG_LED_PWM=y 186 | # CONFIG_PWM=y 187 | # # CONFIG_PWM_SHELL=y 188 | # CONFIG_PWM_GECKO=y 189 | CONFIG_GPIO=y 190 | 191 | # Stack size 192 | CONFIG_MAIN_STACK_SIZE=4096 193 | # CONFIG_USERSPACE=n 194 | 195 | # CONFIG_WAKE_TIMER_DURATION=0 196 | -------------------------------------------------------------------------------- /samples/wake_sleep/src/strerror_table.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | /* 8 | * TODO: Determine the method or configuration to remove this header file and 9 | * reference the generated version, which resides in the following relative path: 10 | * .../wake_sleep/zephyr/include/generated/libc/minimal/strerror_table.h. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #define sys_nerr 141 20 | static const char *const sys_errlist[sys_nerr] = { 21 | [0] = "Success", 22 | [EPERM] = "Not owner", 23 | [ENOENT] = "No such file or directory", 24 | [ESRCH] = "No such context", 25 | [EINTR] = "Interrupted system call", 26 | [EIO] = "I/O error", 27 | [ENXIO] = "No such device or address", 28 | [ENOEXEC] = "Exec format error", 29 | [EBADF] = "Bad file number", 30 | [ECHILD] = "No children", 31 | [EAGAIN] = "No more contexts", 32 | [ENOMEM] = "Not enough core", 33 | [EACCES] = "Permission denied", 34 | [EFAULT] = "Bad address", 35 | [ENOTBLK] = "Block device required", 36 | [EBUSY] = "Mount device busy", 37 | [EEXIST] = "File exists", 38 | [EXDEV] = "Cross-device link", 39 | [ENODEV] = "No such device", 40 | [ENOTDIR] = "Not a directory", 41 | [EISDIR] = "Is a directory", 42 | [EINVAL] = "Invalid argument", 43 | [ENFILE] = "File table overflow", 44 | [EMFILE] = "Too many open files", 45 | [ENOTTY] = "Not a typewriter", 46 | [ETXTBSY] = "Text file busy", 47 | [EFBIG] = "File too large", 48 | [ENOSPC] = "No space left on device", 49 | [ESPIPE] = "Illegal seek", 50 | [EROFS] = "Read-only file system", 51 | [EMLINK] = "Too many links", 52 | [EPIPE] = "Broken pipe", 53 | [EDOM] = "Argument too large", 54 | [ERANGE] = "Result too large", 55 | [ENOMSG] = "Unexpected message type", 56 | [EDEADLK] = "Resource deadlock avoided", 57 | [ENOLCK] = "No locks available", 58 | [ENOSTR] = "STREAMS device required", 59 | [ENODATA] = "Missing expected message data", 60 | [ETIME] = "STREAMS timeout occurred", 61 | [ENOSR] = "Insufficient memory", 62 | [EPROTO] = "Generic STREAMS error", 63 | [EBADMSG] = "Invalid STREAMS message", 64 | [ENOSYS] = "Function not implemented", 65 | [ENOTEMPTY] = "Directory not empty", 66 | [ENAMETOOLONG] = "File name too long", 67 | [ELOOP] = "Too many levels of symbolic links", 68 | [EOPNOTSUPP] = "Operation not supported on socket", 69 | [EPFNOSUPPORT] = "Protocol family not supported", 70 | [ECONNRESET] = "Connection reset by peer", 71 | [ENOBUFS] = "No buffer space available", 72 | [EAFNOSUPPORT] = "Addr family not supported", 73 | [EPROTOTYPE] = "Protocol wrong type for socket", 74 | [ENOTSOCK] = "Socket operation on non-socket", 75 | [ENOPROTOOPT] = "Protocol not available", 76 | [ESHUTDOWN] = "Can't send after socket shutdown", 77 | [ECONNREFUSED] = "Connection refused", 78 | [EADDRINUSE] = "Address already in use", 79 | [ECONNABORTED] = "Software caused connection abort", 80 | [ENETUNREACH] = "Network is unreachable", 81 | [ENETDOWN] = "Network is down", 82 | [ETIMEDOUT] = "Connection timed out", 83 | [EHOSTDOWN] = "Host is down", 84 | [EHOSTUNREACH] = "No route to host", 85 | [EINPROGRESS] = "Operation now in progress", 86 | [EALREADY] = "Operation already in progress", 87 | [EDESTADDRREQ] = "Destination address required", 88 | [EMSGSIZE] = "Message size", 89 | [EPROTONOSUPPORT] = "Protocol not supported", 90 | [ESOCKTNOSUPPORT] = "Socket type not supported", 91 | [EADDRNOTAVAIL] = "Can't assign requested address", 92 | [ENETRESET] = "Network dropped connection on reset", 93 | [EISCONN] = "Socket is already connected", 94 | [ENOTCONN] = "Socket is not connected", 95 | [ETOOMANYREFS] = "Too many references: can't splice", 96 | [ENOTSUP] = "Unsupported value", 97 | [EILSEQ] = "Illegal byte sequence", 98 | [EOVERFLOW] = "Value overflow", 99 | [ECANCELED] = "Operation canceled", 100 | }; 101 | static const uint8_t sys_errlen[sys_nerr] = { 102 | [0] = 8, 103 | [EPERM] = 10, 104 | [ENOENT] = 26, 105 | [ESRCH] = 16, 106 | [EINTR] = 24, 107 | [EIO] = 10, 108 | [ENXIO] = 26, 109 | [ENOEXEC] = 18, 110 | [EBADF] = 16, 111 | [ECHILD] = 12, 112 | [EAGAIN] = 17, 113 | [ENOMEM] = 16, 114 | [EACCES] = 18, 115 | [EFAULT] = 12, 116 | [ENOTBLK] = 22, 117 | [EBUSY] = 18, 118 | [EEXIST] = 12, 119 | [EXDEV] = 18, 120 | [ENODEV] = 15, 121 | [ENOTDIR] = 16, 122 | [EISDIR] = 15, 123 | [EINVAL] = 17, 124 | [ENFILE] = 20, 125 | [EMFILE] = 20, 126 | [ENOTTY] = 17, 127 | [ETXTBSY] = 15, 128 | [EFBIG] = 15, 129 | [ENOSPC] = 24, 130 | [ESPIPE] = 13, 131 | [EROFS] = 22, 132 | [EMLINK] = 15, 133 | [EPIPE] = 12, 134 | [EDOM] = 19, 135 | [ERANGE] = 17, 136 | [ENOMSG] = 24, 137 | [EDEADLK] = 26, 138 | [ENOLCK] = 19, 139 | [ENOSTR] = 24, 140 | [ENODATA] = 30, 141 | [ETIME] = 25, 142 | [ENOSR] = 20, 143 | [EPROTO] = 22, 144 | [EBADMSG] = 24, 145 | [ENOSYS] = 25, 146 | [ENOTEMPTY] = 20, 147 | [ENAMETOOLONG] = 19, 148 | [ELOOP] = 34, 149 | [EOPNOTSUPP] = 34, 150 | [EPFNOSUPPORT] = 30, 151 | [ECONNRESET] = 25, 152 | [ENOBUFS] = 26, 153 | [EAFNOSUPPORT] = 26, 154 | [EPROTOTYPE] = 31, 155 | [ENOTSOCK] = 31, 156 | [ENOPROTOOPT] = 23, 157 | [ESHUTDOWN] = 33, 158 | [ECONNREFUSED] = 19, 159 | [EADDRINUSE] = 23, 160 | [ECONNABORTED] = 33, 161 | [ENETUNREACH] = 23, 162 | [ENETDOWN] = 16, 163 | [ETIMEDOUT] = 21, 164 | [EHOSTDOWN] = 13, 165 | [EHOSTUNREACH] = 17, 166 | [EINPROGRESS] = 26, 167 | [EALREADY] = 30, 168 | [EDESTADDRREQ] = 29, 169 | [EMSGSIZE] = 13, 170 | [EPROTONOSUPPORT] = 23, 171 | [ESOCKTNOSUPPORT] = 26, 172 | [EADDRNOTAVAIL] = 31, 173 | [ENETRESET] = 36, 174 | [EISCONN] = 28, 175 | [ENOTCONN] = 24, 176 | [ETOOMANYREFS] = 34, 177 | [ENOTSUP] = 18, 178 | [EILSEQ] = 22, 179 | [EOVERFLOW] = 15, 180 | [ECANCELED] = 19, 181 | }; 182 | -------------------------------------------------------------------------------- /samples/tmo_shell/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 T-Mobile USA, Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | cmake_minimum_required(VERSION 3.20.0) 6 | 7 | set(ZEPHYR_EXTRA_MODULES "$ENV{ZEPHYR_EXTRA_MODULES};${CMAKE_SOURCE_DIR}/../../") 8 | 9 | find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) 10 | project(tmo_shell) 11 | 12 | zephyr_include_directories(${BOARD_DIR}) 13 | 14 | target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/ PRIVATE ${ZEPHYR_BASE}/drivers/modem/) 15 | target_sources(app PRIVATE src/tmo_shell.c) 16 | target_sources(app PRIVATE src/tmo_buzzer.c) 17 | target_sources(app PRIVATE src/tmo_shell_main.c) 18 | target_sources(app PRIVATE src/tmo_web_demo.c) 19 | target_sources(app PRIVATE src/tmo_http_request.c) 20 | target_sources(app PRIVATE src/tmo_dfu_download.c) 21 | target_sources(app PRIVATE src/tmo_file.c) 22 | target_sources(app PRIVATE src/tmo_modem_edrx.c) 23 | target_sources(app PRIVATE src/tmo_modem_psm.c) 24 | target_sources(app PRIVATE src/buzzer_test.c) 25 | target_sources(app PRIVATE src/led_test.c) 26 | target_sources(app PRIVATE src/misc_test.c) 27 | target_sources(app PRIVATE src/tmo_file.c) 28 | target_sources(app PRIVATE src/tmo_adc.c) 29 | target_sources(app PRIVATE src/tmo_bq24250.c) 30 | target_sources(app PRIVATE src/tmo_battery_ctrl.c) 31 | target_sources(app PRIVATE src/tmo_sntp.c) 32 | target_sources(app PRIVATE src/tmo_modem.c) 33 | target_sources(app PRIVATE src/tmo_tone_player.c) 34 | target_sources_ifdef(CONFIG_WIFI app PRIVATE src/tmo_wifi.c) 35 | target_sources_ifdef(CONFIG_BT_SMP app PRIVATE src/tmo_smp.c) 36 | target_sources_ifdef(CONFIG_BT_PERIPHERAL app PRIVATE src/tmo_ble_demo.c) 37 | target_sources_ifdef(CONFIG_BT_PERIPHERAL app PRIVATE src/tmo_gnss.c) 38 | target_sources_ifdef(CONFIG_NET_SOCKETS_SOCKOPT_TLS app PRIVATE src/tmo_certs.c) 39 | target_sources_ifdef(CONFIG_PING app PRIVATE src/tmo_ping.c) 40 | target_sources_ifdef(CONFIG_TMO_HTTP_MOCK_SOCKET app PRIVATE src/tmo_http_mock_socket.c) 41 | target_sources_ifdef(CONFIG_PM_DEVICE app PRIVATE src/tmo_pm.c) 42 | target_sources_ifdef(CONFIG_PM app PRIVATE src/tmo_pm_sys.c) 43 | target_sources_ifdef(CONFIG_FUEL_GAUGE app PRIVATE src/tmo_fuel_gauge.c) 44 | 45 | set(gen_dir ${ZEPHYR_BINARY_DIR}/include/generated/) 46 | 47 | generate_inc_file_for_target( 48 | app 49 | src/servercert.der 50 | ${gen_dir}/servercert.der.inc 51 | ) 52 | 53 | generate_inc_file_for_target( 54 | app 55 | src/devcert.der 56 | ${gen_dir}/devcert.der.inc 57 | ) 58 | 59 | generate_inc_file_for_target( 60 | app 61 | src/devkey.der 62 | ${gen_dir}/devkey.der.inc 63 | ) 64 | 65 | generate_inc_file_for_target( 66 | app 67 | src/digicert_ca.der 68 | ${gen_dir}/digicert_ca.der.inc 69 | ) 70 | 71 | generate_inc_file_for_target( 72 | app 73 | src/lets-encrypt-r3.der 74 | ${gen_dir}/lets-encrypt-r3.der.inc 75 | ) 76 | 77 | generate_inc_file_for_target( 78 | app 79 | src/entrust_g2_ca.der 80 | ${gen_dir}/entrust_g2_ca.der.inc 81 | ) 82 | 83 | if(DEFINED CONFIG_TMO_SHELL_BUILD_EK) 84 | add_subdirectory(src/ek18) 85 | endif() 86 | 87 | 88 | # zephyr: base upstream version tag used for tmo-main 89 | if(DEFINED ENV{ZEPHYR_BASE_TAG}) 90 | add_compile_definitions(VERSION_ZEPHYR_BASE_TAG="$ENV{ZEPHYR_BASE_TAG}") 91 | else() 92 | execute_process( 93 | COMMAND git log --grep "Merge branch 'main' into tmo-main" --max-count 1 --pretty=%H 94 | WORKING_DIRECTORY ${ZEPHYR_BASE} 95 | OUTPUT_VARIABLE ZEPHYR_BASE_TAG 96 | OUTPUT_STRIP_TRAILING_WHITESPACE 97 | ) 98 | if ("${ZEPHYR_BASE_TAG}" STREQUAL "") 99 | execute_process( 100 | COMMAND git log --grep "^Initial commit$" --max-count 1 --pretty=%H 101 | WORKING_DIRECTORY ${ZEPHYR_BASE} 102 | OUTPUT_VARIABLE ZEPHYR_BASE_TAG 103 | OUTPUT_STRIP_TRAILING_WHITESPACE 104 | ) 105 | endif() 106 | if ("${ZEPHYR_BASE_TAG}" STREQUAL "") 107 | set(ZEPHYR_BASE_TAG "UNKNOWN") 108 | endif() 109 | message("ZEPHYR_BASE_TAG: ${ZEPHYR_BASE_TAG}") 110 | add_compile_definitions(VERSION_ZEPHYR_BASE_TAG="${ZEPHYR_BASE_TAG}") 111 | endif() 112 | 113 | # tmo-rtos: current version tag in tmo-main 114 | if(DEFINED ENV{TMO_RTOS_TAG}) 115 | add_compile_definitions(VERSION_TMO_RTOS_TAG="$ENV{TMO_RTOS_TAG}") 116 | else() 117 | execute_process( 118 | COMMAND git describe --dirty --tags 119 | WORKING_DIRECTORY ${ZEPHYR_BASE} 120 | OUTPUT_VARIABLE RAW_TMO_RTOS_TAG 121 | OUTPUT_STRIP_TRAILING_WHITESPACE 122 | ) 123 | if ("${RAW_TMO_RTOS_TAG}" STREQUAL "") 124 | set(RAW_TMO_RTOS_TAG "UNKNOWN") 125 | endif() 126 | string(REPLACE "-dirty" "+" TMO_RTOS_TAG ${RAW_TMO_RTOS_TAG}) 127 | message("TMO_RTOS_TAG: ${TMO_RTOS_TAG}") 128 | add_compile_definitions(VERSION_TMO_RTOS_TAG="${TMO_RTOS_TAG}") 129 | endif() 130 | 131 | if(DEFINED ENV{SLOT}) 132 | add_compile_definitions(BOOT_SLOT="$ENV{SLOT}") 133 | endif() 134 | 135 | # tmo-sdk: current version tag in tmo-sdk 136 | if(DEFINED ENV{TMO_SDK_TAG}) 137 | add_compile_definitions(VERSION_TMO_SDK_TAG="$ENV{TMO_SDK_TAG}") 138 | else() 139 | execute_process( 140 | COMMAND git describe --abbrev=0 --tags 141 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 142 | OUTPUT_VARIABLE LATEST_TMO_TAG 143 | OUTPUT_STRIP_TRAILING_WHITESPACE 144 | ) 145 | 146 | execute_process( 147 | COMMAND git describe --dirty --always --all --long --match ${LATEST_TMO_TAG} 148 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 149 | OUTPUT_VARIABLE RAW_TMO_SDK_TAG 150 | OUTPUT_STRIP_TRAILING_WHITESPACE 151 | ) 152 | if ("${RAW_TMO_SDK_TAG}" STREQUAL "") 153 | set(RAW_TMO_SDK_TAG "UNKNOWN") 154 | endif() 155 | string(REPLACE "-dirty" "+" TMO_SDK_TAG ${RAW_TMO_SDK_TAG}) 156 | message("TMO_SDK_TAG: ${TMO_SDK_TAG}") 157 | add_compile_definitions(VERSION_TMO_SDK_TAG="${TMO_SDK_TAG}") 158 | endif() 159 | 160 | add_compile_definitions(VERSION_BOARD="${BOARD}") 161 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_sntp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "tmo_shell.h" 6 | #include "tmo_sntp.h" 7 | #include 8 | 9 | #include 10 | LOG_MODULE_REGISTER(sntp_client, LOG_LEVEL_DBG); 11 | 12 | #include 13 | #ifdef CONFIG_POSIX_API 14 | #include 15 | #endif 16 | 17 | #include 18 | #include 19 | 20 | static int resolve_dns(const char *host, char *ip_str, int *ipVer) 21 | { 22 | struct addrinfo hints; 23 | struct addrinfo *res; 24 | int errcode; 25 | char addrstr[100]; 26 | void *ptr = NULL; 27 | 28 | memset(&hints, 0, sizeof(hints)); 29 | hints.ai_family = PF_UNSPEC; 30 | hints.ai_socktype = SOCK_STREAM; 31 | hints.ai_flags |= AI_CANONNAME; 32 | 33 | errcode = getaddrinfo(host, NULL, &hints, &res); 34 | if (errcode != 0) { 35 | printf("[sntp] getaddrinfo\n"); 36 | return -1; 37 | } 38 | 39 | if (!res) { 40 | printf("[sntp] result is null\n"); 41 | return -1; 42 | } 43 | 44 | printf("[sntp] Host: %s\n", host); 45 | inet_ntop(res->ai_family, res->ai_addr->data, addrstr, 100); 46 | 47 | switch (res->ai_family) { 48 | case AF_INET: 49 | ptr = &((struct sockaddr_in *)res->ai_addr)->sin_addr; 50 | *ipVer = 4; 51 | break; 52 | case AF_INET6: 53 | ptr = &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr; 54 | *ipVer = 6; 55 | break; 56 | } 57 | 58 | inet_ntop(res->ai_family, ptr, addrstr, 100); 59 | memcpy(ip_str, addrstr, strlen(addrstr)); 60 | *ipVer = res->ai_family == PF_INET6 ? 6 : 4; 61 | printf("[sntp] IPv%d address: %s\n", *ipVer, ip_str); 62 | freeaddrinfo(res); 63 | return 0; 64 | } 65 | 66 | static void date_print(const struct shell *shell, struct tm *tm) 67 | { 68 | shell_print(shell, 69 | "%d-%02u-%02u " 70 | "%02u:%02u:%02u UTC", 71 | tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, 72 | tm->tm_sec); 73 | } 74 | 75 | static int time_date_set(const struct shell *shell, uint32_t epoch_sec) 76 | { 77 | struct tm tm; 78 | struct timespec tp = {0}; 79 | tp.tv_sec = (uint32_t)epoch_sec; 80 | 81 | gmtime_r(&tp.tv_sec, &tm); 82 | date_print(shell, &tm); 83 | 84 | #if defined(CONFIG_COUNTER_GECKO_RTCC) 85 | RTCC_CounterSet(tp.tv_sec); 86 | #endif 87 | 88 | if (clock_settime(CLOCK_REALTIME, &tp) == -1) { 89 | shell_error(shell, "system clock set failed"); 90 | return -EINVAL; 91 | } 92 | shell_print(shell, "successfully updated RTC"); 93 | 94 | return 0; 95 | } 96 | 97 | int isValidIpAddress(char *ipAddress) 98 | { 99 | struct sockaddr_in sa; 100 | return inet_pton(AF_INET, ipAddress, &(sa.sin_addr)); 101 | } 102 | 103 | int tmo_update_time(const struct shell *shell, char *host, int iface_idx) 104 | { 105 | #if defined(CONFIG_NET_IPV6) 106 | #ifdef DEBUG 107 | struct sockaddr_in6 addr6; 108 | #endif 109 | #endif 110 | char ip_addr[100]; 111 | int ipVer = 4; 112 | 113 | // Create and zero out the packet. All 48 bytes worth. 114 | ntp_packet packet = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 115 | memset(&packet, 0, sizeof(ntp_packet)); 116 | 117 | // Set the first byte's bits to 00,011,011 for li = 0, vn = 3, and mode = 3. The rest will 118 | // be left set to zero. 119 | *((char *)&packet + 0) = 0x1b; // Represents 27 in base 10 or 00011011 in base 2. 120 | 121 | struct net_if *iface = net_if_get_by_index(iface_idx); 122 | 123 | if (tmo_offload_init(iface_idx)) { 124 | return -1; 125 | } 126 | 127 | if (iface == NULL) { 128 | shell_error(shell, "Interface %d not found", iface_idx); 129 | return -EINVAL; 130 | } 131 | 132 | int sd = zsock_socket_ext(AF_INET, SOCK_DGRAM, IPPROTO_UDP, iface); 133 | if (sd == -1) { 134 | if (errno == ENOMEM) { 135 | shell_error(shell, "No sockets available, errno = %d", errno); 136 | } else { 137 | shell_error(shell, "Socket creation failed, errno = %d", errno); 138 | } 139 | return 0; 140 | } 141 | 142 | memset(ip_addr, 0, sizeof(char) * 100); 143 | if (isValidIpAddress(host)) { 144 | #ifdef DEBUG 145 | shell_print(shell, "ip"); 146 | #endif 147 | strncpy(ip_addr, host, strlen(host)); 148 | } else { 149 | #ifdef DEBUG 150 | shell_print(shell, "dns"); 151 | #endif 152 | resolve_dns(host, ip_addr, &ipVer); 153 | } 154 | 155 | struct sockaddr_in sin; 156 | sin.sin_family = AF_INET; 157 | sin.sin_port = htons(SNTP_PORT); 158 | inet_pton(AF_INET, ip_addr, &sin.sin_addr); 159 | #ifdef DEBUG 160 | shell_error(shell, "IP Address %s converted %d", ip_addr, sin.sin_addr.s_addr); 161 | #endif 162 | 163 | if (zsock_connect(sd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { 164 | shell_error(shell, "zsock_connect errno"); 165 | } 166 | 167 | int stat = zsock_send(sd, (char *)&packet, sizeof(ntp_packet), 0); 168 | if (stat == -1) { 169 | shell_error(shell, "Send failed, errno = %d", errno); 170 | zsock_close(sd); 171 | return -EINVAL; 172 | } 173 | k_msleep(2000); 174 | 175 | int recvsize = sizeof(ntp_packet); 176 | 177 | memset((char *)&packet, 0, sizeof(ntp_packet)); 178 | int total = 0; 179 | while (total < recvsize || recvsize == 0) { 180 | stat = zsock_recv(sd, ((char *)&packet) + total, recvsize - total, 181 | ZSOCK_MSG_DONTWAIT); 182 | if (stat == -1) { 183 | shell_error(shell, "recv failed, errno = %d", errno); 184 | zsock_close(sd); 185 | return -1; 186 | } 187 | total += stat; 188 | } 189 | if (total == -1 && errno == EWOULDBLOCK) { 190 | shell_print(shell, "No data available!"); 191 | zsock_close(sd); 192 | return total; 193 | } 194 | 195 | packet.txTm_s = ntohl(packet.txTm_s); // Time-stamp seconds. 196 | packet.txTm_f = ntohl(packet.txTm_f); // Time-stamp fraction of a second. 197 | 198 | time_t txTm = (time_t)(packet.txTm_s - NTP_TIMESTAMP_DELTA); 199 | #ifdef DEBUG 200 | shell_print(shell, "epoch %lld", txTm); 201 | #endif 202 | time_date_set(shell, txTm); 203 | zsock_close(sd); 204 | return 0; 205 | } 206 | -------------------------------------------------------------------------------- /samples/tmo_shell/src/tmo_file.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 T-Mobile USA, Inc. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "tmo_file.h" 15 | #include "dfu_murata_1sc.h" 16 | 17 | #define READ_SIZE 4096 18 | extern uint8_t mxfer_buf[]; 19 | #define SHA_DIGEST_20 20 20 | 21 | int tmo_cp(const struct shell *shell, size_t argc, char **argv) 22 | { 23 | int ret = 0; 24 | struct fs_dirent entry_src; 25 | 26 | if (argc != 3) { 27 | shell_error(shell, "usage: tmo file cp "); 28 | return -EINVAL; 29 | } 30 | 31 | char *src = argv[1]; 32 | char *dst = argv[2]; 33 | 34 | shell_print(shell, "tmo_cp: %s %s", src, dst); 35 | if (strcmp(src, dst) == 0) { 36 | shell_error(shell, "cannot copy file to itself"); 37 | return -EINVAL; 38 | } 39 | 40 | ret = fs_stat(src, &entry_src); 41 | if (ret) { 42 | shell_error(shell, "cannot stat %s", src); 43 | return -EINVAL; 44 | } 45 | 46 | if (entry_src.type != FS_DIR_ENTRY_FILE) { 47 | shell_error(shell, "%s is not a file", src); 48 | return -EINVAL; 49 | } 50 | 51 | struct fs_file_t zfp_src; 52 | fs_file_t_init(&zfp_src); 53 | ret = fs_open(&zfp_src, src, FS_O_READ); 54 | if (ret) { 55 | shell_error(shell, "cannot open %s", src); 56 | return ret; 57 | } 58 | 59 | struct fs_file_t zfp_dst; 60 | fs_file_t_init(&zfp_dst); 61 | ret = fs_open(&zfp_dst, dst, FS_O_CREATE | FS_O_WRITE); 62 | if (ret) { 63 | shell_error(shell, "cannot open %s", dst); 64 | fs_close(&zfp_src); 65 | return ret; 66 | } 67 | 68 | while (1) { 69 | ret = fs_read(&zfp_src, mxfer_buf, READ_SIZE); 70 | if (ret < 0) { 71 | shell_error(shell, "error reading from %s", src); 72 | goto end; 73 | } 74 | 75 | if (ret == 0) { 76 | goto end; 77 | } 78 | 79 | int size = ret; 80 | ret = fs_write(&zfp_dst, mxfer_buf, size); 81 | if (ret < 0) { 82 | shell_error(shell, "error writing to %s", dst); 83 | goto end; 84 | } 85 | 86 | if (ret != size) { 87 | shell_error(shell, "size mismatch"); 88 | ret = -ENOSPC; 89 | goto end; 90 | } 91 | } 92 | end: 93 | fs_close(&zfp_src); 94 | fs_close(&zfp_dst); 95 | return ret; 96 | } 97 | 98 | int tmo_ll(const struct shell *shell, size_t argc, char **argv) 99 | { 100 | if (argc < 2) { 101 | shell_error(shell, "usage: tmo file ll "); 102 | return -EINVAL; 103 | } 104 | 105 | struct fs_dir_t zdp; 106 | fs_dir_t_init(&zdp); 107 | 108 | for (int i=1;i\n", longest); 129 | printf(spec, entry.name); 130 | } 131 | } 132 | fs_closedir(&zdp); 133 | } 134 | shell_print(shell, "Total: %u", total); 135 | } 136 | return 0; 137 | } 138 | 139 | int tmo_mv(const struct shell *shell, size_t argc, char **argv) 140 | { 141 | int ret = 0; 142 | 143 | if (argc < 3) { 144 | shell_error(shell, "usage: tmo file mv "); 145 | return -EINVAL; 146 | } 147 | 148 | char *src = argv[1]; 149 | char *dst = argv[2]; 150 | shell_print(shell, "Renaming %s to %s", src, dst); 151 | ret = fs_rename(src, dst); 152 | if (ret) { 153 | shell_error(shell, "fs_rename returned %d\n", ret); 154 | } 155 | return ret; 156 | } 157 | 158 | int cmd_sha1(const struct shell *shell, size_t argc, char **argv) 159 | { 160 | if (argc < 2) { 161 | shell_error(shell, "Missing required arguments"); 162 | shell_print(shell, "Usage: tmo sha1 \n"); 163 | return -EINVAL; 164 | } 165 | 166 | char *filename = argv[1]; 167 | 168 | struct fs_file_t sha1file = {0}; 169 | int readbytes = 0; 170 | int totalreadbytes = 0; 171 | 172 | mbedtls_sha1_context tmo_sha1_ctx; 173 | unsigned char tmo_sha1_output[SHA_DIGEST_20]; 174 | 175 | uint32_t crc32 = 0; 176 | uint32_t mcrc32 = 0; 177 | 178 | mbedtls_sha1_init(&tmo_sha1_ctx); 179 | memset(tmo_sha1_output, 0, sizeof(tmo_sha1_output)); 180 | mbedtls_sha1_starts(&tmo_sha1_ctx); 181 | 182 | readbytes = 0; 183 | totalreadbytes = 0; 184 | 185 | if (fs_open(&sha1file, filename, FS_O_READ) != 0) { 186 | shell_error(shell, "%s is missing", filename); 187 | return -EINVAL; 188 | } 189 | 190 | fs_seek(&sha1file, 0, FS_SEEK_SET); 191 | 192 | int notdone = 1; 193 | while (notdone) 194 | { 195 | readbytes = fs_read(&sha1file, mxfer_buf, UA_HEADER_SIZE); 196 | if (readbytes < 0) { 197 | shell_error(shell, "Could not read file %s", filename); 198 | fs_close(&sha1file); 199 | return -1; 200 | } 201 | if ((totalreadbytes == 0) && (readbytes != UA_HEADER_SIZE)) { 202 | shell_error(shell, "Error reading header, read %d bytes\n", readbytes); 203 | fs_close(&sha1file); 204 | return -1; 205 | } 206 | 207 | totalreadbytes += readbytes; 208 | if (readbytes == 0) { 209 | notdone = 0; 210 | } 211 | else { 212 | mbedtls_sha1_update(&tmo_sha1_ctx, (unsigned char *)mxfer_buf, readbytes); 213 | crc32 = crc32_ieee_update(crc32, mxfer_buf, readbytes); 214 | if (totalreadbytes > UA_HEADER_SIZE) 215 | mcrc32 = murata_1sc_crc32_update(mcrc32, mxfer_buf, readbytes); 216 | } 217 | } 218 | 219 | mbedtls_sha1_finish(&tmo_sha1_ctx, tmo_sha1_output); 220 | mcrc32 = murata_1sc_crc32_finish(mcrc32, totalreadbytes - UA_HEADER_SIZE); 221 | 222 | shell_print(shell, " Size: %d bytes", (uint32_t) totalreadbytes); 223 | shell_print(shell, " CRC32: %x", crc32); 224 | shell_print(shell, "MCRC32: %x", mcrc32); 225 | 226 | printf(" SHA1:"); 227 | for (int i = 0; i < SHA_DIGEST_20; i++) { 228 | printf(" %02x", tmo_sha1_output[i]); 229 | } 230 | printf("\n"); 231 | 232 | fs_close(&sha1file); 233 | return 0; 234 | } 235 | -------------------------------------------------------------------------------- /samples/mqtt_publisher_aws/src/test_certs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Intel Corporation 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | */ 6 | 7 | #ifndef __TEST_CERTS_H__ 8 | #define __TEST_CERTS_H__ 9 | 10 | #if defined(CONFIG_NET_SOCKETS_OFFLOAD) 11 | /* By default only certificates in DER format are supported. If you want to use 12 | * certificate in PEM format, you can enable support for it in Kconfig. 13 | */ 14 | 15 | #if defined(CONFIG_TLS_CREDENTIAL_FILENAMES) 16 | static const unsigned char ca_certificate[] = "ca_cert.der"; 17 | #else 18 | static const unsigned char ca_certificate[] = { 19 | #include "ca_cert.der.inc" 20 | }; 21 | #endif 22 | 23 | #else 24 | #include 25 | 26 | #if defined(MBEDTLS_X509_CRT_PARSE_C) 27 | /* This byte array can be generated by 28 | * "cat ca.crt | sed -e '1d;$d' | base64 -d |xxd -i" 29 | */ 30 | static const unsigned char ca_certificate[] = { 31 | 0x30, 0x82, 0x02, 0xfb, 0x30, 0x82, 0x01, 0xe3, 32 | 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 33 | 0xee, 0x10, 0x1f, 0xc1, 0xf2, 0x30, 0xe9, 0x11, 34 | 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 35 | 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 36 | 0x14, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 37 | 0x04, 0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 38 | 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x1e, 0x17, 39 | 0x0d, 0x31, 0x37, 0x30, 0x36, 0x32, 0x36, 0x31, 40 | 0x30, 0x35, 0x36, 0x31, 0x30, 0x5a, 0x17, 0x0d, 41 | 0x34, 0x34, 0x31, 0x31, 0x31, 0x31, 0x31, 0x30, 42 | 0x35, 0x36, 0x31, 0x30, 0x5a, 0x30, 0x14, 0x31, 43 | 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 44 | 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 45 | 0x6f, 0x73, 0x74, 0x30, 0x82, 0x01, 0x22, 0x30, 46 | 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 47 | 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 48 | 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 49 | 0x82, 0x01, 0x01, 0x00, 0xc6, 0x00, 0x7b, 0x0d, 50 | 0xd1, 0x17, 0x43, 0x6b, 0xa9, 0xa7, 0x79, 0x9c, 51 | 0x0f, 0x8d, 0x77, 0x91, 0xd2, 0xf7, 0x47, 0x35, 52 | 0xb3, 0x17, 0xe2, 0xdd, 0xed, 0x6d, 0x01, 0xf9, 53 | 0xb1, 0x92, 0xc9, 0x48, 0x80, 0xe0, 0x1f, 0xcf, 54 | 0xb7, 0xa4, 0x5f, 0xf0, 0x36, 0xea, 0xbf, 0xe1, 55 | 0x33, 0xf8, 0xa9, 0xc5, 0xe6, 0xd4, 0x19, 0x8b, 56 | 0x82, 0x25, 0xd9, 0x19, 0x74, 0x70, 0x79, 0xec, 57 | 0xc6, 0x68, 0xc9, 0xef, 0xce, 0x1a, 0xa9, 0xf0, 58 | 0xb7, 0x01, 0x35, 0x91, 0xff, 0xd3, 0x75, 0x6e, 59 | 0x02, 0xba, 0x06, 0x9a, 0x2a, 0xac, 0xcf, 0x22, 60 | 0xbf, 0x2b, 0x1f, 0xc1, 0x72, 0x38, 0x22, 0x35, 61 | 0xea, 0xda, 0x6f, 0xdd, 0x67, 0xa2, 0x2b, 0x19, 62 | 0x38, 0x19, 0x0e, 0x44, 0xd1, 0x71, 0x38, 0xb4, 63 | 0x6d, 0x26, 0x85, 0xd6, 0xc6, 0xbe, 0xc1, 0x6f, 64 | 0x3c, 0xee, 0xaf, 0x94, 0x3c, 0x05, 0x56, 0x4e, 65 | 0xad, 0x53, 0x81, 0x8b, 0xd4, 0x23, 0x31, 0x69, 66 | 0x72, 0x27, 0x93, 0xb4, 0x3a, 0xac, 0x23, 0xe8, 67 | 0x10, 0xae, 0xf5, 0x9f, 0x0b, 0xa6, 0x6e, 0xd3, 68 | 0x73, 0xca, 0x18, 0x11, 0xca, 0xbe, 0x71, 0x00, 69 | 0x56, 0x29, 0x34, 0x54, 0xcc, 0xda, 0x29, 0x5b, 70 | 0x26, 0x29, 0x99, 0x4d, 0x5f, 0xa1, 0xa6, 0xb9, 71 | 0xcb, 0x2b, 0xb2, 0x0f, 0x10, 0x00, 0x04, 0xa9, 72 | 0x11, 0x2c, 0x48, 0xb1, 0x99, 0xa5, 0xca, 0x7c, 73 | 0x67, 0xa5, 0xbe, 0x14, 0x20, 0x12, 0xb7, 0x3b, 74 | 0x7a, 0x4f, 0xdc, 0xc7, 0xd5, 0x2d, 0x04, 0x66, 75 | 0xbb, 0xf5, 0x0c, 0xcd, 0xf1, 0x32, 0x39, 0xd7, 76 | 0x51, 0x9b, 0xba, 0xdb, 0xf1, 0xa7, 0xfe, 0x2d, 77 | 0x9a, 0xe6, 0x9c, 0x6b, 0x54, 0xda, 0xf1, 0xdd, 78 | 0x48, 0xf9, 0xd7, 0xf0, 0x35, 0x7c, 0x8e, 0x24, 79 | 0x7e, 0x44, 0x2f, 0xf3, 0xbf, 0x39, 0x0e, 0x96, 80 | 0xab, 0xe1, 0x45, 0x03, 0x8b, 0x54, 0xdc, 0xe1, 81 | 0xb6, 0x11, 0x81, 0x21, 0x02, 0x03, 0x01, 0x00, 82 | 0x01, 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 83 | 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 84 | 0xa4, 0xef, 0x6d, 0xdc, 0x9b, 0x23, 0xc5, 0x3a, 85 | 0xdd, 0x34, 0xd9, 0x01, 0x1c, 0x68, 0x03, 0x53, 86 | 0xae, 0x92, 0xc2, 0xc9, 0x30, 0x1f, 0x06, 0x03, 87 | 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 88 | 0x14, 0xa4, 0xef, 0x6d, 0xdc, 0x9b, 0x23, 0xc5, 89 | 0x3a, 0xdd, 0x34, 0xd9, 0x01, 0x1c, 0x68, 0x03, 90 | 0x53, 0xae, 0x92, 0xc2, 0xc9, 0x30, 0x0c, 0x06, 91 | 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 92 | 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 93 | 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 94 | 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x67, 95 | 0x65, 0xbf, 0x93, 0x89, 0xde, 0x4f, 0x71, 0xff, 96 | 0x1c, 0x93, 0x68, 0xa0, 0x64, 0x09, 0x5e, 0x95, 97 | 0x94, 0xf5, 0xd5, 0xf4, 0x6b, 0x20, 0x32, 0xd8, 98 | 0x04, 0x80, 0xac, 0xf8, 0x52, 0x36, 0x7a, 0x38, 99 | 0x83, 0xae, 0xab, 0x29, 0x22, 0x42, 0x71, 0x7e, 100 | 0xea, 0xe5, 0x4f, 0x71, 0xac, 0x44, 0x3f, 0x9e, 101 | 0x5e, 0x49, 0x22, 0x05, 0xee, 0xa6, 0x7b, 0xab, 102 | 0x56, 0x2e, 0xb3, 0x9a, 0x35, 0x1a, 0x88, 0xc3, 103 | 0x54, 0x9b, 0xfd, 0xac, 0x65, 0x54, 0xaf, 0x21, 104 | 0xa7, 0xe0, 0xdd, 0x62, 0x29, 0x8c, 0xae, 0x26, 105 | 0x0b, 0x84, 0x1f, 0x69, 0x78, 0x84, 0xc6, 0x7e, 106 | 0xcf, 0xc8, 0xf5, 0x92, 0x8c, 0x05, 0xa8, 0x13, 107 | 0x38, 0xcd, 0x0b, 0x98, 0x53, 0xfb, 0xdd, 0x8d, 108 | 0x51, 0x90, 0xa8, 0x51, 0xfa, 0x52, 0xbe, 0x28, 109 | 0xd4, 0x71, 0x50, 0x73, 0x1f, 0xb0, 0xb6, 0x0e, 110 | 0x45, 0xb1, 0x47, 0x41, 0x06, 0xd9, 0x1d, 0x7a, 111 | 0x34, 0xe7, 0x80, 0x2e, 0x0c, 0x02, 0x50, 0x97, 112 | 0xde, 0xa8, 0x7a, 0x84, 0x2c, 0x1d, 0xf4, 0x51, 113 | 0x56, 0xa5, 0x52, 0xb5, 0x04, 0x2e, 0xcb, 0xdd, 114 | 0x8b, 0x2e, 0x16, 0xc6, 0xde, 0xc8, 0xe9, 0x8d, 115 | 0xee, 0x5e, 0xb6, 0xa0, 0xe0, 0x2b, 0x85, 0x2a, 116 | 0x89, 0x7b, 0xba, 0x68, 0x80, 0x2b, 0xfb, 0x6e, 117 | 0x2e, 0x80, 0xe7, 0x7a, 0x97, 0x09, 0xb5, 0x2f, 118 | 0x20, 0x8e, 0xed, 0xbc, 0x98, 0x6f, 0x95, 0xd5, 119 | 0x5b, 0x3d, 0x26, 0x19, 0x26, 0x14, 0x39, 0x82, 120 | 0xa8, 0xa8, 0x42, 0x46, 0xab, 0x59, 0x93, 0x47, 121 | 0x83, 0xf7, 0x79, 0xbf, 0x73, 0xb5, 0x5d, 0x5d, 122 | 0x78, 0xfe, 0x62, 0xac, 0xed, 0xb7, 0x1e, 0x4a, 123 | 0xad, 0xc3, 0x99, 0x39, 0x7d, 0x3e, 0x30, 0x21, 124 | 0x26, 0x1d, 0x66, 0xdb, 0x0d, 0xf3, 0xba, 0x87, 125 | 0x46, 0xf0, 0x04, 0xfc, 0xc3, 0xbe, 0x84, 0x85, 126 | 0x3c, 0x01, 0xef, 0xe0, 0x68, 0x65, 0xee, 127 | }; 128 | #endif /* MBEDTLS_X509_CRT_PARSE_C */ 129 | 130 | #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) 131 | /* Avoid leading zero in psk because there's a potential issue of mosquitto 132 | * that leading zero of psk will be skipped and it leads to TLS handshake 133 | * failure 134 | */ 135 | const unsigned char client_psk[] = { 136 | 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 137 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f 138 | }; 139 | 140 | const char client_psk_id[] = "Client_identity"; 141 | #endif 142 | 143 | #endif /* CONFIG_NET_SOCKETS_OFFLOAD */ 144 | 145 | #endif 146 | --------------------------------------------------------------------------------