diff --git a/board/Nordic_NRF52832/BSP/Inc/nrfx_config.h b/board/Nordic_NRF52832/BSP/Inc/nrfx_config.h index 5675db8e..9535a8ea 100644 --- a/board/Nordic_NRF52832/BSP/Inc/nrfx_config.h +++ b/board/Nordic_NRF52832/BSP/Inc/nrfx_config.h @@ -238,11 +238,11 @@ // NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver //========================================================== #ifndef NRFX_GPIOTE_ENABLED -#define NRFX_GPIOTE_ENABLED 0 +#define NRFX_GPIOTE_ENABLED 1 #endif // NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins #ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS -#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4 #endif // NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority diff --git a/board/Nordic_NRF52832/BSP/Inc/nrfx_glue.h b/board/Nordic_NRF52832/BSP/Inc/nrfx_glue.h index 2490941c..720b68b5 100644 --- a/board/Nordic_NRF52832/BSP/Inc/nrfx_glue.h +++ b/board/Nordic_NRF52832/BSP/Inc/nrfx_glue.h @@ -42,6 +42,8 @@ extern "C" { #endif +#include "apply_old_config.h" + int NVIC_IRQ_IS_ENABLED(unsigned int irq); unsigned int nrfx_enter_critical(void); void nrfx_exit_critical(unsigned int ctx); @@ -61,12 +63,13 @@ void nrfx_exit_critical(unsigned int ctx); //------------------------------------------------------------------------------ +#include /** * @brief Macro for placing a runtime assertion. * * @param expression Expression to evaluate. */ -#define NRFX_ASSERT(expression) +#define NRFX_ASSERT(expression) ASSERT(expression) /** * @brief Macro for placing a compile time assertion. @@ -230,15 +233,38 @@ void nrfx_exit_critical(unsigned int ctx); #define NRFX_ATOMIC_FETCH_SUB(p_data, value) //------------------------------------------------------------------------------ +#ifndef NRFX_CUSTOM_ERROR_CODES +#include /** * @brief When set to a non-zero value, this macro specifies that the - * @ref nrfx_error_codes and the @ref nrfx_err_t type itself are defined + * @ref nrfx_error_codes and the @ref ret_code_t type itself are defined * in a customized way and the default definitions from @c * should not be used. */ -#define NRFX_CUSTOM_ERROR_CODES 0 +#define NRFX_CUSTOM_ERROR_CODES 1 +typedef ret_code_t nrfx_err_t; + +#define NRFX_SUCCESS NRF_SUCCESS +#define NRFX_ERROR_INTERNAL NRF_ERROR_INTERNAL +#define NRFX_ERROR_NO_MEM NRF_ERROR_NO_MEM +#define NRFX_ERROR_NOT_SUPPORTED NRF_ERROR_NOT_SUPPORTED +#define NRFX_ERROR_INVALID_PARAM NRF_ERROR_INVALID_PARAM +#define NRFX_ERROR_INVALID_STATE NRF_ERROR_INVALID_STATE +#define NRFX_ERROR_INVALID_LENGTH NRF_ERROR_INVALID_LENGTH +#define NRFX_ERROR_TIMEOUT NRF_ERROR_TIMEOUT +#define NRFX_ERROR_FORBIDDEN NRF_ERROR_FORBIDDEN +#define NRFX_ERROR_NULL NRF_ERROR_NULL +#define NRFX_ERROR_INVALID_ADDR NRF_ERROR_INVALID_ADDR +#define NRFX_ERROR_BUSY NRF_ERROR_BUSY +#define NRFX_ERROR_ALREADY_INITIALIZED NRF_ERROR_MODULE_ALREADY_INITIALIZED + +#define NRFX_ERROR_DRV_TWI_ERR_OVERRUN NRF_ERROR_DRV_TWI_ERR_OVERRUN +#define NRFX_ERROR_DRV_TWI_ERR_ANACK NRF_ERROR_DRV_TWI_ERR_ANACK +#define NRFX_ERROR_DRV_TWI_ERR_DNACK NRF_ERROR_DRV_TWI_ERR_DNACK + +#endif // NRFX_CUSTOM_ERROR_CODES //------------------------------------------------------------------------------ /** diff --git a/board/Nordic_NRF52832/BSP/Inc/sdk_config.h b/board/Nordic_NRF52832/BSP/Inc/sdk_config.h index 57f633ff..5ae4da19 100644 --- a/board/Nordic_NRF52832/BSP/Inc/sdk_config.h +++ b/board/Nordic_NRF52832/BSP/Inc/sdk_config.h @@ -1943,7 +1943,7 @@ #endif // NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins #ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS -#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4 #endif // NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority @@ -7088,7 +7088,7 @@ // NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library //========================================================== #ifndef NRF_FSTORAGE_ENABLED -#define NRF_FSTORAGE_ENABLED 0 +#define NRF_FSTORAGE_ENABLED 1 #endif // nrf_fstorage - Common settings diff --git a/board/Nordic_NRF52832/KEIL/llsync/RTE/_TencentOS_tiny/RTE_Components.h b/board/Nordic_NRF52832/KEIL/llsync/RTE/_TencentOS_tiny/RTE_Components.h new file mode 100644 index 00000000..ef69c225 --- /dev/null +++ b/board/Nordic_NRF52832/KEIL/llsync/RTE/_TencentOS_tiny/RTE_Components.h @@ -0,0 +1,21 @@ + +/* + * Auto generated Run-Time-Environment Configuration File + * *** Do not modify ! *** + * + * Project: 'TencentOS_tiny' + * Target: 'TencentOS_tiny' + */ + +#ifndef RTE_COMPONENTS_H +#define RTE_COMPONENTS_H + + +/* + * Define the Device Header File: + */ +#define CMSIS_device_header "nrf.h" + + + +#endif /* RTE_COMPONENTS_H */ diff --git a/board/Nordic_NRF52832/KEIL/llsync/TencentOS_tiny.uvprojx b/board/Nordic_NRF52832/KEIL/llsync/TencentOS_tiny.uvprojx new file mode 100644 index 00000000..1d3aa8d6 --- /dev/null +++ b/board/Nordic_NRF52832/KEIL/llsync/TencentOS_tiny.uvprojx @@ -0,0 +1,1401 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + TencentOS_tiny + 0x4 + ARM-ADS + 5060750::V5.06 update 6 (build 750)::ARMCC + 0 + + + nRF52832_xxAA + Nordic Semiconductor + NordicSemiconductor.nRF_DeviceFamilyPack.8.24.1 + http://developer.nordicsemi.com/nRF5_SDK/pieces/nRF_DeviceFamilyPack/ + IRAM(0x20000000,0x10000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC4000 -FN2 -FF0nrf52xxx -FS00 -FL0200000 -FF1nrf52xxx_uicr -FS110001000 -FL11000 -FP0($$Device:nRF52832_xxAA$Flash\nrf52xxx.flm) -FP1($$Device:nRF52832_xxAA$Flash\nrf52xxx_uicr.flm)) + 0 + $$Device:nRF52832_xxAA$Device\Include\nrf.h + + + + + + + + + + $$Device:nRF52832_xxAA$SVD\nrf52.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + TencentOS_tiny + 1 + 0 + 0 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -MPU + DCM.DLL + -pCM4 + SARMCM3.DLL + -MPU + TCM.DLL + -pCM4 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + -1 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M4" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x10000 + + + 1 + 0x0 + 0x80000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x80000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + + --reduce_paths --gnu + NRF52,NRF52832_XXAA,BOARD_PCA10040,NIMBLE_CFG_CONTROLLER=1,CONFIG_GPIO_AS_PINRESET + + ..\..\BSP\Inc;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc;..\..\..\..\kernel\core\include;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\TOS_CONFIG;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\porting\nimble\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\ext\tinycrypt\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\drivers\nrf52\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\transport\ram\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\lls\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\ans\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\bas\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\bleuart\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\gap\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\ias\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\lls\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\tps\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\gatt\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\store\ram\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\util\include;..\..\..\..\components\connectivity\Bluetooth_5.0\porting\TencentOS_tiny\include;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\modules\nrfx;..\..\BSP\Src;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\dis\include;..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\bas\include;.\nimble;..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\src\internal_inc;..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\inc;..\..\..\..\examples\nimble_llsync\date_template;..\..\..\..\examples\nimble_llsync;..\..\..\..\examples\nimble_llsync\fprintf;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\softdevice\s132\headers;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\softdevice\common;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\util;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\fstorage;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\experimental_section_vars;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\log;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\log\src;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\strerror;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\memobj;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\balloc;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\atomic;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\ringbuf;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\boards;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\modules\nrfx\drivers\include;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\integration\nrfx\legacy;..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\modules\nrfx\hal + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 4 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + + + + + + + + + + + + Startup + + + arm_startup_nrf52.s + 2 + .\arm_startup_nrf52.s + + + + + Drivers + + + mcu_init.c + 1 + ..\..\BSP\Src\mcu_init.c + + + nrfx_glue.c + 1 + ..\..\BSP\Src\nrfx_glue.c + + + nrfx_rtc.c + 1 + ..\..\BSP\Src\nrfx_rtc.c + + + nrfx_uart.c + 1 + ..\..\BSP\Src\nrfx_uart.c + + + simple_uart.c + 1 + ..\..\BSP\Src\simple_uart.c + + + system_nrf52.c + 1 + ..\..\BSP\Src\system_nrf52.c + + + nrfx_prs.c + 1 + ..\..\BSP\Src\prs\nrfx_prs.c + + + rtc.c + 1 + ..\..\BSP\Src\rtc.c + + + + + tos/arch + + + tos_cpu.c + 1 + ..\..\..\..\arch\arm\arm-v7m\common\tos_cpu.c + + + port_c.c + 1 + ..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_c.c + + + port_s.S + 2 + ..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc\port_s.S + + + + + tos/kernel + + + tos_event.c + 1 + ..\..\..\..\kernel\core\tos_event.c + + + tos_global.c + 1 + ..\..\..\..\kernel\core\tos_global.c + + + tos_mmblk.c + 1 + ..\..\..\..\kernel\core\tos_mmblk.c + + + tos_mmheap.c + 1 + ..\..\..\..\kernel\core\tos_mmheap.c + + + tos_mutex.c + 1 + ..\..\..\..\kernel\core\tos_mutex.c + + + tos_pend.c + 1 + ..\..\..\..\kernel\core\tos_pend.c + + + tos_robin.c + 1 + ..\..\..\..\kernel\core\tos_robin.c + + + tos_sched.c + 1 + ..\..\..\..\kernel\core\tos_sched.c + + + tos_sem.c + 1 + ..\..\..\..\kernel\core\tos_sem.c + + + tos_sys.c + 1 + ..\..\..\..\kernel\core\tos_sys.c + + + tos_task.c + 1 + ..\..\..\..\kernel\core\tos_task.c + + + tos_tick.c + 1 + ..\..\..\..\kernel\core\tos_tick.c + + + tos_time.c + 1 + ..\..\..\..\kernel\core\tos_time.c + + + tos_timer.c + 1 + ..\..\..\..\kernel\core\tos_timer.c + + + tos_binary_heap.c + 1 + ..\..\..\..\kernel\core\tos_binary_heap.c + + + tos_char_fifo.c + 1 + ..\..\..\..\kernel\core\tos_char_fifo.c + + + tos_completion.c + 1 + ..\..\..\..\kernel\core\tos_completion.c + + + tos_countdownlatch.c + 1 + ..\..\..\..\kernel\core\tos_countdownlatch.c + + + tos_mail_queue.c + 1 + ..\..\..\..\kernel\core\tos_mail_queue.c + + + tos_message_queue.c + 1 + ..\..\..\..\kernel\core\tos_message_queue.c + + + tos_priority_mail_queue.c + 1 + ..\..\..\..\kernel\core\tos_priority_mail_queue.c + + + tos_priority_message_queue.c + 1 + ..\..\..\..\kernel\core\tos_priority_message_queue.c + + + tos_priority_queue.c + 1 + ..\..\..\..\kernel\core\tos_priority_queue.c + + + tos_ring_queue.c + 1 + ..\..\..\..\kernel\core\tos_ring_queue.c + + + + + tos/cmsis + + + cmsis_os.c + 1 + ..\..\..\..\osal\cmsis_os\cmsis_os.c + + + + + example + + + ble_qiot_import.c + 1 + ..\..\..\..\examples\nimble_llsync\ble_qiot_import.c + + + ble_qiot_template.c + 1 + ..\..\..\..\examples\nimble_llsync\date_template\ble_qiot_template.c + + + flash_storage.c + 1 + ..\..\..\..\examples\nimble_llsync\flash_storage.c + + + main.c + 1 + ..\..\..\..\examples\nimble_llsync\main.c + + + gatt_svr.c + 1 + ..\..\..\..\examples\nimble_llsync\gatt_svr.c + + + + + CONFIG + + + tos_config.h + 5 + ..\..\TOS_CONFIG\tos_config.h + + + nrfx_config.h + 5 + ..\..\BSP\Inc\nrfx_config.h + + + private_syscfg.h + 5 + ..\..\..\..\components\connectivity\Bluetooth_5.0\porting\TencentOS_tiny\include\nrf52832\config\private_syscfg.h + + + + + porting/TencentOS_tiny + + + nimble_port_tencentos_tiny.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\porting\TencentOS_tiny\src\nimble_port_tencentos_tiny.c + + + npl_os_tencenos_tiny.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\porting\TencentOS_tiny\src\npl_os_tencenos_tiny.c + + + nrf5x_isr.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\porting\TencentOS_tiny\src\nrf5x_isr.c + + + tencent_os_tiny_libc.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\porting\TencentOS_tiny\src\tencent_os_tiny_libc.c + + + console.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\porting\TencentOS_tiny\src\console.c + + + + + NimBLE/host/src + + + ble_att.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_att.c + + + ble_att_clt.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_att_clt.c + + + ble_att_cmd.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_att_cmd.c + + + ble_att_svr.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_att_svr.c + + + ble_eddystone.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_eddystone.c + + + ble_gap.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_gap.c + + + ble_gattc.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_gattc.c + + + ble_gatts.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_gatts.c + + + ble_gatts_lcl.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_gatts_lcl.c + + + ble_hs.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs.c + + + ble_hs_adv.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_adv.c + + + ble_hs_atomic.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_atomic.c + + + ble_hs_cfg.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_cfg.c + + + ble_hs_conn.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_conn.c + + + ble_hs_dbg.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_dbg.c + + + ble_hs_flow.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_flow.c + + + ble_hs_hci.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_hci.c + + + ble_hs_hci_cmd.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_hci_cmd.c + + + ble_hs_hci_evt.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_hci_evt.c + + + ble_hs_hci_util.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_hci_util.c + + + ble_hs_id.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_id.c + + + ble_hs_log.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_log.c + + + ble_hs_mbuf.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_mbuf.c + + + ble_hs_misc.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_misc.c + + + ble_hs_mqueue.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_mqueue.c + + + ble_hs_periodic_sync.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_periodic_sync.c + + + ble_hs_pvcy.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_pvcy.c + + + ble_hs_shutdown.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_shutdown.c + + + ble_hs_startup.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_startup.c + + + ble_hs_stop.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_hs_stop.c + + + ble_ibeacon.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_ibeacon.c + + + ble_l2cap.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_l2cap.c + + + ble_l2cap_coc.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_l2cap_coc.c + + + ble_l2cap_sig.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_l2cap_sig.c + + + ble_l2cap_sig_cmd.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_l2cap_sig_cmd.c + + + ble_monitor.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_monitor.c + + + ble_sm.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_sm.c + + + ble_sm_alg.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_sm_alg.c + + + ble_sm_cmd.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_sm_cmd.c + + + ble_sm_lgcy.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_sm_lgcy.c + + + ble_sm_sc.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_sm_sc.c + + + ble_store.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_store.c + + + ble_store_util.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_store_util.c + + + ble_uuid.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\src\ble_uuid.c + + + + + NimBLE/controller + + + ble_ll.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll.c + + + ble_ll_adv.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_adv.c + + + ble_ll_conn.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_conn.c + + + ble_ll_conn_hci.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_conn_hci.c + + + ble_ll_ctrl.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_ctrl.c + + + ble_ll_dtm.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_dtm.c + + + ble_ll_hci.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_hci.c + + + ble_ll_hci_ev.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_hci_ev.c + + + ble_ll_rand.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_rand.c + + + ble_ll_resolv.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_resolv.c + + + ble_ll_scan.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_scan.c + + + ble_ll_sched.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_sched.c + + + ble_ll_supp_cmd.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_supp_cmd.c + + + ble_ll_sync.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_sync.c + + + ble_ll_trace.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_trace.c + + + ble_ll_utils.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_utils.c + + + ble_ll_whitelist.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_whitelist.c + + + ble_ll_xcvr.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\controller\src\ble_ll_xcvr.c + + + + + NimBLE/port + + + endian.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\porting\nimble\src\endian.c + + + hal_timer.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\porting\nimble\src\hal_timer.c + + + mem.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\porting\nimble\src\mem.c + + + nimble_port.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\porting\nimble\src\nimble_port.c + + + os_cputime.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\porting\nimble\src\os_cputime.c + + + os_cputime_pwr2.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\porting\nimble\src\os_cputime_pwr2.c + + + os_mbuf.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\porting\nimble\src\os_mbuf.c + + + os_mempool.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\porting\nimble\src\os_mempool.c + + + os_msys_init.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\porting\nimble\src\os_msys_init.c + + + + + NimBLE/tinycrypt + + + aes_decrypt.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\ext\tinycrypt\src\aes_decrypt.c + + + aes_encrypt.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\ext\tinycrypt\src\aes_encrypt.c + + + cmac_mode.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\ext\tinycrypt\src\cmac_mode.c + + + ecc.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\ext\tinycrypt\src\ecc.c + + + ecc_dh.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\ext\tinycrypt\src\ecc_dh.c + + + utils.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\ext\tinycrypt\src\utils.c + + + + + NimBLE/transport/ram + + + ble_hci_ram.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\transport\ram\src\ble_hci_ram.c + + + + + NimBLE/src + + + ble_util.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\src\ble_util.c + + + + + NimBLE/drivers/nrf52 + + + ble_hw.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\drivers\nrf52\src\ble_hw.c + + + ble_phy.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\drivers\nrf52\src\ble_phy.c + + + + + NimBLE/host/services/ans + + + ble_svc_ans.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\ans\src\ble_svc_ans.c + + + + + NimBLE/host/services/bas + + + ble_svc_bas.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\bas\src\ble_svc_bas.c + + + + + NimBLE/host/services/bleuart + + + bleuart.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\bleuart\src\bleuart.c + + + + + NimBLE/host/services/gap + + + ble_svc_gap.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\gap\src\ble_svc_gap.c + + + + + NimBLE/host/services/gatt + + + ble_svc_gatt.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\gatt\src\ble_svc_gatt.c + + + + + NimBLE/host/services/ias + + + ble_svc_ias.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\ias\src\ble_svc_ias.c + + + + + NimBLE/host/services/lls + + + ble_svc_lls.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\lls\src\ble_svc_lls.c + + + + + NimBLE/host/services/tps + + + ble_svc_tps.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\services\tps\src\ble_svc_tps.c + + + + + NimBLE/host/store/ram + + + ble_store_ram.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\store\ram\src\ble_store_ram.c + + + + + NimBLE/host/util + + + addr.c + 1 + ..\..\..\..\components\connectivity\Bluetooth_5.0\3rdparty\NimBLE_1_2_0\nimble\host\util\src\addr.c + + + + + qcloud_iot_explorer_ble + + + ble_qiot_llsync_data.c + 1 + ..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_data.c + + + ble_qiot_llsync_device.c + 1 + ..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_device.c + + + ble_qiot_llsync_event.c + 1 + ..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_event.c + + + ble_qiot_service.c + 1 + ..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\src\core\ble_qiot_service.c + + + ble_qiot_utils_base64.c + 1 + ..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_base64.c + + + ble_qiot_utils_hmac.c + 1 + ..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_hmac.c + + + ble_qiot_utils_log.c + 1 + ..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_log.c + + + ble_qiot_utils_md5.c + 1 + ..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_md5.c + + + ble_qiot_utils_sha1.c + 1 + ..\..\..\..\components\connectivity\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_sha1.c + + + + + nRF_Libraries + + + nrf_fstorage.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\fstorage\nrf_fstorage.c + + + nrf_fstorage_nvmc.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\fstorage\nrf_fstorage_nvmc.c + + + nrf_atomic.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\atomic\nrf_atomic.c + + + nrf_nvmc.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\modules\nrfx\hal\nrf_nvmc.c + + + nrf_fprintf.c + 1 + ..\..\..\..\examples\nimble_llsync\fprintf\nrf_fprintf.c + + + nrf_memobj.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\memobj\nrf_memobj.c + + + nrf_balloc.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\balloc\nrf_balloc.c + + + nrf_ringbuf.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\ringbuf\nrf_ringbuf.c + + + nrf_strerror.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\strerror\nrf_strerror.c + + + app_error.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\util\app_error.c + + + app_error_handler_keil.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\util\app_error_handler_keil.c + + + app_error_weak.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\util\app_error_weak.c + + + app_util_platform.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\util\app_util_platform.c + + + nrf_fprintf_format.c + 1 + ..\..\..\..\examples\nimble_llsync\fprintf\nrf_fprintf_format.c + + + boards.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\boards\boards.c + + + + + nRF_Log + + + nrf_log_frontend.c + 1 + ..\..\..\..\platform\vendor_bsp\nordic\nRF5_SDK_15.3.0\components\libraries\log\src\nrf_log_frontend.c + + + + + ::CMSIS + + + + + + + + + + + + + + + + + + RTE\Device\nRF51822_xxAA\arm_startup_nrf51.s + + + + + + RTE\Device\nRF51822_xxAA\system_nrf51.c + + + + + + + + + + + <Project Info> + + + + + + 0 + 1 + + + + +
diff --git a/board/Nordic_NRF52832/KEIL/llsync/arm_startup_nrf52.s b/board/Nordic_NRF52832/KEIL/llsync/arm_startup_nrf52.s new file mode 100644 index 00000000..62da8608 --- /dev/null +++ b/board/Nordic_NRF52832/KEIL/llsync/arm_startup_nrf52.s @@ -0,0 +1,371 @@ +; Copyright (c) 2009-2018 ARM Limited. All rights reserved. +; +; SPDX-License-Identifier: Apache-2.0 +; +; Licensed under the Apache License, Version 2.0 (the License); you may +; not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an AS IS BASIS, WITHOUT +; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. +; +; NOTICE: This file has been modified by Nordic Semiconductor ASA. + + IF :DEF: __STARTUP_CONFIG +#ifdef __STARTUP_CONFIG +#include "startup_config.h" +#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT +#define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 +#endif +#endif + ENDIF + + IF :DEF: __STARTUP_CONFIG +Stack_Size EQU __STARTUP_CONFIG_STACK_SIZE + ELIF :DEF: __STACK_SIZE +Stack_Size EQU __STACK_SIZE + ELSE +Stack_Size EQU 8192 + ENDIF + + IF :DEF: __STARTUP_CONFIG +Stack_Align EQU __STARTUP_CONFIG_STACK_ALIGNEMENT + ELSE +Stack_Align EQU 3 + ENDIF + + AREA STACK, NOINIT, READWRITE, ALIGN=Stack_Align +Stack_Mem SPACE Stack_Size +__initial_sp + + IF :DEF: __STARTUP_CONFIG +Heap_Size EQU __STARTUP_CONFIG_HEAP_SIZE + ELIF :DEF: __HEAP_SIZE +Heap_Size EQU __HEAP_SIZE + ELSE +Heap_Size EQU 8192 + ENDIF + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler + DCD NMI_Handler + DCD HardFault_Handler + DCD MemoryManagement_Handler + DCD BusFault_Handler + DCD UsageFault_Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler + DCD DebugMon_Handler + DCD 0 ; Reserved + DCD PendSV_Handler + DCD SysTick_Handler + + ; External Interrupts + DCD POWER_CLOCK_IRQHandler + DCD RADIO_IRQHandler + DCD UARTE0_UART0_IRQHandler + DCD SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler + DCD SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler + DCD NFCT_IRQHandler + DCD GPIOTE_IRQHandler + DCD SAADC_IRQHandler + DCD TIMER0_IRQHandler + DCD TIMER1_IRQHandler + DCD TIMER2_IRQHandler + DCD RTC0_IRQHandler + DCD TEMP_IRQHandler + DCD RNG_IRQHandler + DCD ECB_IRQHandler + DCD CCM_AAR_IRQHandler + DCD WDT_IRQHandler + DCD RTC1_IRQHandler + DCD QDEC_IRQHandler + DCD COMP_LPCOMP_IRQHandler + DCD SWI0_EGU0_IRQHandler + DCD SWI1_EGU1_IRQHandler + DCD SWI2_EGU2_IRQHandler + DCD SWI3_EGU3_IRQHandler + DCD SWI4_EGU4_IRQHandler + DCD SWI5_EGU5_IRQHandler + DCD TIMER3_IRQHandler + DCD TIMER4_IRQHandler + DCD PWM0_IRQHandler + DCD PDM_IRQHandler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD MWU_IRQHandler + DCD PWM1_IRQHandler + DCD PWM2_IRQHandler + DCD SPIM2_SPIS2_SPI2_IRQHandler + DCD RTC2_IRQHandler + DCD I2S_IRQHandler + DCD FPU_IRQHandler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset Handler + + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemoryManagement_Handler\ + PROC + EXPORT MemoryManagement_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT POWER_CLOCK_IRQHandler [WEAK] + EXPORT RADIO_IRQHandler [WEAK] + EXPORT UARTE0_UART0_IRQHandler [WEAK] + EXPORT SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler [WEAK] + EXPORT SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler [WEAK] + EXPORT NFCT_IRQHandler [WEAK] + EXPORT GPIOTE_IRQHandler [WEAK] + EXPORT SAADC_IRQHandler [WEAK] + EXPORT TIMER0_IRQHandler [WEAK] + EXPORT TIMER1_IRQHandler [WEAK] + EXPORT TIMER2_IRQHandler [WEAK] + EXPORT RTC0_IRQHandler [WEAK] + EXPORT TEMP_IRQHandler [WEAK] + EXPORT RNG_IRQHandler [WEAK] + EXPORT ECB_IRQHandler [WEAK] + EXPORT CCM_AAR_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC1_IRQHandler [WEAK] + EXPORT QDEC_IRQHandler [WEAK] + EXPORT COMP_LPCOMP_IRQHandler [WEAK] + EXPORT SWI0_EGU0_IRQHandler [WEAK] + EXPORT SWI1_EGU1_IRQHandler [WEAK] + EXPORT SWI2_EGU2_IRQHandler [WEAK] + EXPORT SWI3_EGU3_IRQHandler [WEAK] + EXPORT SWI4_EGU4_IRQHandler [WEAK] + EXPORT SWI5_EGU5_IRQHandler [WEAK] + EXPORT TIMER3_IRQHandler [WEAK] + EXPORT TIMER4_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PDM_IRQHandler [WEAK] + EXPORT MWU_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT PWM2_IRQHandler [WEAK] + EXPORT SPIM2_SPIS2_SPI2_IRQHandler [WEAK] + EXPORT RTC2_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT FPU_IRQHandler [WEAK] +POWER_CLOCK_IRQHandler +RADIO_IRQHandler +UARTE0_UART0_IRQHandler +SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler +SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler +NFCT_IRQHandler +GPIOTE_IRQHandler +SAADC_IRQHandler +TIMER0_IRQHandler +TIMER1_IRQHandler +TIMER2_IRQHandler +RTC0_IRQHandler +TEMP_IRQHandler +RNG_IRQHandler +ECB_IRQHandler +CCM_AAR_IRQHandler +WDT_IRQHandler +RTC1_IRQHandler +QDEC_IRQHandler +COMP_LPCOMP_IRQHandler +SWI0_EGU0_IRQHandler +SWI1_EGU1_IRQHandler +SWI2_EGU2_IRQHandler +SWI3_EGU3_IRQHandler +SWI4_EGU4_IRQHandler +SWI5_EGU5_IRQHandler +TIMER3_IRQHandler +TIMER4_IRQHandler +PWM0_IRQHandler +PDM_IRQHandler +MWU_IRQHandler +PWM1_IRQHandler +PWM2_IRQHandler +SPIM2_SPIS2_SPI2_IRQHandler +RTC2_IRQHandler +I2S_IRQHandler +FPU_IRQHandler + B . + ENDP + ALIGN + +; User Initial Stack & Heap + + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap PROC + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + ENDP + + ALIGN + + ENDIF + + END diff --git a/board/Nordic_NRF52832/KEIL/llsync/nimble/config/private_syscfg.h b/board/Nordic_NRF52832/KEIL/llsync/nimble/config/private_syscfg.h new file mode 100644 index 00000000..4dc1ca94 --- /dev/null +++ b/board/Nordic_NRF52832/KEIL/llsync/nimble/config/private_syscfg.h @@ -0,0 +1,1245 @@ +#ifndef _PRIVATE_SYSCFG_H_ +#define _PRIVATE_SYSCFG_H_ + +#include "tos_config.h" + +#ifndef OS_TICKS_PER_SEC +#define OS_TICKS_PER_SEC TOS_CFG_CPU_TICK_PER_SECOND +#endif + +#ifndef MYNEWT_VAL_BLE_HOST_TASK_STACK_SIZE +#define MYNEWT_VAL_BLE_HOST_TASK_STACK_SIZE (2048) +#endif + +#ifndef MYNEWT_VAL_BLE_HOST_TASK_PRIORITY +#define MYNEWT_VAL_BLE_HOST_TASK_PRIORITY (5) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_TASK_STACK_SIZE +#define MYNEWT_VAL_BLE_LL_TASK_STACK_SIZE (2048) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_TASK_PRIORITY +#define MYNEWT_VAL_BLE_LL_TASK_PRIORITY (4) // must higher than MYNEWT_VAL_BLE_HOST_TASK_PRIORITY, numerically smaller +#endif + +#ifndef MYNEWT_VAL_OS_CPUTIME_FREQ +#define MYNEWT_VAL_OS_CPUTIME_FREQ (32768) +#endif + +#ifndef MYNEWT_VAL_BLEUART_MAX_INPUT +#define MYNEWT_VAL_BLEUART_MAX_INPUT (256) +#endif + +#ifndef MYNEWT_VAL_OS_CPUTIME_TIMER_NUM +#define MYNEWT_VAL_OS_CPUTIME_TIMER_NUM (5) +#endif + +/*** sys/log/stub */ +#ifndef MYNEWT_VAL_LOG_LEVEL +#define MYNEWT_VAL_LOG_LEVEL (10) +#endif + +/*** crypto/tinycrypt */ +#ifndef MYNEWT_VAL_TINYCRYPT_UECC_RNG_TRNG_DEV_NAME +#define MYNEWT_VAL_TINYCRYPT_UECC_RNG_TRNG_DEV_NAME ("trng") +#endif + +#ifndef MYNEWT_VAL_TINYCRYPT_UECC_RNG_USE_TRNG +#define MYNEWT_VAL_TINYCRYPT_UECC_RNG_USE_TRNG (0) +#endif + +#ifndef MYNEWT_VAL_BSP_NRF51 +#define MYNEWT_VAL_BSP_NRF51 (0) +#endif + +#ifndef MYNEWT_VAL_BSP_NRF52 +#define MYNEWT_VAL_BSP_NRF52 (1) +#endif + +#ifndef MYNEWT_VAL_MCU_NRF52832 +#define MYNEWT_VAL_MCU_NRF52832 (1) +#endif + +#ifndef MYNEWT_VAL_MCU_NRF52840 +#define MYNEWT_VAL_MCU_NRF52840 (0) +#endif + +/* hw/mcu/nordic/nrf52xxx */ +#ifndef MYNEWT_VAL_TIMER_0 +#define MYNEWT_VAL_TIMER_0 (0) +#endif + +#ifndef MYNEWT_VAL_TIMER_1 +#define MYNEWT_VAL_TIMER_1 (0) +#endif + +#ifndef MYNEWT_VAL_TIMER_2 +#define MYNEWT_VAL_TIMER_2 (0) +#endif + +#ifndef MYNEWT_VAL_TIMER_3 +#define MYNEWT_VAL_TIMER_3 (0) +#endif + +#ifndef MYNEWT_VAL_TIMER_4 +#define MYNEWT_VAL_TIMER_4 (0) +#endif + +#ifndef MYNEWT_VAL_TIMER_5 +#define MYNEWT_VAL_TIMER_5 (1) +#endif + +/*** nimble/controller */ +#ifndef MYNEWT_VAL_BLE_LL_RNG_BUFSIZE +#define MYNEWT_VAL_BLE_LL_RNG_BUFSIZE (32) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_NUM_SCAN_DUP_ADVS +#define MYNEWT_VAL_BLE_LL_NUM_SCAN_DUP_ADVS (8) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_NUM_SCAN_RSP_ADVS +#define MYNEWT_VAL_BLE_LL_NUM_SCAN_RSP_ADVS (8) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_OUR_SCA +#define MYNEWT_VAL_BLE_LL_OUR_SCA (60) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CONN_INIT_SLOTS +#define MYNEWT_VAL_BLE_LL_CONN_INIT_SLOTS (4) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CONN_INIT_MIN_WIN_OFFSET +#define MYNEWT_VAL_BLE_LL_CONN_INIT_MIN_WIN_OFFSET (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_MFRG_ID +#define MYNEWT_VAL_BLE_LL_MFRG_ID (0xFFFF) +#endif + +#ifndef MYNEWT_VAL_BLE_NUM_COMP_PKT_RATE +#define MYNEWT_VAL_BLE_NUM_COMP_PKT_RATE (2 * 128) +#endif + +#ifndef MYNEWT_VAL_BLE_PUBLIC_DEV_ADDR +#define MYNEWT_VAL_BLE_PUBLIC_DEV_ADDR (((uint8_t[6]){0xcc, 0xbb, 0xaa, 0x33, 0x22, 0x11})) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_TX_PWR_DBM +#define MYNEWT_VAL_BLE_LL_TX_PWR_DBM (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_MASTER_SCA +#define MYNEWT_VAL_BLE_LL_MASTER_SCA (4) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE +#define MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE (251) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_SUPP_MAX_RX_BYTES +#define MYNEWT_VAL_BLE_LL_SUPP_MAX_RX_BYTES (MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_SUPP_MAX_TX_BYTES +#define MYNEWT_VAL_BLE_LL_SUPP_MAX_TX_BYTES (MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CONN_INIT_MAX_TX_BYTES +#define MYNEWT_VAL_BLE_LL_CONN_INIT_MAX_TX_BYTES (27) +#endif + +/* Overridden by nimble/controller (defined by nimble/controller) */ +#ifndef MYNEWT_VAL_BLE_LL_WHITELIST_SIZE +#define MYNEWT_VAL_BLE_LL_WHITELIST_SIZE (8) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_DBG_HCI_CMD_PIN +#define MYNEWT_VAL_BLE_LL_DBG_HCI_CMD_PIN (-1) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_DBG_HCI_EV_PIN +#define MYNEWT_VAL_BLE_LL_DBG_HCI_EV_PIN (-1) +#endif + +/*** nimble/drivers/nrf52 */ +#ifndef MYNEWT_VAL_BLE_PHY_DBG_TIME_TXRXEN_READY_PIN +#define MYNEWT_VAL_BLE_PHY_DBG_TIME_TXRXEN_READY_PIN (-1) +#endif + +#ifndef MYNEWT_VAL_BLE_PHY_DBG_TIME_ADDRESS_END_PIN +#define MYNEWT_VAL_BLE_PHY_DBG_TIME_ADDRESS_END_PIN (-1) +#endif + +#ifndef MYNEWT_VAL_BLE_PHY_DBG_TIME_WFR_PIN +#define MYNEWT_VAL_BLE_PHY_DBG_TIME_WFR_PIN (-1) +#endif + +////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////// + +#if 1 + +/*** crypto/tinycrypt */ +#ifndef MYNEWT_VAL_TINYCRYPT_UECC_RNG_TRNG_DEV_NAME +#define MYNEWT_VAL_TINYCRYPT_UECC_RNG_TRNG_DEV_NAME ("trng") +#endif + +#ifndef MYNEWT_VAL_TINYCRYPT_UECC_RNG_USE_TRNG +#define MYNEWT_VAL_TINYCRYPT_UECC_RNG_USE_TRNG (0) +#endif + +#ifndef MYNEWT_VAL_BSP_NRF51 +#define MYNEWT_VAL_BSP_NRF51 (1) +#endif + +#ifndef MYNEWT_VAL_BSP_NRF52 +#define MYNEWT_VAL_BSP_NRF52 (0) +#endif + +#ifndef MYNEWT_VAL_MCU_NRF52832 +#define MYNEWT_VAL_MCU_NRF52832 (0) +#endif + +#ifndef MYNEWT_VAL_MCU_NRF52840 +#define MYNEWT_VAL_MCU_NRF52840 (0) +#endif + +/* hw/mcu/nordic/nrf52xxx */ +#ifndef MYNEWT_VAL_TIMER_0 +#define MYNEWT_VAL_TIMER_0 (0) +#endif + +#ifndef MYNEWT_VAL_TIMER_1 +#define MYNEWT_VAL_TIMER_1 (0) +#endif + +#ifndef MYNEWT_VAL_TIMER_2 +#define MYNEWT_VAL_TIMER_2 (0) +#endif + +#ifndef MYNEWT_VAL_TIMER_3 +#define MYNEWT_VAL_TIMER_3 (0) +#endif + +#ifndef MYNEWT_VAL_TIMER_4 +#define MYNEWT_VAL_TIMER_4 (0) +#endif + +#ifndef MYNEWT_VAL_TIMER_5 +#define MYNEWT_VAL_TIMER_5 (1) +#endif + +#ifndef MYNEWT_VAL_TRNG +#define MYNEWT_VAL_TRNG (0) +#endif + +/*** kernel/os */ +#ifndef MYNEWT_VAL_FLOAT_USER +#define MYNEWT_VAL_FLOAT_USER (0) +#endif + +#ifndef MYNEWT_VAL_MSYS_1_BLOCK_COUNT +#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT (12) +#endif + +#ifndef MYNEWT_VAL_MSYS_1_BLOCK_SIZE +#define MYNEWT_VAL_MSYS_1_BLOCK_SIZE (292) +#endif + +#ifndef MYNEWT_VAL_MSYS_2_BLOCK_COUNT +#define MYNEWT_VAL_MSYS_2_BLOCK_COUNT (0) +#endif + +#ifndef MYNEWT_VAL_MSYS_2_BLOCK_SIZE +#define MYNEWT_VAL_MSYS_2_BLOCK_SIZE (0) +#endif + +#ifndef MYNEWT_VAL_OS_CLI +#define MYNEWT_VAL_OS_CLI (0) +#endif + +#ifndef MYNEWT_VAL_OS_COREDUMP +#define MYNEWT_VAL_OS_COREDUMP (0) +#endif + +#ifndef MYNEWT_VAL_OS_CPUTIME_FREQ +#define MYNEWT_VAL_OS_CPUTIME_FREQ (32768) +#endif + +#ifndef MYNEWT_VAL_OS_CPUTIME_TIMER_NUM +#define MYNEWT_VAL_OS_CPUTIME_TIMER_NUM (5) +#endif + +/*** nimble */ +#ifndef MYNEWT_VAL_BLE_EXT_ADV +#define MYNEWT_VAL_BLE_EXT_ADV (0) +#endif + +#ifndef MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE +#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31) +#endif + +#ifndef MYNEWT_VAL_BLE_MAX_CONNECTIONS +#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES +#define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES (0) +#endif + +#ifndef MYNEWT_VAL_BLE_ROLE_BROADCASTER +#define MYNEWT_VAL_BLE_ROLE_BROADCASTER (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ROLE_CENTRAL +#define MYNEWT_VAL_BLE_ROLE_CENTRAL (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ROLE_OBSERVER +#define MYNEWT_VAL_BLE_ROLE_OBSERVER (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ROLE_PERIPHERAL +#define MYNEWT_VAL_BLE_ROLE_PERIPHERAL (1) +#endif + +#ifndef MYNEWT_VAL_BLE_WHITELIST +#define MYNEWT_VAL_BLE_WHITELIST (1) +#endif + +/*** nimble/controller */ +#ifndef MYNEWT_VAL_BLE_CONTROLLER +#define MYNEWT_VAL_BLE_CONTROLLER (1) +#endif + +#ifndef MYNEWT_VAL_BLE_DEVICE +#define MYNEWT_VAL_BLE_DEVICE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_HW_WHITELIST_ENABLE +#define MYNEWT_VAL_BLE_HW_WHITELIST_ENABLE (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_ADD_STRICT_SCHED_PERIODS +#define MYNEWT_VAL_BLE_LL_ADD_STRICT_SCHED_PERIODS (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_CONN_PARAM_REQ +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_CONN_PARAM_REQ (1) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_DATA_LEN_EXT +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_DATA_LEN_EXT (1) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_EXT_SCAN_FILT +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_EXT_SCAN_FILT (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_2M_PHY +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_2M_PHY (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CODED_PHY +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CODED_PHY (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CSA2 +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CSA2 (1) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION (1) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_PING +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_PING (MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_EXT_ADV +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_EXT_ADV (MYNEWT_VAL_BLE_EXT_ADV) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PRIVACY +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PRIVACY (1) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_SLAVE_INIT_FEAT_XCHG +#define MYNEWT_VAL_BLE_LL_CFG_FEAT_SLAVE_INIT_FEAT_XCHG (1) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CONN_INIT_MAX_TX_BYTES +#define MYNEWT_VAL_BLE_LL_CONN_INIT_MAX_TX_BYTES (27) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CONN_INIT_MIN_WIN_OFFSET +#define MYNEWT_VAL_BLE_LL_CONN_INIT_MIN_WIN_OFFSET (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_CONN_INIT_SLOTS +#define MYNEWT_VAL_BLE_LL_CONN_INIT_SLOTS (4) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_DIRECT_TEST_MODE +#define MYNEWT_VAL_BLE_LL_DIRECT_TEST_MODE (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_EXT_ADV_AUX_PTR_CNT +#define MYNEWT_VAL_BLE_LL_EXT_ADV_AUX_PTR_CNT (5) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_MASTER_SCA +#define MYNEWT_VAL_BLE_LL_MASTER_SCA (4) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE +#define MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE (251) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_MFRG_ID +#define MYNEWT_VAL_BLE_LL_MFRG_ID (0xFFFF) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_NUM_SCAN_DUP_ADVS +#define MYNEWT_VAL_BLE_LL_NUM_SCAN_DUP_ADVS (8) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_NUM_SCAN_RSP_ADVS +#define MYNEWT_VAL_BLE_LL_NUM_SCAN_RSP_ADVS (8) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_OUR_SCA +#define MYNEWT_VAL_BLE_LL_OUR_SCA (60) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_PRIO +#define MYNEWT_VAL_BLE_LL_PRIO (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_RESOLV_LIST_SIZE +#define MYNEWT_VAL_BLE_LL_RESOLV_LIST_SIZE (4) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_RNG_BUFSIZE +#define MYNEWT_VAL_BLE_LL_RNG_BUFSIZE (32) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_STRICT_CONN_SCHEDULING +#define MYNEWT_VAL_BLE_LL_STRICT_CONN_SCHEDULING (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_SUPP_MAX_RX_BYTES +#define MYNEWT_VAL_BLE_LL_SUPP_MAX_RX_BYTES (MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_SUPP_MAX_TX_BYTES +#define MYNEWT_VAL_BLE_LL_SUPP_MAX_TX_BYTES (MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_SYSVIEW +#define MYNEWT_VAL_BLE_LL_SYSVIEW (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_TX_PWR_DBM +#define MYNEWT_VAL_BLE_LL_TX_PWR_DBM (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_USECS_PER_PERIOD +#define MYNEWT_VAL_BLE_LL_USECS_PER_PERIOD (3250) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_VND_EVENT_ON_ASSERT +#define MYNEWT_VAL_BLE_LL_VND_EVENT_ON_ASSERT (0) +#endif + +#ifndef MYNEWT_VAL_BLE_LL_WHITELIST_SIZE +#define MYNEWT_VAL_BLE_LL_WHITELIST_SIZE (8) +#endif + +#ifndef MYNEWT_VAL_BLE_LP_CLOCK +#define MYNEWT_VAL_BLE_LP_CLOCK (1) +#endif + +#ifndef MYNEWT_VAL_BLE_NUM_COMP_PKT_RATE +#define MYNEWT_VAL_BLE_NUM_COMP_PKT_RATE ((2 * 128)) /* XXX */ +#endif + +#ifndef MYNEWT_VAL_BLE_PUBLIC_DEV_ADDR +#define MYNEWT_VAL_BLE_PUBLIC_DEV_ADDR (((uint8_t[6]){0xcc, 0xbb, 0xaa, 0x33, 0x22, 0x11})) +#endif + +#ifndef MYNEWT_VAL_BLE_XTAL_SETTLE_TIME +#define MYNEWT_VAL_BLE_XTAL_SETTLE_TIME (1500) +#endif + +/*** nimble/drivers/nrf52 */ +#ifndef MYNEWT_VAL_BLE_PHY_CODED_RX_IFS_EXTRA_MARGIN +#define MYNEWT_VAL_BLE_PHY_CODED_RX_IFS_EXTRA_MARGIN (0) +#endif + +#ifndef MYNEWT_VAL_BLE_PHY_DBG_TIME_ADDRESS_END_PIN +#define MYNEWT_VAL_BLE_PHY_DBG_TIME_ADDRESS_END_PIN (-1) +#endif + +#ifndef MYNEWT_VAL_BLE_PHY_DBG_TIME_TXRXEN_READY_PIN +#define MYNEWT_VAL_BLE_PHY_DBG_TIME_TXRXEN_READY_PIN (-1) +#endif + +#ifndef MYNEWT_VAL_BLE_PHY_DBG_TIME_WFR_PIN +#define MYNEWT_VAL_BLE_PHY_DBG_TIME_WFR_PIN (-1) +#endif + +#ifndef MYNEWT_VAL_BLE_PHY_NRF52840_ERRATA_164 +#define MYNEWT_VAL_BLE_PHY_NRF52840_ERRATA_164 (0) +#endif + +#ifndef MYNEWT_VAL_BLE_PHY_NRF52840_ERRATA_191 +#define MYNEWT_VAL_BLE_PHY_NRF52840_ERRATA_191 (1) +#endif + +#ifndef MYNEWT_VAL_BLE_PHY_SYSVIEW +#define MYNEWT_VAL_BLE_PHY_SYSVIEW (0) +#endif + +/*** nimble/host */ +#ifndef MYNEWT_VAL_BLE_ATT_PREFERRED_MTU +#define MYNEWT_VAL_BLE_ATT_PREFERRED_MTU (256) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_FIND_INFO +#define MYNEWT_VAL_BLE_ATT_SVR_FIND_INFO (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_FIND_TYPE +#define MYNEWT_VAL_BLE_ATT_SVR_FIND_TYPE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_INDICATE +#define MYNEWT_VAL_BLE_ATT_SVR_INDICATE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_MAX_PREP_ENTRIES +#define MYNEWT_VAL_BLE_ATT_SVR_MAX_PREP_ENTRIES (64) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_NOTIFY +#define MYNEWT_VAL_BLE_ATT_SVR_NOTIFY (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE +#define MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE_TMO +#define MYNEWT_VAL_BLE_ATT_SVR_QUEUED_WRITE_TMO (30000) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ +#define MYNEWT_VAL_BLE_ATT_SVR_READ (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ_BLOB +#define MYNEWT_VAL_BLE_ATT_SVR_READ_BLOB (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ_GROUP_TYPE +#define MYNEWT_VAL_BLE_ATT_SVR_READ_GROUP_TYPE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ_MULT +#define MYNEWT_VAL_BLE_ATT_SVR_READ_MULT (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_READ_TYPE +#define MYNEWT_VAL_BLE_ATT_SVR_READ_TYPE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_SIGNED_WRITE +#define MYNEWT_VAL_BLE_ATT_SVR_SIGNED_WRITE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_WRITE +#define MYNEWT_VAL_BLE_ATT_SVR_WRITE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_ATT_SVR_WRITE_NO_RSP +#define MYNEWT_VAL_BLE_ATT_SVR_WRITE_NO_RSP (1) +#endif + +#ifndef MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE +#define MYNEWT_VAL_BLE_GAP_MAX_PENDING_CONN_PARAM_UPDATE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_DISC_ALL_CHRS +#define MYNEWT_VAL_BLE_GATT_DISC_ALL_CHRS (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_DISC_ALL_DSCS +#define MYNEWT_VAL_BLE_GATT_DISC_ALL_DSCS (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_DISC_ALL_SVCS +#define MYNEWT_VAL_BLE_GATT_DISC_ALL_SVCS (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_DISC_CHR_UUID +#define MYNEWT_VAL_BLE_GATT_DISC_CHR_UUID (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_DISC_SVC_UUID +#define MYNEWT_VAL_BLE_GATT_DISC_SVC_UUID (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_FIND_INC_SVCS +#define MYNEWT_VAL_BLE_GATT_FIND_INC_SVCS (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_INDICATE +#define MYNEWT_VAL_BLE_GATT_INDICATE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_MAX_PROCS +#define MYNEWT_VAL_BLE_GATT_MAX_PROCS (4) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_NOTIFY +#define MYNEWT_VAL_BLE_GATT_NOTIFY (1) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_READ +#define MYNEWT_VAL_BLE_GATT_READ (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_READ_LONG +#define MYNEWT_VAL_BLE_GATT_READ_LONG (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_READ_MAX_ATTRS +#define MYNEWT_VAL_BLE_GATT_READ_MAX_ATTRS (8) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_READ_MULT +#define MYNEWT_VAL_BLE_GATT_READ_MULT (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_READ_UUID +#define MYNEWT_VAL_BLE_GATT_READ_UUID (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_RESUME_RATE +#define MYNEWT_VAL_BLE_GATT_RESUME_RATE (1000) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_SIGNED_WRITE +#define MYNEWT_VAL_BLE_GATT_SIGNED_WRITE (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_WRITE +#define MYNEWT_VAL_BLE_GATT_WRITE (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_WRITE_LONG +#define MYNEWT_VAL_BLE_GATT_WRITE_LONG (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_WRITE_MAX_ATTRS +#define MYNEWT_VAL_BLE_GATT_WRITE_MAX_ATTRS (4) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_WRITE_NO_RSP +#define MYNEWT_VAL_BLE_GATT_WRITE_NO_RSP (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_GATT_WRITE_RELIABLE +#define MYNEWT_VAL_BLE_GATT_WRITE_RELIABLE (MYNEWT_VAL_BLE_ROLE_CENTRAL) +#endif + +#ifndef MYNEWT_VAL_BLE_HOST +#define MYNEWT_VAL_BLE_HOST (1) +#endif + +#ifndef MYNEWT_VAL_BLE_HS_AUTO_START +#define MYNEWT_VAL_BLE_HS_AUTO_START (1) +#endif + +#ifndef MYNEWT_VAL_BLE_HS_DEBUG +#define MYNEWT_VAL_BLE_HS_DEBUG (0) +#endif + +#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL +#define MYNEWT_VAL_BLE_HS_FLOW_CTRL (0) +#endif + +#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_ITVL +#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_ITVL (1000) +#endif + +#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_THRESH +#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_THRESH (2) +#endif + +#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_TX_ON_DISCONNECT +#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_TX_ON_DISCONNECT (0) +#endif + +#ifndef MYNEWT_VAL_BLE_HS_PHONY_HCI_ACKS +#define MYNEWT_VAL_BLE_HS_PHONY_HCI_ACKS (0) +#endif + +#ifndef MYNEWT_VAL_BLE_HS_REQUIRE_OS +#define MYNEWT_VAL_BLE_HS_REQUIRE_OS (1) +#endif + +#ifndef MYNEWT_VAL_BLE_HS_STOP_ON_SHUTDOWN +#define MYNEWT_VAL_BLE_HS_STOP_ON_SHUTDOWN (1) +#endif + +#ifndef MYNEWT_VAL_BLE_HS_SYSINIT_STAGE +#define MYNEWT_VAL_BLE_HS_SYSINIT_STAGE (200) +#endif + +#ifndef MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM +#define MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM (0) +#endif + +#ifndef MYNEWT_VAL_BLE_L2CAP_COC_MTU +#define MYNEWT_VAL_BLE_L2CAP_COC_MTU (MYNEWT_VAL_MSYS_1_BLOCK_SIZE-8) +#endif + +#ifndef MYNEWT_VAL_BLE_L2CAP_JOIN_RX_FRAGS +#define MYNEWT_VAL_BLE_L2CAP_JOIN_RX_FRAGS (1) +#endif + +#ifndef MYNEWT_VAL_BLE_L2CAP_MAX_CHANS +#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS (3*MYNEWT_VAL_BLE_MAX_CONNECTIONS) +#endif + +#ifndef MYNEWT_VAL_BLE_L2CAP_RX_FRAG_TIMEOUT +#define MYNEWT_VAL_BLE_L2CAP_RX_FRAG_TIMEOUT (30000) +#endif + +#ifndef MYNEWT_VAL_BLE_L2CAP_SIG_MAX_PROCS +#define MYNEWT_VAL_BLE_L2CAP_SIG_MAX_PROCS (1) +#endif + +/* nimble-mesh */ +#ifndef MYNEWT_VAL_BLE_MESH +#define MYNEWT_VAL_BLE_MESH (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MONITOR_CONSOLE_BUFFER_SIZE +#define MYNEWT_VAL_BLE_MONITOR_CONSOLE_BUFFER_SIZE (128) +#endif + +#ifndef MYNEWT_VAL_BLE_MONITOR_RTT +#define MYNEWT_VAL_BLE_MONITOR_RTT (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MONITOR_RTT_BUFFERED +#define MYNEWT_VAL_BLE_MONITOR_RTT_BUFFERED (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MONITOR_RTT_BUFFER_NAME +#define MYNEWT_VAL_BLE_MONITOR_RTT_BUFFER_NAME ("monitor") +#endif + +#ifndef MYNEWT_VAL_BLE_MONITOR_RTT_BUFFER_SIZE +#define MYNEWT_VAL_BLE_MONITOR_RTT_BUFFER_SIZE (256) +#endif + +#ifndef MYNEWT_VAL_BLE_MONITOR_UART +#define MYNEWT_VAL_BLE_MONITOR_UART (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MONITOR_UART_BAUDRATE +#define MYNEWT_VAL_BLE_MONITOR_UART_BAUDRATE (1000000) +#endif + +#ifndef MYNEWT_VAL_BLE_MONITOR_UART_BUFFER_SIZE +#define MYNEWT_VAL_BLE_MONITOR_UART_BUFFER_SIZE (64) +#endif + +#ifndef MYNEWT_VAL_BLE_MONITOR_UART_DEV +#define MYNEWT_VAL_BLE_MONITOR_UART_DEV ("uart0") +#endif + +#ifndef MYNEWT_VAL_BLE_RPA_TIMEOUT +#define MYNEWT_VAL_BLE_RPA_TIMEOUT (300) +#endif + +#ifndef MYNEWT_VAL_BLE_SM_BONDING +#define MYNEWT_VAL_BLE_SM_BONDING (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SM_IO_CAP +#define MYNEWT_VAL_BLE_SM_IO_CAP (BLE_HS_IO_NO_INPUT_OUTPUT) +#endif + +#ifndef MYNEWT_VAL_BLE_SM_KEYPRESS +#define MYNEWT_VAL_BLE_SM_KEYPRESS (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SM_LEGACY +#define MYNEWT_VAL_BLE_SM_LEGACY (1) +#endif + +#ifndef MYNEWT_VAL_BLE_SM_MAX_PROCS +#define MYNEWT_VAL_BLE_SM_MAX_PROCS (1) +#endif + +#ifndef MYNEWT_VAL_BLE_SM_MITM +#define MYNEWT_VAL_BLE_SM_MITM (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SM_OOB_DATA_FLAG +#define MYNEWT_VAL_BLE_SM_OOB_DATA_FLAG (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SM_OUR_KEY_DIST +#define MYNEWT_VAL_BLE_SM_OUR_KEY_DIST (0) +#endif + +/* nimble-host */ +#ifndef MYNEWT_VAL_BLE_SM_SC +#define MYNEWT_VAL_BLE_SM_SC (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS +#define MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SM_THEIR_KEY_DIST +#define MYNEWT_VAL_BLE_SM_THEIR_KEY_DIST (0) +#endif + +#ifndef MYNEWT_VAL_BLE_STORE_MAX_BONDS +#define MYNEWT_VAL_BLE_STORE_MAX_BONDS (3) +#endif + +#ifndef MYNEWT_VAL_BLE_STORE_MAX_CCCDS +#define MYNEWT_VAL_BLE_STORE_MAX_CCCDS (8) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_ADV_BUF_COUNT +#define MYNEWT_VAL_BLE_MESH_ADV_BUF_COUNT (20) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_ADV_TASK_PRIO +#define MYNEWT_VAL_BLE_MESH_ADV_TASK_PRIO (9) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_APP_KEY_COUNT +#define MYNEWT_VAL_BLE_MESH_APP_KEY_COUNT (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_CFG_CLI +#define MYNEWT_VAL_BLE_MESH_CFG_CLI (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_CRPL +#define MYNEWT_VAL_BLE_MESH_CRPL (10) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG +#define MYNEWT_VAL_BLE_MESH_DEBUG (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_ACCESS +#define MYNEWT_VAL_BLE_MESH_DEBUG_ACCESS (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_ADV +#define MYNEWT_VAL_BLE_MESH_DEBUG_ADV (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_BEACON +#define MYNEWT_VAL_BLE_MESH_DEBUG_BEACON (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_CRYPTO +#define MYNEWT_VAL_BLE_MESH_DEBUG_CRYPTO (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_FRIEND +#define MYNEWT_VAL_BLE_MESH_DEBUG_FRIEND (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_LOW_POWER +#define MYNEWT_VAL_BLE_MESH_DEBUG_LOW_POWER (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_MODEL +#define MYNEWT_VAL_BLE_MESH_DEBUG_MODEL (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_NET +#define MYNEWT_VAL_BLE_MESH_DEBUG_NET (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_PROV +#define MYNEWT_VAL_BLE_MESH_DEBUG_PROV (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_PROXY +#define MYNEWT_VAL_BLE_MESH_DEBUG_PROXY (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_SETTINGS +#define MYNEWT_VAL_BLE_MESH_DEBUG_SETTINGS (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEBUG_TRANS +#define MYNEWT_VAL_BLE_MESH_DEBUG_TRANS (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEVICE_NAME +#define MYNEWT_VAL_BLE_MESH_DEVICE_NAME ("nimble-mesh-node") +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_DEV_UUID +#define MYNEWT_VAL_BLE_MESH_DEV_UUID (((uint8_t[16]){0xdd, 0xdd, 0})) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_FRIEND +#define MYNEWT_VAL_BLE_MESH_FRIEND (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_FRIEND_LPN_COUNT +#define MYNEWT_VAL_BLE_MESH_FRIEND_LPN_COUNT (2) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_FRIEND_QUEUE_SIZE +#define MYNEWT_VAL_BLE_MESH_FRIEND_QUEUE_SIZE (16) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_FRIEND_RECV_WIN +#define MYNEWT_VAL_BLE_MESH_FRIEND_RECV_WIN (255) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_FRIEND_SEG_RX +#define MYNEWT_VAL_BLE_MESH_FRIEND_SEG_RX (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_FRIEND_SUB_LIST_SIZE +#define MYNEWT_VAL_BLE_MESH_FRIEND_SUB_LIST_SIZE (3) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_GATT_PROXY +#define MYNEWT_VAL_BLE_MESH_GATT_PROXY (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_HEALTH_CLI +#define MYNEWT_VAL_BLE_MESH_HEALTH_CLI (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_IVU_DIVIDER +#define MYNEWT_VAL_BLE_MESH_IVU_DIVIDER (4) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_IV_UPDATE_TEST +#define MYNEWT_VAL_BLE_MESH_IV_UPDATE_TEST (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LABEL_COUNT +#define MYNEWT_VAL_BLE_MESH_LABEL_COUNT (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LOW_POWER +#define MYNEWT_VAL_BLE_MESH_LOW_POWER (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_AUTO +#define MYNEWT_VAL_BLE_MESH_LPN_AUTO (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_AUTO_TIMEOUT +#define MYNEWT_VAL_BLE_MESH_LPN_AUTO_TIMEOUT (15) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_ESTABLISHMENT +#define MYNEWT_VAL_BLE_MESH_LPN_ESTABLISHMENT (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_GROUPS +#define MYNEWT_VAL_BLE_MESH_LPN_GROUPS (10) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_INIT_POLL_TIMEOUT +#define MYNEWT_VAL_BLE_MESH_LPN_INIT_POLL_TIMEOUT (MYNEWT_VAL_BLE_MESH_LPN_POLL_TIMEOUT) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_MIN_QUEUE_SIZE +#define MYNEWT_VAL_BLE_MESH_LPN_MIN_QUEUE_SIZE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_POLL_TIMEOUT +#define MYNEWT_VAL_BLE_MESH_LPN_POLL_TIMEOUT (300) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_RECV_DELAY +#define MYNEWT_VAL_BLE_MESH_LPN_RECV_DELAY (100) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_RECV_WIN_FACTOR +#define MYNEWT_VAL_BLE_MESH_LPN_RECV_WIN_FACTOR (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_RETRY_TIMEOUT +#define MYNEWT_VAL_BLE_MESH_LPN_RETRY_TIMEOUT (8) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_RSSI_FACTOR +#define MYNEWT_VAL_BLE_MESH_LPN_RSSI_FACTOR (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_LPN_SCAN_LATENCY +#define MYNEWT_VAL_BLE_MESH_LPN_SCAN_LATENCY (10) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_MODEL_GROUP_COUNT +#define MYNEWT_VAL_BLE_MESH_MODEL_GROUP_COUNT (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_MODEL_KEY_COUNT +#define MYNEWT_VAL_BLE_MESH_MODEL_KEY_COUNT (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_MSG_CACHE_SIZE +#define MYNEWT_VAL_BLE_MESH_MSG_CACHE_SIZE (10) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_NODE_ID_TIMEOUT +#define MYNEWT_VAL_BLE_MESH_NODE_ID_TIMEOUT (60) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_OOB_INPUT_ACTIONS +#define MYNEWT_VAL_BLE_MESH_OOB_INPUT_ACTIONS (((BT_MESH_NO_INPUT))) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_OOB_INPUT_SIZE +#define MYNEWT_VAL_BLE_MESH_OOB_INPUT_SIZE (4) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_OOB_OUTPUT_ACTIONS +#define MYNEWT_VAL_BLE_MESH_OOB_OUTPUT_ACTIONS (((BT_MESH_DISPLAY_NUMBER))) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_OOB_OUTPUT_SIZE +#define MYNEWT_VAL_BLE_MESH_OOB_OUTPUT_SIZE (4) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_PB_ADV +#define MYNEWT_VAL_BLE_MESH_PB_ADV (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_PB_GATT +#define MYNEWT_VAL_BLE_MESH_PB_GATT (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_PROV +#define MYNEWT_VAL_BLE_MESH_PROV (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_PROXY +#define MYNEWT_VAL_BLE_MESH_PROXY (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_PROXY_FILTER_SIZE +#define MYNEWT_VAL_BLE_MESH_PROXY_FILTER_SIZE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_RELAY +#define MYNEWT_VAL_BLE_MESH_RELAY (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_RPL_STORE_TIMEOUT +#define MYNEWT_VAL_BLE_MESH_RPL_STORE_TIMEOUT (5) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_RX_SDU_MAX +#define MYNEWT_VAL_BLE_MESH_RX_SDU_MAX (72) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_RX_SEG_MSG_COUNT +#define MYNEWT_VAL_BLE_MESH_RX_SEG_MSG_COUNT (2) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_SEQ_STORE_RATE +#define MYNEWT_VAL_BLE_MESH_SEQ_STORE_RATE (128) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_SETTINGS +#define MYNEWT_VAL_BLE_MESH_SETTINGS (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_SHELL +#define MYNEWT_VAL_BLE_MESH_SHELL (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_SHELL_MODELS +#define MYNEWT_VAL_BLE_MESH_SHELL_MODELS (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_STORE_TIMEOUT +#define MYNEWT_VAL_BLE_MESH_STORE_TIMEOUT (2) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_SUBNET_COUNT +#define MYNEWT_VAL_BLE_MESH_SUBNET_COUNT (1) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_SYSINIT_STAGE +#define MYNEWT_VAL_BLE_MESH_SYSINIT_STAGE (500) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_SYSINIT_STAGE_SHELL +#define MYNEWT_VAL_BLE_MESH_SYSINIT_STAGE_SHELL (1000) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_TESTING +#define MYNEWT_VAL_BLE_MESH_TESTING (0) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_MAX +#define MYNEWT_VAL_BLE_MESH_TX_SEG_MAX (6) +#endif + +#ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_MSG_COUNT +#define MYNEWT_VAL_BLE_MESH_TX_SEG_MSG_COUNT (4) +#endif + +/*** nimble/host/services/ans */ +#ifndef MYNEWT_VAL_BLE_SVC_ANS_NEW_ALERT_CAT +#define MYNEWT_VAL_BLE_SVC_ANS_NEW_ALERT_CAT (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_ANS_UNR_ALERT_CAT +#define MYNEWT_VAL_BLE_SVC_ANS_UNR_ALERT_CAT (0) +#endif + +/*** nimble/host/services/bas */ +#ifndef MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE +#define MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_NOTIFY_ENABLE (1) +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_READ_PERM +#define MYNEWT_VAL_BLE_SVC_BAS_BATTERY_LEVEL_READ_PERM (0) +#endif + +/*** nimble/host/services/gap */ +#ifndef MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE +#define MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE_WRITE_PERM +#define MYNEWT_VAL_BLE_SVC_GAP_APPEARANCE_WRITE_PERM (-1) +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION +#define MYNEWT_VAL_BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION (-1) +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME +#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME ("nimble") +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH +#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH (31) +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_WRITE_PERM +#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_WRITE_PERM (-1) +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL +#define MYNEWT_VAL_BLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_GAP_PPCP_MIN_CONN_INTERVAL +#define MYNEWT_VAL_BLE_SVC_GAP_PPCP_MIN_CONN_INTERVAL (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_GAP_PPCP_SLAVE_LATENCY +#define MYNEWT_VAL_BLE_SVC_GAP_PPCP_SLAVE_LATENCY (0) +#endif + +#ifndef MYNEWT_VAL_BLE_SVC_GAP_PPCP_SUPERVISION_TMO +#define MYNEWT_VAL_BLE_SVC_GAP_PPCP_SUPERVISION_TMO (0) +#endif + +/*** nimble/transport */ +#ifndef MYNEWT_VAL_BLE_HCI_TRANSPORT_EMSPI +#define MYNEWT_VAL_BLE_HCI_TRANSPORT_EMSPI (0) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_TRANSPORT_NIMBLE_BUILTIN +#define MYNEWT_VAL_BLE_HCI_TRANSPORT_NIMBLE_BUILTIN (1) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_TRANSPORT_RAM +#define MYNEWT_VAL_BLE_HCI_TRANSPORT_RAM (0) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_TRANSPORT_SOCKET +#define MYNEWT_VAL_BLE_HCI_TRANSPORT_SOCKET (0) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_TRANSPORT_UART +#define MYNEWT_VAL_BLE_HCI_TRANSPORT_UART (0) +#endif + +/*** nimble/transport/ram */ +#ifndef MYNEWT_VAL_BLE_ACL_BUF_COUNT +#define MYNEWT_VAL_BLE_ACL_BUF_COUNT (4) +#endif + +#ifndef MYNEWT_VAL_BLE_ACL_BUF_SIZE +#define MYNEWT_VAL_BLE_ACL_BUF_SIZE (255) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_EVT_BUF_SIZE +#define MYNEWT_VAL_BLE_HCI_EVT_BUF_SIZE (70) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_EVT_HI_BUF_COUNT +#define MYNEWT_VAL_BLE_HCI_EVT_HI_BUF_COUNT (2) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_EVT_LO_BUF_COUNT +#define MYNEWT_VAL_BLE_HCI_EVT_LO_BUF_COUNT (8) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_UART_BAUD +#define MYNEWT_VAL_BLE_HCI_UART_BAUD (115200) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_UART_DATA_BITS +#define MYNEWT_VAL_BLE_HCI_UART_DATA_BITS (8) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_UART_FLOW_CTRL +#define MYNEWT_VAL_BLE_HCI_UART_FLOW_CTRL (0) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_UART_PARITY +#define MYNEWT_VAL_BLE_HCI_UART_PARITY (HAL_UART_PARITY_NONE) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_UART_PORT +#define MYNEWT_VAL_BLE_HCI_UART_PORT (0) +#endif + +#ifndef MYNEWT_VAL_BLE_HCI_UART_STOP_BITS +#define MYNEWT_VAL_BLE_HCI_UART_STOP_BITS (1) +#endif + +#endif + +////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////// + +#endif + diff --git a/components/connectivity/qcloud_iot_explorer_ble/.clang-format b/components/connectivity/qcloud_iot_explorer_ble/.clang-format new file mode 100644 index 00000000..c0737607 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/.clang-format @@ -0,0 +1,10 @@ +BasedOnStyle: Google +BreakBeforeBraces: Linux +AlignConsecutiveDeclarations: true +AlignConsecutiveMacros: true +AlignConsecutiveAssignments: true +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: false +SortIncludes: false +IndentWidth: 4 +ColumnLimit: 120 diff --git a/components/connectivity/qcloud_iot_explorer_ble/.gitignore b/components/connectivity/qcloud_iot_explorer_ble/.gitignore new file mode 100644 index 00000000..7e4ce942 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/.gitignore @@ -0,0 +1,4 @@ +/test/build/ +/test/cmake-build-debug/ +/.idea/ +/test/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/LICENSE b/components/connectivity/qcloud_iot_explorer_ble/LICENSE new file mode 100644 index 00000000..0b158c9f --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/LICENSE @@ -0,0 +1,31 @@ +Tencent is pleased to support the open source community by making IoT Hub available. + +Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. + +If you have downloaded a copy of the IoT Hub binary from Tencent, please note that the IoT Hub binary is licensed under the MIT License. + +If you have downloaded a copy of the IoT Hub source code from Tencent, please note that IoT Hub source code is licensed under the MIT License, + +except for the third-party components listed below which are subject to different license terms. Your integration of IoT Hub into your own projects may require compliance with the MIT License, + +as well as the other licenses applicable to the third-party components included within IoT Hub. + +A copy of the MIT License is included in this file. + +Open Source Software Licensed under the MIT License: The below software in this distribution may have been modified by Tencent (“Tencent Modifications”). All Tencent Modifications are Copyright (C) 2016 THL A29 Limited. +-------------------------------------------------------------------- +1. cpp-feather-ini-parser 1.42 +Copyright (c) 2014 Turbine1991 + +2. Dirent 1.22 +Copyright (c) 2015 Toni Rönkkö + + +Terms of the MIT License: +-------------------------------------------------------------------- + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/components/connectivity/qcloud_iot_explorer_ble/config/ble_qiot_config.h b/components/connectivity/qcloud_iot_explorer_ble/config/ble_qiot_config.h new file mode 100644 index 00000000..f14538e2 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/config/ble_qiot_config.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_QIOT_CONFIG_H +#define QCLOUD_BLE_QIOT_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define BLE_QIOT_SDK_VERSION "1.2.0" // sdk version +#define BLE_QIOT_SDK_DEBUG 0 // sdk debug switch + +// the device broadcast is controlled by the user, but we provide a mechanism to help the device save more power. +// if you want broadcast is triggered by something like press a button instead of all the time, and the broadcast +// stopped automatically in a few minutes if the device is not bind, define BLE_QIOT_BUTTON_BROADCAST is 1 and +// BLE_QIOT_BIND_TIMEOUT is the period that broadcast stopped. +// if the device in the bound state, broadcast dose not stop automatically. +#define BLE_QIOT_BUTTON_BROADCAST 1 +#if (1 == BLE_QIOT_BUTTON_BROADCAST) +#define BLE_QIOT_BIND_TIMEOUT (2 * 60 * 1000) // unit: ms +#endif + +// some data like integer need to be transmitted in a certain byte order, defined it according to your device +#define __ORDER_LITTLE_ENDIAN__ 1234 +#define __ORDER_BIG_ENDIAN__ 4321 +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ + +// in some BLE stack ble_qiot_log_hex() maybe not work, user can use there own hexdump function +#define BLE_QIOT_USER_DEFINE_HEDUMP 0 + +#if (1 == BLE_QIOT_USER_DEFINE_HEDUMP) +// add your code here like this +// #define ble_qiot_log_hex(level, hex_name, data, data_len) \ +// do { \ +// MY_RAW_LOG("\r\nble qiot dump: %s, length: %d\r\n", hex_name, data_len); \ +// MY_RAW_HEXDUMP_(data, data_len); \ +// } while(0) + +// or use your own hexdump function with same definition +// void ble_qiot_log_hex(e_ble_qiot_log_level level, const char *hex_name, const char *data, uint32_t data_len); +#endif // BLE_QIOT_USER_DEFINE_HEDUMP + +// Macro for logging a formatted string, the function must printf raw string without any color, prefix, newline or +// timestamp +#define BLE_QIOT_LOG_PRINT(...) printf(__VA_ARGS__) + +// some sdk info needs to stored on the device and the address is up to you +#define BLE_QIOT_RECORD_FLASH_ADDR 0x3f000 + +// the following definition will affect the stack that LLSync used,the minimum value tested is +// 2048(BLE_QIOT_EVENT_MAX_SIZE is 128, BLE_QIOT_EVENT_BUF_SIZE is 23 ) the max length that llsync event data, depends +// on the length of user data reported to Tencent Lianlian at a time +#define BLE_QIOT_EVENT_MAX_SIZE (128) +// the minimum between BLE_QIOT_EVENT_MAX_SIZE and mtu +#define BLE_QIOT_EVENT_BUF_SIZE (23) + +#ifdef __cplusplus +} +#endif + +#endif // QCLOUD_BLE_QIOT_CONFIG_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/docs/LLSync SDK 接入指引.md b/components/connectivity/qcloud_iot_explorer_ble/docs/LLSync SDK 接入指引.md new file mode 100644 index 00000000..79773f3f --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/docs/LLSync SDK 接入指引.md @@ -0,0 +1,123 @@ +# 1 概述 + +本文档介绍如何将 LLSync SDK 移植到目标硬件平台。 + +# 2 接入指引 + +一般情况下,各平台接入 LLSync SDK 可以分为两个步骤: + +## 2.1 硬件抽象层移植 + +`ble_qiot_import.h`中列出了所有需要开发者适配的接口,开发者可以参考函数描述在硬件平台上做具体实现。 + +### 2.1.1 设备接口适配 + +| 序号 | 函数 | 说明 | +| :--: | :-----------------: | :----------------------------------: | +| 1 | ble_get_product_id | 获取设备三元信息之产品ID | +| 2 | ble_get_device_name | 获取设备三元信息之设备名称 | +| 3 | ble_get_psk | 获取设备三元信息之设备密钥 | +| 4 | ble_get_mac | 获取设备蓝牙MAC地址 | +| 5 | ble_write_flash | SDK 需要存储内部信息到设备存储介质 | +| 6 | ble_read_flash | SDK 需要从设备存储介质读取存储的信息 | +| 7 | 定时器接口 | 定时器类接口 | + +1. 设备三元信息在 [物联网开发平台](https://cloud.tencent.com/product/iotexplorer) 新建产品并创建设备后通过 [查看设备信息](https://cloud.tencent.com/document/product/1081/34741#.E6.9F.A5.E7.9C.8B.E8.AE.BE.E5.A4.87.E4.BF.A1.E6.81.AF) 获取。开发者需要负责信息存储,存储介质不做限制,开发阶段可以将三元信息保存在代码中,量产阶段可以将信息存储在片上 flash、片外 flash、eeprom等或带有文件系统的存储介质中,方便量产烧录。 +2. 不同的蓝牙协议栈获取到的 mac 地址字节序可能不同,适配该接口时可能需要进行转换。LLSync 使用大端方式存储,即 mac 地址的第 0 字节存储在低地址,mac 地址的第 5 字节存储在高地址,一般与阅读顺序相同。 +3. SDK 需要存储约 20 字节数据到 flash 中,存储介质不做限制,存储地址由开发者划分,通过宏`BLE_QIOT_RECORD_FLASH_ADDR`指定;若开发者使用文件系统保存SDK数据,不涉及存储地址时宏`BLE_QIOT_RECORD_FLASH_ADDR`可设置为 0。 +4. ble_write_flash() 接口只负责数据写入,擦除、读写平衡等需由开发者在合适的时机进行,例如在写入前进行擦除,写入完成后回收旧page等。 +5. 当使用定时广播功能时,需要实现定时器类接口。若不使用定时广播功能,定时器类接口可以实现为桩函数。 + +### 2.1.2 BLE 协议栈适配 + +| 序号 | 函数 | 说明 | +| :--: | :------------------------: | :-----------------------------: | +| 1 | ble_services_add | 添加 LLSync 服务到 BLE 协议栈 | +| 2 | ble_advertising_start | 开始广播接口 | +| 2 | ble_advertising_stop | 停止广播接口 | +| 4 | ble_send_notify | 向 UUID FFE3写入通知 | +| 5 | ble_get_user_data_mtu_size | 获取向 UUID FFE3 写入数据的最大长度 | + +1. LLsync SDK 定义了若干 BLE attribute characteristic,LLSync SDK 初始化时会调用 ble_services_add() 将其加入 BLE 协议栈。具体服务可以通过 ble_qiot_export.h 的 ble_get_qiot_services() 获取。如果蓝牙协议栈不支持动态添加蓝牙服务,也可以参考 `service_info` 结构体静态蓝牙服务。对于每一个attribute characteristic value max length开发者需要保证大于等于蓝牙协议栈支持的mtu大小,以免造成数据丢失、指针越界等问题。 +2. LLSync 规定了广播数据的格式,开发者需要通过 BLE 协议栈将传入的数据广播出去,微信小程序依赖广播数据发现并连接设备。广播数据包含两种类型,分别是 `0x02 ` 或 `0x03 ` 和 `0xFF < Manufacturer Specific Data>`。 +3. 开发者可以根据实际情况选择使用 `0x02` 或 `0x03` 类型广播UUID,UUID中必须包含 `#define IOT_BLE_UUID_SERVICE 0xFFE0`,如有需开发者也可以加入自己私有的 service UUID。 +4. Manufacturer Specific Data 广播类型包含 company identifier在内一共为 17 字节。如果开发者需要广播设备名等其他信息,只使用广播包很可能放不下,此时可以使用广播扫描回应包携带更多广播数据。 +5. LLSync 规定了数据的最大长度为2048字节,SDK 实现了数据的分片发送,连续多次调用`ble_send_notify`将数据发送出去。SDK 内没有做数据重传处理,因此开发者需要保证数据的发送成功。 + +## 2.2 数据模版代码生成 + +1. 开发者在物联网开发平台创建设备,定义 [数据模版](https://cloud.tencent.com/document/product/1081/34916) + +2. 通过脚本将数据模版转换为C代码 + + ```c + iot@iot-MB0 scripts % python3 interpret_json_dt/src/interpret_dt_ble.py interpret_json_dt/example.json + reading json file start + reading json file end + generate header file start + generate header file end + generate source file start + generate source file end + ``` + +3. 拷贝生成的`ble_qiot_template.c`和`ble_qiot_template.h`到用户代码文件夹。 + +# 3 应用开发 + +## 3.1 SDK配置 + +拷贝`ble_qiot_config.h`到用户代码文件夹,并做简单配置。 + +1. `BLE_QIOT_RECORD_FLASH_ADDR`是 SDK 数据的存储地址。 +2. `__BYTE_ORDER__`是设备的大小端定义。 +3. SDK 支持定时广播。定义`BLE_QIOT_BUTTON_BROADCAST`为1,当设备在未绑定状态下开始广播时,经过`BLE_QIOT_BUTTON_BROADCAST`定义的时间后广播自动停止。设备处于绑定状态时不支持定时广播功能。 +4. 适配 SDK 的log输出接口 `#define BLE_QIOT_LOG_PRINT(...) printf(__VA_ARGS__)`,根据实际情况将 printf 替换为自己的打印函数。由于部分蓝牙协议栈特殊的缓存机制,LLSync SDK 提供的 ble_qiot_log_hex() 可能无法正常工作,请将宏 `#define BLE_QIOT_USER_DEFINE_HEDUMP 0` 打开,由用户自己实现 ble_qiot_log_hex() 接口。 +5. `BLE_QIOT_EVENT_MAX_SIZE`定义了设备端可以通过notify发送的最大数据量,用户可以通过减小此数值来优化堆栈。经测试,`BLE_QIOT_EVENT_MAX_SIZE`配置为128,`BLE_QIOT_EVENT_BUF_SIZE`配置为23时栈内存占用2k不到。 +6. `BLE_QIOT_EVENT_BUF_SIZE`配置为`BLE_QIOT_EVENT_MAX_SIZE`和MTU的最小值。 +## 3.2 例程代码抽取 + +SDK 已经适配了多个硬件平台,例程代码存储在`samples/nrf52832`目录下。开发者可以通过脚本将指定硬件平台的例程抽取出来,将抽取后的代码加入硬件平台进行编译。以`nordic 52832`示例: + +```c +iot@iot-MB0 code_extract % python3 code_extract.py nrf52832 +extract code for nrf52832 start, dest dir /iot/Desktop/work_code/qcloud_iot_explorer_ble/scripts/code_extract/qcloud-iot-ble-nrf52832 +extract code success +``` + +一般的,例程代码中会提供相应的`readme.md`文档说明如何编译。 + +## 3.3 数据模版开发 + +例程中`data_template`目录下包含了数据模版文件和转换后的 C 代码模版,开发者可以进行参考。 + +1. 对于数据模版中的`propertyies`,C 代码模版中给每个`id`生成了`ble_property_xxx_set`和`ble_property_xxx_get`两个接口。SDK 收到服务器下发的数据后通过`ble_property_xxx_set`传递给用户,开发者接收数据后进行处理。`ble_property_xxx_get`用于获取设备上的数据,SDK 负责将其上报到服务器。在`sg_ble_property_array`中定义了每个`id`的属性。 +2. 对于数据模版中的`events`,每个`event`有若干个`param`,C 代码模版中给每个`param`生成了一个`ble_event_get_xxx`接口,用于获取设备上的数据,SDK 负责将其上报到服务器。在`sg_ble_event_array`中定义了每个`event`的属性,每个`event`也有一个数组用来描述其包含的所有`param`的属性。 +3. 对于数据模版中的`actions`,每个`action`有若干个`inputid`和`outputid`,`inputid`中定义了服务器下发的数据,`outputid`中定义了设备上报的数据,C 代码模版中给每个`action`生成了`ble_action_handle_xxx_input_cb`和`ble_action_handle_xxx_output_cb`两个接口。SDK 收到服务器下发的数据后通过`ble_action_handle_xxx_input_cb`传递给用户,开发者接收数据后进行处理,处理结束后 SDK 通过`ble_action_handle_xxx_output_cb`获取用户反馈的数据上报到服务器。在`sg_ble_action_array`中定义了每个`action`的属性。 + +一般约定,用户数据以网络序进行传递,所以开发者需要做字节序转换。 + +## 3.4 API说明 + +在`ble_qiot_export.h`中提供了 API 函数,一般情况下用户只需要调用 API 函数即可完成应用开发。 + +| 序号 | 函数 | 说明 | +| :--: | :------------------------: | :----------------------------------------------------------: | +| 1 | ble_qiot_explorer_init | SDK 初始化 | +| 2 | ble_event_get_status | 获取数据模版最新信息,对应数据模版`get_status`方法 | +| 3 | ble_event_report_property | 上报设备最新信息,对应数据模版`report`方法 | +| 4 | ble_event_post | 上报事件,对应数据模版`event_post`方法 | +| 5 | ble_qiot_advertising_start | 开始广播,广播包内容请参考 ble_advertising_start | +| 6 | ble_qiot_advertising_stop | 停止广播 | +| 7 | ble_device_info_write_cb | UUID FFE1数据到达后调用此接口传入数据 | +| 8 | ble_lldata_write_cb | UUID FFE2数据到达后调用此接口传入数据 | +| 9 | ble_get_qiot_services | 获取需要加入协议栈的蓝牙服务 | +| 10 | ble_gap_connect_cb | 蓝牙设备连接时调用此接口通知SDK | +| 11 | ble_gap_disconnect_cb | 蓝牙设备断开连接时调用此接口通知SDK | + +# 4 LLSync 协议 + +请参见《LLSync蓝牙设备接入协议.pdf》 + +# 5 物联网开发平台使用帮助 + +参见 https://cloud.tencent.com/document/product/1081 diff --git a/components/connectivity/qcloud_iot_explorer_ble/docs/LLSync蓝牙设备接入协议.pdf b/components/connectivity/qcloud_iot_explorer_ble/docs/LLSync蓝牙设备接入协议.pdf new file mode 100644 index 00000000..73ad7d8c Binary files /dev/null and b/components/connectivity/qcloud_iot_explorer_ble/docs/LLSync蓝牙设备接入协议.pdf differ diff --git a/components/connectivity/qcloud_iot_explorer_ble/docs/连连Sync蓝牙设备接入协议1.0.0.docx b/components/connectivity/qcloud_iot_explorer_ble/docs/连连Sync蓝牙设备接入协议1.0.0.docx new file mode 100644 index 00000000..bae58f21 Binary files /dev/null and b/components/connectivity/qcloud_iot_explorer_ble/docs/连连Sync蓝牙设备接入协议1.0.0.docx differ diff --git a/components/connectivity/qcloud_iot_explorer_ble/docs/连连Sync蓝牙设备接入协议1.2.0.docx b/components/connectivity/qcloud_iot_explorer_ble/docs/连连Sync蓝牙设备接入协议1.2.0.docx new file mode 100644 index 00000000..424c1de5 Binary files /dev/null and b/components/connectivity/qcloud_iot_explorer_ble/docs/连连Sync蓝牙设备接入协议1.2.0.docx differ diff --git a/components/connectivity/qcloud_iot_explorer_ble/docs/连连Sync蓝牙设备接入协议1.2.0.pdf b/components/connectivity/qcloud_iot_explorer_ble/docs/连连Sync蓝牙设备接入协议1.2.0.pdf new file mode 100644 index 00000000..ae45fbdb Binary files /dev/null and b/components/connectivity/qcloud_iot_explorer_ble/docs/连连Sync蓝牙设备接入协议1.2.0.pdf differ diff --git a/components/connectivity/qcloud_iot_explorer_ble/inc/ble_qiot_export.h b/components/connectivity/qcloud_iot_explorer_ble/inc/ble_qiot_export.h new file mode 100644 index 00000000..d8b60315 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/inc/ble_qiot_export.h @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef QCLOUD_BLE_QIOT_EXPORT_H +#define QCLOUD_BLE_QIOT_EXPORT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include "ble_qiot_common.h" + +// Tencent Company ID +#define TENCENT_COMPANY_IDENTIFIER 0xFEE7 +#define TENCENT_COMPANY_IDENTIFIER2 0xFEBA + +#define IOT_BLE_UUID_BASE \ + { \ + 0xe2, 0xa4, 0x1b, 0x54, 0x93, 0xe4, 0x6a, 0xb5, 0x20, 0x4e, 0xd0, 0x65, 0x00, 0x00, 0x00, 0x00 \ + } + +// llsync services uuid +#define IOT_BLE_UUID_SERVICE 0xFFE0 + +// characteristics uuid +#define IOT_BLE_UUID_DEVICE_INFO 0xFFE1 // used to connection and identity authentication +#define IOT_BLE_UUID_DATA 0xFFE2 // used to send data to the device from server +#define IOT_BLE_UUID_EVENT 0xFFE3 // used to send data to the server from device + +typedef enum { + GATT_CHAR_BROADCAST = (1 << 0), // Broadcasting of the value permitted. + GATT_CHAR_READ = (1 << 1), // Reading the value permitted. + GATT_CHAR_WRITE_WO_RESP = (1 << 2), // Writing the value with Write Command permitted. + GATT_CHAR_WRITE = (1 << 3), // Writing the value with Write Request permitted. + GATT_CHAR_NOTIFY = (1 << 4), // Notification of the value permitted. + GATT_CHAR_INDICATE = (1 << 5), // Indications of the value permitted. + GATT_CHAR_AUTH_SIGNED_WR = (1 << 6), // Writing the value with Signed Write Command permitted. +} char_props_s; + +// the callback function prototype definition for the characteristics +typedef void (*ble_on_write_cb)(const uint8_t *buf, uint16_t len); + +// the characteristics attributes +typedef struct { + uint16_t uuid16; + uint8_t gatt_char_props; + ble_on_write_cb on_write; +} qiot_char_s; + +// the service attributes +typedef struct { + uint16_t service_uuid16; + uint8_t service_uuid128[16]; + uint16_t gatt_max_mtu; + + qiot_char_s device_info; + qiot_char_s data; + qiot_char_s event; +} qiot_service_init_s; + +typedef enum { + BLE_QIOT_RS_OK = 0, // success + BLE_QIOT_RS_ERR = -1, // normal error + BLE_QIOT_RS_ERR_FLASH = -2, // flash error + BLE_QIOT_RS_ERR_PARA = -3, // parameters error + BLE_QIOT_RS_VALID_SIGN_ERR = -4, +} ble_qiot_ret_status_t; + +/** + * @brief get llsync services context + * + * @return llsync services struct + */ +const qiot_service_init_s *ble_get_qiot_services(void); + +/** + * @brief llsync sdck initialize + * @note you should called it before any other sdk api + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_qiot_explorer_init(void); + +/** + * @brief get property of the device from the server + * @note the property will be received from IOT_BLE_UUID_DATA if success + * @return BLE_QIOT_RS_OK is success, other is error. if success, the data from server will come to + */ +ble_qiot_ret_status_t ble_event_get_status(void); + +/** + * @brief report property of the device to the server + * @note the reply will be received from IOT_BLE_UUID_DATA if success + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_event_report_property(void); + +/** + * @brief report mtu of the device to the server + * @note report mtu to the server for optimizing bandwidth usage. this mtu equals (ATT_MTU - 3) + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_event_report_device_info(void); + +/** + * @brief post event to the server + * @param event_id id of the event + * @note the reply will be received from IOT_BLE_UUID_DATA if success + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_event_post(uint8_t event_id); + +/** + * @brief start llsync advertising + * @note broadcast data according to the device bind state, reference to llsync protocol + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_qiot_advertising_start(void); + +/** + * @brief stop advertising + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_qiot_advertising_stop(void); + +/** + * @brief device info write callbcak, call the function when characteristic IOT_BLE_UUID_DEVICE_INFO received data + * @param buf a pointer point to the data + * @param len data length + * @return none + */ +void ble_device_info_write_cb(const uint8_t *buf, uint16_t len); + +/** + * @brief data write callback, call the function when characteristic IOT_BLE_UUID_DATA received data + * @param buf a pointer point to the data + * @param len data length + * @return none + */ +void ble_lldata_write_cb(const uint8_t *buf, uint16_t len); + +/** + * @brief gap event connect call-back, when gap get ble connect event, use this function + * tell qiot ble sdk + * @return none + */ +void ble_gap_connect_cb(void); + +/** + * @brief gap event disconnect call-back, when gap get ble disconnect event, use this function + * tell qiot ble sdk + * @return none + */ +void ble_gap_disconnect_cb(void); + +#ifdef __cplusplus +} +#endif +#endif // QCLOUD_BLE_QIOT_EXPORT_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/inc/ble_qiot_import.h b/components/connectivity/qcloud_iot_explorer_ble/inc/ble_qiot_import.h new file mode 100644 index 00000000..30ae3cf5 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/inc/ble_qiot_import.h @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef QCLOUD_BLE_QIOT_IMPORT_H +#define QCLOUD_BLE_QIOT_IMPORT_H + +#if defined(__cplusplus) +extern "C" { +#endif + +#include +#include "ble_qiot_export.h" + +// 16 bits service UUIDs list, use advertising type 0x02 or 0x03 +typedef struct +{ + uint8_t uuid_num; + uint16_t *uuids; +} uuid_list_s; + +// advertise manufacture specific data, use advertising type 0xFF +typedef struct +{ + uint16_t company_identifier; + uint8_t *adv_data; + uint8_t adv_data_len; +} manufacturer_data_s; + +typedef struct { + uuid_list_s uuid_info; + manufacturer_data_s manufacturer_info; +} adv_info_s; + +/** + * @brief get device product id + * @param product_id the buf storage product id, 10 bytes permanent + * @return 0 is success, other is error + */ +int ble_get_product_id(char *product_id); + +/** + * @brief get device name + * @param device_name the buf storage device name, the max length of the device name is 48 bytes + * @return length of device name, 0 is error + */ +int ble_get_device_name(char *device_name); + +/** + * @brief get device secret + * @param psk the buf storage secret, 24 bytes permanent + * @return 0 is success, other is error + */ +int ble_get_psk(char *psk); + +/** + * @brief get mac address + * @param mac the buf storage mac, 6 bytes permanent + * @return 0 is success, other is error + */ +int ble_get_mac(char *mac); + +/** + * @brief write data to flash + * @param flash_addr write address in flash + * @param write_buf point to write buf + * @param write_len length of data to write + * @return write_len is success, other is error + */ +int ble_write_flash(uint32_t flash_addr, const char *write_buf, uint16_t write_len); + +/** + * @brief read data from flash + * @param flash_addr read address from flash + * @param read_buf point to read buf + * @param read_len length of data to read + * @return read_len is success, other is error + */ +int ble_read_flash(uint32_t flash_addr, char *read_buf, uint16_t read_len); + +/** + * @brief add llsync services to ble stack + * @param qiot_service_init_s llsync service + * @return none + */ +void ble_services_add(const qiot_service_init_s *p_service); + +/** + * @brief start llsync advertising + * @param adv a pointer point to advertising data + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_advertising_start(adv_info_s *adv); + +/** + * @brief stop advertising + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_advertising_stop(void); + +/** + * @brief send a notification to host, use characteristic IOT_BLE_UUID_EVENT + * @param buf a pointer point to indication information + * @param len indication information length + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_send_notify(uint8_t *buf, uint8_t len); + +/** + * @brief get the max size of data that user can used, normally is ATT_MTU - 3 + * @return the value + */ +uint16_t ble_get_user_data_mtu_size(void); + +// timer type +enum { + BLE_TIMER_ONE_SHOT_TYPE = 0, + BLE_TIMER_PERIOD_TYPE, + BLE_TIMER_BUTT, +}; +typedef void *ble_timer_t; + +// timer callback prototype +typedef void (*ble_timer_cb)(void *param); + +/** + * @brief create a timer + * @param type timer type + * @param timeout_handle timer callback + * @return timer identifier is return, NULL is error + */ +ble_timer_t ble_timer_create(uint8_t type, ble_timer_cb timeout_handle); + +/** + * @brief start a timer + * @param timer_id Timer identifier + * @param period timer period(unit: ms) + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_timer_start(ble_timer_t timer_id, uint32_t period); + +/** + * @brief stop a timer + * @param timer_id Timer identifier + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_timer_stop(ble_timer_t timer_id); + +/** + * @brief delete a timer + * @param timer_id Timer identifier + * @return BLE_QIOT_RS_OK is success, other is error + */ +ble_qiot_ret_status_t ble_timer_delete(ble_timer_t timer_id); + +#if defined(__cplusplus) +} +#endif + +#endif // QCLOUD_BLE_QIOT_IMPORT_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/readme.md b/components/connectivity/qcloud_iot_explorer_ble/readme.md new file mode 100644 index 00000000..659ffc7a --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/readme.md @@ -0,0 +1,48 @@ +## 概述 + +LLSync SDK 提供了 LLSync 协议接入方案,SDK 内实现了 LLSync 协议用于和 APP(网关设备)进行通信,打通了 `BLE设备-APP(网关设备)-物联网开发平台` 的数据链路,支持开发者快速接入 BLE 设备到物联网开发平台。开发者接入 LLSync SDK需要做的工作有: + +1. 添加 LLSync Service到 BLE 协议栈中 +2. 通过脚本将数据模版转换为C代码,添加相应的数据处理 + +LLSync SDK 封装了协议实现细节和数据传输过程,让开发者可以聚焦在数据处理上,以达到快速开发的目的。 + + +## 软件架构 + +LLSync SDK 结构框图: + +![LLSync结构框图](https://main.qcloudimg.com/raw/9fabb2c222ae40d6a93641b745a327bd.png) + +SDK 分三层设计,从上至下分别为应用层、LLSync核心层、HAL移植层。 + +* 应用层:LLSync SDK 生成了数据模版的模版文件,用户需要根据需求做具体实现。 +* LLSync 核心组件:实现了 BLE 设备和App (网关设备)之间的通信协议,身份认证,数据解析等功能,用户一般无需改动即可使用。 +* HAL 移植层:主要是适配 BLE 协议栈,用户需要进行移植和适配。 + +## 目录结构 + +```c +qcloud_iot_explorer_ble + ├─config # SDK 配置文件 + ├─docs # 文档 + ├─inc # 头文件 + ├─samples # 参考实现源码 + │ ├─esp32 # esp32例程 + │ ├─lifesense # apollo3 blue例程 + │ ├─nrf52832 # nordic 52832例程 + ├─scripts # 脚本 + │ ├─code_extract # 代码抽取 + │ ├─interpret_json_dt # 数据模版转换 + │ ├─config # ini文件,记录常量 + │ ├─src # 脚本源码 + │ ├─dt_fixed_content # C代码中的固定内容 + └─src # LLSync源码 + ├─core # 核心代码 + ├─internal_inc # 内部头文件 + └─utils # 工具代码 +``` + +## 移植指引 + +请参见 LLSync SDK接入指引.md diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/CMakeLists.txt b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/CMakeLists.txt new file mode 100644 index 00000000..81a08531 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(llsync) diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/CMakeLists.txt b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/CMakeLists.txt new file mode 100644 index 00000000..36f697e0 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/CMakeLists.txt @@ -0,0 +1,28 @@ +if (CONFIG_QCLOUD_LLSYNC_SUPPORT) + set(srcs + src/core/ble_qiot_llsync_data.c + src/core/ble_qiot_llsync_device.c + src/core/ble_qiot_llsync_event.c + src/core/ble_qiot_service.c + src/utils/ble_qiot_utils_base64.c + src/utils/ble_qiot_utils_hmac.c + src/utils/ble_qiot_utils_log.c + src/utils/ble_qiot_utils_md5.c + src/utils/ble_qiot_utils_sha1.c) + + list(APPEND srcs + date_template/ble_qiot_template.c) + + list(APPEND srcs + hal/ble_qiot_ble_device.c + hal/ble_qiot_ble_service.c) + + set(includes inc src/internal_inc) + set(priv_includes date_template src/internal_inc hal) + +endif () + +idf_component_register(SRCS "${srcs}" + INCLUDE_DIRS "${includes}" + PRIV_INCLUDE_DIRS "${priv_includes}" + REQUIRES bt) diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/Kconfig b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/Kconfig new file mode 100644 index 00000000..226d0c79 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/Kconfig @@ -0,0 +1,7 @@ +menu "QCloud LLSync" +config QCLOUD_LLSYNC_SUPPORT + + bool "QCloud LLSync support." + default "y" + +endmenu diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/date_template/ble_qiot_template.c b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/date_template/ble_qiot_template.c new file mode 100644 index 00000000..2c85f1f0 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/date_template/ble_qiot_template.c @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_template.h" + +#include +#include +#include + +#include "ble_qiot_export.h" +#include "ble_qiot_common.h" +#include "ble_qiot_param_check.h" + +float sg_ch20_ppm = 0.0; +static int ble_property_ch20_ppm_value_set(const char *data, uint16_t len) +{ + return 0; +} + +static int ble_property_ch20_ppm_value_get(char *data, uint16_t buf_len) +{ + memcpy(data, &sg_ch20_ppm, sizeof(float)); + return sizeof(float); +} + +static ble_property_t sg_ble_property_array[BLE_QIOT_PROPERTY_ID_BUTT] = { + {ble_property_ch20_ppm_value_set, ble_property_ch20_ppm_value_get, BLE_QIOT_PROPERTY_AUTH_READ, + BLE_QIOT_DATA_TYPE_FLOAT}, +}; + +static bool ble_check_space_enough_by_type(uint8_t type, uint16_t left_size) +{ + switch (type) { + case BLE_QIOT_DATA_TYPE_BOOL: + return left_size >= sizeof(uint8_t); + case BLE_QIOT_DATA_TYPE_INT: + case BLE_QIOT_DATA_TYPE_FLOAT: + case BLE_QIOT_DATA_TYPE_TIME: + return left_size >= sizeof(uint32_t); + case BLE_QIOT_DATA_TYPE_ENUM: + return left_size >= sizeof(uint16_t); + default: + // string length is unknow, default true + return true; + } +} + +static uint16_t ble_check_ret_value_by_type(uint8_t type, uint16_t buf_len, uint16_t ret_val) +{ + switch (type) { + case BLE_QIOT_DATA_TYPE_BOOL: + return ret_val <= sizeof(uint8_t); + case BLE_QIOT_DATA_TYPE_INT: + case BLE_QIOT_DATA_TYPE_FLOAT: + case BLE_QIOT_DATA_TYPE_TIME: + return ret_val <= sizeof(uint32_t); + case BLE_QIOT_DATA_TYPE_ENUM: + return ret_val <= sizeof(uint16_t); + default: + // string length is unknow, default true + return ret_val <= buf_len; + } +} + +uint8_t ble_get_property_type_by_id(uint8_t id) +{ + if (id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + return sg_ble_property_array[id].type; +} + +int ble_user_property_set_data(const e_ble_tlv *tlv) +{ + POINTER_SANITY_CHECK(tlv, BLE_QIOT_RS_ERR_PARA); + if (tlv->id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", tlv->id); + return BLE_QIOT_RS_ERR; + } + + if (NULL != sg_ble_property_array[tlv->id].set_cb) { + if (0 != sg_ble_property_array[tlv->id].set_cb(tlv->val, tlv->len)) { + ble_qiot_log_e("set property id %d failed", tlv->id); + return BLE_QIOT_RS_ERR; + } else { + return BLE_QIOT_RS_OK; + } + } + ble_qiot_log_e("invalid set callback, id %d", tlv->id); + + return BLE_QIOT_RS_ERR; +} + +int ble_user_property_get_data_by_id(uint8_t id, char *buf, uint16_t buf_len) +{ + int ret_len = 0; + + POINTER_SANITY_CHECK(buf, BLE_QIOT_RS_ERR_PARA); + if (id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", id); + return -1; + } + + if (NULL != sg_ble_property_array[id].get_cb) { + if (!ble_check_space_enough_by_type(sg_ble_property_array[id].type, buf_len)) { + ble_qiot_log_e("not enough space get property id %d data", id); + return -1; + } + ret_len = sg_ble_property_array[id].get_cb(buf, buf_len); + if (ret_len < 0) { + ble_qiot_log_e("get property id %d data failed", id); + return -1; + } else { + if (ble_check_ret_value_by_type(sg_ble_property_array[id].type, buf_len, ret_len)) { + return ret_len; + } else { + ble_qiot_log_e("property id %d length invalid", id); + return -1; + } + } + } + ble_qiot_log_e("invalid callback, property id %d", id); + + return 0; +} + +int ble_user_property_report_reply_handle(uint8_t result) +{ + ble_qiot_log_d("report reply result %d", result); + + return BLE_QIOT_RS_OK; +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/date_template/ble_qiot_template.h b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/date_template/ble_qiot_template.h new file mode 100644 index 00000000..806d2a34 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/date_template/ble_qiot_template.h @@ -0,0 +1,163 @@ +/* +* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. +* Licensed under the MIT License (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://opensource.org/licenses/MIT +* Unless required by applicable law or agreed to in writing, software distributed under the License is +* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +* either express or implied. See the License for the specific language governing permissions and +* limitations under the License. +* +*/ +#ifndef BLE_QIOT_TEMPLATE_H_ +#define BLE_QIOT_TEMPLATE_H_ +#ifdef __cplusplus +extern "C"{ +#endif + +#include + + +// data type in template, corresponding to type in json file +enum { + BLE_QIOT_DATA_TYPE_BOOL = 0, + BLE_QIOT_DATA_TYPE_INT, + BLE_QIOT_DATA_TYPE_STRING, + BLE_QIOT_DATA_TYPE_FLOAT, + BLE_QIOT_DATA_TYPE_ENUM, + BLE_QIOT_DATA_TYPE_TIME, + BLE_QIOT_DATA_TYPE_BUTT, +}; + +// message type, reference data template +enum { + BLE_QIOT_MSG_TYPE_PROPERTY = 0, + BLE_QIOT_MSG_TYPE_EVENT, + BLE_QIOT_MSG_TYPE_ACTION, + BLE_QIOT_MSG_TYPE_BUTT, +}; + +// define property authority, not used +enum { + BLE_QIOT_PROPERTY_AUTH_RW = 0, + BLE_QIOT_PROPERTY_AUTH_READ, + BLE_QIOT_PROPERTY_AUTH_BUTT, +}; + +// define reply result +enum { + BLE_QIOT_REPLY_SUCCESS = 0, + BLE_QIOT_REPLY_FAIL, + BLE_QIOT_REPLY_DATA_ERR, + BLE_QIOT_REPLY_BUTT, +}; + +// define message flow direction +enum { + BLE_QIOT_EFFECT_REQUEST = 0, + BLE_QIOT_EFFECT_REPLY, + BLE_QIOT_EFFECT_BUTT, +}; + +// define message type that from server to device +enum { + BLE_QIOT_DATA_DOWN_REPORT_REPLY = 0, + BLE_QIOT_DATA_DOWN_CONTROL, + BLE_QIOT_DATA_DOWN_GET_STATUS_REPLY, + BLE_QIOT_DATA_DOWN_ACTION, + BLE_QIOT_DATA_DOWN_EVENT_REPLY, +}; + +// define message type that from device to server +enum { + BLE_QIOT_EVENT_UP_PROPERTY_REPORT = 0, + BLE_QIOT_EVENT_UP_CONTROL_REPLY, + BLE_QIOT_EVENT_UP_GET_STATUS, + BLE_QIOT_EVENT_UP_EVENT_POST, + BLE_QIOT_EVENT_UP_ACTION_REPLY, + BLE_QIOT_EVENT_UP_BIND_SIGN_RET, + BLE_QIOT_EVENT_UP_CONN_SIGN_RET, + BLE_QIOT_EVENT_UP_UNBIND_SIGN_RET, + BLE_QIOT_EVENT_UP_REPORT_MTU, + BLE_QIOT_EVENT_UP_BUTT, +}; + +// msg header define, bit 7-6 is msg type, bit 5 means request or reply, bit 4 - 0 is id +#define BLE_QIOT_PARSE_MSG_HEAD_TYPE(_C) (((_C) & 0XFF) >> 6) +#define BLE_QIOT_PARSE_MSG_HEAD_EFFECT(_C) ((((_C) & 0XFF) & 0X20) ? BLE_QIOT_EFFECT_REPLY : BLE_QIOT_EFFECT_REQUEST) +#define BLE_QIOT_PARSE_MSG_HEAD_ID(_C) ((_C) & 0X1F) +#define BLE_QIOT_PACKAGE_MSG_HEAD(_TYPE, _REPLY, _ID) (((_TYPE) << 6) | (((_REPLY) == BLE_QIOT_EFFECT_REPLY) << 5) | ((_ID) & 0X1F)) + +// tlv header define, bit 7 - 5 is type, bit 4 - 0 depends on type of data template +#define BLE_QIOT_PARSE_TLV_HEAD_TYPE(_C) (((_C) & 0XFF) >> 5) +#define BLE_QIOT_PARSE_TLV_HEAD_ID(_C) ((_C) & 0X1F) +#define BLE_QIOT_PACKAGE_TLV_HEAD(_TYPE, _ID) (((_TYPE) << 5) | ((_ID) & 0X1F)) + + +// define tlv struct +typedef struct{ + uint8_t type; + uint8_t id; + uint16_t len; + char *val; +}e_ble_tlv; +#define BLE_QIOT_INCLUDE_PROPERTY + +// define property id +enum { + BLE_QIOT_PROPERTY_ID_CH20_PPM_VALUE = 0, + BLE_QIOT_PROPERTY_ID_BUTT, +}; + +// define ch20_ppm_value attributes +#define BLE_QIOT_PROPERTY_CH20_PPM_VALUE_MIN (0) +#define BLE_QIOT_PROPERTY_CH20_PPM_VALUE_MAX (2) +#define BLE_QIOT_PROPERTY_CH20_PPM_VALUE_START (0) +#define BLE_QIOT_PROPERTY_CH20_PPM_VALUE_STEP (0.001) + +// define property set handle return 0 if success, other is error +// sdk call the function that inform the server data to the device +typedef int (*property_set_cb)(const char *data, uint16_t len); + +// define property get handle. return the data length obtained, -1 is error, 0 is no data +// sdk call the function fetch user data and send to the server, the data should wrapped by user adn skd just transmit +typedef int (*property_get_cb)(char *buf, uint16_t buf_len); + +// each property have a struct ble_property_t, make up a array named sg_ble_property_array +typedef struct{ + property_set_cb set_cb; //set callback + property_get_cb get_cb; //get callback + uint8_t authority; //property authority + uint8_t type; //data type +}ble_property_t; +// property module +#ifdef BLE_QIOT_INCLUDE_PROPERTY +uint8_t ble_get_property_type_by_id(uint8_t id); +int ble_user_property_set_data(const e_ble_tlv *tlv); +int ble_user_property_get_data_by_id(uint8_t id, char *buf, uint16_t buf_len); +int ble_user_property_report_reply_handle(uint8_t result); +#endif + +// event module +#ifdef BLE_QIOT_INCLUDE_EVENT +int ble_event_get_id_array_size(uint8_t event_id); +uint8_t ble_event_get_param_id_type(uint8_t event_id, uint8_t param_id); +int ble_event_get_data_by_id(uint8_t event_id, uint8_t param_id, char *out_buf, uint16_t buf_len); +int ble_user_event_reply_handle(uint8_t event_id, uint8_t result); +#endif + +// action module +#ifdef BLE_QIOT_INCLUDE_ACTION +uint8_t ble_action_get_intput_type_by_id(uint8_t action_id, uint8_t input_id); +uint8_t ble_action_get_output_type_by_id(uint8_t action_id, uint8_t output_id); +int ble_action_get_input_id_size(uint8_t action_id); +int ble_action_get_output_id_size(uint8_t action_id); +int ble_action_user_handle_input_param(uint8_t action_id, e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array); +int ble_action_user_handle_output_param(uint8_t action_id, uint8_t output_id, char *buf, uint16_t buf_len); +#endif + + +#ifdef __cplusplus +} +#endif +#endif //BLE_QIOT_TEMPLATE_H_ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/date_template/esp32.json b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/date_template/esp32.json new file mode 100644 index 00000000..58e006ec --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/date_template/esp32.json @@ -0,0 +1,26 @@ +{ + "version": "1.0", + "profile": { + "ProductId": "1NBPCQ7L2O", + "CategoryId": "1" + }, + "properties": [ + { + "id": "ch20_ppm_value", + "name": "甲醛浓度值", + "desc": "", + "mode": "r", + "define": { + "type": "float", + "min": "0", + "max": "2", + "start": "0", + "step": "0.001", + "unit": "ppm(mg/m3)" + }, + "required": false + } + ], + "events": [], + "actions": [] +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/hal/ble_qiot_ble_device.c b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/hal/ble_qiot_ble_device.c new file mode 100644 index 00000000..3fb1bbd9 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/hal/ble_qiot_ble_device.c @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#include "ble_qiot_export.h" +#include "ble_qiot_service.h" +#include "ble_qiot_import.h" + +// add std head file here +#include + +// add ble qiot head file here +#include "ble_qiot_import.h" + +#include "ble_qiot_config.h" + +#include "esp_bt_device.h" +#include "esp_spi_flash.h" + +// divece info which defined in explorer platform +#define PRODUCT_ID "1NBPCQ7L2O" +#define DEVICE_NAME "123" +#define SECRET_KEY "q/WQFemC2ejNZTNWMqHerA==" + + +int ble_get_product_id(char *product_id) +{ + memcpy(product_id, PRODUCT_ID, strlen(PRODUCT_ID)); + + return 0; +} + +int ble_get_device_name(char *device_name) +{ + memcpy(device_name, DEVICE_NAME, strlen(DEVICE_NAME)); + + return strlen(DEVICE_NAME); +} + +int ble_get_psk(char *psk) +{ + memcpy(psk, SECRET_KEY, strlen(SECRET_KEY)); + + return 0; +} + +int ble_get_mac(char *mac) +{ + char *address = (char *)esp_bt_dev_get_address(); + memcpy(mac, address, 6); + + return 0; +} + +int ble_write_flash(uint32_t flash_addr, const char *write_buf, uint16_t write_len) +{ + int ret = spi_flash_erase_range(flash_addr, BLE_QIOT_RECORD_FLASH_PAGESIZE); + ret = spi_flash_write(flash_addr, write_buf, write_len); + + return ret == ESP_OK ? write_len : ret; +} + +int ble_read_flash(uint32_t flash_addr, char *read_buf, uint16_t read_len) +{ + int ret = spi_flash_read(flash_addr, read_buf, read_len); + + return ret == ESP_OK ? read_len : ret; +} + +ble_timer_t ble_timer_create(uint8_t type, ble_timer_cb timeout_handle) +{ + return NULL; +} + +ble_qiot_ret_status_t ble_timer_start(ble_timer_t timer_id, uint32_t period) +{ + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_timer_stop(ble_timer_t timer_id) +{ + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_timer_delete(ble_timer_t timer_id) +{ + return BLE_QIOT_RS_OK; +} + +// should return ATT_MTU - 3 +uint16_t ble_get_user_data_mtu_size(void) +{ + // esp32 can not get mtu,use default mtu + return 20; +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/hal/ble_qiot_ble_service.c b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/hal/ble_qiot_ble_service.c new file mode 100644 index 00000000..f38fe1a5 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/hal/ble_qiot_ble_service.c @@ -0,0 +1,536 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/event_groups.h" +#include "esp_system.h" +#include "esp_log.h" +#include "nvs_flash.h" +#include "esp_bt.h" +#include "esp_gap_ble_api.h" +#include "esp_gatts_api.h" +#include "esp_bt_main.h" +#include "esp_gatt_common_api.h" + +#include "ble_qiot_config.h" +#include "ble_qiot_export.h" +#include "ble_qiot_service.h" +#include "ble_qiot_import.h" + +#define LLSYNC_LOG_TAG "LLSYNC" + +/* Attributes State Machine */ +enum +{ + IDX_SVC, + IDX_CHAR_A, + IDX_CHAR_VAL_A, + + IDX_CHAR_B, + IDX_CHAR_VAL_B, + + IDX_CHAR_C, + IDX_CHAR_VAL_C, + IDX_CHAR_CFG_C, + + HRS_IDX_NB, +}; + +#define PROFILE_NUM 1 +#define PROFILE_APP_IDX 0 +#define LLSYNC_APP_ID 0x55 +#define SAMPLE_DEVICE_NAME "l" +#define SVC_INST_ID 0 + +/* The max length of characteristic value. When the GATT client performs a write or prepare write operation, +* the data length must be less than LLSYNC_CHAR_VAL_LEN_MAX. +*/ +#define LLSYNC_CHAR_VAL_LEN_MAX 500 +#define PREPARE_BUF_MAX_SIZE 1024 +#define CHAR_DECLARATION_SIZE (sizeof(uint8_t)) + +#define ADV_CONFIG_FLAG (1 << 0) + +static uint8_t adv_config_done = 0; + +uint16_t llsync_handle_table[HRS_IDX_NB]; + +typedef struct { + uint8_t *prepare_buf; + int prepare_len; + uint16_t handle; +} prepare_type_env_t; + +static prepare_type_env_t prepare_write_env; + +static uint8_t raw_adv_data[32] = { + /* flags */ + 0x02, 0x01, 0x06, + /* service uuid */ + 0x03, 0x03, 0xE0, 0xFF, +}; + +static esp_ble_adv_params_t adv_params = { + .adv_int_min = 0x20, + .adv_int_max = 0x40, + .adv_type = ADV_TYPE_IND, + .own_addr_type = BLE_ADDR_TYPE_PUBLIC, + .channel_map = ADV_CHNL_ALL, + .adv_filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, +}; + +struct gatts_profile_inst { + esp_gatts_cb_t gatts_cb; + uint16_t gatts_if; + uint16_t app_id; + uint16_t conn_id; + uint16_t service_handle; + esp_gatt_srvc_id_t service_id; + uint16_t char_handle; + esp_bt_uuid_t char_uuid; + esp_gatt_perm_t perm; + esp_gatt_char_prop_t property; + uint16_t descr_handle; + esp_bt_uuid_t descr_uuid; +}; + +ble_qiot_ret_status_t ble_advertising_start(adv_info_s *adv) +{ + uint8_t usr_adv_data[31] = {0}; + uint8_t len = 0; + uint8_t index = 0; + + memcpy(usr_adv_data, &adv->manufacturer_info.company_identifier, sizeof(uint16_t)); + len = sizeof(uint16_t); + memcpy(usr_adv_data + len, adv->manufacturer_info.adv_data, adv->manufacturer_info.adv_data_len); + len += adv->manufacturer_info.adv_data_len; + + index = 7; + raw_adv_data[index++] = len + 1; + raw_adv_data[index++] = 0xFF; + memcpy(raw_adv_data + index, usr_adv_data, len); + index += len; + + raw_adv_data[index++] = strlen(SAMPLE_DEVICE_NAME) + 1; + raw_adv_data[index++] = 0x09; + memcpy(raw_adv_data + index, SAMPLE_DEVICE_NAME, strlen(SAMPLE_DEVICE_NAME)); + index += strlen(SAMPLE_DEVICE_NAME); + + esp_log_buffer_hex("adv", raw_adv_data, index); + //config adv data + esp_err_t ret = esp_ble_gap_config_adv_data_raw(raw_adv_data, index); + if (ret) { + ESP_LOGE(LLSYNC_LOG_TAG, "config adv data failed, error code = %x", ret); + } + adv_config_done |= ADV_CONFIG_FLAG; + + ESP_LOGI(LLSYNC_LOG_TAG, "start advertising"); + esp_ble_gap_start_advertising(&adv_params); + + return 0; +} + +ble_qiot_ret_status_t ble_advertising_stop(void) +{ + esp_ble_gap_stop_advertising(); + return 0; +} + +static void gatts_profile_event_handler(esp_gatts_cb_event_t event, + esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param); + +/* One gatt-based profile one app_id and one gatts_if, this array will store the gatts_if returned by ESP_GATTS_REG_EVT */ +static struct gatts_profile_inst llsync_profile_tab[PROFILE_NUM] = { + [PROFILE_APP_IDX] = { + .gatts_cb = gatts_profile_event_handler, + .gatts_if = ESP_GATT_IF_NONE, /* Not get the gatt_if, so initial is ESP_GATT_IF_NONE */ + }, +}; + +ble_qiot_ret_status_t ble_send_notify(uint8_t *buf, uint8_t len) +{ + esp_ble_gatts_send_indicate(llsync_profile_tab[PROFILE_APP_IDX].gatts_if, llsync_profile_tab[PROFILE_APP_IDX].conn_id, + llsync_handle_table[IDX_CHAR_VAL_C],len, buf, false); + return BLE_QIOT_RS_OK; +} + +static const uint16_t primary_service_uuid = ESP_GATT_UUID_PRI_SERVICE; +static const uint16_t character_declaration_uuid = ESP_GATT_UUID_CHAR_DECLARE; +static const uint16_t character_client_config_uuid = ESP_GATT_UUID_CHAR_CLIENT_CONFIG; +static const uint8_t char_prop_write = ESP_GATT_CHAR_PROP_BIT_WRITE; +static const uint8_t char_prop_notify = ESP_GATT_CHAR_PROP_BIT_NOTIFY; +static const uint8_t heart_measurement_ccc[2] = {0x00, 0x00}; + +/* service_uuid and Characteristic_uuid*/ +static uint8_t llsync_service_uuid[16] = { + 0xe2, 0xa4, 0x1b, 0x54, 0x93, 0xe4, 0x6a, 0xb5, 0x20, 0x4e, 0xd0, 0x65, 0xe0, 0xff, 0x00, 0x00, +}; +static uint8_t llsync_device_info_uuid[16] = { + 0xe2, 0xa4, 0x1b, 0x54, 0x93, 0xe4, 0x6a, 0xb5, 0x20, 0x4e, 0xd0, 0x65, 0xe1, 0xff, 0x00, 0x00, +}; +static uint8_t llsync_data_uuid[16] = { + 0xe2, 0xa4, 0x1b, 0x54, 0x93, 0xe4, 0x6a, 0xb5, 0x20, 0x4e, 0xd0, 0x65, 0xe2, 0xff, 0x00, 0x00, +}; +static uint8_t llsync_event_uuid[16] = { + 0xe2, 0xa4, 0x1b, 0x54, 0x93, 0xe4, 0x6a, 0xb5, 0x20, 0x4e, 0xd0, 0x65, 0xe3, 0xff, 0x00, 0x00, +}; + + +/* Full Database Description - Used to add attributes into the database */ +static const esp_gatts_attr_db_t gatt_db[HRS_IDX_NB] = + { + // Service Declaration + [IDX_SVC] = + {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&primary_service_uuid, ESP_GATT_PERM_READ, + sizeof(llsync_service_uuid), sizeof(llsync_service_uuid), (uint8_t *)llsync_service_uuid}}, + + /* Characteristic Declaration */ + [IDX_CHAR_A] = + {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_declaration_uuid, ESP_GATT_PERM_READ, + CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_write}}, + /* Characteristic Value */ + [IDX_CHAR_VAL_A] = + {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)llsync_device_info_uuid, ESP_GATT_PERM_WRITE, + LLSYNC_CHAR_VAL_LEN_MAX, 0, NULL}}, + + /* Characteristic Declaration */ + [IDX_CHAR_B] = + {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_declaration_uuid, ESP_GATT_PERM_READ, + CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_write}}, + /* Characteristic Value */ + [IDX_CHAR_VAL_B] = + {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)llsync_data_uuid, ESP_GATT_PERM_WRITE, + LLSYNC_CHAR_VAL_LEN_MAX, 0, NULL}}, + + /* Characteristic Declaration */ + [IDX_CHAR_C] = + {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_declaration_uuid, ESP_GATT_PERM_READ, + CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}}, + /* Characteristic Value */ + [IDX_CHAR_VAL_C] = + {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)llsync_event_uuid, 0, + LLSYNC_CHAR_VAL_LEN_MAX, 0, NULL}}, + /* Characteristic User Descriptor */ + [IDX_CHAR_CFG_C] = + {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, + sizeof(uint16_t), sizeof(heart_measurement_ccc), (uint8_t *)heart_measurement_ccc}}, + }; + +static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) +{ + switch (event) { + case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT: + ESP_LOGI(LLSYNC_LOG_TAG, "ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT"); + adv_config_done &= (~ADV_CONFIG_FLAG); + if (adv_config_done == 0) { + ble_qiot_advertising_start(); + adv_config_done = 2; + } + break; + case ESP_GAP_BLE_ADV_START_COMPLETE_EVT: + /* advertising start complete event to indicate advertising start successfully or failed */ + if (param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) { + ESP_LOGE(LLSYNC_LOG_TAG, "advertising start failed"); + }else{ + ESP_LOGI(LLSYNC_LOG_TAG, "advertising start successfully"); + } + break; + case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT: + if (param->adv_stop_cmpl.status != ESP_BT_STATUS_SUCCESS) { + ESP_LOGE(LLSYNC_LOG_TAG, "Advertising stop failed"); + } + else { + ESP_LOGI(LLSYNC_LOG_TAG, "Stop adv successfully\n"); + } + break; + case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT: + ESP_LOGI(LLSYNC_LOG_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d", + param->update_conn_params.status, + param->update_conn_params.min_int, + param->update_conn_params.max_int, + param->update_conn_params.conn_int, + param->update_conn_params.latency, + param->update_conn_params.timeout); + break; + default: + break; + } +} + +void example_prepare_write_event_env(esp_gatt_if_t gatts_if, prepare_type_env_t *prepare_write_env, esp_ble_gatts_cb_param_t *param) +{ + ESP_LOGI(LLSYNC_LOG_TAG, "prepare write, handle = %d, value len = %d", param->write.handle, param->write.len); + esp_gatt_status_t status = ESP_GATT_OK; + if (prepare_write_env->prepare_buf == NULL) { + prepare_write_env->prepare_buf = (uint8_t *)malloc(PREPARE_BUF_MAX_SIZE * sizeof(uint8_t)); + prepare_write_env->prepare_len = 0; + prepare_write_env->handle = 0; + if (prepare_write_env->prepare_buf == NULL) { + ESP_LOGE(LLSYNC_LOG_TAG, "%s, Gatt_server prep no mem", __func__); + status = ESP_GATT_NO_RESOURCES; + } + } else { + if(param->write.offset > PREPARE_BUF_MAX_SIZE) { + status = ESP_GATT_INVALID_OFFSET; + } else if ((param->write.offset + param->write.len) > PREPARE_BUF_MAX_SIZE) { + status = ESP_GATT_INVALID_ATTR_LEN; + } + } + /*send response when param->write.need_rsp is true */ + if (param->write.need_rsp){ + esp_gatt_rsp_t *gatt_rsp = (esp_gatt_rsp_t *)malloc(sizeof(esp_gatt_rsp_t)); + if (gatt_rsp != NULL){ + gatt_rsp->attr_value.len = param->write.len; + gatt_rsp->attr_value.handle = param->write.handle; + gatt_rsp->attr_value.offset = param->write.offset; + gatt_rsp->attr_value.auth_req = ESP_GATT_AUTH_REQ_NONE; + memcpy(gatt_rsp->attr_value.value, param->write.value, param->write.len); + esp_err_t response_err = esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, status, gatt_rsp); + if (response_err != ESP_OK){ + ESP_LOGE(LLSYNC_LOG_TAG, "Send response error"); + } + free(gatt_rsp); + }else{ + ESP_LOGE(LLSYNC_LOG_TAG, "%s, malloc failed", __func__); + } + } + if (status != ESP_GATT_OK){ + return; + } + memcpy(prepare_write_env->prepare_buf + param->write.offset, + param->write.value, + param->write.len); + prepare_write_env->prepare_len += param->write.len; + prepare_write_env->handle = param->write.handle; +} + +void example_exec_write_event_env(prepare_type_env_t *prepare_write_env, esp_ble_gatts_cb_param_t *param){ + if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC && prepare_write_env->prepare_buf){ + if (prepare_write_env->handle == llsync_handle_table[IDX_CHAR_VAL_A]){ + ESP_LOGI(LLSYNC_LOG_TAG, "ble_device_info_write_cb"); + ble_device_info_write_cb(prepare_write_env->prepare_buf, prepare_write_env->prepare_len); + }else if (prepare_write_env->handle == llsync_handle_table[IDX_CHAR_VAL_B]){ + ESP_LOGI(LLSYNC_LOG_TAG, "ble_lldata_write_cb"); + ble_lldata_write_cb(prepare_write_env->prepare_buf, prepare_write_env->prepare_len); + } + esp_log_buffer_hex(LLSYNC_LOG_TAG, prepare_write_env->prepare_buf, prepare_write_env->prepare_len); + }else{ + ESP_LOGI(LLSYNC_LOG_TAG,"ESP_GATT_PREP_WRITE_CANCEL"); + } + if (prepare_write_env->prepare_buf) { + free(prepare_write_env->prepare_buf); + prepare_write_env->prepare_buf = NULL; + } + prepare_write_env->prepare_len = 0; +} + + +static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) +{ + switch (event) { + case ESP_GATTS_REG_EVT: + { + esp_err_t set_dev_name_ret = esp_ble_gap_set_device_name(SAMPLE_DEVICE_NAME); + if (set_dev_name_ret) { + ESP_LOGE(LLSYNC_LOG_TAG, "set device name failed, error code = %x", set_dev_name_ret); + } + esp_err_t raw_adv_ret = esp_ble_gap_config_adv_data_raw(raw_adv_data, 7); + if (raw_adv_ret){ + ESP_LOGE(LLSYNC_LOG_TAG, "config raw adv data failed, error code = %x ", raw_adv_ret); + } + adv_config_done |= ADV_CONFIG_FLAG; + esp_err_t create_attr_ret = esp_ble_gatts_create_attr_tab(gatt_db, gatts_if, HRS_IDX_NB, SVC_INST_ID); + if (create_attr_ret) { + ESP_LOGE(LLSYNC_LOG_TAG, "create attr table failed, error code = %x", create_attr_ret); + } + } + break; + case ESP_GATTS_READ_EVT: + ESP_LOGI(LLSYNC_LOG_TAG, "ESP_GATTS_READ_EVT"); + break; + case ESP_GATTS_WRITE_EVT: + if (!param->write.is_prep){ + // the data length of gattc write must be less than LLSYNC_CHAR_VAL_LEN_MAX. + ESP_LOGI(LLSYNC_LOG_TAG, "GATT_WRITE_EVT, handle = %d, value len = %d, value :", param->write.handle, param->write.len); + esp_log_buffer_hex(LLSYNC_LOG_TAG, param->write.value, param->write.len); + if (param->write.handle == llsync_handle_table[IDX_CHAR_VAL_A]){ + ESP_LOGI(LLSYNC_LOG_TAG, "ble_device_info_write_cb"); + ble_device_info_write_cb(param->write.value, param->write.len); + }else if (param->write.handle == llsync_handle_table[IDX_CHAR_VAL_B]){ + ESP_LOGI(LLSYNC_LOG_TAG, "ble_lldata_write_cb"); + ble_lldata_write_cb(param->write.value, param->write.len); + } + ESP_LOGI(LLSYNC_LOG_TAG, "GATT_WRITE_EVT OVER"); + /* send response when param->write.need_rsp is true*/ + if (param->write.need_rsp){ + esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, ESP_GATT_OK, NULL); + } + }else{ + example_prepare_write_event_env(gatts_if, &prepare_write_env, param); + } + break; + case ESP_GATTS_EXEC_WRITE_EVT: + // the length of gattc prepare write data must be less than GATTS_DEMO_CHAR_VAL_LEN_MAX. + ESP_LOGI(LLSYNC_LOG_TAG, "ESP_GATTS_EXEC_WRITE_EVT"); + example_exec_write_event_env(&prepare_write_env, param); + break; + case ESP_GATTS_MTU_EVT: + ESP_LOGI(LLSYNC_LOG_TAG, "ESP_GATTS_MTU_EVT, MTU %d", param->mtu.mtu); + break; + case ESP_GATTS_CONF_EVT: + ESP_LOGI(LLSYNC_LOG_TAG, "ESP_GATTS_CONF_EVT, status = %d, attr_handle %d", param->conf.status, param->conf.handle); + break; + case ESP_GATTS_START_EVT: + ESP_LOGI(LLSYNC_LOG_TAG, "SERVICE_START_EVT, status %d, service_handle %d", param->start.status, param->start.service_handle); + break; + case ESP_GATTS_CONNECT_EVT: + ESP_LOGI(LLSYNC_LOG_TAG, "ESP_GATTS_CONNECT_EVT, conn_id = %d", param->connect.conn_id); + esp_log_buffer_hex(LLSYNC_LOG_TAG, param->connect.remote_bda, 6); + esp_ble_conn_update_params_t conn_params = {0}; + memcpy(conn_params.bda, param->connect.remote_bda, sizeof(esp_bd_addr_t)); + /* For the iOS system, please refer to Apple official documents about the BLE connection parameters restrictions. */ + conn_params.latency = 0; + conn_params.max_int = 0x20; // max_int = 0x20*1.25ms = 40ms + conn_params.min_int = 0x10; // min_int = 0x10*1.25ms = 20ms + conn_params.timeout = 400; // timeout = 400*10ms = 4000ms + //start sent the update connection parameters to the peer device. + esp_ble_gap_update_conn_params(&conn_params); + break; + case ESP_GATTS_DISCONNECT_EVT: + ESP_LOGI(LLSYNC_LOG_TAG, "ESP_GATTS_DISCONNECT_EVT, reason = 0x%x", param->disconnect.reason); + ble_qiot_advertising_start(); + break; + case ESP_GATTS_CREAT_ATTR_TAB_EVT:{ + if (param->add_attr_tab.status != ESP_GATT_OK){ + ESP_LOGE(LLSYNC_LOG_TAG, "create attribute table failed, error code=0x%x", param->add_attr_tab.status); + } + else if (param->add_attr_tab.num_handle != HRS_IDX_NB){ + ESP_LOGE(LLSYNC_LOG_TAG, "create attribute table abnormally, num_handle (%d) doesn't equal to HRS_IDX_NB(%d)", param->add_attr_tab.num_handle, HRS_IDX_NB); + } + else { + ESP_LOGI(LLSYNC_LOG_TAG, "create attribute table successfully, the number handle = %d\n",param->add_attr_tab.num_handle); + memcpy(llsync_handle_table, param->add_attr_tab.handles, sizeof(llsync_handle_table)); + esp_ble_gatts_start_service(llsync_handle_table[IDX_SVC]); + } + break; + } + case ESP_GATTS_STOP_EVT: + case ESP_GATTS_OPEN_EVT: + case ESP_GATTS_CANCEL_OPEN_EVT: + case ESP_GATTS_CLOSE_EVT: + case ESP_GATTS_LISTEN_EVT: + case ESP_GATTS_CONGEST_EVT: + case ESP_GATTS_UNREG_EVT: + case ESP_GATTS_DELETE_EVT: + default: + break; + } +} + + +static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) +{ + /* If event is register event, store the gatts_if for each profile */ + if (event == ESP_GATTS_REG_EVT) { + if (param->reg.status == ESP_GATT_OK) { + llsync_profile_tab[PROFILE_APP_IDX].gatts_if = gatts_if; + } else { + ESP_LOGE(LLSYNC_LOG_TAG, "reg app failed, app_id %04x, status %d", param->reg.app_id, param->reg.status); + return; + } + } + + do { + int idx; + for (idx = 0; idx < PROFILE_NUM; idx++) { + /* ESP_GATT_IF_NONE, not specify a certain gatt_if, need to call every profile cb function */ + if (gatts_if == ESP_GATT_IF_NONE || gatts_if == llsync_profile_tab[idx].gatts_if) { + if (llsync_profile_tab[idx].gatts_cb) { + llsync_profile_tab[idx].gatts_cb(event, gatts_if, param); + } + } + } + } while (0); +} + +void ble_services_add(const qiot_service_init_s *p_service) +{ + // do nothing + return; +} + +void ble_qiot_service_init(void) +{ + esp_err_t ret; + + ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)); + + esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); + ret = esp_bt_controller_init(&bt_cfg); + if (ret) { + ESP_LOGE(LLSYNC_LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret)); + return; + } + + ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); + if (ret) { + ESP_LOGE(LLSYNC_LOG_TAG, "%s enable controller failed: %s", __func__, esp_err_to_name(ret)); + return; + } + + ret = esp_bluedroid_init(); + if (ret) { + ESP_LOGE(LLSYNC_LOG_TAG, "%s init bluetooth failed: %s", __func__, esp_err_to_name(ret)); + return; + } + + ret = esp_bluedroid_enable(); + if (ret) { + ESP_LOGE(LLSYNC_LOG_TAG, "%s enable bluetooth failed: %s", __func__, esp_err_to_name(ret)); + return; + } + + // init llsync sdk + ble_qiot_explorer_init(); + + ret = esp_ble_gatts_register_callback(gatts_event_handler); + if (ret){ + ESP_LOGE(LLSYNC_LOG_TAG, "gatts register error, error code = %x", ret); + return; + } + + ret = esp_ble_gap_register_callback(gap_event_handler); + if (ret){ + ESP_LOGE(LLSYNC_LOG_TAG, "gap register error, error code = %x", ret); + return; + } + + ret = esp_ble_gatts_app_register(LLSYNC_APP_ID); + if (ret){ + ESP_LOGE(LLSYNC_LOG_TAG, "gatts app register error, error code = %x", ret); + return; + } + + return; +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/hal/ble_qiot_config.h b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/hal/ble_qiot_config.h new file mode 100644 index 00000000..ce6df686 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/components/qcloud_llsync/hal/ble_qiot_config.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_QIOT_CONFIG_H +#define QCLOUD_BLE_QIOT_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include "esp_log.h" + +#define BLE_QIOT_SDK_VERSION "1.2.0" // sdk version +#define BLE_QIOT_SDK_DEBUG 0 // sdk debug switch + +// the device broadcast is controlled by the user, but we provide a mechanism to help the device save more power. +// if you want broadcast is triggered by something like press a button instead of all the time, and the broadcast +// stopped automatically in a few minutes if the device is not bind, define BLE_QIOT_BUTTON_BROADCAST is 1 and +// BLE_QIOT_BIND_TIMEOUT is the period that broadcast stopped. +// if the device in the bound state, broadcast dose not stop automatically. +#define BLE_QIOT_BUTTON_BROADCAST 0 +#if (1 == BLE_QIOT_BUTTON_BROADCAST) +#define BLE_QIOT_BIND_TIMEOUT (2 * 60 * 1000) // unit: ms +#endif + +// some data like integer need to be transmitted in a certain byte order, defined it according to your device +#define __ORDER_LITTLE_ENDIAN__ 1234 +#define __ORDER_BIG_ENDIAN__ 4321 +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ + +// in some BLE stack ble_qiot_log_hex() maybe not work, user can use there own hexdump function +#define BLE_QIOT_USER_DEFINE_HEDUMP 1 + +#if (1 == BLE_QIOT_USER_DEFINE_HEDUMP) +#define ble_qiot_log_hex(level, hex_name, data, data_len) \ + do { \ + esp_log_buffer_hex(hex_name, data, data_len); \ + } while (0) +#endif // BLE_QIOT_USER_DEFINE_HEDUMP + +// Macro for logging a formatted string, the function must printf raw string without any color, prefix, newline or +// timestamp +#define BLE_QIOT_LOG_PRINT(...) printf(__VA_ARGS__) + +// nrf52832xxAA Flash size is 512KB, nrf52832xxAB Flash size is 512KB, be carefol of the address! +#define BLE_QIOT_RECORD_FLASH_ADDR 0xFE000 // qiot data storage address +#define BLE_QIOT_RECORD_FLASH_PAGESIZE 4096 // flash page size, see chip datasheet + +// the following definition will affect the stack that LLSync used,the minimum value tested is +// 2048(BLE_QIOT_EVENT_MAX_SIZE is 128, BLE_QIOT_EVENT_BUF_SIZE is 23 ) the max length that llsync event data, depends +// on the length of user data reported to Tencent Lianlian at a time +#define BLE_QIOT_EVENT_MAX_SIZE (128) +// the minimum between BLE_QIOT_EVENT_MAX_SIZE and mtu +#define BLE_QIOT_EVENT_BUF_SIZE (23) +#ifdef __cplusplus +} +#endif + +#endif // QCLOUD_BLE_QIOT_CONFIG_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/main/CMakeLists.txt b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/main/CMakeLists.txt new file mode 100644 index 00000000..f0b8a5fa --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/main/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register(SRCS "app_main.c" INCLUDE_DIRS "") diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/main/app_main.c b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/main/app_main.c new file mode 100644 index 00000000..6fda5f01 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/main/app_main.c @@ -0,0 +1,54 @@ +/* + * ESPRESSIF MIT License + * + * Copyright (c) 2017 + * + * Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP32 only, in which case, + * it is free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the Software is furnished + * to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "esp_system.h" +#include "nvs_flash.h" + +#include "ble_qiot_export.h" + +extern void ble_qiot_service_init(void); +extern float sg_ch20_ppm; + +static void test_task(void *pvParameters) +{ + while (1) { + sg_ch20_ppm += 0.001; + printf("report ppm %.3f\n", sg_ch20_ppm); + ble_event_report_property(); + vTaskDelay(10000 / portTICK_PERIOD_MS); + } +} + +void app_main() +{ + nvs_flash_init(); + + ble_qiot_service_init(); + xTaskCreate(test_task, "tsk1", 4 * 1024, NULL, 5, NULL); +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/partitions.csv b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/partitions.csv new file mode 100644 index 00000000..1a1d62bf --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/partitions.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offset, Size +phy_init, data, phy, 0xf000, 0x1000 +otadata,data,ota, 0x10000, 8K +nvs,data,nvs, 0x12000, 56K +ota_0,app, ota_0, 0x100000,0x180000 +ota_1,app, ota_1, 0x280000,0x180000 diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/readme.md b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/readme.md new file mode 100644 index 00000000..66557434 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/readme.md @@ -0,0 +1,36 @@ +## 说明 +本工程模拟了一个甲醛监测场景,ESP32任务定期模拟甲醛数据(也可以通过甲醛监测传感器实时获取),ESP32通过BLE和腾讯连连小程序连接,使用LLSync协议传输数据,由腾讯连连小程序将甲醛数据上传到物联网开发平台。 + +## 使用说明 +1. 安装`ESP-IDF`,请参考[官网文档](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#step-2-get-esp-idf) +```c +mkdir -p ~/esp +cd ~/esp +git clone --recursive https://github.com/espressif/esp-idf.git +``` +2. 抽取`qcloud-iot-ble-esp32`组件 +```c +cd scripts +python3 code_extract/code_extract.py esp32 +``` +3. 拷贝`qcloud-iot-ble-esp32`组件到`ESP-IDF`目录下 +```c +cp -r scripts/code_extract/qcloud-iot-ble-esp32 $IDF_PATH +cd $IDF_PATH/qcloud-iot-ble-esp32 +``` +4. 登陆[物联网开发平台](https://cloud.tencent.com/product/iotexplorer), 使用`qcloud_llsync/date_template/esp32.json`作为数据模版创建设备。 +使用新设备的三元信息替换`qcloud_llsync/hal/ble_qiot_ble_device.c`中宏定义中的设备信息,编译并烧录到开发板。 +```c +idf.py flash +``` +5. 打开腾讯连连小程序,添加设备,观察串口输出和小程序界面,串口输出如下: +```c +report ppm 0.028 +I (271165) post data: 00 00 05 60 43 60 e5 3c +I (271165) LLSYNC: ESP_GATTS_CONF_EVT, status = 0, attr_handle 46 +I (271445) LLSYNC: GATT_WRITE_EVT, handle = 44, value len = 2, value : +I (271445) LLSYNC: 20 00 +I (271445) LLSYNC: ble_lldata_write_cb +I (271445) LLSYNC: GATT_WRITE_EVT OVER +``` +可以观察到小程序界面甲醛数据同步变化。 diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/sdkconfig b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/sdkconfig new file mode 100644 index 00000000..921fdd8d --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/sdkconfig @@ -0,0 +1,1612 @@ +# +# Automatically generated file. DO NOT EDIT. +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +CONFIG_IDF_CMAKE=y +CONFIG_IDF_TARGET="esp32" +CONFIG_IDF_TARGET_ESP32=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 + +# +# SDK tool configuration +# +CONFIG_SDK_TOOLPREFIX="xtensa-esp32-elf-" +# CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set +# end of SDK tool configuration + +# +# Build type +# +CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y +# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set +CONFIG_APP_BUILD_GENERATE_BINARIES=y +CONFIG_APP_BUILD_BOOTLOADER=y +CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y +# end of Build type + +# +# Application manager +# +CONFIG_APP_COMPILE_TIME_DATE=y +# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set +# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set +# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set +CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 +# end of Application manager + +# +# Bootloader config +# +CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set +CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y +# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set +CONFIG_BOOTLOADER_LOG_LEVEL=3 +# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set +CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y +# CONFIG_BOOTLOADER_FACTORY_RESET is not set +# CONFIG_BOOTLOADER_APP_TEST is not set +CONFIG_BOOTLOADER_WDT_ENABLE=y +# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set +CONFIG_BOOTLOADER_WDT_TIME_MS=9000 +# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set +CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 +# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set +# end of Bootloader config + +# +# Security features +# +# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set +# CONFIG_SECURE_BOOT is not set +# CONFIG_SECURE_FLASH_ENC_ENABLED is not set +# end of Security features + +# +# Serial flasher config +# +CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 +CONFIG_ESPTOOLPY_WITH_STUB=y +# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set +# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set +CONFIG_ESPTOOLPY_FLASHMODE_DIO=y +# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set +CONFIG_ESPTOOLPY_FLASHMODE="dio" +# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set +CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set +# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set +CONFIG_ESPTOOLPY_FLASHFREQ="40m" +# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +CONFIG_ESPTOOLPY_BEFORE_RESET=y +# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set +CONFIG_ESPTOOLPY_BEFORE="default_reset" +CONFIG_ESPTOOLPY_AFTER_RESET=y +# CONFIG_ESPTOOLPY_AFTER_NORESET is not set +CONFIG_ESPTOOLPY_AFTER="hard_reset" +# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 +# end of Serial flasher config + +# +# Partition Table +# +# CONFIG_PARTITION_TABLE_SINGLE_APP is not set +# CONFIG_PARTITION_TABLE_TWO_OTA is not set +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_MD5=y +# end of Partition Table + +# +# Compiler options +# +CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y +# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set +# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_COMPILER_OPTIMIZATION_NONE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +# CONFIG_COMPILER_CXX_EXCEPTIONS is not set +# CONFIG_COMPILER_CXX_RTTI is not set +CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y +# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set +# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set +# end of Compiler options + +# +# Component config +# + +# +# Application Level Tracing +# +# CONFIG_APPTRACE_DEST_TRAX is not set +CONFIG_APPTRACE_DEST_NONE=y +CONFIG_APPTRACE_LOCK_ENABLE=y +# end of Application Level Tracing + +# +# Bluetooth +# +CONFIG_BT_ENABLED=y + +# +# Bluetooth controller +# +CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y +# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set +# CONFIG_BTDM_CTRL_MODE_BTDM is not set +CONFIG_BTDM_CTRL_BLE_MAX_CONN=3 +CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0 +CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0 +CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0 +CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=3 +CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0 +CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0 +CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y +# CONFIG_BTDM_CTRL_PINNED_TO_CORE_1 is not set +CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 +CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y +# CONFIG_BTDM_CTRL_HCI_MODE_UART_H4 is not set + +# +# MODEM SLEEP Options +# +CONFIG_BTDM_MODEM_SLEEP=y +CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG=y +# CONFIG_BTDM_MODEM_SLEEP_MODE_EVED is not set +CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL=y +# end of MODEM SLEEP Options + +CONFIG_BTDM_BLE_DEFAULT_SCA_250PPM=y +CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 +CONFIG_BTDM_BLE_SCAN_DUPL=y +CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE=y +# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA is not set +# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE is not set +CONFIG_BTDM_SCAN_DUPL_TYPE=0 +CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE=200 +# CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN is not set +CONFIG_BTDM_CTRL_FULL_SCAN_SUPPORTED=y +CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y +CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 +CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 +# CONFIG_BTDM_COEX_BT_OPTIONS is not set +# end of Bluetooth controller + +CONFIG_BT_BLUEDROID_ENABLED=y +# CONFIG_BT_NIMBLE_ENABLED is not set +# CONFIG_BT_CONTROLLER_ONLY is not set + +# +# Bluedroid Options +# +CONFIG_BT_BTC_TASK_STACK_SIZE=3072 +CONFIG_BT_BLUEDROID_PINNED_TO_CORE_0=y +# CONFIG_BT_BLUEDROID_PINNED_TO_CORE_1 is not set +CONFIG_BT_BLUEDROID_PINNED_TO_CORE=0 +CONFIG_BT_BTU_TASK_STACK_SIZE=4096 +# CONFIG_BT_BLUEDROID_MEM_DEBUG is not set +# CONFIG_BT_CLASSIC_ENABLED is not set +CONFIG_BT_BLE_ENABLED=y +CONFIG_BT_GATTS_ENABLE=y +# CONFIG_BT_GATTS_PPCP_CHAR_GAP is not set +# CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MANUAL is not set +CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_AUTO=y +CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE=0 +CONFIG_BT_GATTC_ENABLE=y +# CONFIG_BT_GATTC_CACHE_NVS_FLASH is not set +CONFIG_BT_BLE_SMP_ENABLE=y +# CONFIG_BT_SMP_SLAVE_CON_PARAMS_UPD_ENABLE is not set +# CONFIG_BT_STACK_NO_LOG is not set + +# +# BT DEBUG LOG LEVEL +# +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_HCI_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_HCI_TRACE_LEVEL=2 +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_BTM_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_BTM_TRACE_LEVEL=2 +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_L2CAP_TRACE_LEVEL=2 +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL=2 +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_SDP_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_SDP_TRACE_LEVEL=2 +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_GAP_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_GAP_TRACE_LEVEL=2 +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_BNEP_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_BNEP_TRACE_LEVEL=2 +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_PAN_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_PAN_TRACE_LEVEL=2 +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_A2D_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_A2D_TRACE_LEVEL=2 +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_AVDT_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_AVDT_TRACE_LEVEL=2 +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_AVCT_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_AVCT_TRACE_LEVEL=2 +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_AVRC_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_AVRC_TRACE_LEVEL=2 +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_MCA_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_MCA_TRACE_LEVEL=2 +# CONFIG_BT_LOG_HID_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_HID_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_HID_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_HID_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_HID_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_HID_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_HID_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_HID_TRACE_LEVEL=2 +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_APPL_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_APPL_TRACE_LEVEL=2 +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_GATT_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_GATT_TRACE_LEVEL=2 +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_SMP_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_SMP_TRACE_LEVEL=2 +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_BTIF_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_BTIF_TRACE_LEVEL=2 +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_BTC_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_BTC_TRACE_LEVEL=2 +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_OSI_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_OSI_TRACE_LEVEL=2 +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_BLUFI_TRACE_LEVEL=2 +# end of BT DEBUG LOG LEVEL + +CONFIG_BT_ACL_CONNECTIONS=4 +# CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST is not set +# CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY is not set +# CONFIG_BT_BLE_HOST_QUEUE_CONG_CHECK is not set +CONFIG_BT_SMP_ENABLE=y +# CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN is not set +CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT=30 +CONFIG_BT_RESERVE_DRAM=0xdb5c +# end of Bluedroid Options +# end of Bluetooth + +# CONFIG_BLE_MESH is not set + +# +# CoAP Configuration +# +CONFIG_COAP_MBEDTLS_PSK=y +# CONFIG_COAP_MBEDTLS_PKI is not set +# CONFIG_COAP_MBEDTLS_DEBUG is not set +CONFIG_COAP_LOG_DEFAULT_LEVEL=0 +# end of CoAP Configuration + +# +# Driver configurations +# + +# +# ADC configuration +# +# CONFIG_ADC_FORCE_XPD_FSM is not set +CONFIG_ADC_DISABLE_DAC=y +# end of ADC configuration + +# +# SPI configuration +# +# CONFIG_SPI_MASTER_IN_IRAM is not set +CONFIG_SPI_MASTER_ISR_IN_IRAM=y +# CONFIG_SPI_SLAVE_IN_IRAM is not set +CONFIG_SPI_SLAVE_ISR_IN_IRAM=y +# end of SPI configuration + +# +# UART configuration +# +# CONFIG_UART_ISR_IN_IRAM is not set +# end of UART configuration + +# +# RTCIO configuration +# +# CONFIG_RTCIO_SUPPORT_RTC_GPIO_DESC is not set +# end of RTCIO configuration +# end of Driver configurations + +# +# eFuse Bit Manager +# +# CONFIG_EFUSE_CUSTOM_TABLE is not set +# CONFIG_EFUSE_VIRTUAL is not set +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set +CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set +CONFIG_EFUSE_MAX_BLK_LEN=192 +# end of eFuse Bit Manager + +# +# ESP-TLS +# +CONFIG_ESP_TLS_USING_MBEDTLS=y +# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set +# CONFIG_ESP_TLS_SERVER is not set +# CONFIG_ESP_TLS_PSK_VERIFICATION is not set +# end of ESP-TLS + +# +# ESP32-specific +# +CONFIG_ESP32_REV_MIN_0=y +# CONFIG_ESP32_REV_MIN_1 is not set +# CONFIG_ESP32_REV_MIN_2 is not set +# CONFIG_ESP32_REV_MIN_3 is not set +CONFIG_ESP32_REV_MIN=0 +CONFIG_ESP32_DPORT_WORKAROUND=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 +# CONFIG_ESP32_SPIRAM_SUPPORT is not set +# CONFIG_ESP32_TRAX is not set +CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 +# CONFIG_ESP32_ULP_COPROC_ENABLED is not set +CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0 +CONFIG_ESP32_DEBUG_OCDAWARE=y +CONFIG_ESP32_BROWNOUT_DET=y +CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_ESP32_BROWNOUT_DET_LVL=0 +CONFIG_ESP32_REDUCE_PHY_TX_POWER=y +CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y +# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set +CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y +# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set +# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set +# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set +CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 +CONFIG_ESP32_XTAL_FREQ_40=y +# CONFIG_ESP32_XTAL_FREQ_26 is not set +# CONFIG_ESP32_XTAL_FREQ_AUTO is not set +CONFIG_ESP32_XTAL_FREQ=40 +# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set +# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set +# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set +CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 +# end of ESP32-specific + +# +# Power Management +# +# CONFIG_PM_ENABLE is not set +# end of Power Management + +# +# ADC-Calibration +# +CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y +CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y +CONFIG_ADC_CAL_LUT_ENABLE=y +# end of ADC-Calibration + +# +# Common ESP-related +# +CONFIG_ESP_ERR_TO_NAME_LOOKUP=y +CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 +CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 +CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y +CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 +CONFIG_ESP_CONSOLE_UART_DEFAULT=y +# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_UART_NONE is not set +CONFIG_ESP_CONSOLE_UART_NUM=0 +CONFIG_ESP_CONSOLE_UART_TX_GPIO=1 +CONFIG_ESP_CONSOLE_UART_RX_GPIO=3 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +CONFIG_ESP_INT_WDT=y +CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 +CONFIG_ESP_INT_WDT_CHECK_CPU1=y +CONFIG_ESP_TASK_WDT=y +# CONFIG_ESP_TASK_WDT_PANIC is not set +CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y +# CONFIG_ESP_PANIC_HANDLER_IRAM is not set +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_BT_OFFSET=2 +CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y +# end of Common ESP-related + +# +# Ethernet +# +CONFIG_ETH_ENABLED=y +CONFIG_ETH_USE_ESP32_EMAC=y +CONFIG_ETH_PHY_INTERFACE_RMII=y +# CONFIG_ETH_PHY_INTERFACE_MII is not set +CONFIG_ETH_RMII_CLK_INPUT=y +# CONFIG_ETH_RMII_CLK_OUTPUT is not set +CONFIG_ETH_RMII_CLK_IN_GPIO=0 +CONFIG_ETH_DMA_BUFFER_SIZE=512 +CONFIG_ETH_DMA_RX_BUFFER_NUM=10 +CONFIG_ETH_DMA_TX_BUFFER_NUM=10 +CONFIG_ETH_USE_SPI_ETHERNET=y +CONFIG_ETH_SPI_ETHERNET_DM9051=y +# CONFIG_ETH_USE_OPENETH is not set +# end of Ethernet + +# +# Event Loop Library +# +# CONFIG_ESP_EVENT_LOOP_PROFILING is not set +CONFIG_ESP_EVENT_POST_FROM_ISR=y +CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y +# end of Event Loop Library + +# +# GDB Stub +# +# end of GDB Stub + +# +# ESP HTTP client +# +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y +# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set +# end of ESP HTTP client + +# +# HTTP Server +# +CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 +CONFIG_HTTPD_MAX_URI_LEN=512 +CONFIG_HTTPD_ERR_RESP_NO_DELAY=y +CONFIG_HTTPD_PURGE_BUF_LEN=32 +# CONFIG_HTTPD_LOG_PURGE_DATA is not set +# CONFIG_HTTPD_WS_SUPPORT is not set +# end of HTTP Server + +# +# ESP HTTPS OTA +# +# CONFIG_OTA_ALLOW_HTTP is not set +# end of ESP HTTPS OTA + +# +# ESP HTTPS server +# +# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set +# end of ESP HTTPS server + +# +# ESP NETIF Adapter +# +CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 +CONFIG_ESP_NETIF_TCPIP_LWIP=y +# CONFIG_ESP_NETIF_LOOPBACK is not set +CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=y +# end of ESP NETIF Adapter + +# +# ESP System Settings +# +# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set +CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y +# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set +# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set +# end of ESP System Settings + +# +# High resolution timer (esp_timer) +# +# CONFIG_ESP_TIMER_PROFILING is not set +CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 +# CONFIG_ESP_TIMER_IMPL_FRC2 is not set +CONFIG_ESP_TIMER_IMPL_TG0_LAC=y +# end of High resolution timer (esp_timer) + +# +# Wi-Fi +# +CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE=y +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +CONFIG_ESP32_WIFI_NVS_ENABLED=y +CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y +# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +# CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE is not set +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y +# end of Wi-Fi + +# +# PHY +# +CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP32_PHY_MAX_TX_POWER=20 +# end of PHY + +# +# Core dump +# +# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set +CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +# end of Core dump + +# +# FAT Filesystem support +# +# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set +CONFIG_FATFS_CODEPAGE_437=y +# CONFIG_FATFS_CODEPAGE_720 is not set +# CONFIG_FATFS_CODEPAGE_737 is not set +# CONFIG_FATFS_CODEPAGE_771 is not set +# CONFIG_FATFS_CODEPAGE_775 is not set +# CONFIG_FATFS_CODEPAGE_850 is not set +# CONFIG_FATFS_CODEPAGE_852 is not set +# CONFIG_FATFS_CODEPAGE_855 is not set +# CONFIG_FATFS_CODEPAGE_857 is not set +# CONFIG_FATFS_CODEPAGE_860 is not set +# CONFIG_FATFS_CODEPAGE_861 is not set +# CONFIG_FATFS_CODEPAGE_862 is not set +# CONFIG_FATFS_CODEPAGE_863 is not set +# CONFIG_FATFS_CODEPAGE_864 is not set +# CONFIG_FATFS_CODEPAGE_865 is not set +# CONFIG_FATFS_CODEPAGE_866 is not set +# CONFIG_FATFS_CODEPAGE_869 is not set +# CONFIG_FATFS_CODEPAGE_932 is not set +# CONFIG_FATFS_CODEPAGE_936 is not set +# CONFIG_FATFS_CODEPAGE_949 is not set +# CONFIG_FATFS_CODEPAGE_950 is not set +CONFIG_FATFS_CODEPAGE=437 +CONFIG_FATFS_LFN_NONE=y +# CONFIG_FATFS_LFN_HEAP is not set +# CONFIG_FATFS_LFN_STACK is not set +CONFIG_FATFS_FS_LOCK=0 +CONFIG_FATFS_TIMEOUT_MS=10000 +CONFIG_FATFS_PER_FILE_CACHE=y +# end of FAT Filesystem support + +# +# Modbus configuration +# +CONFIG_FMB_COMM_MODE_RTU_EN=y +CONFIG_FMB_COMM_MODE_ASCII_EN=y +CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150 +CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200 +CONFIG_FMB_QUEUE_LENGTH=20 +CONFIG_FMB_SERIAL_TASK_STACK_SIZE=2048 +CONFIG_FMB_SERIAL_BUF_SIZE=256 +CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8 +CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000 +CONFIG_FMB_SERIAL_TASK_PRIO=10 +# CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT is not set +CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_FMB_CONTROLLER_STACK_SIZE=4096 +CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 +CONFIG_FMB_TIMER_PORT_ENABLED=y +CONFIG_FMB_TIMER_GROUP=0 +CONFIG_FMB_TIMER_INDEX=0 +# CONFIG_FMB_TIMER_ISR_IN_IRAM is not set +# end of Modbus configuration + +# +# FreeRTOS +# +# CONFIG_FREERTOS_UNICORE is not set +CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +CONFIG_FREERTOS_CORETIMER_0=y +# CONFIG_FREERTOS_CORETIMER_1 is not set +CONFIG_FREERTOS_HZ=100 +CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set +CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y +# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set +CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y +CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 +CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y +# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set +# CONFIG_FREERTOS_ASSERT_DISABLE is not set +CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 +CONFIG_FREERTOS_ISR_STACKSIZE=1536 +# CONFIG_FREERTOS_LEGACY_HOOKS is not set +CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 +# CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION is not set +CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 +CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 +CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 +# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set +# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set +CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y +CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y +# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set +CONFIG_FREERTOS_DEBUG_OCDAWARE=y +# CONFIG_FREERTOS_FPU_IN_ISR is not set +# end of FreeRTOS + +# +# Heap memory debugging +# +CONFIG_HEAP_POISONING_DISABLED=y +# CONFIG_HEAP_POISONING_LIGHT is not set +# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set +CONFIG_HEAP_TRACING_OFF=y +# CONFIG_HEAP_TRACING_STANDALONE is not set +# CONFIG_HEAP_TRACING_TOHOST is not set +# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set +# end of Heap memory debugging + +# +# jsmn +# +# CONFIG_JSMN_PARENT_LINKS is not set +# CONFIG_JSMN_STRICT is not set +# end of jsmn + +# +# libsodium +# +# end of libsodium + +# +# Log output +# +# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set +# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set +# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set +# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_LOG_COLORS=y +CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y +# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set +# end of Log output + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y +# CONFIG_LWIP_L2_TO_L3_COPY is not set +# CONFIG_LWIP_IRAM_OPTIMIZATION is not set +CONFIG_LWIP_TIMERS_ONDEMAND=y +CONFIG_LWIP_MAX_SOCKETS=10 +# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set +# CONFIG_LWIP_SO_LINGER is not set +CONFIG_LWIP_SO_REUSE=y +CONFIG_LWIP_SO_REUSE_RXTOALL=y +# CONFIG_LWIP_SO_RCVBUF is not set +# CONFIG_LWIP_NETBUF_RECVINFO is not set +CONFIG_LWIP_IP4_FRAG=y +CONFIG_LWIP_IP6_FRAG=y +# CONFIG_LWIP_IP4_REASSEMBLY is not set +# CONFIG_LWIP_IP6_REASSEMBLY is not set +# CONFIG_LWIP_IP_FORWARD is not set +# CONFIG_LWIP_STATS is not set +# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set +CONFIG_LWIP_ESP_GRATUITOUS_ARP=y +CONFIG_LWIP_GARP_TMR_INTERVAL=60 +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 +CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set + +# +# DHCP server +# +CONFIG_LWIP_DHCPS_LEASE_UNIT=60 +CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +# end of DHCP server + +# CONFIG_LWIP_AUTOIP is not set +# CONFIG_LWIP_IPV6_AUTOCONFIG is not set +CONFIG_LWIP_NETIF_LOOPBACK=y +CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 + +# +# TCP +# +CONFIG_LWIP_MAX_ACTIVE_TCP=16 +CONFIG_LWIP_MAX_LISTENING_TCP=16 +CONFIG_LWIP_TCP_MAXRTX=12 +CONFIG_LWIP_TCP_SYNMAXRTX=6 +CONFIG_LWIP_TCP_MSS=1440 +CONFIG_LWIP_TCP_TMR_INTERVAL=250 +CONFIG_LWIP_TCP_MSL=60000 +CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 +CONFIG_LWIP_TCP_WND_DEFAULT=5744 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 +CONFIG_LWIP_TCP_QUEUE_OOSEQ=y +# CONFIG_LWIP_TCP_SACK_OUT is not set +# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_LWIP_TCP_OVERSIZE_MSS=y +# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set +CONFIG_LWIP_TCP_RTO_TIME=3000 +# end of TCP + +# +# UDP +# +CONFIG_LWIP_MAX_UDP_PCBS=16 +CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 +# end of UDP + +CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set +CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_LWIP_PPP_SUPPORT is not set +CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 +CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 + +# +# ICMP +# +# CONFIG_LWIP_MULTICAST_PING is not set +# CONFIG_LWIP_BROADCAST_PING is not set +# end of ICMP + +# +# LWIP RAW API +# +CONFIG_LWIP_MAX_RAW_PCBS=16 +# end of LWIP RAW API + +# +# SNTP +# +CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 +CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 +# end of SNTP + +CONFIG_LWIP_ESP_LWIP_ASSERT=y +# end of LWIP + +# +# mbedTLS +# +CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y +# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set +# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set +CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y +CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 +CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 +# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set +# CONFIG_MBEDTLS_DEBUG is not set + +# +# Certificate Bundle +# +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set +# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set +# end of Certificate Bundle + +# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set +# CONFIG_MBEDTLS_CMAC_C is not set +CONFIG_MBEDTLS_HARDWARE_AES=y +CONFIG_MBEDTLS_HARDWARE_MPI=y +CONFIG_MBEDTLS_HARDWARE_SHA=y +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set +CONFIG_MBEDTLS_HAVE_TIME=y +# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set +CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y +CONFIG_MBEDTLS_SHA512_C=y +CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y +# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set +# CONFIG_MBEDTLS_TLS_DISABLED is not set +CONFIG_MBEDTLS_TLS_SERVER=y +CONFIG_MBEDTLS_TLS_CLIENT=y +CONFIG_MBEDTLS_TLS_ENABLED=y + +# +# TLS Key Exchange Methods +# +# CONFIG_MBEDTLS_PSK_MODES is not set +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y +# end of TLS Key Exchange Methods + +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y +# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set +CONFIG_MBEDTLS_SSL_PROTO_TLS1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +CONFIG_MBEDTLS_SSL_ALPN=y +CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y +CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y + +# +# Symmetric Ciphers +# +CONFIG_MBEDTLS_AES_C=y +# CONFIG_MBEDTLS_CAMELLIA_C is not set +# CONFIG_MBEDTLS_DES_C is not set +CONFIG_MBEDTLS_RC4_DISABLED=y +# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set +# CONFIG_MBEDTLS_RC4_ENABLED is not set +# CONFIG_MBEDTLS_BLOWFISH_C is not set +# CONFIG_MBEDTLS_XTEA_C is not set +CONFIG_MBEDTLS_CCM_C=y +CONFIG_MBEDTLS_GCM_C=y +# end of Symmetric Ciphers + +# CONFIG_MBEDTLS_RIPEMD160_C is not set + +# +# Certificates +# +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +# end of Certificates + +CONFIG_MBEDTLS_ECP_C=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y +# CONFIG_MBEDTLS_ECJPAKE_C is not set +CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +CONFIG_MBEDTLS_ECP_NIST_OPTIM=y +# CONFIG_MBEDTLS_POLY1305_C is not set +# CONFIG_MBEDTLS_CHACHA20_C is not set +# CONFIG_MBEDTLS_HKDF_C is not set +# CONFIG_MBEDTLS_THREADING_C is not set +# CONFIG_MBEDTLS_SECURITY_RISKS is not set +# end of mbedTLS + +# +# mDNS +# +CONFIG_MDNS_MAX_SERVICES=10 +CONFIG_MDNS_TASK_PRIORITY=1 +CONFIG_MDNS_TASK_STACK_SIZE=4096 +# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_MDNS_TASK_AFFINITY_CPU0=y +# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set +CONFIG_MDNS_TASK_AFFINITY=0x0 +CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 +CONFIG_MDNS_TIMER_PERIOD_MS=100 +# end of mDNS + +# +# ESP-MQTT Configurations +# +CONFIG_MQTT_PROTOCOL_311=y +CONFIG_MQTT_TRANSPORT_SSL=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y +# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set +# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set +# CONFIG_MQTT_CUSTOM_OUTBOX is not set +# end of ESP-MQTT Configurations + +# +# Newlib +# +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y +# CONFIG_NEWLIB_NANO_FORMAT is not set +# end of Newlib + +# +# NVS +# +# end of NVS + +# +# OpenSSL +# +# CONFIG_OPENSSL_DEBUG is not set +# CONFIG_OPENSSL_ASSERT_DO_NOTHING is not set +CONFIG_OPENSSL_ASSERT_EXIT=y +# end of OpenSSL + +# +# PThreads +# +CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_PTHREAD_STACK_MIN=768 +CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y +# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set +# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set +CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" +# end of PThreads + +# +# SPI Flash driver +# +# CONFIG_SPI_FLASH_VERIFY_WRITE is not set +# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set +CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y +CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set +# CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set +# CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set +# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set +CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y +CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 +CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 + +# +# Auto-detect flash chips +# +CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y +# end of Auto-detect flash chips +# end of SPI Flash driver + +# +# SPIFFS Configuration +# +CONFIG_SPIFFS_MAX_PARTITIONS=3 + +# +# SPIFFS Cache Configuration +# +CONFIG_SPIFFS_CACHE=y +CONFIG_SPIFFS_CACHE_WR=y +# CONFIG_SPIFFS_CACHE_STATS is not set +# end of SPIFFS Cache Configuration + +CONFIG_SPIFFS_PAGE_CHECK=y +CONFIG_SPIFFS_GC_MAX_RUNS=10 +# CONFIG_SPIFFS_GC_STATS is not set +CONFIG_SPIFFS_PAGE_SIZE=256 +CONFIG_SPIFFS_OBJ_NAME_LEN=32 +# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set +CONFIG_SPIFFS_USE_MAGIC=y +CONFIG_SPIFFS_USE_MAGIC_LENGTH=y +CONFIG_SPIFFS_META_LENGTH=4 +CONFIG_SPIFFS_USE_MTIME=y + +# +# Debug Configuration +# +# CONFIG_SPIFFS_DBG is not set +# CONFIG_SPIFFS_API_DBG is not set +# CONFIG_SPIFFS_GC_DBG is not set +# CONFIG_SPIFFS_CACHE_DBG is not set +# CONFIG_SPIFFS_CHECK_DBG is not set +# CONFIG_SPIFFS_TEST_VISUALISATION is not set +# end of Debug Configuration +# end of SPIFFS Configuration + +# +# TinyUSB +# + +# +# Descriptor configuration +# +CONFIG_USB_DESC_CUSTOM_VID=0x1234 +CONFIG_USB_DESC_CUSTOM_PID=0x5678 +# end of Descriptor configuration +# end of TinyUSB + +# +# Unity unit testing library +# +CONFIG_UNITY_ENABLE_FLOAT=y +CONFIG_UNITY_ENABLE_DOUBLE=y +# CONFIG_UNITY_ENABLE_COLOR is not set +CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y +# CONFIG_UNITY_ENABLE_FIXTURE is not set +# CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set +# end of Unity unit testing library + +# +# Virtual file system +# +CONFIG_VFS_SUPPORT_IO=y +CONFIG_VFS_SUPPORT_DIR=y +CONFIG_VFS_SUPPORT_SELECT=y +CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_VFS_SUPPORT_TERMIOS=y + +# +# Host File System I/O (Semihosting) +# +CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 +# end of Host File System I/O (Semihosting) +# end of Virtual file system + +# +# Wear Levelling +# +# CONFIG_WL_SECTOR_SIZE_512 is not set +CONFIG_WL_SECTOR_SIZE_4096=y +CONFIG_WL_SECTOR_SIZE=4096 +# end of Wear Levelling + +# +# Wi-Fi Provisioning Manager +# +CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 +CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 +# end of Wi-Fi Provisioning Manager + +# +# Supplicant +# +CONFIG_WPA_MBEDTLS_CRYPTO=y +# CONFIG_WPA_DEBUG_PRINT is not set +# CONFIG_WPA_TESTING_OPTIONS is not set +# CONFIG_WPA_WPS_WARS is not set +# end of Supplicant + +# +# QCloud LLSync +# +CONFIG_QCLOUD_LLSYNC_SUPPORT=y +# end of QCloud LLSync +# end of Component config + +# +# Compatibility options +# +# CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set +# end of Compatibility options + +# Deprecated options for backward compatibility +CONFIG_TOOLPREFIX="xtensa-esp32-elf-" +# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set +CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y +# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set +CONFIG_LOG_BOOTLOADER_LEVEL=3 +# CONFIG_APP_ROLLBACK_ENABLE is not set +# CONFIG_FLASH_ENCRYPTION_ENABLED is not set +# CONFIG_FLASHMODE_QIO is not set +# CONFIG_FLASHMODE_QOUT is not set +CONFIG_FLASHMODE_DIO=y +# CONFIG_FLASHMODE_DOUT is not set +# CONFIG_MONITOR_BAUD_9600B is not set +# CONFIG_MONITOR_BAUD_57600B is not set +CONFIG_MONITOR_BAUD_115200B=y +# CONFIG_MONITOR_BAUD_230400B is not set +# CONFIG_MONITOR_BAUD_921600B is not set +# CONFIG_MONITOR_BAUD_2MB is not set +# CONFIG_MONITOR_BAUD_OTHER is not set +CONFIG_MONITOR_BAUD_OTHER_VAL=115200 +CONFIG_MONITOR_BAUD=115200 +CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y +# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set +CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y +# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set +# CONFIG_CXX_EXCEPTIONS is not set +CONFIG_STACK_CHECK_NONE=y +# CONFIG_STACK_CHECK_NORM is not set +# CONFIG_STACK_CHECK_STRONG is not set +# CONFIG_STACK_CHECK_ALL is not set +# CONFIG_WARN_WRITE_STRINGS is not set +# CONFIG_DISABLE_GCC8_WARNINGS is not set +# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set +CONFIG_ESP32_APPTRACE_DEST_NONE=y +CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY=y +# CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY is not set +# CONFIG_BTDM_CONTROLLER_MODE_BTDM is not set +CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN=3 +CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=3 +CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=0 +CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=0 +CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 +CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y +# CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4 is not set +CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=y +CONFIG_BLE_SCAN_DUPLICATE=y +CONFIG_SCAN_DUPLICATE_BY_DEVICE_ADDR=y +# CONFIG_SCAN_DUPLICATE_BY_ADV_DATA is not set +# CONFIG_SCAN_DUPLICATE_BY_ADV_DATA_AND_DEVICE_ADDR is not set +CONFIG_SCAN_DUPLICATE_TYPE=0 +CONFIG_DUPLICATE_SCAN_CACHE_SIZE=200 +# CONFIG_BLE_MESH_SCAN_DUPLICATE_EN is not set +CONFIG_BTDM_CONTROLLER_FULL_SCAN_SUPPORTED=y +CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED=y +CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM=100 +CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 +CONFIG_BLUEDROID_ENABLED=y +# CONFIG_NIMBLE_ENABLED is not set +CONFIG_BTC_TASK_STACK_SIZE=3072 +CONFIG_BLUEDROID_PINNED_TO_CORE_0=y +# CONFIG_BLUEDROID_PINNED_TO_CORE_1 is not set +CONFIG_BLUEDROID_PINNED_TO_CORE=0 +CONFIG_BTU_TASK_STACK_SIZE=4096 +# CONFIG_BLUEDROID_MEM_DEBUG is not set +# CONFIG_CLASSIC_BT_ENABLED is not set +CONFIG_GATTS_ENABLE=y +# CONFIG_GATTS_SEND_SERVICE_CHANGE_MANUAL is not set +CONFIG_GATTS_SEND_SERVICE_CHANGE_AUTO=y +CONFIG_GATTS_SEND_SERVICE_CHANGE_MODE=0 +CONFIG_GATTC_ENABLE=y +# CONFIG_GATTC_CACHE_NVS_FLASH is not set +CONFIG_BLE_SMP_ENABLE=y +# CONFIG_SMP_SLAVE_CON_PARAMS_UPD_ENABLE is not set +# CONFIG_HCI_TRACE_LEVEL_NONE is not set +# CONFIG_HCI_TRACE_LEVEL_ERROR is not set +CONFIG_HCI_TRACE_LEVEL_WARNING=y +# CONFIG_HCI_TRACE_LEVEL_API is not set +# CONFIG_HCI_TRACE_LEVEL_EVENT is not set +# CONFIG_HCI_TRACE_LEVEL_DEBUG is not set +# CONFIG_HCI_TRACE_LEVEL_VERBOSE is not set +CONFIG_HCI_INITIAL_TRACE_LEVEL=2 +# CONFIG_BTM_TRACE_LEVEL_NONE is not set +# CONFIG_BTM_TRACE_LEVEL_ERROR is not set +CONFIG_BTM_TRACE_LEVEL_WARNING=y +# CONFIG_BTM_TRACE_LEVEL_API is not set +# CONFIG_BTM_TRACE_LEVEL_EVENT is not set +# CONFIG_BTM_TRACE_LEVEL_DEBUG is not set +# CONFIG_BTM_TRACE_LEVEL_VERBOSE is not set +CONFIG_BTM_INITIAL_TRACE_LEVEL=2 +# CONFIG_L2CAP_TRACE_LEVEL_NONE is not set +# CONFIG_L2CAP_TRACE_LEVEL_ERROR is not set +CONFIG_L2CAP_TRACE_LEVEL_WARNING=y +# CONFIG_L2CAP_TRACE_LEVEL_API is not set +# CONFIG_L2CAP_TRACE_LEVEL_EVENT is not set +# CONFIG_L2CAP_TRACE_LEVEL_DEBUG is not set +# CONFIG_L2CAP_TRACE_LEVEL_VERBOSE is not set +CONFIG_L2CAP_INITIAL_TRACE_LEVEL=2 +# CONFIG_RFCOMM_TRACE_LEVEL_NONE is not set +# CONFIG_RFCOMM_TRACE_LEVEL_ERROR is not set +CONFIG_RFCOMM_TRACE_LEVEL_WARNING=y +# CONFIG_RFCOMM_TRACE_LEVEL_API is not set +# CONFIG_RFCOMM_TRACE_LEVEL_EVENT is not set +# CONFIG_RFCOMM_TRACE_LEVEL_DEBUG is not set +# CONFIG_RFCOMM_TRACE_LEVEL_VERBOSE is not set +CONFIG_RFCOMM_INITIAL_TRACE_LEVEL=2 +# CONFIG_SDP_TRACE_LEVEL_NONE is not set +# CONFIG_SDP_TRACE_LEVEL_ERROR is not set +CONFIG_SDP_TRACE_LEVEL_WARNING=y +# CONFIG_SDP_TRACE_LEVEL_API is not set +# CONFIG_SDP_TRACE_LEVEL_EVENT is not set +# CONFIG_SDP_TRACE_LEVEL_DEBUG is not set +# CONFIG_SDP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BTH_LOG_SDP_INITIAL_TRACE_LEVEL=2 +# CONFIG_GAP_TRACE_LEVEL_NONE is not set +# CONFIG_GAP_TRACE_LEVEL_ERROR is not set +CONFIG_GAP_TRACE_LEVEL_WARNING=y +# CONFIG_GAP_TRACE_LEVEL_API is not set +# CONFIG_GAP_TRACE_LEVEL_EVENT is not set +# CONFIG_GAP_TRACE_LEVEL_DEBUG is not set +# CONFIG_GAP_TRACE_LEVEL_VERBOSE is not set +CONFIG_GAP_INITIAL_TRACE_LEVEL=2 +CONFIG_BNEP_INITIAL_TRACE_LEVEL=2 +# CONFIG_PAN_TRACE_LEVEL_NONE is not set +# CONFIG_PAN_TRACE_LEVEL_ERROR is not set +CONFIG_PAN_TRACE_LEVEL_WARNING=y +# CONFIG_PAN_TRACE_LEVEL_API is not set +# CONFIG_PAN_TRACE_LEVEL_EVENT is not set +# CONFIG_PAN_TRACE_LEVEL_DEBUG is not set +# CONFIG_PAN_TRACE_LEVEL_VERBOSE is not set +CONFIG_PAN_INITIAL_TRACE_LEVEL=2 +# CONFIG_A2D_TRACE_LEVEL_NONE is not set +# CONFIG_A2D_TRACE_LEVEL_ERROR is not set +CONFIG_A2D_TRACE_LEVEL_WARNING=y +# CONFIG_A2D_TRACE_LEVEL_API is not set +# CONFIG_A2D_TRACE_LEVEL_EVENT is not set +# CONFIG_A2D_TRACE_LEVEL_DEBUG is not set +# CONFIG_A2D_TRACE_LEVEL_VERBOSE is not set +CONFIG_A2D_INITIAL_TRACE_LEVEL=2 +# CONFIG_AVDT_TRACE_LEVEL_NONE is not set +# CONFIG_AVDT_TRACE_LEVEL_ERROR is not set +CONFIG_AVDT_TRACE_LEVEL_WARNING=y +# CONFIG_AVDT_TRACE_LEVEL_API is not set +# CONFIG_AVDT_TRACE_LEVEL_EVENT is not set +# CONFIG_AVDT_TRACE_LEVEL_DEBUG is not set +# CONFIG_AVDT_TRACE_LEVEL_VERBOSE is not set +CONFIG_AVDT_INITIAL_TRACE_LEVEL=2 +# CONFIG_AVCT_TRACE_LEVEL_NONE is not set +# CONFIG_AVCT_TRACE_LEVEL_ERROR is not set +CONFIG_AVCT_TRACE_LEVEL_WARNING=y +# CONFIG_AVCT_TRACE_LEVEL_API is not set +# CONFIG_AVCT_TRACE_LEVEL_EVENT is not set +# CONFIG_AVCT_TRACE_LEVEL_DEBUG is not set +# CONFIG_AVCT_TRACE_LEVEL_VERBOSE is not set +CONFIG_AVCT_INITIAL_TRACE_LEVEL=2 +# CONFIG_AVRC_TRACE_LEVEL_NONE is not set +# CONFIG_AVRC_TRACE_LEVEL_ERROR is not set +CONFIG_AVRC_TRACE_LEVEL_WARNING=y +# CONFIG_AVRC_TRACE_LEVEL_API is not set +# CONFIG_AVRC_TRACE_LEVEL_EVENT is not set +# CONFIG_AVRC_TRACE_LEVEL_DEBUG is not set +# CONFIG_AVRC_TRACE_LEVEL_VERBOSE is not set +CONFIG_AVRC_INITIAL_TRACE_LEVEL=2 +# CONFIG_MCA_TRACE_LEVEL_NONE is not set +# CONFIG_MCA_TRACE_LEVEL_ERROR is not set +CONFIG_MCA_TRACE_LEVEL_WARNING=y +# CONFIG_MCA_TRACE_LEVEL_API is not set +# CONFIG_MCA_TRACE_LEVEL_EVENT is not set +# CONFIG_MCA_TRACE_LEVEL_DEBUG is not set +# CONFIG_MCA_TRACE_LEVEL_VERBOSE is not set +CONFIG_MCA_INITIAL_TRACE_LEVEL=2 +# CONFIG_HID_TRACE_LEVEL_NONE is not set +# CONFIG_HID_TRACE_LEVEL_ERROR is not set +CONFIG_HID_TRACE_LEVEL_WARNING=y +# CONFIG_HID_TRACE_LEVEL_API is not set +# CONFIG_HID_TRACE_LEVEL_EVENT is not set +# CONFIG_HID_TRACE_LEVEL_DEBUG is not set +# CONFIG_HID_TRACE_LEVEL_VERBOSE is not set +CONFIG_HID_INITIAL_TRACE_LEVEL=2 +# CONFIG_APPL_TRACE_LEVEL_NONE is not set +# CONFIG_APPL_TRACE_LEVEL_ERROR is not set +CONFIG_APPL_TRACE_LEVEL_WARNING=y +# CONFIG_APPL_TRACE_LEVEL_API is not set +# CONFIG_APPL_TRACE_LEVEL_EVENT is not set +# CONFIG_APPL_TRACE_LEVEL_DEBUG is not set +# CONFIG_APPL_TRACE_LEVEL_VERBOSE is not set +CONFIG_APPL_INITIAL_TRACE_LEVEL=2 +# CONFIG_GATT_TRACE_LEVEL_NONE is not set +# CONFIG_GATT_TRACE_LEVEL_ERROR is not set +CONFIG_GATT_TRACE_LEVEL_WARNING=y +# CONFIG_GATT_TRACE_LEVEL_API is not set +# CONFIG_GATT_TRACE_LEVEL_EVENT is not set +# CONFIG_GATT_TRACE_LEVEL_DEBUG is not set +# CONFIG_GATT_TRACE_LEVEL_VERBOSE is not set +CONFIG_GATT_INITIAL_TRACE_LEVEL=2 +# CONFIG_SMP_TRACE_LEVEL_NONE is not set +# CONFIG_SMP_TRACE_LEVEL_ERROR is not set +CONFIG_SMP_TRACE_LEVEL_WARNING=y +# CONFIG_SMP_TRACE_LEVEL_API is not set +# CONFIG_SMP_TRACE_LEVEL_EVENT is not set +# CONFIG_SMP_TRACE_LEVEL_DEBUG is not set +# CONFIG_SMP_TRACE_LEVEL_VERBOSE is not set +CONFIG_SMP_INITIAL_TRACE_LEVEL=2 +# CONFIG_BTIF_TRACE_LEVEL_NONE is not set +# CONFIG_BTIF_TRACE_LEVEL_ERROR is not set +CONFIG_BTIF_TRACE_LEVEL_WARNING=y +# CONFIG_BTIF_TRACE_LEVEL_API is not set +# CONFIG_BTIF_TRACE_LEVEL_EVENT is not set +# CONFIG_BTIF_TRACE_LEVEL_DEBUG is not set +# CONFIG_BTIF_TRACE_LEVEL_VERBOSE is not set +CONFIG_BTIF_INITIAL_TRACE_LEVEL=2 +# CONFIG_BTC_TRACE_LEVEL_NONE is not set +# CONFIG_BTC_TRACE_LEVEL_ERROR is not set +CONFIG_BTC_TRACE_LEVEL_WARNING=y +# CONFIG_BTC_TRACE_LEVEL_API is not set +# CONFIG_BTC_TRACE_LEVEL_EVENT is not set +# CONFIG_BTC_TRACE_LEVEL_DEBUG is not set +# CONFIG_BTC_TRACE_LEVEL_VERBOSE is not set +CONFIG_BTC_INITIAL_TRACE_LEVEL=2 +# CONFIG_OSI_TRACE_LEVEL_NONE is not set +# CONFIG_OSI_TRACE_LEVEL_ERROR is not set +CONFIG_OSI_TRACE_LEVEL_WARNING=y +# CONFIG_OSI_TRACE_LEVEL_API is not set +# CONFIG_OSI_TRACE_LEVEL_EVENT is not set +# CONFIG_OSI_TRACE_LEVEL_DEBUG is not set +# CONFIG_OSI_TRACE_LEVEL_VERBOSE is not set +CONFIG_OSI_INITIAL_TRACE_LEVEL=2 +# CONFIG_BLUFI_TRACE_LEVEL_NONE is not set +# CONFIG_BLUFI_TRACE_LEVEL_ERROR is not set +CONFIG_BLUFI_TRACE_LEVEL_WARNING=y +# CONFIG_BLUFI_TRACE_LEVEL_API is not set +# CONFIG_BLUFI_TRACE_LEVEL_EVENT is not set +# CONFIG_BLUFI_TRACE_LEVEL_DEBUG is not set +# CONFIG_BLUFI_TRACE_LEVEL_VERBOSE is not set +CONFIG_BLUFI_INITIAL_TRACE_LEVEL=2 +# CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK is not set +CONFIG_SMP_ENABLE=y +# CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY is not set +CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT=30 +CONFIG_ADC2_DISABLE_DAC=y +# CONFIG_SPIRAM_SUPPORT is not set +CONFIG_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_TWO_UNIVERSAL_MAC_ADDRESS is not set +CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y +CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 +# CONFIG_ULP_COPROC_ENABLED is not set +CONFIG_ULP_COPROC_RESERVE_MEM=0 +CONFIG_BROWNOUT_DET=y +CONFIG_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_BROWNOUT_DET_LVL=0 +CONFIG_REDUCE_PHY_TX_POWER=y +CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y +# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL is not set +# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC is not set +# CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256 is not set +# CONFIG_DISABLE_BASIC_ROM_CONSOLE is not set +# CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set +CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_MAIN_TASK_STACK_SIZE=3584 +CONFIG_IPC_TASK_STACK_SIZE=1024 +CONFIG_CONSOLE_UART_DEFAULT=y +# CONFIG_CONSOLE_UART_CUSTOM is not set +# CONFIG_CONSOLE_UART_NONE is not set +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_TX_GPIO=1 +CONFIG_CONSOLE_UART_RX_GPIO=3 +CONFIG_CONSOLE_UART_BAUDRATE=115200 +CONFIG_INT_WDT=y +CONFIG_INT_WDT_TIMEOUT_MS=300 +CONFIG_INT_WDT_CHECK_CPU1=y +CONFIG_TASK_WDT=y +# CONFIG_TASK_WDT_PANIC is not set +CONFIG_TASK_WDT_TIMEOUT_S=5 +CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y +# CONFIG_EVENT_LOOP_PROFILING is not set +CONFIG_POST_EVENTS_FROM_ISR=y +CONFIG_POST_EVENTS_FROM_IRAM_ISR=y +# CONFIG_ESP32S2_PANIC_PRINT_HALT is not set +CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y +# CONFIG_ESP32S2_PANIC_SILENT_REBOOT is not set +# CONFIG_ESP32S2_PANIC_GDBSTUB is not set +CONFIG_TIMER_TASK_STACK_SIZE=3584 +CONFIG_SW_COEXIST_ENABLE=y +CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND=150 +CONFIG_MB_MASTER_DELAY_MS_CONVERT=200 +CONFIG_MB_QUEUE_LENGTH=20 +CONFIG_MB_SERIAL_TASK_STACK_SIZE=2048 +CONFIG_MB_SERIAL_BUF_SIZE=256 +CONFIG_MB_SERIAL_TASK_PRIO=10 +# CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT is not set +CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_MB_CONTROLLER_STACK_SIZE=4096 +CONFIG_MB_EVENT_QUEUE_TIMEOUT=20 +CONFIG_MB_TIMER_PORT_ENABLED=y +CONFIG_MB_TIMER_GROUP=0 +CONFIG_MB_TIMER_INDEX=0 +# CONFIG_SUPPORT_STATIC_ALLOCATION is not set +CONFIG_TIMER_TASK_PRIORITY=1 +CONFIG_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_TIMER_QUEUE_LENGTH=10 +# CONFIG_L2_TO_L3_COPY is not set +# CONFIG_USE_ONLY_LWIP_SELECT is not set +CONFIG_ESP_GRATUITOUS_ARP=y +CONFIG_GARP_TMR_INTERVAL=60 +CONFIG_TCPIP_RECVMBOX_SIZE=32 +CONFIG_TCP_MAXRTX=12 +CONFIG_TCP_SYNMAXRTX=6 +CONFIG_TCP_MSS=1440 +CONFIG_TCP_MSL=60000 +CONFIG_TCP_SND_BUF_DEFAULT=5744 +CONFIG_TCP_WND_DEFAULT=5744 +CONFIG_TCP_RECVMBOX_SIZE=6 +CONFIG_TCP_QUEUE_OOSEQ=y +# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_TCP_OVERSIZE_MSS=y +# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_TCP_OVERSIZE_DISABLE is not set +CONFIG_UDP_RECVMBOX_SIZE=6 +CONFIG_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set +# CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set +CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_PPP_SUPPORT is not set +CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_ESP32_PTHREAD_STACK_MIN=768 +CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y +# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 is not set +# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 is not set +CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y +# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set +# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set +CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_SUPPORT_TERMIOS=y +CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 +# End of deprecated options diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/sdkconfig.old b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/sdkconfig.old new file mode 100644 index 00000000..52b1a691 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/esp32/sdkconfig.old @@ -0,0 +1,1257 @@ +# +# Automatically generated file. DO NOT EDIT. +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +CONFIG_IDF_CMAKE=y +CONFIG_IDF_TARGET="esp32" +CONFIG_IDF_TARGET_ESP32=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 + +# +# SDK tool configuration +# +CONFIG_SDK_TOOLPREFIX="xtensa-esp32-elf-" +# CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set +# end of SDK tool configuration + +# +# Build type +# +CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y +# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set +CONFIG_APP_BUILD_GENERATE_BINARIES=y +CONFIG_APP_BUILD_BOOTLOADER=y +CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y +# end of Build type + +# +# Application manager +# +CONFIG_APP_COMPILE_TIME_DATE=y +# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set +# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set +# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set +CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 +# end of Application manager + +# +# Bootloader config +# +CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set +CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y +# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set +CONFIG_BOOTLOADER_LOG_LEVEL=3 +# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set +CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y +# CONFIG_BOOTLOADER_FACTORY_RESET is not set +# CONFIG_BOOTLOADER_APP_TEST is not set +CONFIG_BOOTLOADER_WDT_ENABLE=y +# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set +CONFIG_BOOTLOADER_WDT_TIME_MS=9000 +# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set +CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 +# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set +# end of Bootloader config + +# +# Security features +# +# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set +# CONFIG_SECURE_BOOT is not set +# CONFIG_SECURE_FLASH_ENC_ENABLED is not set +# end of Security features + +# +# Serial flasher config +# +CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 +CONFIG_ESPTOOLPY_WITH_STUB=y +# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set +# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set +CONFIG_ESPTOOLPY_FLASHMODE_DIO=y +# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set +CONFIG_ESPTOOLPY_FLASHMODE="dio" +# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set +CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set +# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set +CONFIG_ESPTOOLPY_FLASHFREQ="40m" +# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y +# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE="2MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +CONFIG_ESPTOOLPY_BEFORE_RESET=y +# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set +CONFIG_ESPTOOLPY_BEFORE="default_reset" +CONFIG_ESPTOOLPY_AFTER_RESET=y +# CONFIG_ESPTOOLPY_AFTER_NORESET is not set +CONFIG_ESPTOOLPY_AFTER="hard_reset" +# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 +# end of Serial flasher config + +# +# Partition Table +# +# CONFIG_PARTITION_TABLE_SINGLE_APP is not set +# CONFIG_PARTITION_TABLE_TWO_OTA is not set +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_MD5=y +# end of Partition Table + +# +# Compiler options +# +CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y +# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set +# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_COMPILER_OPTIMIZATION_NONE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +# CONFIG_COMPILER_CXX_EXCEPTIONS is not set +# CONFIG_COMPILER_CXX_RTTI is not set +CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y +# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set +# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set +# end of Compiler options + +# +# Component config +# + +# +# Application Level Tracing +# +# CONFIG_APPTRACE_DEST_TRAX is not set +CONFIG_APPTRACE_DEST_NONE=y +CONFIG_APPTRACE_LOCK_ENABLE=y +# end of Application Level Tracing + +# +# Bluetooth +# +CONFIG_BT_ENABLED=y + +# +# Bluetooth controller +# +CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y +# CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY is not set +# CONFIG_BTDM_CTRL_MODE_BTDM is not set +CONFIG_BTDM_CTRL_BLE_MAX_CONN=3 +CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0 +CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0 +CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0 +CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=3 +CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0 +CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0 +CONFIG_BTDM_CTRL_PINNED_TO_CORE_0=y +# CONFIG_BTDM_CTRL_PINNED_TO_CORE_1 is not set +CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 +CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y +# CONFIG_BTDM_CTRL_HCI_MODE_UART_H4 is not set + +# +# MODEM SLEEP Options +# +CONFIG_BTDM_MODEM_SLEEP=y +CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG=y +# CONFIG_BTDM_MODEM_SLEEP_MODE_EVED is not set +CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL=y +# end of MODEM SLEEP Options + +CONFIG_BTDM_BLE_DEFAULT_SCA_250PPM=y +CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 +CONFIG_BTDM_BLE_SCAN_DUPL=y +CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE=y +# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA is not set +# CONFIG_BTDM_SCAN_DUPL_TYPE_DATA_DEVICE is not set +CONFIG_BTDM_SCAN_DUPL_TYPE=0 +CONFIG_BTDM_SCAN_DUPL_CACHE_SIZE=200 +# CONFIG_BTDM_BLE_MESH_SCAN_DUPL_EN is not set +CONFIG_BTDM_CTRL_FULL_SCAN_SUPPORTED=y +CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y +CONFIG_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 +CONFIG_BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 +# CONFIG_BTDM_COEX_BT_OPTIONS is not set +# end of Bluetooth controller + +CONFIG_BT_BLUEDROID_ENABLED=y +# CONFIG_BT_NIMBLE_ENABLED is not set +# CONFIG_BT_CONTROLLER_ONLY is not set + +# +# Bluedroid Options +# +CONFIG_BT_BTC_TASK_STACK_SIZE=3072 +CONFIG_BT_BLUEDROID_PINNED_TO_CORE_0=y +# CONFIG_BT_BLUEDROID_PINNED_TO_CORE_1 is not set +CONFIG_BT_BLUEDROID_PINNED_TO_CORE=0 +CONFIG_BT_BTU_TASK_STACK_SIZE=4096 +# CONFIG_BT_BLUEDROID_MEM_DEBUG is not set +# CONFIG_BT_CLASSIC_ENABLED is not set +CONFIG_BT_BLE_ENABLED=y +CONFIG_BT_GATTS_ENABLE=y +# CONFIG_BT_GATTS_PPCP_CHAR_GAP is not set +# CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MANUAL is not set +CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_AUTO=y +CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE=0 +CONFIG_BT_GATTC_ENABLE=y +# CONFIG_BT_GATTC_CACHE_NVS_FLASH is not set +CONFIG_BT_BLE_SMP_ENABLE=y +# CONFIG_BT_SMP_SLAVE_CON_PARAMS_UPD_ENABLE is not set +# CONFIG_BT_STACK_NO_LOG is not set + +# +# BT DEBUG LOG LEVEL +# +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_HCI_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_HCI_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_HCI_TRACE_LEVEL=2 +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_BTM_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_BTM_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_BTM_TRACE_LEVEL=2 +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_L2CAP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_L2CAP_TRACE_LEVEL=2 +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL=2 +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_SDP_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_SDP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_SDP_TRACE_LEVEL=2 +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_GAP_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_GAP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_GAP_TRACE_LEVEL=2 +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_BNEP_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_BNEP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_BNEP_TRACE_LEVEL=2 +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_PAN_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_PAN_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_PAN_TRACE_LEVEL=2 +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_A2D_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_A2D_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_A2D_TRACE_LEVEL=2 +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_AVDT_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_AVDT_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_AVDT_TRACE_LEVEL=2 +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_AVCT_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_AVCT_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_AVCT_TRACE_LEVEL=2 +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_AVRC_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_AVRC_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_AVRC_TRACE_LEVEL=2 +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_MCA_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_MCA_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_MCA_TRACE_LEVEL=2 +# CONFIG_BT_LOG_HID_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_HID_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_HID_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_HID_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_HID_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_HID_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_HID_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_HID_TRACE_LEVEL=2 +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_APPL_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_APPL_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_APPL_TRACE_LEVEL=2 +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_GATT_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_GATT_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_GATT_TRACE_LEVEL=2 +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_SMP_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_SMP_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_SMP_TRACE_LEVEL=2 +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_BTIF_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_BTIF_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_BTIF_TRACE_LEVEL=2 +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_BTC_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_BTC_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_BTC_TRACE_LEVEL=2 +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_OSI_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_OSI_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_OSI_TRACE_LEVEL=2 +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_NONE is not set +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_ERROR is not set +CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_WARNING=y +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_API is not set +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_EVENT is not set +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_DEBUG is not set +# CONFIG_BT_LOG_BLUFI_TRACE_LEVEL_VERBOSE is not set +CONFIG_BT_LOG_BLUFI_TRACE_LEVEL=2 +# end of BT DEBUG LOG LEVEL + +CONFIG_BT_ACL_CONNECTIONS=4 +# CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST is not set +# CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY is not set +# CONFIG_BT_BLE_HOST_QUEUE_CONG_CHECK is not set +CONFIG_BT_SMP_ENABLE=y +# CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN is not set +CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT=30 +CONFIG_BT_RESERVE_DRAM=0xdb5c +# end of Bluedroid Options +# end of Bluetooth + +# CONFIG_BLE_MESH is not set + +# +# CoAP Configuration +# +CONFIG_COAP_MBEDTLS_PSK=y +# CONFIG_COAP_MBEDTLS_PKI is not set +# CONFIG_COAP_MBEDTLS_DEBUG is not set +CONFIG_COAP_LOG_DEFAULT_LEVEL=0 +# end of CoAP Configuration + +# +# Driver configurations +# + +# +# ADC configuration +# +# CONFIG_ADC_FORCE_XPD_FSM is not set +CONFIG_ADC_DISABLE_DAC=y +# end of ADC configuration + +# +# SPI configuration +# +# CONFIG_SPI_MASTER_IN_IRAM is not set +CONFIG_SPI_MASTER_ISR_IN_IRAM=y +# CONFIG_SPI_SLAVE_IN_IRAM is not set +CONFIG_SPI_SLAVE_ISR_IN_IRAM=y +# end of SPI configuration + +# +# UART configuration +# +# CONFIG_UART_ISR_IN_IRAM is not set +# end of UART configuration + +# +# RTCIO configuration +# +# CONFIG_RTCIO_SUPPORT_RTC_GPIO_DESC is not set +# end of RTCIO configuration +# end of Driver configurations + +# +# eFuse Bit Manager +# +# CONFIG_EFUSE_CUSTOM_TABLE is not set +# CONFIG_EFUSE_VIRTUAL is not set +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set +CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set +CONFIG_EFUSE_MAX_BLK_LEN=192 +# end of eFuse Bit Manager + +# +# ESP-TLS +# +CONFIG_ESP_TLS_USING_MBEDTLS=y +# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set +# CONFIG_ESP_TLS_SERVER is not set +# CONFIG_ESP_TLS_PSK_VERIFICATION is not set +# end of ESP-TLS + +# +# ESP32-specific +# +CONFIG_ESP32_REV_MIN_0=y +# CONFIG_ESP32_REV_MIN_1 is not set +# CONFIG_ESP32_REV_MIN_2 is not set +# CONFIG_ESP32_REV_MIN_3 is not set +CONFIG_ESP32_REV_MIN=0 +CONFIG_ESP32_DPORT_WORKAROUND=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 +# CONFIG_ESP32_SPIRAM_SUPPORT is not set +# CONFIG_ESP32_TRAX is not set +CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 +# CONFIG_ESP32_ULP_COPROC_ENABLED is not set +CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0 +CONFIG_ESP32_DEBUG_OCDAWARE=y +CONFIG_ESP32_BROWNOUT_DET=y +CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_ESP32_BROWNOUT_DET_LVL=0 +CONFIG_ESP32_REDUCE_PHY_TX_POWER=y +CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y +# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set +CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y +# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set +# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set +# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set +CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 +CONFIG_ESP32_XTAL_FREQ_40=y +# CONFIG_ESP32_XTAL_FREQ_26 is not set +# CONFIG_ESP32_XTAL_FREQ_AUTO is not set +CONFIG_ESP32_XTAL_FREQ=40 +# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set +# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set +# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set +CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 +# end of ESP32-specific + +# +# Power Management +# +# CONFIG_PM_ENABLE is not set +# end of Power Management + +# +# ADC-Calibration +# +CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y +CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y +CONFIG_ADC_CAL_LUT_ENABLE=y +# end of ADC-Calibration + +# +# Common ESP-related +# +CONFIG_ESP_ERR_TO_NAME_LOOKUP=y +CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 +CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 +CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y +CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 +CONFIG_ESP_CONSOLE_UART_DEFAULT=y +# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_UART_NONE is not set +CONFIG_ESP_CONSOLE_UART_NUM=0 +CONFIG_ESP_CONSOLE_UART_TX_GPIO=1 +CONFIG_ESP_CONSOLE_UART_RX_GPIO=3 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +CONFIG_ESP_INT_WDT=y +CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 +CONFIG_ESP_INT_WDT_CHECK_CPU1=y +CONFIG_ESP_TASK_WDT=y +# CONFIG_ESP_TASK_WDT_PANIC is not set +CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y +# CONFIG_ESP_PANIC_HANDLER_IRAM is not set +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_BT_OFFSET=2 +CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y +# end of Common ESP-related + +# +# Ethernet +# +CONFIG_ETH_ENABLED=y +CONFIG_ETH_USE_ESP32_EMAC=y +CONFIG_ETH_PHY_INTERFACE_RMII=y +# CONFIG_ETH_PHY_INTERFACE_MII is not set +CONFIG_ETH_RMII_CLK_INPUT=y +# CONFIG_ETH_RMII_CLK_OUTPUT is not set +CONFIG_ETH_RMII_CLK_IN_GPIO=0 +CONFIG_ETH_DMA_BUFFER_SIZE=512 +CONFIG_ETH_DMA_RX_BUFFER_NUM=10 +CONFIG_ETH_DMA_TX_BUFFER_NUM=10 +CONFIG_ETH_USE_SPI_ETHERNET=y +CONFIG_ETH_SPI_ETHERNET_DM9051=y +# CONFIG_ETH_USE_OPENETH is not set +# end of Ethernet + +# +# Event Loop Library +# +# CONFIG_ESP_EVENT_LOOP_PROFILING is not set +CONFIG_ESP_EVENT_POST_FROM_ISR=y +CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y +# end of Event Loop Library + +# +# GDB Stub +# +# end of GDB Stub + +# +# ESP HTTP client +# +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y +# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set +# end of ESP HTTP client + +# +# HTTP Server +# +CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 +CONFIG_HTTPD_MAX_URI_LEN=512 +CONFIG_HTTPD_ERR_RESP_NO_DELAY=y +CONFIG_HTTPD_PURGE_BUF_LEN=32 +# CONFIG_HTTPD_LOG_PURGE_DATA is not set +# CONFIG_HTTPD_WS_SUPPORT is not set +# end of HTTP Server + +# +# ESP HTTPS OTA +# +# CONFIG_OTA_ALLOW_HTTP is not set +# end of ESP HTTPS OTA + +# +# ESP HTTPS server +# +# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set +# end of ESP HTTPS server + +# +# ESP NETIF Adapter +# +CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 +CONFIG_ESP_NETIF_TCPIP_LWIP=y +# CONFIG_ESP_NETIF_LOOPBACK is not set +CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=y +# end of ESP NETIF Adapter + +# +# ESP System Settings +# +# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set +CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y +# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set +# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set +# end of ESP System Settings + +# +# High resolution timer (esp_timer) +# +# CONFIG_ESP_TIMER_PROFILING is not set +CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 +# CONFIG_ESP_TIMER_IMPL_FRC2 is not set +CONFIG_ESP_TIMER_IMPL_TG0_LAC=y +# end of High resolution timer (esp_timer) + +# +# Wi-Fi +# +CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE=y +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +CONFIG_ESP32_WIFI_NVS_ENABLED=y +CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y +# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +# CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE is not set +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y +# end of Wi-Fi + +# +# PHY +# +CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP32_PHY_MAX_TX_POWER=20 +# end of PHY + +# +# Core dump +# +# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set +CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +# end of Core dump + +# +# FAT Filesystem support +# +# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set +CONFIG_FATFS_CODEPAGE_437=y +# CONFIG_FATFS_CODEPAGE_720 is not set +# CONFIG_FATFS_CODEPAGE_737 is not set +# CONFIG_FATFS_CODEPAGE_771 is not set +# CONFIG_FATFS_CODEPAGE_775 is not set +# CONFIG_FATFS_CODEPAGE_850 is not set +# CONFIG_FATFS_CODEPAGE_852 is not set +# CONFIG_FATFS_CODEPAGE_855 is not set +# CONFIG_FATFS_CODEPAGE_857 is not set +# CONFIG_FATFS_CODEPAGE_860 is not set +# CONFIG_FATFS_CODEPAGE_861 is not set +# CONFIG_FATFS_CODEPAGE_862 is not set +# CONFIG_FATFS_CODEPAGE_863 is not set +# CONFIG_FATFS_CODEPAGE_864 is not set +# CONFIG_FATFS_CODEPAGE_865 is not set +# CONFIG_FATFS_CODEPAGE_866 is not set +# CONFIG_FATFS_CODEPAGE_869 is not set +# CONFIG_FATFS_CODEPAGE_932 is not set +# CONFIG_FATFS_CODEPAGE_936 is not set +# CONFIG_FATFS_CODEPAGE_949 is not set +# CONFIG_FATFS_CODEPAGE_950 is not set +CONFIG_FATFS_CODEPAGE=437 +CONFIG_FATFS_LFN_NONE=y +# CONFIG_FATFS_LFN_HEAP is not set +# CONFIG_FATFS_LFN_STACK is not set +CONFIG_FATFS_FS_LOCK=0 +CONFIG_FATFS_TIMEOUT_MS=10000 +CONFIG_FATFS_PER_FILE_CACHE=y +# end of FAT Filesystem support + +# +# Modbus configuration +# +CONFIG_FMB_COMM_MODE_RTU_EN=y +CONFIG_FMB_COMM_MODE_ASCII_EN=y +CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150 +CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200 +CONFIG_FMB_QUEUE_LENGTH=20 +CONFIG_FMB_SERIAL_TASK_STACK_SIZE=2048 +CONFIG_FMB_SERIAL_BUF_SIZE=256 +CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8 +CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000 +CONFIG_FMB_SERIAL_TASK_PRIO=10 +# CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT is not set +CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_FMB_CONTROLLER_STACK_SIZE=4096 +CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 +CONFIG_FMB_TIMER_PORT_ENABLED=y +CONFIG_FMB_TIMER_GROUP=0 +CONFIG_FMB_TIMER_INDEX=0 +# CONFIG_FMB_TIMER_ISR_IN_IRAM is not set +# end of Modbus configuration + +# +# FreeRTOS +# +# CONFIG_FREERTOS_UNICORE is not set +CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +CONFIG_FREERTOS_CORETIMER_0=y +# CONFIG_FREERTOS_CORETIMER_1 is not set +CONFIG_FREERTOS_HZ=100 +CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set +CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y +# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set +CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y +CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 +CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y +# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set +# CONFIG_FREERTOS_ASSERT_DISABLE is not set +CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 +CONFIG_FREERTOS_ISR_STACKSIZE=1536 +# CONFIG_FREERTOS_LEGACY_HOOKS is not set +CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 +# CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION is not set +CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 +CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 +CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 +# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set +# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set +CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y +CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y +# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set +CONFIG_FREERTOS_DEBUG_OCDAWARE=y +# CONFIG_FREERTOS_FPU_IN_ISR is not set +# end of FreeRTOS + +# +# Heap memory debugging +# +CONFIG_HEAP_POISONING_DISABLED=y +# CONFIG_HEAP_POISONING_LIGHT is not set +# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set +CONFIG_HEAP_TRACING_OFF=y +# CONFIG_HEAP_TRACING_STANDALONE is not set +# CONFIG_HEAP_TRACING_TOHOST is not set +# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set +# end of Heap memory debugging + +# +# jsmn +# +# CONFIG_JSMN_PARENT_LINKS is not set +# CONFIG_JSMN_STRICT is not set +# end of jsmn + +# +# libsodium +# +# end of libsodium + +# +# Log output +# +# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set +# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set +# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set +# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_LOG_COLORS=y +CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y +# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set +# end of Log output + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y +# CONFIG_LWIP_L2_TO_L3_COPY is not set +# CONFIG_LWIP_IRAM_OPTIMIZATION is not set +CONFIG_LWIP_TIMERS_ONDEMAND=y +CONFIG_LWIP_MAX_SOCKETS=10 +# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set +# CONFIG_LWIP_SO_LINGER is not set +CONFIG_LWIP_SO_REUSE=y +CONFIG_LWIP_SO_REUSE_RXTOALL=y +# CONFIG_LWIP_SO_RCVBUF is not set +# CONFIG_LWIP_NETBUF_RECVINFO is not set +CONFIG_LWIP_IP4_FRAG=y +CONFIG_LWIP_IP6_FRAG=y +# CONFIG_LWIP_IP4_REASSEMBLY is not set +# CONFIG_LWIP_IP6_REASSEMBLY is not set +# CONFIG_LWIP_IP_FORWARD is not set +# CONFIG_LWIP_STATS is not set +# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set +CONFIG_LWIP_ESP_GRATUITOUS_ARP=y +CONFIG_LWIP_GARP_TMR_INTERVAL=60 +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 +CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set + +# +# DHCP server +# +CONFIG_LWIP_DHCPS_LEASE_UNIT=60 +CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +# end of DHCP server + +# CONFIG_LWIP_AUTOIP is not set +# CONFIG_LWIP_IPV6_AUTOCONFIG is not set +CONFIG_LWIP_NETIF_LOOPBACK=y +CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 + +# +# TCP +# +CONFIG_LWIP_MAX_ACTIVE_TCP=16 +CONFIG_LWIP_MAX_LISTENING_TCP=16 +CONFIG_LWIP_TCP_MAXRTX=12 +CONFIG_LWIP_TCP_SYNMAXRTX=6 +CONFIG_LWIP_TCP_MSS=1440 +CONFIG_LWIP_TCP_TMR_INTERVAL=250 +CONFIG_LWIP_TCP_MSL=60000 +CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 +CONFIG_LWIP_TCP_WND_DEFAULT=5744 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 +CONFIG_LWIP_TCP_QUEUE_OOSEQ=y +# CONFIG_LWIP_TCP_SACK_OUT is not set +# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_LWIP_TCP_OVERSIZE_MSS=y +# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set +CONFIG_LWIP_TCP_RTO_TIME=3000 +# end of TCP + +# +# UDP +# +CONFIG_LWIP_MAX_UDP_PCBS=16 +CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 +# end of UDP + +CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set +CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_LWIP_PPP_SUPPORT is not set +CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 +CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 + +# +# ICMP +# +# CONFIG_LWIP_MULTICAST_PING is not set +# CONFIG_LWIP_BROADCAST_PING is not set +# end of ICMP + +# +# LWIP RAW API +# +CONFIG_LWIP_MAX_RAW_PCBS=16 +# end of LWIP RAW API + +# +# SNTP +# +CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 +CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 +# end of SNTP + +CONFIG_LWIP_ESP_LWIP_ASSERT=y +# end of LWIP + +# +# mbedTLS +# +CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y +# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set +# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set +CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y +CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 +CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 +# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set +# CONFIG_MBEDTLS_DEBUG is not set + +# +# Certificate Bundle +# +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set +# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set +# end of Certificate Bundle + +# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set +# CONFIG_MBEDTLS_CMAC_C is not set +CONFIG_MBEDTLS_HARDWARE_AES=y +CONFIG_MBEDTLS_HARDWARE_MPI=y +CONFIG_MBEDTLS_HARDWARE_SHA=y +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set +CONFIG_MBEDTLS_HAVE_TIME=y +# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set +CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y +CONFIG_MBEDTLS_SHA512_C=y +CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y +# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set +# CONFIG_MBEDTLS_TLS_DISABLED is not set +CONFIG_MBEDTLS_TLS_SERVER=y +CONFIG_MBEDTLS_TLS_CLIENT=y +CONFIG_MBEDTLS_TLS_ENABLED=y + +# +# TLS Key Exchange Methods +# +# CONFIG_MBEDTLS_PSK_MODES is not set +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y +# end of TLS Key Exchange Methods + +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y +# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set +CONFIG_MBEDTLS_SSL_PROTO_TLS1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +CONFIG_MBEDTLS_SSL_ALPN=y +CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y +CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y + +# +# Symmetric Ciphers +# +CONFIG_MBEDTLS_AES_C=y +# CONFIG_MBEDTLS_CAMELLIA_C is not set +# CONFIG_MBEDTLS_DES_C is not set +CONFIG_MBEDTLS_RC4_DISABLED=y +# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set +# CONFIG_MBEDTLS_RC4_ENABLED is not set +# CONFIG_MBEDTLS_BLOWFISH_C is not set +# CONFIG_MBEDTLS_XTEA_C is not set +CONFIG_MBEDTLS_CCM_C=y +CONFIG_MBEDTLS_GCM_C=y +# end of Symmetric Ciphers + +# CONFIG_MBEDTLS_RIPEMD160_C is not set + +# +# Certificates +# +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +# end of Certificates + +CONFIG_MBEDTLS_ECP_C=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y +# CONFIG_MBEDTLS_ECJPAKE_C is not set +CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +CONFIG_MBEDTLS_ECP_NIST_OPTIM=y +# CONFIG_MBEDTLS_POLY1305_C is not set +# CONFIG_MBEDTLS_CHACHA20_C is not set +# CONFIG_MBEDTLS_HKDF_C is not set +# CONFIG_MBEDTLS_THREADING_C is not set +# CONFIG_MBEDTLS_SECURITY_RISKS is not set +# end of mbedTLS + +# +# mDNS +# +CONFIG_MDNS_MAX_SERVICES=10 +CONFIG_MDNS_TASK_PRIORITY=1 +CONFIG_MDNS_TASK_STACK_SIZE=4096 +# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_MDNS_TASK_AFFINITY_CPU0=y +# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set +CONFIG_MDNS_TASK_AFFINITY=0x0 +CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 +CONFIG_MDNS_TIMER_PERIOD_MS=100 +# end of mDNS + +# +# ESP-MQTT Configurations +# +CONFIG_MQTT_PROTOCOL_311=y +CONFIG_MQTT_TRANSPORT_SSL=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y +# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set +# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set +# CONFIG_MQTT_CUSTOM_OUTBOX is not set +# end of ESP-MQTT Configurations + +# +# Newlib +# +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y +# CONFIG_NEWLIB_NANO_FORMAT is not set +# end of Newlib + +# +# NVS +# +# end of NVS + +# +# OpenSSL +# +# CONFIG_OPENSSL_DEBUG is not set +# CONFIG_OPENSSL_ASSERT_DO_NOTHING is not set +CONFIG_OPENSSL_ASSERT_EXIT=y +# end of OpenSSL + +# +# PThreads +# +CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_PTHREAD_STACK_MIN=768 +CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y +# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set +# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set +CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" +# end of PThreads + +# +# SPI Flash driver +# +# CONFIG_SPI_FLASH_VERIFY_WRITE is not set +# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set +CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y +CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set +# CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set +# CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set +# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set +CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y +CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 +CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 + +# +# Auto-detect flash chips +# +CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y +# end of Auto-detect flash chips +# end of SPI Flash driver + +# +# SPIFFS Configuration +# +CONFIG_SPIFFS_MAX_PARTITIONS=3 + +# +# SPIFFS Cache Configuration +# +CONFIG_SPIFFS_CACHE=y +CONFIG_SPIFFS_CACHE_WR=y +# CONFIG_SPIFFS_CACHE_STATS is not set +# end of SPIFFS Cache Configuration + +CONFIG_SPIFFS_PAGE_CHECK=y +CONFIG_SPIFFS_GC_MAX_RUNS=10 +# CONFIG_SPIFFS_GC_STATS is not set +CONFIG_SPIFFS_PAGE_SIZE=256 +CONFIG_SPIFFS_OBJ_NAME_LEN=32 +# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set +CONFIG_SPIFFS_USE_MAGIC=y +CONFIG_SPIFFS_USE_MAGIC_LENGTH=y +CONFIG_SPIFFS_META_LENGTH=4 +CONFIG_SPIFFS_USE_MTIME=y + +# +# Debug Configuration +# +# CONFIG_SPIFFS_DBG is not set +# CONFIG_SPIFFS_API_DBG is not set +# CONFIG_SPIFFS_GC_DBG is not set +# CONFIG_SPIFFS_CACHE_DBG is not set +# CONFIG_SPIFFS_CHECK_DBG is not set +# CONFIG_SPIFFS_TEST_VISUALISATION is not set +# end of Debug Configuration +# end of SPIFFS Configuration + +# +# TinyUSB +# + +# +# Descriptor configuration +# +CONFIG_USB_DESC_CUSTOM_VID=0x1234 +CONFIG_USB_DESC_CUSTOM_PID=0x5678 +# end of Descriptor configuration +# end of TinyUSB + +# +# Unity unit testing library +# +CONFIG_UNITY_ENABLE_FLOAT=y +CONFIG_UNITY_ENABLE_DOUBLE=y +# CONFIG_UNITY_ENABLE_COLOR is not set +CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y +# CONFIG_UNITY_ENABLE_FIXTURE is not set +# CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set +# end of Unity unit testing library + +# +# Virtual file system +# +CONFIG_VFS_SUPPORT_IO=y +CONFIG_VFS_SUPPORT_DIR=y +CONFIG_VFS_SUPPORT_SELECT=y +CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_VFS_SUPPORT_TERMIOS=y + +# +# Host File System I/O (Semihosting) +# +CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 +# end of Host File System I/O (Semihosting) +# end of Virtual file system + +# +# Wear Levelling +# +# CONFIG_WL_SECTOR_SIZE_512 is not set +CONFIG_WL_SECTOR_SIZE_4096=y +CONFIG_WL_SECTOR_SIZE=4096 +# end of Wear Levelling + +# +# Wi-Fi Provisioning Manager +# +CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 +CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 +# end of Wi-Fi Provisioning Manager + +# +# Supplicant +# +CONFIG_WPA_MBEDTLS_CRYPTO=y +# CONFIG_WPA_DEBUG_PRINT is not set +# CONFIG_WPA_TESTING_OPTIONS is not set +# CONFIG_WPA_WPS_WARS is not set +# end of Supplicant + +# +# QCloud LLSync +# +CONFIG_QCLOUD_LLSYNC_SUPPORT=y +# end of QCloud LLSync +# end of Component config + +# +# Compatibility options +# +# CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set +# end of Compatibility options diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/data_template/ble_qiot_template.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/data_template/ble_qiot_template.c new file mode 100644 index 00000000..a583eecd --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/data_template/ble_qiot_template.c @@ -0,0 +1,485 @@ +/* +* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. +* Licensed under the MIT License (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://opensource.org/licenses/MIT +* Unless required by applicable law or agreed to in writing, software distributed under the License is +* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +* either express or implied. See the License for the specific language governing permissions and +* limitations under the License. +* +*/ +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_template.h" + +#include +#include +#include + +#include "ble_qiot_export.h" +#include "ble_qiot_common.h" +#include "ble_qiot_utils_base64.h" +#include "ble_qiot_param_check.h" + +// ignore property power switch, +static int ble_property_power_switch_set(const char *data, uint16_t len) +{ + return 0; +} + +static int ble_property_power_switch_get(char *data, uint16_t buf_len) +{ + return 0; +} + +// ignore heart rate set function, cause its read-only +static int ble_property_heart_rate_set(const char *data, uint16_t len) +{ + return 0; +} + +static int32_t sg_heart_rate = 128; +static int ble_property_heart_rate_get(char *data, uint16_t buf_len) +{ + // get your heart rate and copy to the buf which data pointed + // you must convert to network order if the data type is int or enum + int32_t heart_rate = HTONL(sg_heart_rate); + memcpy(data, &heart_rate, sizeof(int32_t)); + + // if get data success, return the length of data. must 4 bytes for int type + // if get data error, return -1 + // if the data no need report, just return 0 + return sizeof(uint32_t); +} + +// ignore blood oxygen set function, cause its read-only +static int ble_property_blood_oxygen_set(const char *data, uint16_t len) +{ + return 0; +} + +static int32_t sg_blood_oxygen = 96; +static int ble_property_blood_oxygen_get(char *data, uint16_t buf_len) +{ + // copy your blood_oxygen to data + int32_t blood_oxygen = HTONL(sg_blood_oxygen); + memcpy(data, &blood_oxygen, sizeof(int32_t)); + + return sizeof(uint32_t); +} + +static ble_property_t sg_ble_property_array[BLE_QIOT_PROPERTY_ID_BUTT] = { + {ble_property_power_switch_set, ble_property_power_switch_get, BLE_QIOT_PROPERTY_AUTH_RW, BLE_QIOT_DATA_TYPE_BOOL}, + {ble_property_heart_rate_set, ble_property_heart_rate_get, BLE_QIOT_PROPERTY_AUTH_READ, BLE_QIOT_DATA_TYPE_INT}, + {ble_property_blood_oxygen_set, ble_property_blood_oxygen_get, BLE_QIOT_PROPERTY_AUTH_READ, BLE_QIOT_DATA_TYPE_INT}, +}; + +uint8_t ble_get_property_type_by_id(uint8_t id) +{ + if (id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + return sg_ble_property_array[id].type; +} + +int ble_user_property_set_data(const e_ble_tlv *tlv) +{ + POINTER_SANITY_CHECK(tlv, BLE_QIOT_RS_ERR_PARA); + if (tlv->id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", tlv->id); + return BLE_QIOT_RS_ERR; + } + + if (NULL != sg_ble_property_array[tlv->id].set_cb) { + if (0 != sg_ble_property_array[tlv->id].set_cb(tlv->val, tlv->len)) { + ble_qiot_log_e("set property id %d failed", tlv->id); + return BLE_QIOT_RS_ERR; + }else { + return BLE_QIOT_RS_OK; + } + } + ble_qiot_log_e("invalid set callback, id %d", tlv->id); + + return BLE_QIOT_RS_ERR; +} + +int ble_user_property_get_data_by_id(uint8_t id, char *buf, uint16_t buf_len) +{ + POINTER_SANITY_CHECK(buf, BLE_QIOT_RS_ERR_PARA); + + if (NULL != sg_ble_property_array[id].get_cb) { + return sg_ble_property_array[id].get_cb(buf, buf_len); + } + ble_qiot_log_e("invalid get callback, property id %d", id); + + return 0; +} + +int ble_user_property_report_reply_handle(uint8_t result) +{ + ble_qiot_log_d("report reply result %d", result); + + return BLE_QIOT_RS_OK; +} + +//of course you can get all param data, here is just a sample and i'm a bit lazy, so i set some event param return 0 means no data to report +static int ble_event_get_sleep_report_total_sleep_time(char *data, uint16_t buf_len) +{ + return 0; +} + +static int32_t sg_falling_asleep_time = 1599557269; +static int ble_event_get_sleep_report_falling_asleep_time(char *data, uint16_t buf_len) +{ + int32_t time = 0; + + time = HTONL(sg_falling_asleep_time); + ble_qiot_log_i("time %d", time); + memcpy(data, &time, sizeof(int32_t)); + + return sizeof(uint32_t); +} + +static int ble_event_get_sleep_report_wakeup_time(char *data, uint16_t buf_len) +{ + return 0; +} + +static int ble_event_get_sleep_report_deep_sleep_time(char *data, uint16_t buf_len) +{ + return 0; +} + +static int ble_event_get_sleep_report_light_sleep_time(char *data, uint16_t buf_len) +{ + return 0; +} + +static int32_t sg_sleep_score = 64; +static int ble_event_get_sleep_report_sleep_score(char *data, uint16_t buf_len) +{ + int32_t score = 0; + + score = HTONL(sg_sleep_score); + ble_qiot_log_i("score %d", score); + memcpy(data, &score, sizeof(int32_t)); + + return sizeof(uint32_t); +} + +static ble_event_param sg_ble_event_sleep_report_array[BLE_QIOT_EVENT_SLEEP_REPORT_PARAM_ID_BUTT] = { + {ble_event_get_sleep_report_total_sleep_time, BLE_QIOT_DATA_TYPE_INT}, + {ble_event_get_sleep_report_falling_asleep_time, BLE_QIOT_DATA_TYPE_TIME}, + {ble_event_get_sleep_report_wakeup_time, BLE_QIOT_DATA_TYPE_TIME}, + {ble_event_get_sleep_report_deep_sleep_time, BLE_QIOT_DATA_TYPE_INT}, + {ble_event_get_sleep_report_light_sleep_time, BLE_QIOT_DATA_TYPE_INT}, + {ble_event_get_sleep_report_sleep_score, BLE_QIOT_DATA_TYPE_INT}, +}; + +typedef struct sleep_data_{ + int time; + uint8_t state; + uint8_t rsv; +}__attribute__((packed))sleep_data; + +static int ble_event_get_sleep_data_data(char *data, uint16_t buf_len) +{ + int i = 0; + sleep_data user_data; + int base_time = 1599555600; // 2020/9/8 17:00:00 + int ret_len = 0; + char base64_out_buf[16] = {0}; + size_t base64_out_len = 0; + + for (i = 0; i < 60; i++){ + user_data.time = HTONL(base_time + i * 60); // 1 minute time step + user_data.state = 1; // light sleep + user_data.rsv = 0; + +#if 1 == BLE_QIOT_POST_BASE64 + memset(base64_out_buf, 0, sizeof(base64_out_buf)); + base64_out_len = 0; + if (BLE_QIOT_RS_OK != qcloud_iot_utils_base64encode((uint8_t *)base64_out_buf, sizeof(base64_out_buf), &base64_out_len, (const uint8_t *)&user_data, sizeof(user_data))){ + ble_qiot_log_e("event base64 failed"); + return -1; + } + memcpy(data + ret_len, base64_out_buf, base64_out_len); + ret_len += base64_out_len; +#else + memcpy(data + ret_len, &user_data, sizeof(user_data)); + ret_len += sizeof(user_data); +#endif + } + ble_qiot_log_e("ret_len %d, base64_out_len %d", ret_len, base64_out_len); + return ret_len; +} + +static ble_event_param sg_ble_event_sleep_data_array[BLE_QIOT_EVENT_SLEEP_DATA_PARAM_ID_BUTT] = { + {ble_event_get_sleep_data_data, BLE_QIOT_DATA_TYPE_STRING}, +}; + +static int ble_event_get_heart_rate_data_data(char *data, uint16_t buf_len) +{ + return 0; +} + +static ble_event_param sg_ble_event_heart_rate_data_array[BLE_QIOT_EVENT_HEART_RATE_DATA_PARAM_ID_BUTT] = { + {ble_event_get_heart_rate_data_data, BLE_QIOT_DATA_TYPE_STRING}, +}; + +static int ble_event_get_blood_oxygen_data_data(char *data, uint16_t buf_len) +{ + return 0; +} + +static ble_event_param sg_ble_event_blood_oxygen_data_array[BLE_QIOT_EVENT_BLOOD_OXYGEN_DATA_PARAM_ID_BUTT] = { + {ble_event_get_blood_oxygen_data_data, BLE_QIOT_DATA_TYPE_STRING}, +}; + +static int ble_event_get_today_activity_data(char *data, uint16_t buf_len) +{ + return 0; +} + +static ble_event_param sg_ble_event_today_activity_array[BLE_QIOT_EVENT_TODAY_ACTIVITY_PARAM_ID_BUTT] = { + {ble_event_get_today_activity_data, BLE_QIOT_DATA_TYPE_STRING}, +}; + +static ble_event_t sg_ble_event_array[BLE_QIOT_EVENT_ID_BUTT] = { + {sg_ble_event_sleep_report_array, sizeof(sg_ble_event_sleep_report_array) / sizeof(ble_event_param)}, + {sg_ble_event_sleep_data_array, sizeof(sg_ble_event_sleep_data_array) / sizeof(ble_event_param)}, + {sg_ble_event_heart_rate_data_array, sizeof(sg_ble_event_heart_rate_data_array) / sizeof(ble_event_param)}, + {sg_ble_event_blood_oxygen_data_array, sizeof(sg_ble_event_blood_oxygen_data_array) / sizeof(ble_event_param)}, + {sg_ble_event_today_activity_array, sizeof(sg_ble_event_today_activity_array) / sizeof(ble_event_param)}, +}; + +int ble_event_get_id_array_size(uint8_t event_id) +{ + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return -1; + } + + return sg_ble_event_array[event_id].array_size; +} + +uint8_t ble_event_get_param_id_type(uint8_t event_id, uint8_t param_id) +{ + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (param_id >= sg_ble_event_array[event_id].array_size) { + ble_qiot_log_e("invalid param id %d", param_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_event_array[event_id].event_array[param_id].type; +} + +int ble_event_get_data_by_id(uint8_t event_id, uint8_t param_id, char *out_buf, uint16_t buf_len) +{ + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return -1; + } + if (param_id >= sg_ble_event_array[event_id].array_size) { + ble_qiot_log_e("invalid param id %d", param_id); + return -1; + } + if (NULL == sg_ble_event_array[event_id].event_array[param_id].get_cb) { + ble_qiot_log_e("invalid callback, event id %d, param id %d", event_id, param_id); + return -1; + } + + return sg_ble_event_array[event_id].event_array[param_id].get_cb(out_buf, buf_len); +} + +int ble_user_event_reply_handle(uint8_t event_id, uint8_t result) +{ + ble_qiot_log_d("event id %d, reply result %d", event_id, result); + + return BLE_QIOT_RS_OK; +} + +bool ble_check_space_enough_by_type(uint8_t type, uint32_t left_size) +{ + switch(type) + { + case BLE_QIOT_DATA_TYPE_BOOL: + return left_size >= sizeof(uint8_t); + case BLE_QIOT_DATA_TYPE_INT: + case BLE_QIOT_DATA_TYPE_FLOAT: + case BLE_QIOT_DATA_TYPE_TIME: + return left_size >= sizeof(uint32_t); + case BLE_QIOT_DATA_TYPE_ENUM: + return left_size >= sizeof(uint16_t); + default: + // string length is unknow, default true + return true; + } +} + +typedef struct read_property{ + uint16_t property_id; + uint16_t val; +}__attribute__((packed))read_property; + +static int sg_read_property_id = 0; +static int ble_action_handle_read_property_input_cb(e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array) +{ + int i = 0; + int result = 0; + + for (i = 0; i < input_array_size; i++){ + ble_qiot_log_d("input id %d", input_param_array[i].id); + } + memcpy(&result, input_param_array[0].val, sizeof(int)); + sg_read_property_id = NTOHL(result); + // if the input tirger + output_id_array[BLE_QIOT_ACTION_READ_PROPERTY_OUTPUT_ID_VALUE] = true; + + return 0; +} + +static int ble_action_handle_read_property_output_cb(uint8_t output_id, char *buf, uint16_t buf_len) +{ + read_property user_data; + uint8_t base64_out_buf[16] = {0}; + size_t base64_out_len = 0; + int ret_len = 0; + + if (BLE_QIOT_PROPERTY_ID_HEART_RATE == sg_read_property_id){ + uint16_t heart_rate = sg_heart_rate; + user_data.property_id = HTONS(sg_read_property_id); + user_data.val = HTONS(heart_rate); + }else{ + uint16_t blood_oxygen = sg_blood_oxygen; + user_data.property_id = HTONS(sg_read_property_id); + user_data.val = HTONS(blood_oxygen); + } + +#if 1 == BLE_QIOT_POST_BASE64 + memset(base64_out_buf, 0, sizeof(base64_out_buf)); + if (BLE_QIOT_RS_OK != qcloud_iot_utils_base64encode((uint8_t *)base64_out_buf, sizeof(base64_out_buf), &base64_out_len, (const uint8_t *)&user_data, sizeof(user_data))){ + ble_qiot_log_e("action base64 failed"); + return -1; + } + memcpy(buf, base64_out_buf, base64_out_len); + ret_len = base64_out_len; +#else + memcpy(buf , &user_data, sizeof(user_data)); + ret_len = sizeof(user_data); +#endif + + return ret_len; +} + +static uint8_t sg_ble_action_read_property_input_type_array[BLE_QIOT_ACTION_READ_PROPERTY_INPUT_ID_BUTT] = { + BLE_QIOT_DATA_TYPE_INT, +}; + +static uint8_t sg_ble_action_read_property_output_type_array[BLE_QIOT_ACTION_READ_PROPERTY_OUTPUT_ID_BUTT] = { + BLE_QIOT_DATA_TYPE_STRING, +}; + +static ble_action_t sg_ble_action_array[BLE_QIOT_ACTION_ID_BUTT] = { + {ble_action_handle_read_property_input_cb, ble_action_handle_read_property_output_cb, + sg_ble_action_read_property_input_type_array, sg_ble_action_read_property_output_type_array, + sizeof(sg_ble_action_read_property_input_type_array) / sizeof(uint8_t), + sizeof(sg_ble_action_read_property_output_type_array) / sizeof(uint8_t)}, +}; + +uint8_t ble_action_get_intput_type_by_id(uint8_t action_id, uint8_t input_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (input_id >= sg_ble_event_array[action_id].array_size) { + ble_qiot_log_e("invalid input id %d", input_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_action_array[action_id].input_type_array[input_id]; +} + +uint8_t ble_action_get_output_type_by_id(uint8_t action_id, uint8_t output_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (output_id >= sg_ble_event_array[action_id].array_size) { + ble_qiot_log_e("invalid output id %d", output_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_action_array[action_id].output_type_array[output_id]; +} + +int ble_action_get_input_id_size(uint8_t action_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + return sg_ble_action_array[action_id].input_id_size; +} + +int ble_action_get_output_id_size(uint8_t action_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + return sg_ble_action_array[action_id].output_id_size; +} + +int ble_action_user_handle_input_param(uint8_t action_id, e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + if (NULL != sg_ble_action_array[action_id].input_cb) { + if (0 != sg_ble_action_array[action_id].input_cb(input_param_array, input_array_size, output_id_array)) { + ble_qiot_log_e("input handle error"); + return -1; + } + } + + return 0; +} + +int ble_action_user_handle_output_param(uint8_t action_id, uint8_t output_id, char *buf, uint16_t buf_len) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + int data_len = 0; + + if (NULL != sg_ble_action_array[action_id].output_cb) { + data_len = sg_ble_action_array[action_id].output_cb(output_id, buf, buf_len); + if (0 > data_len) { + ble_qiot_log_e("output handle error"); + return -1; + } + } + + return data_len; +} + + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/data_template/ble_qiot_template.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/data_template/ble_qiot_template.h new file mode 100644 index 00000000..7a8fe243 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/data_template/ble_qiot_template.h @@ -0,0 +1,301 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef BLE_QIOT_TEMPLATE_H_ +#define BLE_QIOT_TEMPLATE_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define BLE_QIOT_SDK_VER "0.1.0" + +// data type in template +enum { + BLE_QIOT_DATA_TYPE_BOOL = 0, + BLE_QIOT_DATA_TYPE_INT, + BLE_QIOT_DATA_TYPE_STRING, + BLE_QIOT_DATA_TYPE_FLOAT, + BLE_QIOT_DATA_TYPE_ENUM, + BLE_QIOT_DATA_TYPE_TIME, + BLE_QIOT_DATA_TYPE_BUTT, +}; + +// message type +enum { + BLE_QIOT_MSG_TYPE_PROPERTY = 0, + BLE_QIOT_MSG_TYPE_EVENT, + BLE_QIOT_MSG_TYPE_ACTION, + BLE_QIOT_MSG_TYPE_BUTT, +}; + +// define property authority +enum { + BLE_QIOT_PROPERTY_AUTH_RW = 0, + BLE_QIOT_PROPERTY_AUTH_READ, + BLE_QIOT_PROPERTY_AUTH_BUTT, +}; + +// define reply result +enum { + BLE_QIOT_REPLY_SUCCESS = 0, + BLE_QIOT_REPLY_FAIL, + BLE_QIOT_REPLY_DATA_ERR, + BLE_QIOT_REPLY_BUTT, +}; + +// define message request type +enum { + BLE_QIOT_EFFECT_REQUEST = 0, + BLE_QIOT_EFFECT_REPLY, + BLE_QIOT_EFFECT_BUTT, +}; + +// define message type from remote +enum { + BLE_QIOT_DATA_DOWN_REPORT_REPLY = 0, + BLE_QIOT_DATA_DOWN_CONTROL, + BLE_QIOT_DATA_DOWN_GET_STATUS_REPLY, + BLE_QIOT_DATA_DOWN_ACTION, + BLE_QIOT_DATA_DOWN_EVENT_REPLY, +}; + +// define msg type up to remote +enum { + BLE_QIOT_EVENT_UP_PROPERTY_REPORT = 0, + BLE_QIOT_EVENT_UP_CONTROL_REPLY, + BLE_QIOT_EVENT_UP_GET_STATUS, + BLE_QIOT_EVENT_UP_EVENT_POST, + BLE_QIOT_EVENT_UP_ACTION_REPLY, + BLE_QIOT_EVENT_UP_BIND_SIGN_RET, + BLE_QIOT_EVENT_UP_CONN_SIGN_RET, + BLE_QIOT_EVENT_UP_UNBIND_SIGN_RET, + BLE_QIOT_EVENT_UP_REPORT_MTU, + BLE_QIOT_EVENT_UP_BUTT, +}; + +// bit 7-6 is msg type, bit 5 means request or reply, bit 4 - 0 is id +#define BLE_QIOT_PARSE_MSG_HEAD_TYPE(_C) (((_C)&0XFF) >> 6) +#define BLE_QIOT_PARSE_MSG_HEAD_EFFECT(_C) ((((_C)&0XFF) & 0X20) ? BLE_QIOT_EFFECT_REPLY : BLE_QIOT_EFFECT_REQUEST) +#define BLE_QIOT_PARSE_MSG_HEAD_ID(_C) ((_C)&0X1F) +#define BLE_QIOT_PACKAGE_MSG_HEAD(_TYPE, _REPLY, _ID) \ + (((_TYPE) << 6) | (((_REPLY) == BLE_QIOT_EFFECT_REPLY) << 5) | ((_ID)&0X1F)) + +// parse tlv struct +#define BLE_QIOT_PARSE_TLV_HEAD_TYPE(_C) (((_C)&0XFF) >> 5) +#define BLE_QIOT_PARSE_TLV_HEAD_ID(_C) ((_C)&0X1F) +#define BLE_QIOT_PACKAGE_TLV_HEAD(_TYPE, _ID) (((_TYPE) << 5) | ((_ID)&0X1F)) +typedef int (*get_string_cb)(char *buf, uint16_t buf_len, int *offset); + +// define property id +enum { + BLE_QIOT_PROPERTY_ID_POWER_SWITCH = 0, + BLE_QIOT_PROPERTY_ID_HEART_RATE, + BLE_QIOT_PROPERTY_ID_BLOOD_OXYGEN, + BLE_QIOT_PROPERTY_ID_BUTT, +}; + +// define heart_rate attributes +#define BLE_QIOT_PROPERTY_HEART_RATE_MIN (0) +#define BLE_QIOT_PROPERTY_HEART_RATE_MAX (255) +#define BLE_QIOT_PROPERTY_HEART_RATE_START (0) + +// define blood_oxygen attributes +#define BLE_QIOT_PROPERTY_BLOOD_OXYGEN_MIN (70) +#define BLE_QIOT_PROPERTY_BLOOD_OXYGEN_MAX (100) +#define BLE_QIOT_PROPERTY_BLOOD_OXYGEN_START (70) + +// define property set handle. return 0 if success, other is error +typedef int (*property_set_cb)(const char *data, uint16_t len); + +// define property get handle. return the data length obtained, 0 is error +typedef int (*property_get_cb)(char *buf, uint16_t buf_len); + +// define property struct +typedef struct { + property_set_cb set_cb; // set callback + property_get_cb get_cb; // get callback + uint8_t authority; // property authority + uint8_t type; // data type +} ble_property_t; + +// define event id +enum { + BLE_QIOT_EVENT_ID_SLEEP_REPORT = 0, + BLE_QIOT_EVENT_ID_SLEEP_DATA, + BLE_QIOT_EVENT_ID_HEART_RATE_DATA, + BLE_QIOT_EVENT_ID_BLOOD_OXYGEN_DATA, + BLE_QIOT_EVENT_ID_TODAY_ACTIVITY, + BLE_QIOT_EVENT_ID_BUTT, +}; + +// define event param sleep_report +enum { + BLE_QIOT_EVENT_SLEEP_REPORT_PARAM_ID_TOTAL_SLEEP_TIME = 0, + BLE_QIOT_EVENT_SLEEP_REPORT_PARAM_ID_FALLING_ASLEEP_TIME, + BLE_QIOT_EVENT_SLEEP_REPORT_PARAM_ID_WAKEUP_TIME, + BLE_QIOT_EVENT_SLEEP_REPORT_PARAM_ID_DEEP_SLEEP_TIME, + BLE_QIOT_EVENT_SLEEP_REPORT_PARAM_ID_LIGHT_SLEEP_TIME, + BLE_QIOT_EVENT_SLEEP_REPORT_PARAM_ID_SLEEP_SCORE, + BLE_QIOT_EVENT_SLEEP_REPORT_PARAM_ID_BUTT, +}; + +// define total_sleep_time attributes +#define BLE_QIOT_EVENT_SLEEP_REPORT_TOTAL_SLEEP_TIME_MIN (0) +#define BLE_QIOT_EVENT_SLEEP_REPORT_TOTAL_SLEEP_TIME_MAX (86400) + +// define deep_sleep_time attributes +#define BLE_QIOT_EVENT_SLEEP_REPORT_DEEP_SLEEP_TIME_MIN (0) +#define BLE_QIOT_EVENT_SLEEP_REPORT_DEEP_SLEEP_TIME_MAX (1440) + +// define light_sleep_time attributes +#define BLE_QIOT_EVENT_SLEEP_REPORT_LIGHT_SLEEP_TIME_MIN (0) +#define BLE_QIOT_EVENT_SLEEP_REPORT_LIGHT_SLEEP_TIME_MAX (1440) + +// define sleep_score attributes +#define BLE_QIOT_EVENT_SLEEP_REPORT_SLEEP_SCORE_MIN (-1) +#define BLE_QIOT_EVENT_SLEEP_REPORT_SLEEP_SCORE_MAX (100) + +// define event param sleep_data +enum { + BLE_QIOT_EVENT_SLEEP_DATA_PARAM_ID_DATA = 0, + BLE_QIOT_EVENT_SLEEP_DATA_PARAM_ID_BUTT, +}; + +// define data attributes +#define BLE_QIOT_EVENT_SLEEP_DATA_DATA_LEN_MIN (1) +#define BLE_QIOT_EVENT_SLEEP_DATA_DATA_LEN_MAX (2048) + +// define event param heart_rate_data +enum { + BLE_QIOT_EVENT_HEART_RATE_DATA_PARAM_ID_DATA = 0, + BLE_QIOT_EVENT_HEART_RATE_DATA_PARAM_ID_BUTT, +}; + +// define data attributes +#define BLE_QIOT_EVENT_HEART_RATE_DATA_DATA_LEN_MIN (1) +#define BLE_QIOT_EVENT_HEART_RATE_DATA_DATA_LEN_MAX (2048) + +// define event param blood_oxygen_data +enum { + BLE_QIOT_EVENT_BLOOD_OXYGEN_DATA_PARAM_ID_DATA = 0, + BLE_QIOT_EVENT_BLOOD_OXYGEN_DATA_PARAM_ID_BUTT, +}; + +// define data attributes +#define BLE_QIOT_EVENT_BLOOD_OXYGEN_DATA_DATA_LEN_MIN (1) +#define BLE_QIOT_EVENT_BLOOD_OXYGEN_DATA_DATA_LEN_MAX (2048) + +// define event param today_activity +enum { + BLE_QIOT_EVENT_TODAY_ACTIVITY_PARAM_ID_DATA = 0, + BLE_QIOT_EVENT_TODAY_ACTIVITY_PARAM_ID_BUTT, +}; + +// define data attributes +#define BLE_QIOT_EVENT_TODAY_ACTIVITY_DATA_LEN_MIN (1) +#define BLE_QIOT_EVENT_TODAY_ACTIVITY_DATA_LEN_MAX (2048) + +// define event get handle. return 0 if success, other is error +typedef int (*event_get_cb)(char *buf, uint16_t buf_len); + +// define param struct of event +typedef struct { + event_get_cb get_cb; // get param data callback + uint8_t type; // param type +} ble_event_param; + +// define event struct +typedef struct { + ble_event_param *event_array; // array of params data + uint8_t array_size; // array size +} ble_event_t; + +// define action id +enum { + BLE_QIOT_ACTION_ID_READ_PROPERTY = 0, + BLE_QIOT_ACTION_ID_BUTT, +}; + +// define action input read_property +enum { + BLE_QIOT_ACTION_READ_PROPERTY_INPUT_ID_ID = 0, + BLE_QIOT_ACTION_READ_PROPERTY_INPUT_ID_BUTT, +}; + +// define action output read_property +enum { + BLE_QIOT_ACTION_READ_PROPERTY_OUTPUT_ID_VALUE = 0, + BLE_QIOT_ACTION_READ_PROPERTY_OUTPUT_ID_BUTT, +}; +#define BLE_QIOT_ACTION_INPUT_READ_PROPERTY_ID_MIN (0) +#define BLE_QIOT_ACTION_INPUT_READ_PROPERTY_ID_MAX (2) +#define BLE_QIOT_ACTION_INPUT_READ_PROPERTY_ID_START (0) +#define BLE_QIOT_ACTION_INPUT_READ_PROPERTY_ID_STEP (1) + +// define value attributes +#define BLE_QIOT_ACTION_OUTPUT_READ_PROPERTY_VALUE_MIN (0) +#define BLE_QIOT_ACTION_OUTPUT_READ_PROPERTY_VALUE_MAX (255) + +// define max input id and output id +#define BLE_QIOT_ACTION_INPUT_ID_BUTT 1 +#define BLE_QIOT_ACTION_OUTPUT_ID_BUTT 1 + +// define tlv struct +typedef struct { + uint8_t type; + uint8_t id; + uint16_t len; + char * val; +} e_ble_tlv; + +// define action input handle, return 0 is success, other is error. output_id_array filling with id number that need +// obtained +typedef int (*action_input_handle)(e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array); + +// define action output handle, return length of the data +typedef int (*action_output_handle)(uint8_t output_id, char *buf, uint16_t buf_len); + +// define action id struct +typedef struct { + action_input_handle input_cb; // handle input data + action_output_handle output_cb; // get output data in the callback + uint8_t * input_type_array; // type array for input id + uint8_t * output_type_array; // type array for output id + uint8_t input_id_size; // numbers of input id + uint8_t output_id_size; // numbers of output id +} ble_action_t; +// property module +uint8_t ble_get_property_type_by_id(uint8_t id); +int ble_user_property_set_data(const e_ble_tlv *tlv); +int ble_user_property_get_data_by_id(uint8_t id, char *buf, uint16_t buf_len); +int ble_user_property_report_reply_handle(uint8_t result); + +// event module +int ble_event_get_id_array_size(uint8_t event_id); +uint8_t ble_event_get_param_id_type(uint8_t event_id, uint8_t param_id); +int ble_event_get_data_by_id(uint8_t event_id, uint8_t param_id, char *out_buf, uint16_t buf_len); +int ble_user_event_reply_handle(uint8_t event_id, uint8_t result); + +// action module +uint8_t ble_action_get_intput_type_by_id(uint8_t action_id, uint8_t input_id); +uint8_t ble_action_get_output_type_by_id(uint8_t action_id, uint8_t output_id); +int ble_action_get_input_id_size(uint8_t action_id); +int ble_action_get_output_id_size(uint8_t action_id); +int ble_action_user_handle_input_param(uint8_t action_id, e_ble_tlv *input_param_array, uint8_t input_array_size, + uint8_t *output_id_array); +int ble_action_user_handle_output_param(uint8_t action_id, uint8_t output_id, char *buf, uint16_t buf_len); + +#ifdef __cplusplus +} +#endif +#endif // BLE_QIOT_TEMPLATE_H_ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/data_template/lifesense.json b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/data_template/lifesense.json new file mode 100644 index 00000000..e0444eed --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/data_template/lifesense.json @@ -0,0 +1,237 @@ +{ + "version": "1.0", + "profile": { + "ProductId": "0BCDALFUO8", + "CategoryId": "141" + }, + "properties": [ + { + "id": "power_switch", + "name": "手环开关", + "desc": "创建产品必须添加的属性", + "required": true, + "mode": "rw", + "define": { + "type": "bool", + "mapping": { + "0": "关", + "1": "开" + } + } + }, + { + "id": "heart_rate", + "name": "心率值", + "desc": "统计用户心率数据", + "required": true, + "mode": "r", + "define": { + "type": "int", + "unit": "bpm", + "step": "", + "min": "0", + "max": "255", + "start": "0" + } + }, + { + "id": "blood_oxygen", + "name": "血氧值", + "desc": "统计用户血氧数据", + "required": true, + "mode": "r", + "define": { + "type": "int", + "unit": "%", + "step": "", + "min": "70", + "max": "100", + "start": "70" + } + } + ], + "events": [ + { + "id": "sleep_report", + "name": "睡眠报告", + "desc": "用户睡眠报告", + "type": "info", + "required": true, + "params": [ + { + "id": "total_sleep_time", + "name": "总睡眠时间", + "desc": "用户总睡眠时间记录", + "define": { + "type": "int", + "unit": "秒", + "step": "", + "min": "0", + "max": "86400" + } + }, + { + "id": "falling_asleep_time", + "name": "入睡时间", + "desc": "用户入睡时间记录", + "define": { + "type": "timestamp" + } + }, + { + "id": "wakeup_time", + "name": "醒来时间", + "desc": "用户醒来时间记录", + "define": { + "type": "timestamp" + } + }, + { + "id": "deep_sleep_time", + "name": "深睡时间", + "desc": "用户深度睡眠时间记录", + "define": { + "type": "int", + "unit": "分钟", + "step": "", + "min": "0", + "max": "1440" + } + }, + { + "id": "light_sleep_time", + "name": "浅睡时间", + "desc": "用户浅度睡眠时间记录", + "define": { + "type": "int", + "unit": "分钟", + "step": "", + "min": "0", + "max": "1440" + } + }, + { + "id": "sleep_score", + "name": "睡眠评分", + "desc": "用户睡眠评分,-1为无评分功能", + "define": { + "type": "int", + "unit": "", + "step": "", + "min": "-1", + "max": "100" + } + } + ] + }, + { + "id": "sleep_data", + "name": "睡眠数据", + "desc": "用户睡眠数据记录", + "type": "info", + "required": true, + "params": [ + { + "id": "data", + "name": "睡眠数据", + "desc": "", + "define": { + "type": "string", + "min": "1", + "max": "2048" + } + } + ] + }, + { + "id": "heart_rate_data", + "name": "心率数据", + "desc": "用户心率数据记录", + "type": "info", + "required": true, + "params": [ + { + "id": "data", + "name": "心率数据", + "desc": "", + "define": { + "type": "string", + "min": "1", + "max": "2048" + } + } + ] + }, + { + "id": "blood_oxygen_data", + "name": "血氧数据", + "desc": "用户血氧数据记录", + "type": "info", + "required": true, + "params": [ + { + "id": "data", + "name": "血氧数据", + "desc": "", + "define": { + "type": "string", + "min": "1", + "max": "2048" + } + } + ] + }, + { + "id": "today_activity", + "name": "今日活动", + "desc": "用户今日活动数据记录", + "type": "info", + "required": true, + "params": [ + { + "id": "data", + "name": "活动数据", + "desc": "", + "define": { + "type": "string", + "min": "1", + "max": "2048" + } + } + ] + } + ], + "actions": [ + { + "id": "read_property", + "name": "属性读取", + "desc": "", + "input": [ + { + "id": "id", + "name": "属性ID", + "define": { + "type": "int", + "min": "0", + "max": "2", + "start": "0", + "step": "1", + "unit": "" + } + } + ], + "output": [ + { + "id": "value", + "name": "属性值", + "define": { + "type": "string", + "min": "1", + "max": "2048" + } + } + ], + "required": true + } + ] +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/Dbg_RAM.ini b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/Dbg_RAM.ini new file mode 100644 index 00000000..197afe71 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/Dbg_RAM.ini @@ -0,0 +1,55 @@ +/*---------------------------------------------------------------------------- + * Name: Dbg_RAM.ini + * Purpose: RAM Debug Initialization File + * Note(s): + *---------------------------------------------------------------------------- + * This file is part of the uVision/ARM development tools. + * This software may only be used under the terms of a valid, current, + * end user licence from KEIL for a compatible version of KEIL software + * development tools. Nothing else gives you the right to use this software. + * + * This software is supplied "AS IS" without warranties of any kind. + * + * Copyright (c) 2008-2013 Keil - An ARM Company. All rights reserved. + *----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- + TraceSetup() Turn on ITM clocks, etc. + *----------------------------------------------------------------------------*/ +FUNC void TraceSetup (void) +{ + // turn on the ITM/TPIU clock + //_WDWORD(0x40020250, 0x00000201); // TPIU clock enabled at 3MHz +} + +/*---------------------------------------------------------------------------- + Setup() configure PC & SP for RAM Debug + *----------------------------------------------------------------------------*/ +FUNC void Setup (void) { + SP = _RDWORD(0x0000C000+0x0); // Setup Stack Pointer + PC = _RDWORD(0x0000C000+0x4); // Setup Program Counter + _WDWORD(0xE000ED08, 0x0000C000+0x0); // Setup Vector Table Offset Register (done in system file) +} + +/*---------------------------------------------------------------------------- + OnResetExec() executed after reset via uVision's 'Reset'-button + *----------------------------------------------------------------------------*/ +FUNC void OnResetExec (void) +{ +} + + +LOAD %L INCREMENTAL // load the application + + +Setup(); // Setup for Running + +BS main +g + + +/*---------------------------------------------------------------------------- + *----------------------------------------------------------------------------*/ + + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/JLinkSettings.ini b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/JLinkSettings.ini new file mode 100644 index 00000000..6ff4fb6f --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/JLinkSettings.ini @@ -0,0 +1,40 @@ +[BREAKPOINTS] +ForceImpTypeAny = 0 +ShowInfoWin = 1 +EnableFlashBP = 2 +BPDuringExecution = 0 +[CFI] +CFISize = 0x00 +CFIAddr = 0x00 +[CPU] +MonModeVTableAddr = 0xFFFFFFFF +MonModeDebug = 0 +MaxNumAPs = 0 +LowPowerHandlingMode = 0 +OverrideMemMap = 0 +AllowSimulation = 1 +; ScriptFile="AMAPH1KK-KBR.JLinkScript" +[FLASH] +CacheExcludeSize = 0x00 +CacheExcludeAddr = 0x00 +MinNumBytesFlashDL = 0 +SkipProgOnCRCMatch = 1 +VerifyDownload = 1 +AllowCaching = 1 +EnableFlashDL = 2 +Override = 1 +Device="AMA3B1KK-KBR" +[GENERAL] +WorkRAMSize = 0x00 +WorkRAMAddr = 0x00 +RAMUsageLimit = 0x00 +[SWO] +SWOLogFile="" +[MEM] +RdOverrideOrMask = 0x00 +RdOverrideAndMask = 0xFFFFFFFF +RdOverrideAddr = 0xFFFFFFFF +WrOverrideOrMask = 0x00 +WrOverrideAndMask = 0xFFFFFFFF +WrOverrideAddr = 0xFFFFFFFF + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/Makefile b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/Makefile new file mode 100644 index 00000000..ae0949b8 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/Makefile @@ -0,0 +1,80 @@ +#****************************************************************************** +# +# Makefile - Rules for building the libraries, examples and docs. +# +# Copyright (c) 2020, Ambiq Micro +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# Third party software included in this distribution is subject to the +# additional license terms as defined in the /docs/licenses directory. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# This is part of revision 2.4.2 of the AmbiqSuite Development Package. +# +#****************************************************************************** +TARGET := ble_freertos_watch +COMPILERNAME := Keil +PROJECT := ble_freertos_watch_Keil +CONFIG := bin + +SHELL:=/bin/bash +#### Required Executables #### +K := $(shell type -p UV4.exe) +RM := $(shell which rm 2>/dev/null) + +ifeq ($(K),) +all clean: + $(info Tools w/$(COMPILERNAME) not installed.) + $(RM) -rf bin +else + +all: directories binary + +.PHONY: binary +binary: + UV4.exe -b -t "ble_freertos_watch" ble_freertos_watch.uvprojx -j0 || [ $$? -eq 1 ] + +directories: $(CONFIG) + +$(CONFIG): + @mkdir -p $@ + +clean: + @echo Cleaning... ;\ + $(RM) -rf $(CONFIG) + + +../../../bsp/keil/bin/libam_bsp.lib: + $(MAKE) -C ../../../bsp + +../../../../../mcu/apollo3/hal/keil/bin/libam_hal.lib: + $(MAKE) -C ../../../../../mcu/apollo3/hal + +endif +.PHONY: all clean directories + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/ble_freertos_watch.sct b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/ble_freertos_watch.sct new file mode 100644 index 00000000..3df7fe52 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/ble_freertos_watch.sct @@ -0,0 +1,60 @@ +;****************************************************************************** +; +; ble_freertos_watch.sct +; +; Scatter file for Keil linker configuration. +; +;****************************************************************************** + +;****************************************************************************** +; +; Copyright (c) 2020, Ambiq Micro +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions are met: +; +; 1. Redistributions of source code must retain the above copyright notice, +; this list of conditions and the following disclaimer. +; +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; 3. Neither the name of the copyright holder nor the names of its +; contributors may be used to endorse or promote products derived from this +; software without specific prior written permission. +; +; Third party software included in this distribution is subject to the +; additional license terms as defined in the /docs/licenses directory. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +; POSSIBILITY OF SUCH DAMAGE. +; +; This is part of revision 2.4.2 of the AmbiqSuite Development Package. +; +;****************************************************************************** +LR_1 0x0000C000 +{ + FLASH 0x0000C000 0x000F0000 + { + *.o (RESET, +First) + * (+RO) + } + + SRAM 0x10000000 0x00060000 + { + startup_keil.o (STACK, +First) + * (+RW, +ZI) + } +} + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/ble_qiot_demo.uvprojx b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/ble_qiot_demo.uvprojx new file mode 100644 index 00000000..b3eb3998 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/ble_qiot_demo.uvprojx @@ -0,0 +1,1484 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + ble_freertos_watch + 0x4 + ARM-ADS + 5060061::V5.06 update 1 (build 61)::ARMCC + + + AMA3B1KK-KBR + Ambiq Micro + AmbiqMicro.Apollo_DFP.1.2.0 + http://s3.asia.ambiqmicro.com/pack/ + IRAM(0x10000000,0x00060000) IROM(0x0000C000,0x000F4000) CPUTYPE("Cortex-M4") FPU2 CLOCK(48000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD10000000 -FC4000 -FN1 -FF0Apollo3 -FS0C000 -FL0F4000 -FP0($$Device:AMA3B1KK-KBR$Flash\Apollo3.FLM)) + 0 + $Device:AMA3B1KK-KBR$Device\Include\apollo3.h + + + + + + + + + + $$Device:AMA3B1KK-KBR$SVD\apollo3.svd + 0 + 0 + + + + 1024 BGA$Device\Include\apollo3.h\ + 1024 BGA$Device\Include\apollo3.h\ + + 0 + 0 + 0 + 0 + 1 + + .\bin\ + ble_freertos_watch + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 1 + fromelf --bin --output bin\ble_freertos_watch.bin bin\ble_freertos_watch.axf + fromelf -cedrst --output bin\ble_freertos_watch.txt bin\ble_freertos_watch.axf + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -REMAP -MPU + DCM.DLL + -pCM4 + SARMCM3.DLL + -MPU + TCM.DLL + -pCM4 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M4" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 2 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x10000000 + 0x60000 + + + 1 + 0xc000 + 0xf4000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0xc000 + 0xf4000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x10000000 + 0x60000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + 1 + + + AM_DEBUG_PRINTF AM_PART_APOLLO3 SEC_ECC_CFG=SEC_ECC_CFG_UECC WSF_TRACE_ENABLED AM_CUSTOM_BDADDR AM_FREERTOS AM_PACKAGE_BGA keil + + ../../../../../third_party/exactle/ble-profiles/sources/apps/app;../../../../../third_party/exactle/ble-profiles/sources/profiles/anpc;../../../../../third_party/exactle/ble-host/sources/stack/cfg;../../../../../third_party/exactle/ble-profiles/sources/profiles/uribeacon;../../../../../third_party/exactle/ble-host/sources/hci/ambiq;../../../../../third_party/exactle/ble-host/sources/sec/common;../../../../../CMSIS/AmbiqMicro/Include;../../../../../third_party/exactle/ble-profiles/sources/profiles;../../../../../utils;../../../bsp;../../../../../third_party/exactle/ble-profiles/sources/profiles/paspc;../../../../../third_party/exactle/ble-profiles/sources/services;../../../../../third_party/exactle/wsf/include;../../../../../third_party/exactle/ble-host/sources/stack/dm;../../../../../third_party/uecc;../src;../../../../../third_party/exactle/ble-host/sources/stack/hci;../../../../../third_party/exactle/ble-host/sources/hci/ambiq/apollo3;../../../../../third_party/exactle/ble-profiles/sources/profiles/wdxs;../../../../../third_party/exactle/ble-profiles/sources/profiles/include;../../../../../third_party/exactle/ble-profiles/sources/profiles/hid;../../../../../third_party/exactle/ble-profiles/sources/profiles/gatt;../../../../../third_party/FreeRTOSv10.1.1/Source/portable/Keil/AMapollo2;../../../../../third_party/exactle/ble-host/sources/hci/include;../../../../../third_party/exactle/ble-profiles/sources/profiles/hrpc;../../../../../third_party/exactle/ble-profiles/sources/apps;../../../../../third_party/FreeRTOSv10.1.1/Source/include;../../../../../mcu/apollo3;../../../../../third_party/exactle/ble-profiles/sources/profiles/dis;../../../../../third_party/exactle/ble-host/include;../../../../../third_party/exactle/ble-profiles/sources/profiles/bas;../../../../../third_party/exactle/wsf/sources/port/freertos;../../../../../CMSIS/ARM/Include;../../../../../third_party/exactle/ble-host/sources/stack/l2c;../../../../../third_party/exactle/ble-host/sources/stack/smp;../../../../../third_party/exactle/ble-host/sources/stack/att;../../../../../third_party/exactle/wsf/sources;../../../../../third_party/exactle/ble-profiles/include/app;../../../../../third_party/exactle/ble-profiles/sources/profiles/gap;../../../../../third_party/exactle/ble-profiles/sources/profiles/tipc;../../../../../third_party/exactle/wsf/sources/util;../../../../..;../../../../../devices;..\rtt;..\data_template;..\qcloud_iot_explorer_ble\inc;..\qcloud_iot_explorer_ble\src\internal_inc + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + 0 + 1 + 0 + + + + .\ble_freertos_watch.sct + + + ../../../../../mcu/apollo3/hal/keil/bin/libam_hal.lib(am_hal_global.o) --keep=am_hal_global.o(.data) + + + + + + + + exactle_anpc + + + anpc_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/profiles/anpc/anpc_main.c + + + + + exactle_cfg + + + cfg_stack.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/cfg/cfg_stack.c + + + + + exactle_hrpc + + + hrpc_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/profiles/hrpc/hrpc_main.c + + + + + exactle_ambiq + + + hci_cmd.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_cmd.c + + + hci_cmd_ae.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_cmd_ae.c + + + hci_cmd_cte.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_cmd_cte.c + + + hci_cmd_past.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_cmd_past.c + + + hci_cmd_phy.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_cmd_phy.c + + + hci_core.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_core.c + + + hci_core_ps.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_core_ps.c + + + hci_evt.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_evt.c + + + hci_tr.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_tr.c + + + hci_vs.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_vs.c + + + hci_vs_ae.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/hci_vs_ae.c + + + + + exactle_common + + + sec_aes.c + 1 + ../../../../../third_party/exactle/ble-host/sources/sec/common/sec_aes.c + + + sec_aes_rev.c + 1 + ../../../../../third_party/exactle/ble-host/sources/sec/common/sec_aes_rev.c + + + sec_ccm_hci.c + 1 + ../../../../../third_party/exactle/ble-host/sources/sec/common/sec_ccm_hci.c + + + sec_cmac_hci.c + 1 + ../../../../../third_party/exactle/ble-host/sources/sec/common/sec_cmac_hci.c + + + sec_ecc_debug.c + 1 + ../../../../../third_party/exactle/ble-host/sources/sec/common/sec_ecc_debug.c + + + sec_ecc_hci.c + 1 + ../../../../../third_party/exactle/ble-host/sources/sec/common/sec_ecc_hci.c + + + sec_main.c + 1 + ../../../../../third_party/exactle/ble-host/sources/sec/common/sec_main.c + + + + + exactle_dis + + + dis_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/profiles/dis/dis_main.c + + + + + exactle_bas + + + bas_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/profiles/bas/bas_main.c + + + + + exactle_freertos + + + wsf_assert.c + 1 + ../../../../../third_party/exactle/wsf/sources/port/freertos/wsf_assert.c + + + wsf_buf.c + 1 + ../../../../../third_party/exactle/wsf/sources/port/freertos/wsf_buf.c + + + wsf_efs.c + 1 + ../../../../../third_party/exactle/wsf/sources/port/freertos/wsf_efs.c + + + wsf_math.c + 1 + ../../../../../third_party/exactle/wsf/sources/port/freertos/wsf_math.c + + + wsf_msg.c + 1 + ../../../../../third_party/exactle/wsf/sources/port/freertos/wsf_msg.c + + + wsf_os.c + 1 + ../../../../../third_party/exactle/wsf/sources/port/freertos/wsf_os.c + + + wsf_queue.c + 1 + ../../../../../third_party/exactle/wsf/sources/port/freertos/wsf_queue.c + + + wsf_timer.c + 1 + ../../../../../third_party/exactle/wsf/sources/port/freertos/wsf_timer.c + + + wsf_trace.c + 1 + ../../../../../third_party/exactle/wsf/sources/port/freertos/wsf_trace.c + + + + + exactle_l2c + + + l2c_coc.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/l2c/l2c_coc.c + + + l2c_main.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/l2c/l2c_main.c + + + l2c_master.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/l2c/l2c_master.c + + + l2c_slave.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/l2c/l2c_slave.c + + + + + exactle_paspc + + + paspc_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/profiles/paspc/paspc_main.c + + + + + exactle_dm + + + dm_adv.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_adv.c + + + dm_adv_ae.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_adv_ae.c + + + dm_adv_leg.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_adv_leg.c + + + dm_conn.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_conn.c + + + dm_conn_cte.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_conn_cte.c + + + dm_conn_master.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_conn_master.c + + + dm_conn_master_ae.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_conn_master_ae.c + + + dm_conn_master_leg.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_conn_master_leg.c + + + dm_conn_slave.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_conn_slave.c + + + dm_conn_slave_ae.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_conn_slave_ae.c + + + dm_conn_slave_leg.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_conn_slave_leg.c + + + dm_conn_sm.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_conn_sm.c + + + dm_dev.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_dev.c + + + dm_dev_priv.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_dev_priv.c + + + dm_main.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_main.c + + + dm_past.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_past.c + + + dm_phy.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_phy.c + + + dm_priv.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_priv.c + + + dm_scan.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_scan.c + + + dm_scan_ae.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_scan_ae.c + + + dm_scan_leg.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_scan_leg.c + + + dm_sec.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_sec.c + + + dm_sec_lesc.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_sec_lesc.c + + + dm_sec_master.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_sec_master.c + + + dm_sec_slave.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_sec_slave.c + + + dm_sync_ae.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/dm/dm_sync_ae.c + + + + + exactle_smp + + + smpi_act.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smpi_act.c + + + smpi_sc_act.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smpi_sc_act.c + + + smpi_sc_sm.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smpi_sc_sm.c + + + smpi_sm.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smpi_sm.c + + + smpr_act.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smpr_act.c + + + smpr_sc_act.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smpr_sc_act.c + + + smpr_sc_sm.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smpr_sc_sm.c + + + smpr_sm.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smpr_sm.c + + + smp_act.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smp_act.c + + + smp_db.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smp_db.c + + + smp_main.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smp_main.c + + + smp_non.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smp_non.c + + + smp_sc_act.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smp_sc_act.c + + + smp_sc_main.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/smp/smp_sc_main.c + + + + + uecc_uecc + + + uECC.c + 1 + ../../../../../third_party/uecc/uECC.c + + + uECC_ll.c + 1 + ../../../../../third_party/uecc/uECC_ll.c + + + + + src + + + radio_task.c + 1 + ../src/radio_task.c + + + rtos.c + 1 + ../src/rtos.c + + + ble_qiot_demo.c + 1 + ..\src\ble_qiot_demo.c + + + watch_main.c + 1 + ..\src\watch_main.c + + + apollo3_service.c + 1 + ..\src\apollo3_service.c + + + + + exactle_fmpl + + + fmpl_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/profiles/fmpl/fmpl_main.c + + + + + exactle_att + + + attc_disc.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/attc_disc.c + + + attc_main.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/attc_main.c + + + attc_proc.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/attc_proc.c + + + attc_read.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/attc_read.c + + + attc_sign.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/attc_sign.c + + + attc_write.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/attc_write.c + + + atts_ccc.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/atts_ccc.c + + + atts_csf.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/atts_csf.c + + + atts_dyn.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/atts_dyn.c + + + atts_ind.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/atts_ind.c + + + atts_main.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/atts_main.c + + + atts_proc.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/atts_proc.c + + + atts_read.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/atts_read.c + + + atts_sign.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/atts_sign.c + + + atts_write.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/atts_write.c + + + att_main.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/att_main.c + + + att_uuid.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/att/att_uuid.c + + + + + exactle_hci + + + hci_main.c + 1 + ../../../../../third_party/exactle/ble-host/sources/stack/hci/hci_main.c + + + + + exactle_hidapp + + + hidapp_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/hidapp/hidapp_main.c + + + + + exactle_common + + + app_db.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/common/app_db.c + + + app_hw.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/common/app_hw.c + + + app_ui.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/common/app_ui.c + + + ui_console.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/common/ui_console.c + + + ui_lcd.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/common/ui_lcd.c + + + ui_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/common/ui_main.c + + + ui_platform.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/common/ui_platform.c + + + ui_timer.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/common/ui_timer.c + + + + + exactle_apollo3 + + + hci_drv_apollo3.c + 1 + ../../../../../third_party/exactle/ble-host/sources/hci/ambiq/apollo3/hci_drv_apollo3.c + + + + + exactle_uecc + + + sec_ecc.c + 1 + ../../../../../third_party/exactle/ble-host/sources/sec/uecc/sec_ecc.c + + + + + exactle_hid + + + hid_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/profiles/hid/hid_main.c + + + + + exactle_gatt + + + gatt_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/profiles/gatt/gatt_main.c + + + + + FreeRTOSv10.1.1_AMapollo2 + + + port.c + 1 + ../../../../../third_party/FreeRTOSv10.1.1/Source/portable/Keil/AMapollo2/port.c + + + + + exactle_gap + + + gap_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/profiles/gap/gap_main.c + + + + + exactle_tipc + + + tipc_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/profiles/tipc/tipc_main.c + + + + + exactle_util + + + bda.c + 1 + ../../../../../third_party/exactle/wsf/sources/util/bda.c + + + bstream.c + 1 + ../../../../../third_party/exactle/wsf/sources/util/bstream.c + + + calc128.c + 1 + ../../../../../third_party/exactle/wsf/sources/util/calc128.c + + + crc32.c + 1 + ../../../../../third_party/exactle/wsf/sources/util/crc32.c + + + print.c + 1 + ../../../../../third_party/exactle/wsf/sources/util/print.c + + + terminal.c + 1 + ../../../../../third_party/exactle/wsf/sources/util/terminal.c + + + wstr.c + 1 + ../../../../../third_party/exactle/wsf/sources/util/wstr.c + + + + + exactle_app + + + app_disc.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/app_disc.c + + + app_main.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/app_main.c + + + app_master.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/app_master.c + + + app_master_leg.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/app_master_leg.c + + + app_server.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/app_server.c + + + app_slave.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/app_slave.c + + + app_slave_leg.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/app_slave_leg.c + + + app_terminal.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/apps/app/app_terminal.c + + + + + utils + + + am_util_ble.c + 1 + ../../../../../utils/am_util_ble.c + + + am_util_debug.c + 1 + ../../../../../utils/am_util_debug.c + + + am_util_delay.c + 1 + ../../../../../utils/am_util_delay.c + + + am_util_faultisr.c + 1 + ../../../../../utils/am_util_faultisr.c + + + am_util_id.c + 1 + ../../../../../utils/am_util_id.c + + + am_util_stdio.c + 1 + ../../../../../utils/am_util_stdio.c + + + + + FreeRTOSv10.1.1_Source + + + event_groups.c + 1 + ../../../../../third_party/FreeRTOSv10.1.1/Source/event_groups.c + + + list.c + 1 + ../../../../../third_party/FreeRTOSv10.1.1/Source/list.c + + + queue.c + 1 + ../../../../../third_party/FreeRTOSv10.1.1/Source/queue.c + + + tasks.c + 1 + ../../../../../third_party/FreeRTOSv10.1.1/Source/tasks.c + + + timers.c + 1 + ../../../../../third_party/FreeRTOSv10.1.1/Source/timers.c + + + + + FreeRTOSv10.1.1_MemMang + + + heap_2.c + 1 + ../../../../../third_party/FreeRTOSv10.1.1/Source/portable/MemMang/heap_2.c + + + + + devices + + + am_devices_button.c + 1 + ../../../../../devices/am_devices_button.c + + + am_devices_led.c + 1 + ../../../../../devices/am_devices_led.c + + + + + exactle_services + + + svc_batt.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_batt.c + + + svc_bps.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_bps.c + + + svc_core.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_core.c + + + svc_cps.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_cps.c + + + svc_cscs.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_cscs.c + + + svc_dis.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_dis.c + + + svc_gls.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_gls.c + + + svc_gyro.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_gyro.c + + + svc_hid.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_hid.c + + + svc_hrs.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_hrs.c + + + svc_hts.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_hts.c + + + svc_ipss.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_ipss.c + + + svc_plxs.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_plxs.c + + + svc_px.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_px.c + + + svc_rscs.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_rscs.c + + + svc_scpss.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_scpss.c + + + svc_temp.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_temp.c + + + svc_uricfg.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_uricfg.c + + + svc_wdxs.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_wdxs.c + + + svc_wp.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_wp.c + + + svc_wss.c + 1 + ../../../../../third_party/exactle/ble-profiles/sources/services/svc_wss.c + + + + + keil + + + startup_keil.s + 1 + ../keil/startup_keil.s + + + + + lib + + + libam_bsp.lib + 4 + ../../../bsp/keil/bin/libam_bsp.lib + + + libam_hal.lib + 4 + ../../../../../mcu/apollo3/hal/keil/bin/libam_hal.lib + + + + + rtt + + + SEGGER_RTT.c + 1 + ..\rtt\SEGGER_RTT.c + + + SEGGER_RTT_printf.c + 1 + ..\rtt\SEGGER_RTT_printf.c + + + + + qcloud_iot_explorer_ble + + + ble_qiot_llsync_data.c + 1 + ..\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_data.c + + + ble_qiot_llsync_device.c + 1 + ..\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_device.c + + + ble_qiot_llsync_event.c + 1 + ..\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_event.c + + + ble_qiot_service.c + 1 + ..\qcloud_iot_explorer_ble\src\core\ble_qiot_service.c + + + ble_qiot_utils_base64.c + 1 + ..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_base64.c + + + ble_qiot_utils_hmac.c + 1 + ..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_hmac.c + + + ble_qiot_utils_md5.c + 1 + ..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_md5.c + + + ble_qiot_utils_sha1.c + 1 + ..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_sha1.c + + + ble_qiot_template.c + 1 + ..\data_template\ble_qiot_template.c + + + ble_qiot_utils_log.c + 1 + ..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_log.c + + + + + + + +
diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/startup_keil.s b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/startup_keil.s new file mode 100644 index 00000000..2717b367 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/keil/startup_keil.s @@ -0,0 +1,408 @@ +;****************************************************************************** +; +;! @file startup_keil.s +;! +;! @brief Definitions for Apollo3 interrupt handlers, the vector table, and the stack. +; +;****************************************************************************** + +;****************************************************************************** +; +; Copyright (c) 2020, Ambiq Micro +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions are met: +; +; 1. Redistributions of source code must retain the above copyright notice, +; this list of conditions and the following disclaimer. +; +; 2. Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in the +; documentation and/or other materials provided with the distribution. +; +; 3. Neither the name of the copyright holder nor the names of its +; contributors may be used to endorse or promote products derived from this +; software without specific prior written permission. +; +; Third party software included in this distribution is subject to the +; additional license terms as defined in the /docs/licenses directory. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +; POSSIBILITY OF SUCH DAMAGE. +; +; This is part of revision 2.4.2 of the AmbiqSuite Development Package. +; +;****************************************************************************** + +;****************************************************************************** +; +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +;************************************************************************ +Stack EQU 0x00002B00 + +;****************************************************************************** +; +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; +;****************************************************************************** +Heap EQU 0x00000000 + +;****************************************************************************** +; +; Allocate space for the stack. +; +;****************************************************************************** + AREA STACK, NOINIT, READWRITE, ALIGN=3 +StackMem + SPACE Stack +__initial_sp + +;****************************************************************************** +; +; Allocate space for the heap. +; +;****************************************************************************** + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +HeapMem + SPACE Heap +__heap_limit + +;****************************************************************************** +; +; Indicate that the code in this file preserves 8-byte alignment of the stack. +; +;****************************************************************************** + PRESERVE8 + +;****************************************************************************** +; +; Place code into the reset code section. +; +;****************************************************************************** + AREA RESET, CODE, READONLY + THUMB + +;****************************************************************************** +; +; The vector table. +; +;****************************************************************************** +; +; Note: Aliasing and weakly exporting am_mpufault_isr, am_busfault_isr, and +; am_usagefault_isr does not work if am_fault_isr is defined externally. +; Therefore, we'll explicitly use am_fault_isr in the table for those vectors. +; + + EXPORT __Vectors +__Vectors + DCD StackMem + Stack ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; The MPU fault handler + DCD BusFault_Handler ; The bus fault handler + DCD UsageFault_Handler ; The usage fault handler + DCD SecureFault_Handler ; Secure fault handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall handler + DCD DebugMon_Handler ; Debug monitor handler + DCD 0 ; Reserved + DCD PendSV_Handler ; The PendSV handler + DCD SysTick_Handler ; The SysTick handler + + ; + ; Peripheral Interrupts + ; + DCD am_brownout_isr ; 0: Reserved + DCD am_watchdog_isr ; 1: Reserved + DCD am_rtc_isr ; 2: RTC + DCD am_vcomp_isr ; 3: Voltage Comparator + DCD am_ioslave_ios_isr ; 4: I/O Slave general + DCD am_ioslave_acc_isr ; 5: I/O Slave access + DCD am_iomaster0_isr ; 6: I/O Master 0 + DCD am_iomaster1_isr ; 7: I/O Master 1 + DCD am_iomaster2_isr ; 8: I/O Master 2 + DCD am_iomaster3_isr ; 9: I/O Master 3 + DCD am_iomaster4_isr ; 10: I/O Master 4 + DCD am_iomaster5_isr ; 11: I/O Master 5 + DCD am_ble_isr ; 12: BLEIF + DCD am_gpio_isr ; 13: GPIO + DCD am_ctimer_isr ; 14: CTIMER + DCD am_uart_isr ; 15: UART0 + DCD am_uart1_isr ; 16: UART1 + DCD am_scard_isr ; 17: SCARD + DCD am_adc_isr ; 18: ADC + DCD am_pdm0_isr ; 19: PDM + DCD am_mspi0_isr ; 20: MSPI0 + DCD am_software0_isr ; 21: SOFTWARE0 + DCD am_stimer_isr ; 22: SYSTEM TIMER + DCD am_stimer_cmpr0_isr ; 23: SYSTEM TIMER COMPARE0 + DCD am_stimer_cmpr1_isr ; 24: SYSTEM TIMER COMPARE1 + DCD am_stimer_cmpr2_isr ; 25: SYSTEM TIMER COMPARE2 + DCD am_stimer_cmpr3_isr ; 26: SYSTEM TIMER COMPARE3 + DCD am_stimer_cmpr4_isr ; 27: SYSTEM TIMER COMPARE4 + DCD am_stimer_cmpr5_isr ; 28: SYSTEM TIMER COMPARE5 + DCD am_stimer_cmpr6_isr ; 29: SYSTEM TIMER COMPARE6 + DCD am_stimer_cmpr7_isr ; 30: SYSTEM TIMER COMPARE7 + DCD am_clkgen_isr ; 31: CLKGEN + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + +;****************************************************************************** +; +; Place code immediately following vector table. +; +;****************************************************************************** +;****************************************************************************** +; +; The Patch table. +; +; The patch table should pad the vector table size to a total of 64 entries +; (16 core + 48 periph) such that code begins at offset 0x100. +; +;****************************************************************************** + EXPORT __Patchable +__Patchable + DCD 0 ; 32 + DCD 0 ; 33 + DCD 0 ; 34 + DCD 0 ; 35 + DCD 0 ; 36 + DCD 0 ; 37 + DCD 0 ; 38 + DCD 0 ; 39 + DCD 0 ; 40 + DCD 0 ; 41 + DCD 0 ; 42 + DCD 0 ; 43 + DCD 0 ; 44 + DCD 0 ; 45 + DCD 0 ; 46 + DCD 0 ; 47 + +;****************************************************************************** +; +; This is the code that gets called when the processor first starts execution +; following a reset event. +; +;****************************************************************************** +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT __main + + ; + ; Enable the FPU. + ; + MOVW R0, #0xED88 + MOVT R0, #0xE000 + LDR R1, [R0] + ORR R1, #0x00F00000 + STR R1, [R0] + DSB + ISB + + ; + ; Branch to main. + ; + LDR R0, =__main + BX R0 + + ENDP + +;****************************************************************************** +; +; Weak Exception Handlers. +; +;****************************************************************************** + +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SecureFault_Handler\ + PROC + EXPORT SecureFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +am_default_isr\ + PROC + EXPORT am_brownout_isr [WEAK] + EXPORT am_watchdog_isr [WEAK] + EXPORT am_rtc_isr [WEAK] + EXPORT am_vcomp_isr [WEAK] + EXPORT am_ioslave_ios_isr [WEAK] + EXPORT am_ioslave_acc_isr [WEAK] + EXPORT am_iomaster0_isr [WEAK] + EXPORT am_iomaster1_isr [WEAK] + EXPORT am_iomaster2_isr [WEAK] + EXPORT am_iomaster3_isr [WEAK] + EXPORT am_iomaster4_isr [WEAK] + EXPORT am_iomaster5_isr [WEAK] + EXPORT am_ble_isr [WEAK] + EXPORT am_gpio_isr [WEAK] + EXPORT am_ctimer_isr [WEAK] + EXPORT am_uart_isr [WEAK] + EXPORT am_uart0_isr [WEAK] + EXPORT am_uart1_isr [WEAK] + EXPORT am_scard_isr [WEAK] + EXPORT am_adc_isr [WEAK] + EXPORT am_pdm0_isr [WEAK] + EXPORT am_mspi0_isr [WEAK] + EXPORT am_software0_isr [WEAK] + EXPORT am_stimer_isr [WEAK] + EXPORT am_stimer_cmpr0_isr [WEAK] + EXPORT am_stimer_cmpr1_isr [WEAK] + EXPORT am_stimer_cmpr2_isr [WEAK] + EXPORT am_stimer_cmpr3_isr [WEAK] + EXPORT am_stimer_cmpr4_isr [WEAK] + EXPORT am_stimer_cmpr5_isr [WEAK] + EXPORT am_stimer_cmpr6_isr [WEAK] + EXPORT am_stimer_cmpr7_isr [WEAK] + EXPORT am_clkgen_isr [WEAK] + +am_brownout_isr +am_watchdog_isr +am_rtc_isr +am_vcomp_isr +am_ioslave_ios_isr +am_ioslave_acc_isr +am_iomaster0_isr +am_iomaster1_isr +am_iomaster2_isr +am_iomaster3_isr +am_iomaster4_isr +am_iomaster5_isr +am_ble_isr +am_gpio_isr +am_ctimer_isr +am_uart_isr +am_uart0_isr +am_uart1_isr +am_scard_isr +am_adc_isr +am_pdm0_isr +am_mspi0_isr +am_software0_isr +am_stimer_isr +am_stimer_cmpr0_isr +am_stimer_cmpr1_isr +am_stimer_cmpr2_isr +am_stimer_cmpr3_isr +am_stimer_cmpr4_isr +am_stimer_cmpr5_isr +am_stimer_cmpr6_isr +am_stimer_cmpr7_isr +am_clkgen_isr + + ; all device interrupts go here unless the weak label is over + ; ridden in the linker hard spin so the debugger will know it + ; was an unhandled interrupt request a come-from-buffer or + ; instruction trace hardware would sure be nice if you get here + B . + + ENDP + +;****************************************************************************** +; +; Align the end of the section. +; +;****************************************************************************** + ALIGN + +;****************************************************************************** +; +; Initialization of the heap and stack. +; +;****************************************************************************** + AREA |.text|, CODE, READONLY + +;****************************************************************************** +; +; User Initial Stack & Heap. +; +;****************************************************************************** + IF :DEF: __MICROLIB + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + ELSE + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap +__user_initial_stackheap PROC + LDR R0, =HeapMem + LDR R1, =(StackMem + Stack) + LDR R2, =(HeapMem + Heap) + LDR R3, =StackMem + BX LR + + ENDP + + ENDIF + +;****************************************************************************** +; +; Align the end of the section. +; +;****************************************************************************** + ALIGN + +;****************************************************************************** +; +; All Done +; +;****************************************************************************** + END + + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/readme.md b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/readme.md new file mode 100644 index 00000000..624c7367 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/readme.md @@ -0,0 +1,6 @@ +# 说明 + +1. 本工程基于 Ambiq Micro Apollo 3 Blue 平台开发,请联系厂商获取SDK +2. Keil工程的DeviceFamilyPack为 `AmbiqMicro.Apollo_DFP.1.2.0.pack`,请前往 [官网](http://s3.asia.ambiqmicro.com/pack/AmbiqMicro.Apollo_DFP.1.2.0.pack)下载 +3. 例程keil工程文件路径 `\qcloud_iot_explorer_ble\samples\lifesense\keil` +4. 5. 使用 code_extract.py 脚本抽取代码得到 `qcloud-iot-ble-lifesense` 目录,请将该目录放置 NORDIC SDK 的 `\boards\apollo3_evb\examples\` 目录下,打开keil工程编译即可 diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT.c new file mode 100644 index 00000000..334825cf --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT.c @@ -0,0 +1,2030 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2019 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* condition is met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this condition and the following disclaimer. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.82 * +* * +********************************************************************** + +---------------------------END-OF-HEADER------------------------------ +File : SEGGER_RTT.c +Purpose : Implementation of SEGGER real-time transfer (RTT) which + allows real-time communication on targets which support + debugger memory accesses while the CPU is running. +Revision: $Rev: 19464 $ + +Additional information: + Type "int" is assumed to be 32-bits in size + H->T Host to target communication + T->H Target to host communication + + RTT channel 0 is always present and reserved for Terminal usage. + Name is fixed to "Terminal" + + Effective buffer size: SizeOfBuffer - 1 + + WrOff == RdOff: Buffer is empty + WrOff == (RdOff - 1): Buffer is full + WrOff > RdOff: Free space includes wrap-around + WrOff < RdOff: Used space includes wrap-around + (WrOff == (SizeOfBuffer - 1)) && (RdOff == 0): + Buffer full and wrap-around after next byte + + +---------------------------------------------------------------------- +*/ + +#include "SEGGER_RTT.h" + +#include // for memcpy + +/********************************************************************* +* +* Configuration, default values +* +********************************************************************** +*/ + +#ifndef BUFFER_SIZE_UP + #define BUFFER_SIZE_UP 1024 // Size of the buffer for terminal output of target, up to host +#endif + +#ifndef BUFFER_SIZE_DOWN + #define BUFFER_SIZE_DOWN 16 // Size of the buffer for terminal input to target from host (Usually keyboard input) +#endif + +#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS + #define SEGGER_RTT_MAX_NUM_UP_BUFFERS 2 // Number of up-buffers (T->H) available on this target +#endif + +#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS + #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS 2 // Number of down-buffers (H->T) available on this target +#endif + +#ifndef SEGGER_RTT_BUFFER_SECTION + #if defined(SEGGER_RTT_SECTION) + #define SEGGER_RTT_BUFFER_SECTION SEGGER_RTT_SECTION + #endif +#endif + +#ifndef SEGGER_RTT_ALIGNMENT + #define SEGGER_RTT_ALIGNMENT 0 +#endif + +#ifndef SEGGER_RTT_BUFFER_ALIGNMENT + #define SEGGER_RTT_BUFFER_ALIGNMENT 0 +#endif + +#ifndef SEGGER_RTT_MODE_DEFAULT + #define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP +#endif + +#ifndef SEGGER_RTT_LOCK + #define SEGGER_RTT_LOCK() +#endif + +#ifndef SEGGER_RTT_UNLOCK + #define SEGGER_RTT_UNLOCK() +#endif + +#ifndef STRLEN + #define STRLEN(a) strlen((a)) +#endif + +#ifndef STRCPY + #define STRCPY(pDest, pSrc, NumBytes) strcpy((pDest), (pSrc)) +#endif + +#ifndef SEGGER_RTT_MEMCPY_USE_BYTELOOP + #define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 +#endif + +#ifndef SEGGER_RTT_MEMCPY + #ifdef MEMCPY + #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) MEMCPY((pDest), (pSrc), (NumBytes)) + #else + #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) memcpy((pDest), (pSrc), (NumBytes)) + #endif +#endif + +#ifndef MIN + #define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifndef MAX + #define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif +// +// For some environments, NULL may not be defined until certain headers are included +// +#ifndef NULL + #define NULL 0 +#endif + +/********************************************************************* +* +* Defines, fixed +* +********************************************************************** +*/ +#if (defined __ICCARM__) || (defined __ICCRX__) + #define RTT_PRAGMA(P) _Pragma(#P) +#endif + +#if SEGGER_RTT_ALIGNMENT || SEGGER_RTT_BUFFER_ALIGNMENT + #if (defined __GNUC__) + #define SEGGER_RTT_ALIGN(Var, Alignment) Var __attribute__ ((aligned (Alignment))) + #elif (defined __ICCARM__) || (defined __ICCRX__) + #define PRAGMA(A) _Pragma(#A) +#define SEGGER_RTT_ALIGN(Var, Alignment) RTT_PRAGMA(data_alignment=Alignment) \ + Var + #elif (defined __CC_ARM) + #define SEGGER_RTT_ALIGN(Var, Alignment) Var __attribute__ ((aligned (Alignment))) + #else + #error "Alignment not supported for this compiler." + #endif +#else + #define SEGGER_RTT_ALIGN(Var, Alignment) Var +#endif + +#if defined(SEGGER_RTT_SECTION) || defined (SEGGER_RTT_BUFFER_SECTION) + #if (defined __GNUC__) + #define SEGGER_RTT_PUT_SECTION(Var, Section) __attribute__ ((section (Section))) Var + #elif (defined __ICCARM__) || (defined __ICCRX__) +#define SEGGER_RTT_PUT_SECTION(Var, Section) RTT_PRAGMA(location=Section) \ + Var + #elif (defined __CC_ARM) + #define SEGGER_RTT_PUT_SECTION(Var, Section) __attribute__ ((section (Section), zero_init)) Var + #else + #error "Section placement not supported for this compiler." + #endif +#else + #define SEGGER_RTT_PUT_SECTION(Var, Section) Var +#endif + + +#if SEGGER_RTT_ALIGNMENT + #define SEGGER_RTT_CB_ALIGN(Var) SEGGER_RTT_ALIGN(Var, SEGGER_RTT_ALIGNMENT) +#else + #define SEGGER_RTT_CB_ALIGN(Var) Var +#endif + +#if SEGGER_RTT_BUFFER_ALIGNMENT + #define SEGGER_RTT_BUFFER_ALIGN(Var) SEGGER_RTT_ALIGN(Var, SEGGER_RTT_BUFFER_ALIGNMENT) +#else + #define SEGGER_RTT_BUFFER_ALIGN(Var) Var +#endif + + +#if defined(SEGGER_RTT_SECTION) + #define SEGGER_RTT_PUT_CB_SECTION(Var) SEGGER_RTT_PUT_SECTION(Var, SEGGER_RTT_SECTION) +#else + #define SEGGER_RTT_PUT_CB_SECTION(Var) Var +#endif + +#if defined(SEGGER_RTT_BUFFER_SECTION) + #define SEGGER_RTT_PUT_BUFFER_SECTION(Var) SEGGER_RTT_PUT_SECTION(Var, SEGGER_RTT_BUFFER_SECTION) +#else + #define SEGGER_RTT_PUT_BUFFER_SECTION(Var) Var +#endif + +/********************************************************************* +* +* Static const data +* +********************************************************************** +*/ + +static unsigned char _aTerminalId[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + +/********************************************************************* +* +* Static data +* +********************************************************************** +*/ +// +// RTT Control Block and allocate buffers for channel 0 +// +SEGGER_RTT_PUT_CB_SECTION(SEGGER_RTT_CB_ALIGN(SEGGER_RTT_CB _SEGGER_RTT)); + +SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acUpBuffer [BUFFER_SIZE_UP])); +SEGGER_RTT_PUT_BUFFER_SECTION(SEGGER_RTT_BUFFER_ALIGN(static char _acDownBuffer[BUFFER_SIZE_DOWN])); + +static unsigned char _ActiveTerminal; + +/********************************************************************* +* +* Static functions +* +********************************************************************** +*/ + +/********************************************************************* +* +* _DoInit() +* +* Function description +* Initializes the control block an buffers. +* May only be called via INIT() to avoid overriding settings. +* +*/ +#define INIT() do { \ + if (_SEGGER_RTT.acID[0] == '\0') { _DoInit(); } \ + } while (0) +static void _DoInit(void) { + SEGGER_RTT_CB* p; + // + // Initialize control block + // + p = &_SEGGER_RTT; + p->MaxNumUpBuffers = SEGGER_RTT_MAX_NUM_UP_BUFFERS; + p->MaxNumDownBuffers = SEGGER_RTT_MAX_NUM_DOWN_BUFFERS; + // + // Initialize up buffer 0 + // + p->aUp[0].sName = "Terminal"; + p->aUp[0].pBuffer = _acUpBuffer; + p->aUp[0].SizeOfBuffer = sizeof(_acUpBuffer); + p->aUp[0].RdOff = 0u; + p->aUp[0].WrOff = 0u; + p->aUp[0].Flags = SEGGER_RTT_MODE_DEFAULT; + // + // Initialize down buffer 0 + // + p->aDown[0].sName = "Terminal"; + p->aDown[0].pBuffer = _acDownBuffer; + p->aDown[0].SizeOfBuffer = sizeof(_acDownBuffer); + p->aDown[0].RdOff = 0u; + p->aDown[0].WrOff = 0u; + p->aDown[0].Flags = SEGGER_RTT_MODE_DEFAULT; + // + // Finish initialization of the control block. + // Copy Id string in three steps to make sure "SEGGER RTT" is not found + // in initializer memory (usually flash) by J-Link + // + STRCPY(&p->acID[7], "RTT", 9); + RTT__DMB(); + STRCPY(&p->acID[0], "SEGGER", 7); + RTT__DMB(); + p->acID[6] = ' '; + RTT__DMB(); +} + +/********************************************************************* +* +* _WriteBlocking() +* +* Function description +* Stores a specified number of characters in SEGGER RTT ring buffer +* and updates the associated write pointer which is periodically +* read by the host. +* The caller is responsible for managing the write chunk sizes as +* _WriteBlocking() will block until all data has been posted successfully. +* +* Parameters +* pRing Ring buffer to post to. +* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. +* NumBytes Number of bytes to be stored in the SEGGER RTT control block. +* +* Return value +* >= 0 - Number of bytes written into buffer. +*/ +static unsigned _WriteBlocking(SEGGER_RTT_BUFFER_UP* pRing, const char* pBuffer, unsigned NumBytes) { + unsigned NumBytesToWrite; + unsigned NumBytesWritten; + unsigned RdOff; + unsigned WrOff; +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + char* pDst; +#endif + // + // Write data to buffer and handle wrap-around if necessary + // + NumBytesWritten = 0u; + WrOff = pRing->WrOff; + do { + RdOff = pRing->RdOff; // May be changed by host (debug probe) in the meantime + if (RdOff > WrOff) { + NumBytesToWrite = RdOff - WrOff - 1u; + } else { + NumBytesToWrite = pRing->SizeOfBuffer - (WrOff - RdOff + 1u); + } + NumBytesToWrite = MIN(NumBytesToWrite, (pRing->SizeOfBuffer - WrOff)); // Number of bytes that can be written until buffer wrap-around + NumBytesToWrite = MIN(NumBytesToWrite, NumBytes); +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + pDst = pRing->pBuffer + WrOff; + NumBytesWritten += NumBytesToWrite; + NumBytes -= NumBytesToWrite; + WrOff += NumBytesToWrite; + while (NumBytesToWrite--) { + *pDst++ = *pBuffer++; + }; +#else + SEGGER_RTT_MEMCPY(pRing->pBuffer + WrOff, pBuffer, NumBytesToWrite); + NumBytesWritten += NumBytesToWrite; + pBuffer += NumBytesToWrite; + NumBytes -= NumBytesToWrite; + WrOff += NumBytesToWrite; +#endif + if (WrOff == pRing->SizeOfBuffer) { + WrOff = 0u; + } + RTT__DMB(); + pRing->WrOff = WrOff; + } while (NumBytes); + // + return NumBytesWritten; +} + +/********************************************************************* +* +* _WriteNoCheck() +* +* Function description +* Stores a specified number of characters in SEGGER RTT ring buffer +* and updates the associated write pointer which is periodically +* read by the host. +* It is callers responsibility to make sure data actually fits in buffer. +* +* Parameters +* pRing Ring buffer to post to. +* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. +* NumBytes Number of bytes to be stored in the SEGGER RTT control block. +* +* Notes +* (1) If there might not be enough space in the "Up"-buffer, call _WriteBlocking +*/ +static void _WriteNoCheck(SEGGER_RTT_BUFFER_UP* pRing, const char* pData, unsigned NumBytes) { + unsigned NumBytesAtOnce; + unsigned WrOff; + unsigned Rem; +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + char* pDst; +#endif + + WrOff = pRing->WrOff; + Rem = pRing->SizeOfBuffer - WrOff; + if (Rem > NumBytes) { + // + // All data fits before wrap around + // +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + pDst = pRing->pBuffer + WrOff; + WrOff += NumBytes; + while (NumBytes--) { + *pDst++ = *pData++; + }; + RTT__DMB(); + pRing->WrOff = WrOff; +#else + SEGGER_RTT_MEMCPY(pRing->pBuffer + WrOff, pData, NumBytes); + RTT__DMB(); + pRing->WrOff = WrOff + NumBytes; +#endif + } else { + // + // We reach the end of the buffer, so need to wrap around + // +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + pDst = pRing->pBuffer + WrOff; + NumBytesAtOnce = Rem; + while (NumBytesAtOnce--) { + *pDst++ = *pData++; + }; + pDst = pRing->pBuffer; + NumBytesAtOnce = NumBytes - Rem; + while (NumBytesAtOnce--) { + *pDst++ = *pData++; + }; + RTT__DMB(); + pRing->WrOff = NumBytes - Rem; +#else + NumBytesAtOnce = Rem; + SEGGER_RTT_MEMCPY(pRing->pBuffer + WrOff, pData, NumBytesAtOnce); + NumBytesAtOnce = NumBytes - Rem; + SEGGER_RTT_MEMCPY(pRing->pBuffer, pData + Rem, NumBytesAtOnce); + RTT__DMB(); + pRing->WrOff = NumBytesAtOnce; +#endif + } +} + +/********************************************************************* +* +* _PostTerminalSwitch() +* +* Function description +* Switch terminal to the given terminal ID. It is the caller's +* responsibility to ensure the terminal ID is correct and there is +* enough space in the buffer for this to complete successfully. +* +* Parameters +* pRing Ring buffer to post to. +* TerminalId Terminal ID to switch to. +*/ +static void _PostTerminalSwitch(SEGGER_RTT_BUFFER_UP* pRing, unsigned char TerminalId) { + unsigned char ac[2]; + + ac[0] = 0xFFu; + ac[1] = _aTerminalId[TerminalId]; // Caller made already sure that TerminalId does not exceed our terminal limit + _WriteBlocking(pRing, (const char*)ac, 2u); +} + +/********************************************************************* +* +* _GetAvailWriteSpace() +* +* Function description +* Returns the number of bytes that can be written to the ring +* buffer without blocking. +* +* Parameters +* pRing Ring buffer to check. +* +* Return value +* Number of bytes that are free in the buffer. +*/ +static unsigned _GetAvailWriteSpace(SEGGER_RTT_BUFFER_UP* pRing) { + unsigned RdOff; + unsigned WrOff; + unsigned r; + // + // Avoid warnings regarding volatile access order. It's not a problem + // in this case, but dampen compiler enthusiasm. + // + RdOff = pRing->RdOff; + WrOff = pRing->WrOff; + if (RdOff <= WrOff) { + r = pRing->SizeOfBuffer - 1u - WrOff + RdOff; + } else { + r = RdOff - WrOff - 1u; + } + return r; +} + +/********************************************************************* +* +* Public code +* +********************************************************************** +*/ +/********************************************************************* +* +* SEGGER_RTT_ReadUpBufferNoLock() +* +* Function description +* Reads characters from SEGGER real-time-terminal control block +* which have been previously stored by the application. +* Do not lock against interrupts and multiple access. +* Used to do the same operation that J-Link does, to transfer +* RTT data via other channels, such as TCP/IP or UART. +* +* Parameters +* BufferIndex Index of Up-buffer to be used. +* pBuffer Pointer to buffer provided by target application, to copy characters from RTT-up-buffer to. +* BufferSize Size of the target application buffer. +* +* Return value +* Number of bytes that have been read. +* +* Additional information +* This function must not be called when J-Link might also do RTT. +*/ +unsigned SEGGER_RTT_ReadUpBufferNoLock(unsigned BufferIndex, void* pData, unsigned BufferSize) { + unsigned NumBytesRem; + unsigned NumBytesRead; + unsigned RdOff; + unsigned WrOff; + unsigned char* pBuffer; + SEGGER_RTT_BUFFER_UP* pRing; +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + const char* pSrc; +#endif + // + INIT(); + pRing = &_SEGGER_RTT.aUp[BufferIndex]; + pBuffer = (unsigned char*)pData; + RdOff = pRing->RdOff; + WrOff = pRing->WrOff; + NumBytesRead = 0u; + // + // Read from current read position to wrap-around of buffer, first + // + if (RdOff > WrOff) { + NumBytesRem = pRing->SizeOfBuffer - RdOff; + NumBytesRem = MIN(NumBytesRem, BufferSize); +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + pSrc = pRing->pBuffer + RdOff; + NumBytesRead += NumBytesRem; + BufferSize -= NumBytesRem; + RdOff += NumBytesRem; + while (NumBytesRem--) { + *pBuffer++ = *pSrc++; + }; +#else + SEGGER_RTT_MEMCPY(pBuffer, pRing->pBuffer + RdOff, NumBytesRem); + NumBytesRead += NumBytesRem; + pBuffer += NumBytesRem; + BufferSize -= NumBytesRem; + RdOff += NumBytesRem; +#endif + // + // Handle wrap-around of buffer + // + if (RdOff == pRing->SizeOfBuffer) { + RdOff = 0u; + } + } + // + // Read remaining items of buffer + // + NumBytesRem = WrOff - RdOff; + NumBytesRem = MIN(NumBytesRem, BufferSize); + if (NumBytesRem > 0u) { +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + pSrc = pRing->pBuffer + RdOff; + NumBytesRead += NumBytesRem; + BufferSize -= NumBytesRem; + RdOff += NumBytesRem; + while (NumBytesRem--) { + *pBuffer++ = *pSrc++; + }; +#else + SEGGER_RTT_MEMCPY(pBuffer, pRing->pBuffer + RdOff, NumBytesRem); + NumBytesRead += NumBytesRem; + pBuffer += NumBytesRem; + BufferSize -= NumBytesRem; + RdOff += NumBytesRem; +#endif + } + // + // Update read offset of buffer + // + if (NumBytesRead) { + pRing->RdOff = RdOff; + } + // + return NumBytesRead; +} + +/********************************************************************* +* +* SEGGER_RTT_ReadNoLock() +* +* Function description +* Reads characters from SEGGER real-time-terminal control block +* which have been previously stored by the host. +* Do not lock against interrupts and multiple access. +* +* Parameters +* BufferIndex Index of Down-buffer to be used (e.g. 0 for "Terminal"). +* pBuffer Pointer to buffer provided by target application, to copy characters from RTT-down-buffer to. +* BufferSize Size of the target application buffer. +* +* Return value +* Number of bytes that have been read. +*/ +unsigned SEGGER_RTT_ReadNoLock(unsigned BufferIndex, void* pData, unsigned BufferSize) { + unsigned NumBytesRem; + unsigned NumBytesRead; + unsigned RdOff; + unsigned WrOff; + unsigned char* pBuffer; + SEGGER_RTT_BUFFER_DOWN* pRing; +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + const char* pSrc; +#endif + // + INIT(); + pRing = &_SEGGER_RTT.aDown[BufferIndex]; + pBuffer = (unsigned char*)pData; + RdOff = pRing->RdOff; + WrOff = pRing->WrOff; + NumBytesRead = 0u; + // + // Read from current read position to wrap-around of buffer, first + // + if (RdOff > WrOff) { + NumBytesRem = pRing->SizeOfBuffer - RdOff; + NumBytesRem = MIN(NumBytesRem, BufferSize); +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + pSrc = pRing->pBuffer + RdOff; + NumBytesRead += NumBytesRem; + BufferSize -= NumBytesRem; + RdOff += NumBytesRem; + while (NumBytesRem--) { + *pBuffer++ = *pSrc++; + }; +#else + SEGGER_RTT_MEMCPY(pBuffer, pRing->pBuffer + RdOff, NumBytesRem); + NumBytesRead += NumBytesRem; + pBuffer += NumBytesRem; + BufferSize -= NumBytesRem; + RdOff += NumBytesRem; +#endif + // + // Handle wrap-around of buffer + // + if (RdOff == pRing->SizeOfBuffer) { + RdOff = 0u; + } + } + // + // Read remaining items of buffer + // + NumBytesRem = WrOff - RdOff; + NumBytesRem = MIN(NumBytesRem, BufferSize); + if (NumBytesRem > 0u) { +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + pSrc = pRing->pBuffer + RdOff; + NumBytesRead += NumBytesRem; + BufferSize -= NumBytesRem; + RdOff += NumBytesRem; + while (NumBytesRem--) { + *pBuffer++ = *pSrc++; + }; +#else + SEGGER_RTT_MEMCPY(pBuffer, pRing->pBuffer + RdOff, NumBytesRem); + NumBytesRead += NumBytesRem; + pBuffer += NumBytesRem; + BufferSize -= NumBytesRem; + RdOff += NumBytesRem; +#endif + } + if (NumBytesRead) { + pRing->RdOff = RdOff; + } + // + return NumBytesRead; +} + +/********************************************************************* +* +* SEGGER_RTT_ReadUpBuffer +* +* Function description +* Reads characters from SEGGER real-time-terminal control block +* which have been previously stored by the application. +* Used to do the same operation that J-Link does, to transfer +* RTT data via other channels, such as TCP/IP or UART. +* +* Parameters +* BufferIndex Index of Up-buffer to be used. +* pBuffer Pointer to buffer provided by target application, to copy characters from RTT-up-buffer to. +* BufferSize Size of the target application buffer. +* +* Return value +* Number of bytes that have been read. +* +* Additional information +* This function must not be called when J-Link might also do RTT. +* This function locks against all other RTT operations. I.e. during +* the read operation, writing is also locked. +* If only one consumer reads from the up buffer, +* call sEGGER_RTT_ReadUpBufferNoLock() instead. +*/ +unsigned SEGGER_RTT_ReadUpBuffer(unsigned BufferIndex, void* pBuffer, unsigned BufferSize) { + unsigned NumBytesRead; + // + SEGGER_RTT_LOCK(); + // + // Call the non-locking read function + // + NumBytesRead = SEGGER_RTT_ReadUpBufferNoLock(BufferIndex, pBuffer, BufferSize); + // + // Finish up. + // + SEGGER_RTT_UNLOCK(); + // + return NumBytesRead; +} + +/********************************************************************* +* +* SEGGER_RTT_Read +* +* Function description +* Reads characters from SEGGER real-time-terminal control block +* which have been previously stored by the host. +* +* Parameters +* BufferIndex Index of Down-buffer to be used (e.g. 0 for "Terminal"). +* pBuffer Pointer to buffer provided by target application, to copy characters from RTT-down-buffer to. +* BufferSize Size of the target application buffer. +* +* Return value +* Number of bytes that have been read. +*/ +unsigned SEGGER_RTT_Read(unsigned BufferIndex, void* pBuffer, unsigned BufferSize) { + unsigned NumBytesRead; + // + SEGGER_RTT_LOCK(); + // + // Call the non-locking read function + // + NumBytesRead = SEGGER_RTT_ReadNoLock(BufferIndex, pBuffer, BufferSize); + // + // Finish up. + // + SEGGER_RTT_UNLOCK(); + // + return NumBytesRead; +} + +/********************************************************************* +* +* SEGGER_RTT_WriteWithOverwriteNoLock +* +* Function description +* Stores a specified number of characters in SEGGER RTT +* control block. +* SEGGER_RTT_WriteWithOverwriteNoLock does not lock the application +* and overwrites data if the data does not fit into the buffer. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). +* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. +* NumBytes Number of bytes to be stored in the SEGGER RTT control block. +* +* Notes +* (1) If there is not enough space in the "Up"-buffer, data is overwritten. +* (2) For performance reasons this function does not call Init() +* and may only be called after RTT has been initialized. +* Either by calling SEGGER_RTT_Init() or calling another RTT API function first. +* (3) Do not use SEGGER_RTT_WriteWithOverwriteNoLock if a J-Link +* connection reads RTT data. +*/ +void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) { + const char* pData; + SEGGER_RTT_BUFFER_UP* pRing; + unsigned Avail; +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + char* pDst; +#endif + + pData = (const char *)pBuffer; + // + // Get "to-host" ring buffer and copy some elements into local variables. + // + pRing = &_SEGGER_RTT.aUp[BufferIndex]; + // + // Check if we will overwrite data and need to adjust the RdOff. + // + if (pRing->WrOff == pRing->RdOff) { + Avail = pRing->SizeOfBuffer - 1u; + } else if ( pRing->WrOff < pRing->RdOff) { + Avail = pRing->RdOff - pRing->WrOff - 1u; + } else { + Avail = pRing->RdOff - pRing->WrOff - 1u + pRing->SizeOfBuffer; + } + if (NumBytes > Avail) { + pRing->RdOff += (NumBytes - Avail); + while (pRing->RdOff >= pRing->SizeOfBuffer) { + pRing->RdOff -= pRing->SizeOfBuffer; + } + } + // + // Write all data, no need to check the RdOff, but possibly handle multiple wrap-arounds + // + Avail = pRing->SizeOfBuffer - pRing->WrOff; + do { + if (Avail > NumBytes) { + // + // Last round + // +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + pDst = pRing->pBuffer + pRing->WrOff; + Avail = NumBytes; + while (NumBytes--) { + *pDst++ = *pData++; + }; + RTT__DMB(); + pRing->WrOff += Avail; +#else + SEGGER_RTT_MEMCPY(pRing->pBuffer + pRing->WrOff, pData, NumBytes); + RTT__DMB(); + pRing->WrOff += NumBytes; +#endif + break; + } else { + // + // Wrap-around necessary, write until wrap-around and reset WrOff + // +#if SEGGER_RTT_MEMCPY_USE_BYTELOOP + pDst = pRing->pBuffer + pRing->WrOff; + NumBytes -= Avail; + while (Avail--) { + *pDst++ = *pData++; + }; + RTT__DMB(); + pRing->WrOff = 0; +#else + SEGGER_RTT_MEMCPY(pRing->pBuffer + pRing->WrOff, pData, Avail); + pData += Avail; + RTT__DMB(); + pRing->WrOff = 0; + NumBytes -= Avail; +#endif + Avail = (pRing->SizeOfBuffer - 1); + } + } while (NumBytes); +} + +/********************************************************************* +* +* SEGGER_RTT_WriteSkipNoLock +* +* Function description +* Stores a specified number of characters in SEGGER RTT +* control block which is then read by the host. +* SEGGER_RTT_WriteSkipNoLock does not lock the application and +* skips all data, if the data does not fit into the buffer. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). +* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. +* NumBytes Number of bytes to be stored in the SEGGER RTT control block. +* MUST be > 0!!! +* This is done for performance reasons, so no initial check has do be done. +* +* Return value +* 1: Data has been copied +* 0: No space, data has not been copied +* +* Notes +* (1) If there is not enough space in the "Up"-buffer, all data is dropped. +* (2) For performance reasons this function does not call Init() +* and may only be called after RTT has been initialized. +* Either by calling SEGGER_RTT_Init() or calling another RTT API function first. +*/ +#if (RTT_USE_ASM == 0) +unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) { + const char* pData; + SEGGER_RTT_BUFFER_UP* pRing; + unsigned Avail; + unsigned RdOff; + unsigned WrOff; + unsigned Rem; + // + // Cases: + // 1) RdOff <= WrOff => Space until wrap-around is sufficient + // 2) RdOff <= WrOff => Space after wrap-around needed (copy in 2 chunks) + // 3) RdOff < WrOff => No space in buf + // 4) RdOff > WrOff => Space is sufficient + // 5) RdOff > WrOff => No space in buf + // + // 1) is the most common case for large buffers and assuming that J-Link reads the data fast enough + // + pData = (const char *)pBuffer; + pRing = &_SEGGER_RTT.aUp[BufferIndex]; + RdOff = pRing->RdOff; + WrOff = pRing->WrOff; + if (RdOff <= WrOff) { // Case 1), 2) or 3) + Avail = pRing->SizeOfBuffer - WrOff - 1u; // Space until wrap-around (assume 1 byte not usable for case that RdOff == 0) + if (Avail >= NumBytes) { // Case 1)? +CopyStraight: + memcpy(pRing->pBuffer + WrOff, pData, NumBytes); + RTT__DMB(); + pRing->WrOff = WrOff + NumBytes; + return 1; + } + Avail += RdOff; // Space incl. wrap-around + if (Avail >= NumBytes) { // Case 2? => If not, we have case 3) (does not fit) + Rem = pRing->SizeOfBuffer - WrOff; // Space until end of buffer + memcpy(pRing->pBuffer + WrOff, pData, Rem); // Copy 1st chunk + NumBytes -= Rem; + // + // Special case: First check that assumed RdOff == 0 calculated that last element before wrap-around could not be used + // But 2nd check (considering space until wrap-around and until RdOff) revealed that RdOff is not 0, so we can use the last element + // In this case, we may use a copy straight until buffer end anyway without needing to copy 2 chunks + // Therefore, check if 2nd memcpy is necessary at all + // + if (NumBytes) { + memcpy(pRing->pBuffer, pData + Rem, NumBytes); + } + RTT__DMB(); + pRing->WrOff = NumBytes; + return 1; + } + } else { // Potential case 4) + Avail = RdOff - WrOff - 1u; + if (Avail >= NumBytes) { // Case 4)? => If not, we have case 5) (does not fit) + goto CopyStraight; + } + } + return 0; // No space in buffer +} +#endif + +/********************************************************************* +* +* SEGGER_RTT_WriteDownBufferNoLock +* +* Function description +* Stores a specified number of characters in SEGGER RTT +* control block inside a buffer. +* SEGGER_RTT_WriteDownBufferNoLock does not lock the application. +* Used to do the same operation that J-Link does, to transfer +* RTT data from other channels, such as TCP/IP or UART. +* +* Parameters +* BufferIndex Index of "Down"-buffer to be used. +* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. +* NumBytes Number of bytes to be stored in the SEGGER RTT control block. +* +* Return value +* Number of bytes which have been stored in the "Down"-buffer. +* +* Notes +* (1) Data is stored according to buffer flags. +* (2) For performance reasons this function does not call Init() +* and may only be called after RTT has been initialized. +* Either by calling SEGGER_RTT_Init() or calling another RTT API function first. +* +* Additional information +* This function must not be called when J-Link might also do RTT. +*/ +unsigned SEGGER_RTT_WriteDownBufferNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) { + unsigned Status; + unsigned Avail; + const char* pData; + SEGGER_RTT_BUFFER_UP* pRing; + + pData = (const char *)pBuffer; + // + // Get "to-target" ring buffer. + // It is save to cast that to a "to-host" buffer. Up and Down buffer differ in volatility of offsets that might be modified by J-Link. + // + pRing = (SEGGER_RTT_BUFFER_UP*)&_SEGGER_RTT.aDown[BufferIndex]; + // + // How we output depends upon the mode... + // + switch (pRing->Flags) { + case SEGGER_RTT_MODE_NO_BLOCK_SKIP: + // + // If we are in skip mode and there is no space for the whole + // of this output, don't bother. + // + Avail = _GetAvailWriteSpace(pRing); + if (Avail < NumBytes) { + Status = 0u; + } else { + Status = NumBytes; + _WriteNoCheck(pRing, pData, NumBytes); + } + break; + case SEGGER_RTT_MODE_NO_BLOCK_TRIM: + // + // If we are in trim mode, trim to what we can output without blocking. + // + Avail = _GetAvailWriteSpace(pRing); + Status = Avail < NumBytes ? Avail : NumBytes; + _WriteNoCheck(pRing, pData, Status); + break; + case SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL: + // + // If we are in blocking mode, output everything. + // + Status = _WriteBlocking(pRing, pData, NumBytes); + break; + default: + Status = 0u; + break; + } + // + // Finish up. + // + return Status; +} + +/********************************************************************* +* +* SEGGER_RTT_WriteNoLock +* +* Function description +* Stores a specified number of characters in SEGGER RTT +* control block which is then read by the host. +* SEGGER_RTT_WriteNoLock does not lock the application. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). +* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. +* NumBytes Number of bytes to be stored in the SEGGER RTT control block. +* +* Return value +* Number of bytes which have been stored in the "Up"-buffer. +* +* Notes +* (1) Data is stored according to buffer flags. +* (2) For performance reasons this function does not call Init() +* and may only be called after RTT has been initialized. +* Either by calling SEGGER_RTT_Init() or calling another RTT API function first. +*/ +unsigned SEGGER_RTT_WriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) { + unsigned Status; + unsigned Avail; + const char* pData; + SEGGER_RTT_BUFFER_UP* pRing; + + pData = (const char *)pBuffer; + // + // Get "to-host" ring buffer. + // + pRing = &_SEGGER_RTT.aUp[BufferIndex]; + // + // How we output depends upon the mode... + // + switch (pRing->Flags) { + case SEGGER_RTT_MODE_NO_BLOCK_SKIP: + // + // If we are in skip mode and there is no space for the whole + // of this output, don't bother. + // + Avail = _GetAvailWriteSpace(pRing); + if (Avail < NumBytes) { + Status = 0u; + } else { + Status = NumBytes; + _WriteNoCheck(pRing, pData, NumBytes); + } + break; + case SEGGER_RTT_MODE_NO_BLOCK_TRIM: + // + // If we are in trim mode, trim to what we can output without blocking. + // + Avail = _GetAvailWriteSpace(pRing); + Status = Avail < NumBytes ? Avail : NumBytes; + _WriteNoCheck(pRing, pData, Status); + break; + case SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL: + // + // If we are in blocking mode, output everything. + // + Status = _WriteBlocking(pRing, pData, NumBytes); + break; + default: + Status = 0u; + break; + } + // + // Finish up. + // + return Status; +} + +/********************************************************************* +* +* SEGGER_RTT_WriteDownBuffer +* +* Function description +* Stores a specified number of characters in SEGGER RTT control block in a buffer. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). +* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. +* NumBytes Number of bytes to be stored in the SEGGER RTT control block. +* +* Return value +* Number of bytes which have been stored in the "Down"-buffer. +* +* Notes +* (1) Data is stored according to buffer flags. +* +* Additional information +* This function must not be called when J-Link might also do RTT. +* This function locks against all other RTT operations. I.e. during +* the write operation, writing from the application is also locked. +* If only one consumer writes to the down buffer, +* call SEGGER_RTT_WriteDownBufferNoLock() instead. +*/ +unsigned SEGGER_RTT_WriteDownBuffer(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) { + unsigned Status; + // + INIT(); + SEGGER_RTT_LOCK(); + // + // Call the non-locking write function + // + Status = SEGGER_RTT_WriteDownBufferNoLock(BufferIndex, pBuffer, NumBytes); + // + // Finish up. + // + SEGGER_RTT_UNLOCK(); + // + return Status; +} + +/********************************************************************* +* +* SEGGER_RTT_Write +* +* Function description +* Stores a specified number of characters in SEGGER RTT +* control block which is then read by the host. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). +* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. +* NumBytes Number of bytes to be stored in the SEGGER RTT control block. +* +* Return value +* Number of bytes which have been stored in the "Up"-buffer. +* +* Notes +* (1) Data is stored according to buffer flags. +*/ +unsigned SEGGER_RTT_Write(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes) { + unsigned Status; + // + INIT(); + SEGGER_RTT_LOCK(); + // + // Call the non-locking write function + // + Status = SEGGER_RTT_WriteNoLock(BufferIndex, pBuffer, NumBytes); + // + // Finish up. + // + SEGGER_RTT_UNLOCK(); + // + return Status; +} + +/********************************************************************* +* +* SEGGER_RTT_WriteString +* +* Function description +* Stores string in SEGGER RTT control block. +* This data is read by the host. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). +* s Pointer to string. +* +* Return value +* Number of bytes which have been stored in the "Up"-buffer. +* +* Notes +* (1) Data is stored according to buffer flags. +* (2) String passed to this function has to be \0 terminated +* (3) \0 termination character is *not* stored in RTT buffer +*/ +unsigned SEGGER_RTT_WriteString(unsigned BufferIndex, const char* s) { + unsigned Len; + + Len = STRLEN(s); + return SEGGER_RTT_Write(BufferIndex, s, Len); +} + +/********************************************************************* +* +* SEGGER_RTT_PutCharSkipNoLock +* +* Function description +* Stores a single character/byte in SEGGER RTT buffer. +* SEGGER_RTT_PutCharSkipNoLock does not lock the application and +* skips the byte, if it does not fit into the buffer. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). +* c Byte to be stored. +* +* Return value +* Number of bytes which have been stored in the "Up"-buffer. +* +* Notes +* (1) If there is not enough space in the "Up"-buffer, the character is dropped. +* (2) For performance reasons this function does not call Init() +* and may only be called after RTT has been initialized. +* Either by calling SEGGER_RTT_Init() or calling another RTT API function first. +*/ + +unsigned SEGGER_RTT_PutCharSkipNoLock(unsigned BufferIndex, char c) { + SEGGER_RTT_BUFFER_UP* pRing; + unsigned WrOff; + unsigned Status; + // + // Get "to-host" ring buffer. + // + pRing = &_SEGGER_RTT.aUp[BufferIndex]; + // + // Get write position and handle wrap-around if necessary + // + WrOff = pRing->WrOff + 1; + if (WrOff == pRing->SizeOfBuffer) { + WrOff = 0; + } + // + // Output byte if free space is available + // + if (WrOff != pRing->RdOff) { + pRing->pBuffer[pRing->WrOff] = c; + RTT__DMB(); + pRing->WrOff = WrOff; + Status = 1; + } else { + Status = 0; + } + // + return Status; +} + +/********************************************************************* +* +* SEGGER_RTT_PutCharSkip +* +* Function description +* Stores a single character/byte in SEGGER RTT buffer. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). +* c Byte to be stored. +* +* Return value +* Number of bytes which have been stored in the "Up"-buffer. +* +* Notes +* (1) If there is not enough space in the "Up"-buffer, the character is dropped. +*/ + +unsigned SEGGER_RTT_PutCharSkip(unsigned BufferIndex, char c) { + SEGGER_RTT_BUFFER_UP* pRing; + unsigned WrOff; + unsigned Status; + // + // Prepare + // + INIT(); + SEGGER_RTT_LOCK(); + // + // Get "to-host" ring buffer. + // + pRing = &_SEGGER_RTT.aUp[BufferIndex]; + // + // Get write position and handle wrap-around if necessary + // + WrOff = pRing->WrOff + 1; + if (WrOff == pRing->SizeOfBuffer) { + WrOff = 0; + } + // + // Output byte if free space is available + // + if (WrOff != pRing->RdOff) { + pRing->pBuffer[pRing->WrOff] = c; + RTT__DMB(); + pRing->WrOff = WrOff; + Status = 1; + } else { + Status = 0; + } + // + // Finish up. + // + SEGGER_RTT_UNLOCK(); + // + return Status; +} + + /********************************************************************* +* +* SEGGER_RTT_PutChar +* +* Function description +* Stores a single character/byte in SEGGER RTT buffer. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). +* c Byte to be stored. +* +* Return value +* Number of bytes which have been stored in the "Up"-buffer. +* +* Notes +* (1) Data is stored according to buffer flags. +*/ + +unsigned SEGGER_RTT_PutChar(unsigned BufferIndex, char c) { + SEGGER_RTT_BUFFER_UP* pRing; + unsigned WrOff; + unsigned Status; + // + // Prepare + // + INIT(); + SEGGER_RTT_LOCK(); + // + // Get "to-host" ring buffer. + // + pRing = &_SEGGER_RTT.aUp[BufferIndex]; + // + // Get write position and handle wrap-around if necessary + // + WrOff = pRing->WrOff + 1; + if (WrOff == pRing->SizeOfBuffer) { + WrOff = 0; + } + // + // Wait for free space if mode is set to blocking + // + if (pRing->Flags == SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL) { + while (WrOff == pRing->RdOff) { + ; + } + } + // + // Output byte if free space is available + // + if (WrOff != pRing->RdOff) { + pRing->pBuffer[pRing->WrOff] = c; + RTT__DMB(); + pRing->WrOff = WrOff; + Status = 1; + } else { + Status = 0; + } + // + // Finish up. + // + SEGGER_RTT_UNLOCK(); + // + return Status; +} + +/********************************************************************* +* +* SEGGER_RTT_GetKey +* +* Function description +* Reads one character from the SEGGER RTT buffer. +* Host has previously stored data there. +* +* Return value +* < 0 - No character available (buffer empty). +* >= 0 - Character which has been read. (Possible values: 0 - 255) +* +* Notes +* (1) This function is only specified for accesses to RTT buffer 0. +*/ +int SEGGER_RTT_GetKey(void) { + char c; + int r; + + r = (int)SEGGER_RTT_Read(0u, &c, 1u); + if (r == 1) { + r = (int)(unsigned char)c; + } else { + r = -1; + } + return r; +} + +/********************************************************************* +* +* SEGGER_RTT_WaitKey +* +* Function description +* Waits until at least one character is avaible in the SEGGER RTT buffer. +* Once a character is available, it is read and this function returns. +* +* Return value +* >=0 - Character which has been read. +* +* Notes +* (1) This function is only specified for accesses to RTT buffer 0 +* (2) This function is blocking if no character is present in RTT buffer +*/ +int SEGGER_RTT_WaitKey(void) { + int r; + + do { + r = SEGGER_RTT_GetKey(); + } while (r < 0); + return r; +} + +/********************************************************************* +* +* SEGGER_RTT_HasKey +* +* Function description +* Checks if at least one character for reading is available in the SEGGER RTT buffer. +* +* Return value +* == 0 - No characters are available to read. +* == 1 - At least one character is available. +* +* Notes +* (1) This function is only specified for accesses to RTT buffer 0 +*/ +int SEGGER_RTT_HasKey(void) { + unsigned RdOff; + int r; + + INIT(); + RdOff = _SEGGER_RTT.aDown[0].RdOff; + if (RdOff != _SEGGER_RTT.aDown[0].WrOff) { + r = 1; + } else { + r = 0; + } + return r; +} + +/********************************************************************* +* +* SEGGER_RTT_HasData +* +* Function description +* Check if there is data from the host in the given buffer. +* +* Return value: +* ==0: No data +* !=0: Data in buffer +* +*/ +unsigned SEGGER_RTT_HasData(unsigned BufferIndex) { + SEGGER_RTT_BUFFER_DOWN* pRing; + unsigned v; + + pRing = &_SEGGER_RTT.aDown[BufferIndex]; + v = pRing->WrOff; + return v - pRing->RdOff; +} + +/********************************************************************* +* +* SEGGER_RTT_HasDataUp +* +* Function description +* Check if there is data remaining to be sent in the given buffer. +* +* Return value: +* ==0: No data +* !=0: Data in buffer +* +*/ +unsigned SEGGER_RTT_HasDataUp(unsigned BufferIndex) { + SEGGER_RTT_BUFFER_UP* pRing; + unsigned v; + + pRing = &_SEGGER_RTT.aUp[BufferIndex]; + v = pRing->RdOff; + return pRing->WrOff - v; +} + +/********************************************************************* +* +* SEGGER_RTT_AllocDownBuffer +* +* Function description +* Run-time configuration of the next down-buffer (H->T). +* The next buffer, which is not used yet is configured. +* This includes: Buffer address, size, name, flags, ... +* +* Parameters +* sName Pointer to a constant name string. +* pBuffer Pointer to a buffer to be used. +* BufferSize Size of the buffer. +* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message). +* +* Return value +* >= 0 - O.K. Buffer Index +* < 0 - Error +*/ +int SEGGER_RTT_AllocDownBuffer(const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) { + int BufferIndex; + + INIT(); + SEGGER_RTT_LOCK(); + BufferIndex = 0; + do { + if (_SEGGER_RTT.aDown[BufferIndex].pBuffer == NULL) { + break; + } + BufferIndex++; + } while (BufferIndex < _SEGGER_RTT.MaxNumDownBuffers); + if (BufferIndex < _SEGGER_RTT.MaxNumDownBuffers) { + _SEGGER_RTT.aDown[BufferIndex].sName = sName; + _SEGGER_RTT.aDown[BufferIndex].pBuffer = (char*)pBuffer; + _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer = BufferSize; + _SEGGER_RTT.aDown[BufferIndex].RdOff = 0u; + _SEGGER_RTT.aDown[BufferIndex].WrOff = 0u; + _SEGGER_RTT.aDown[BufferIndex].Flags = Flags; + RTT__DMB(); + } else { + BufferIndex = -1; + } + SEGGER_RTT_UNLOCK(); + return BufferIndex; +} + +/********************************************************************* +* +* SEGGER_RTT_AllocUpBuffer +* +* Function description +* Run-time configuration of the next up-buffer (T->H). +* The next buffer, which is not used yet is configured. +* This includes: Buffer address, size, name, flags, ... +* +* Parameters +* sName Pointer to a constant name string. +* pBuffer Pointer to a buffer to be used. +* BufferSize Size of the buffer. +* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message). +* +* Return value +* >= 0 - O.K. Buffer Index +* < 0 - Error +*/ +int SEGGER_RTT_AllocUpBuffer(const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) { + int BufferIndex; + + INIT(); + SEGGER_RTT_LOCK(); + BufferIndex = 0; + do { + if (_SEGGER_RTT.aUp[BufferIndex].pBuffer == NULL) { + break; + } + BufferIndex++; + } while (BufferIndex < _SEGGER_RTT.MaxNumUpBuffers); + if (BufferIndex < _SEGGER_RTT.MaxNumUpBuffers) { + _SEGGER_RTT.aUp[BufferIndex].sName = sName; + _SEGGER_RTT.aUp[BufferIndex].pBuffer = (char*)pBuffer; + _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer = BufferSize; + _SEGGER_RTT.aUp[BufferIndex].RdOff = 0u; + _SEGGER_RTT.aUp[BufferIndex].WrOff = 0u; + _SEGGER_RTT.aUp[BufferIndex].Flags = Flags; + RTT__DMB(); + } else { + BufferIndex = -1; + } + SEGGER_RTT_UNLOCK(); + return BufferIndex; +} + +/********************************************************************* +* +* SEGGER_RTT_ConfigUpBuffer +* +* Function description +* Run-time configuration of a specific up-buffer (T->H). +* Buffer to be configured is specified by index. +* This includes: Buffer address, size, name, flags, ... +* +* Parameters +* BufferIndex Index of the buffer to configure. +* sName Pointer to a constant name string. +* pBuffer Pointer to a buffer to be used. +* BufferSize Size of the buffer. +* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message). +* +* Return value +* >= 0 - O.K. +* < 0 - Error +* +* Additional information +* Buffer 0 is configured on compile-time. +* May only be called once per buffer. +* Buffer name and flags can be reconfigured using the appropriate functions. +*/ +int SEGGER_RTT_ConfigUpBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) { + int r; + + INIT(); + if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumUpBuffers) { + SEGGER_RTT_LOCK(); + if (BufferIndex > 0u) { + _SEGGER_RTT.aUp[BufferIndex].sName = sName; + _SEGGER_RTT.aUp[BufferIndex].pBuffer = (char*)pBuffer; + _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer = BufferSize; + _SEGGER_RTT.aUp[BufferIndex].RdOff = 0u; + _SEGGER_RTT.aUp[BufferIndex].WrOff = 0u; + } + _SEGGER_RTT.aUp[BufferIndex].Flags = Flags; + SEGGER_RTT_UNLOCK(); + r = 0; + } else { + r = -1; + } + return r; +} + +/********************************************************************* +* +* SEGGER_RTT_ConfigDownBuffer +* +* Function description +* Run-time configuration of a specific down-buffer (H->T). +* Buffer to be configured is specified by index. +* This includes: Buffer address, size, name, flags, ... +* +* Parameters +* BufferIndex Index of the buffer to configure. +* sName Pointer to a constant name string. +* pBuffer Pointer to a buffer to be used. +* BufferSize Size of the buffer. +* Flags Operating modes. Define behavior if buffer is full (not enough space for entire message). +* +* Return value +* >= 0 O.K. +* < 0 Error +* +* Additional information +* Buffer 0 is configured on compile-time. +* May only be called once per buffer. +* Buffer name and flags can be reconfigured using the appropriate functions. +*/ +int SEGGER_RTT_ConfigDownBuffer(unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags) { + int r; + + INIT(); + if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumDownBuffers) { + SEGGER_RTT_LOCK(); + if (BufferIndex > 0u) { + _SEGGER_RTT.aDown[BufferIndex].sName = sName; + _SEGGER_RTT.aDown[BufferIndex].pBuffer = (char*)pBuffer; + _SEGGER_RTT.aDown[BufferIndex].SizeOfBuffer = BufferSize; + _SEGGER_RTT.aDown[BufferIndex].RdOff = 0u; + _SEGGER_RTT.aDown[BufferIndex].WrOff = 0u; + } + _SEGGER_RTT.aDown[BufferIndex].Flags = Flags; + RTT__DMB(); + SEGGER_RTT_UNLOCK(); + r = 0; + } else { + r = -1; + } + return r; +} + +/********************************************************************* +* +* SEGGER_RTT_SetNameUpBuffer +* +* Function description +* Run-time configuration of a specific up-buffer name (T->H). +* Buffer to be configured is specified by index. +* +* Parameters +* BufferIndex Index of the buffer to renamed. +* sName Pointer to a constant name string. +* +* Return value +* >= 0 O.K. +* < 0 Error +*/ +int SEGGER_RTT_SetNameUpBuffer(unsigned BufferIndex, const char* sName) { + int r; + + INIT(); + if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumUpBuffers) { + SEGGER_RTT_LOCK(); + _SEGGER_RTT.aUp[BufferIndex].sName = sName; + SEGGER_RTT_UNLOCK(); + r = 0; + } else { + r = -1; + } + return r; +} + +/********************************************************************* +* +* SEGGER_RTT_SetNameDownBuffer +* +* Function description +* Run-time configuration of a specific Down-buffer name (T->H). +* Buffer to be configured is specified by index. +* +* Parameters +* BufferIndex Index of the buffer to renamed. +* sName Pointer to a constant name string. +* +* Return value +* >= 0 O.K. +* < 0 Error +*/ +int SEGGER_RTT_SetNameDownBuffer(unsigned BufferIndex, const char* sName) { + int r; + + INIT(); + if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumDownBuffers) { + SEGGER_RTT_LOCK(); + _SEGGER_RTT.aDown[BufferIndex].sName = sName; + SEGGER_RTT_UNLOCK(); + r = 0; + } else { + r = -1; + } + return r; +} + +/********************************************************************* +* +* SEGGER_RTT_SetFlagsUpBuffer +* +* Function description +* Run-time configuration of specific up-buffer flags (T->H). +* Buffer to be configured is specified by index. +* +* Parameters +* BufferIndex Index of the buffer. +* Flags Flags to set for the buffer. +* +* Return value +* >= 0 O.K. +* < 0 Error +*/ +int SEGGER_RTT_SetFlagsUpBuffer(unsigned BufferIndex, unsigned Flags) { + int r; + + INIT(); + if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumUpBuffers) { + SEGGER_RTT_LOCK(); + _SEGGER_RTT.aUp[BufferIndex].Flags = Flags; + SEGGER_RTT_UNLOCK(); + r = 0; + } else { + r = -1; + } + return r; +} + +/********************************************************************* +* +* SEGGER_RTT_SetFlagsDownBuffer +* +* Function description +* Run-time configuration of specific Down-buffer flags (T->H). +* Buffer to be configured is specified by index. +* +* Parameters +* BufferIndex Index of the buffer to renamed. +* Flags Flags to set for the buffer. +* +* Return value +* >= 0 O.K. +* < 0 Error +*/ +int SEGGER_RTT_SetFlagsDownBuffer(unsigned BufferIndex, unsigned Flags) { + int r; + + INIT(); + if (BufferIndex < (unsigned)_SEGGER_RTT.MaxNumDownBuffers) { + SEGGER_RTT_LOCK(); + _SEGGER_RTT.aDown[BufferIndex].Flags = Flags; + SEGGER_RTT_UNLOCK(); + r = 0; + } else { + r = -1; + } + return r; +} + +/********************************************************************* +* +* SEGGER_RTT_Init +* +* Function description +* Initializes the RTT Control Block. +* Should be used in RAM targets, at start of the application. +* +*/ +void SEGGER_RTT_Init (void) { + _DoInit(); +} + +/********************************************************************* +* +* SEGGER_RTT_SetTerminal +* +* Function description +* Sets the terminal to be used for output on channel 0. +* +* Parameters +* TerminalId Index of the terminal. +* +* Return value +* >= 0 O.K. +* < 0 Error (e.g. if RTT is configured for non-blocking mode and there was no space in the buffer to set the new terminal Id) +*/ +int SEGGER_RTT_SetTerminal (unsigned char TerminalId) { + unsigned char ac[2]; + SEGGER_RTT_BUFFER_UP* pRing; + unsigned Avail; + int r; + // + INIT(); + // + r = 0; + ac[0] = 0xFFu; + if (TerminalId < sizeof(_aTerminalId)) { // We only support a certain number of channels + ac[1] = _aTerminalId[TerminalId]; + pRing = &_SEGGER_RTT.aUp[0]; // Buffer 0 is always reserved for terminal I/O, so we can use index 0 here, fixed + SEGGER_RTT_LOCK(); // Lock to make sure that no other task is writing into buffer, while we are and number of free bytes in buffer does not change downwards after checking and before writing + if ((pRing->Flags & SEGGER_RTT_MODE_MASK) == SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL) { + _ActiveTerminal = TerminalId; + _WriteBlocking(pRing, (const char*)ac, 2u); + } else { // Skipping mode or trim mode? => We cannot trim this command so handling is the same for both modes + Avail = _GetAvailWriteSpace(pRing); + if (Avail >= 2) { + _ActiveTerminal = TerminalId; // Only change active terminal in case of success + _WriteNoCheck(pRing, (const char*)ac, 2u); + } else { + r = -1; + } + } + SEGGER_RTT_UNLOCK(); + } else { + r = -1; + } + return r; +} + +/********************************************************************* +* +* SEGGER_RTT_TerminalOut +* +* Function description +* Writes a string to the given terminal +* without changing the terminal for channel 0. +* +* Parameters +* TerminalId Index of the terminal. +* s String to be printed on the terminal. +* +* Return value +* >= 0 - Number of bytes written. +* < 0 - Error. +* +*/ +int SEGGER_RTT_TerminalOut (unsigned char TerminalId, const char* s) { + int Status; + unsigned FragLen; + unsigned Avail; + SEGGER_RTT_BUFFER_UP* pRing; + // + INIT(); + // + // Validate terminal ID. + // + if (TerminalId < (char)sizeof(_aTerminalId)) { // We only support a certain number of channels + // + // Get "to-host" ring buffer. + // + pRing = &_SEGGER_RTT.aUp[0]; + // + // Need to be able to change terminal, write data, change back. + // Compute the fixed and variable sizes. + // + FragLen = STRLEN(s); + // + // How we output depends upon the mode... + // + SEGGER_RTT_LOCK(); + Avail = _GetAvailWriteSpace(pRing); + switch (pRing->Flags & SEGGER_RTT_MODE_MASK) { + case SEGGER_RTT_MODE_NO_BLOCK_SKIP: + // + // If we are in skip mode and there is no space for the whole + // of this output, don't bother switching terminals at all. + // + if (Avail < (FragLen + 4u)) { + Status = 0; + } else { + _PostTerminalSwitch(pRing, TerminalId); + Status = (int)_WriteBlocking(pRing, s, FragLen); + _PostTerminalSwitch(pRing, _ActiveTerminal); + } + break; + case SEGGER_RTT_MODE_NO_BLOCK_TRIM: + // + // If we are in trim mode and there is not enough space for everything, + // trim the output but always include the terminal switch. If no room + // for terminal switch, skip that totally. + // + if (Avail < 4u) { + Status = -1; + } else { + _PostTerminalSwitch(pRing, TerminalId); + Status = (int)_WriteBlocking(pRing, s, (FragLen < (Avail - 4u)) ? FragLen : (Avail - 4u)); + _PostTerminalSwitch(pRing, _ActiveTerminal); + } + break; + case SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL: + // + // If we are in blocking mode, output everything. + // + _PostTerminalSwitch(pRing, TerminalId); + Status = (int)_WriteBlocking(pRing, s, FragLen); + _PostTerminalSwitch(pRing, _ActiveTerminal); + break; + default: + Status = -1; + break; + } + // + // Finish up. + // + SEGGER_RTT_UNLOCK(); + } else { + Status = -1; + } + return Status; +} + +/********************************************************************* +* +* SEGGER_RTT_GetAvailWriteSpace +* +* Function description +* Returns the number of bytes available in the ring buffer. +* +* Parameters +* BufferIndex Index of the up buffer. +* +* Return value +* Number of bytes that are free in the selected up buffer. +*/ +unsigned SEGGER_RTT_GetAvailWriteSpace (unsigned BufferIndex){ + return _GetAvailWriteSpace(&_SEGGER_RTT.aUp[BufferIndex]); +} + + +/********************************************************************* +* +* SEGGER_RTT_GetBytesInBuffer() +* +* Function description +* Returns the number of bytes currently used in the up buffer. +* +* Parameters +* BufferIndex Index of the up buffer. +* +* Return value +* Number of bytes that are used in the buffer. +*/ +unsigned SEGGER_RTT_GetBytesInBuffer(unsigned BufferIndex) { + unsigned RdOff; + unsigned WrOff; + unsigned r; + // + // Avoid warnings regarding volatile access order. It's not a problem + // in this case, but dampen compiler enthusiasm. + // + RdOff = _SEGGER_RTT.aUp[BufferIndex].RdOff; + WrOff = _SEGGER_RTT.aUp[BufferIndex].WrOff; + if (RdOff <= WrOff) { + r = WrOff - RdOff; + } else { + r = _SEGGER_RTT.aUp[BufferIndex].SizeOfBuffer - (WrOff - RdOff); + } + return r; +} + +/*************************** End of file ****************************/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT.h new file mode 100644 index 00000000..c7b2c6a8 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT.h @@ -0,0 +1,377 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2019 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* condition is met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this condition and the following disclaimer. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.82 * +* * +********************************************************************** + +---------------------------END-OF-HEADER------------------------------ +File : SEGGER_RTT.h +Purpose : Implementation of SEGGER real-time transfer which allows + real-time communication on targets which support debugger + memory accesses while the CPU is running. +Revision: $Rev: 20159 $ +---------------------------------------------------------------------- +*/ + +#ifndef SEGGER_RTT_H +#define SEGGER_RTT_H + +#include "SEGGER_RTT_Conf.h" + + + +/********************************************************************* +* +* Defines, defaults +* +********************************************************************** +*/ +#ifndef RTT_USE_ASM + #if (defined __SES_ARM) // SEGGER Embedded Studio + #define _CC_HAS_RTT_ASM_SUPPORT 1 + #elif (defined __CROSSWORKS_ARM) // Rowley Crossworks + #define _CC_HAS_RTT_ASM_SUPPORT 1 + #elif (defined __ARMCC_VERSION) + #define _CC_HAS_RTT_ASM_SUPPORT 0 + #elif (defined __GNUC__) // GCC + #define _CC_HAS_RTT_ASM_SUPPORT 1 + #elif (defined __clang__) // Clang compiler + #define _CC_HAS_RTT_ASM_SUPPORT 1 + #elif ((defined __IASMARM__) || (defined __ICCARM__)) // IAR assembler/compiler + #define _CC_HAS_RTT_ASM_SUPPORT 1 + #else + #define _CC_HAS_RTT_ASM_SUPPORT 0 + #endif + #if ((defined __IASMARM__) || (defined __ICCARM__)) // IAR assembler/compiler + // + // IAR assembler / compiler + // + #if (defined __ARM7M__) // Needed for old versions that do not know the define yet + #if (__CORE__ == __ARM7M__) // Cortex-M3 + #define _CORE_HAS_RTT_ASM_SUPPORT 1 + #endif + #endif + #if (defined __ARM7EM__) // Needed for old versions that do not know the define yet + #if (__CORE__ == __ARM7EM__) // Cortex-M4/M7 + #define _CORE_HAS_RTT_ASM_SUPPORT 1 + #define _CORE_NEEDS_DMB 1 + #define RTT__DMB() asm("DMB"); + #endif + #endif + #if (defined __ARM8M_BASELINE__) // Needed for old versions that do not know the define yet + #if (__CORE__ == __ARM8M_BASELINE__) // Cortex-M23 + #define _CORE_HAS_RTT_ASM_SUPPORT 1 + #define _CORE_NEEDS_DMB 1 + #define RTT__DMB() asm("DMB"); + #endif + #endif + #if (defined __ARM8M_MAINLINE__) // Needed for old versions that do not know the define yet + #if (__CORE__ == __ARM8M_MAINLINE__) // Cortex-M33 + #define _CORE_HAS_RTT_ASM_SUPPORT 1 + #define _CORE_NEEDS_DMB 1 + #define RTT__DMB() asm("DMB"); + #endif + #endif + #else + // + // GCC / Clang + // + #if (defined __ARM_ARCH_7M__) // Cortex-M3 + #define _CORE_HAS_RTT_ASM_SUPPORT 1 + #elif (defined __ARM_ARCH_7EM__) // Cortex-M4/M7 + #define _CORE_HAS_RTT_ASM_SUPPORT 1 + #define _CORE_NEEDS_DMB 1 + #define RTT__DMB() __asm volatile ("dmb\n" : : :); + #elif (defined __ARM_ARCH_8M_BASE__) // Cortex-M23 + #define _CORE_HAS_RTT_ASM_SUPPORT 1 + #define _CORE_NEEDS_DMB 1 + #define RTT__DMB() __asm volatile ("dmb\n" : : :); + #elif (defined __ARM_ARCH_8M_MAIN__) // Cortex-M33 + #define _CORE_HAS_RTT_ASM_SUPPORT 1 + #define _CORE_NEEDS_DMB 1 + #define RTT__DMB() __asm volatile ("dmb\n" : : :); + #else + #define _CORE_HAS_RTT_ASM_SUPPORT 0 + #endif + #endif + // + // If IDE and core support the ASM version, enable ASM version by default + // + #ifndef _CORE_HAS_RTT_ASM_SUPPORT + #define _CORE_HAS_RTT_ASM_SUPPORT 0 // Default for unknown cores + #endif + #if (_CC_HAS_RTT_ASM_SUPPORT && _CORE_HAS_RTT_ASM_SUPPORT) + #define RTT_USE_ASM (1) + #else + #define RTT_USE_ASM (0) + #endif +#endif + +// +// We need to know if a DMB is needed to make sure that on Cortex-M7 etc. +// the order of accesses to the ring buffers is guaranteed +// Needed for: Cortex-M7, Cortex-M23, Cortex-M33 +// +#ifndef _CORE_NEEDS_DMB + #define _CORE_NEEDS_DMB 0 +#endif + +#ifndef RTT__DMB + #if _CORE_NEEDS_DMB + #error "Don't know how to place inline assembly for DMB" + #else + #define RTT__DMB() + #endif +#endif + +#ifndef SEGGER_RTT_ASM // defined when SEGGER_RTT.h is included from assembly file +#include +#include + +/********************************************************************* +* +* Defines, fixed +* +********************************************************************** +*/ + +/********************************************************************* +* +* Types +* +********************************************************************** +*/ + +// +// Description for a circular buffer (also called "ring buffer") +// which is used as up-buffer (T->H) +// +typedef struct { + const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4" + char* pBuffer; // Pointer to start of buffer + unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty. + unsigned WrOff; // Position of next item to be written by either target. + volatile unsigned RdOff; // Position of next item to be read by host. Must be volatile since it may be modified by host. + unsigned Flags; // Contains configuration flags +} SEGGER_RTT_BUFFER_UP; + +// +// Description for a circular buffer (also called "ring buffer") +// which is used as down-buffer (H->T) +// +typedef struct { + const char* sName; // Optional name. Standard names so far are: "Terminal", "SysView", "J-Scope_t4i4" + char* pBuffer; // Pointer to start of buffer + unsigned SizeOfBuffer; // Buffer size in bytes. Note that one byte is lost, as this implementation does not fill up the buffer in order to avoid the problem of being unable to distinguish between full and empty. + volatile unsigned WrOff; // Position of next item to be written by host. Must be volatile since it may be modified by host. + unsigned RdOff; // Position of next item to be read by target (down-buffer). + unsigned Flags; // Contains configuration flags +} SEGGER_RTT_BUFFER_DOWN; + +// +// RTT control block which describes the number of buffers available +// as well as the configuration for each buffer +// +// +typedef struct { + char acID[16]; // Initialized to "SEGGER RTT" + int MaxNumUpBuffers; // Initialized to SEGGER_RTT_MAX_NUM_UP_BUFFERS (type. 2) + int MaxNumDownBuffers; // Initialized to SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (type. 2) + SEGGER_RTT_BUFFER_UP aUp[SEGGER_RTT_MAX_NUM_UP_BUFFERS]; // Up buffers, transferring information up from target via debug probe to host + SEGGER_RTT_BUFFER_DOWN aDown[SEGGER_RTT_MAX_NUM_DOWN_BUFFERS]; // Down buffers, transferring information down from host via debug probe to target +} SEGGER_RTT_CB; + +/********************************************************************* +* +* Global data +* +********************************************************************** +*/ +extern SEGGER_RTT_CB _SEGGER_RTT; + +/********************************************************************* +* +* RTT API functions +* +********************************************************************** +*/ +#ifdef __cplusplus + extern "C" { +#endif +int SEGGER_RTT_AllocDownBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); +int SEGGER_RTT_AllocUpBuffer (const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); +int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); +int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName, void* pBuffer, unsigned BufferSize, unsigned Flags); +int SEGGER_RTT_GetKey (void); +unsigned SEGGER_RTT_HasData (unsigned BufferIndex); +int SEGGER_RTT_HasKey (void); +unsigned SEGGER_RTT_HasDataUp (unsigned BufferIndex); +void SEGGER_RTT_Init (void); +unsigned SEGGER_RTT_Read (unsigned BufferIndex, void* pBuffer, unsigned BufferSize); +unsigned SEGGER_RTT_ReadNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize); +int SEGGER_RTT_SetNameDownBuffer (unsigned BufferIndex, const char* sName); +int SEGGER_RTT_SetNameUpBuffer (unsigned BufferIndex, const char* sName); +int SEGGER_RTT_SetFlagsDownBuffer (unsigned BufferIndex, unsigned Flags); +int SEGGER_RTT_SetFlagsUpBuffer (unsigned BufferIndex, unsigned Flags); +int SEGGER_RTT_WaitKey (void); +unsigned SEGGER_RTT_Write (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); +unsigned SEGGER_RTT_WriteNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); +unsigned SEGGER_RTT_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); +unsigned SEGGER_RTT_ASM_WriteSkipNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); +unsigned SEGGER_RTT_WriteString (unsigned BufferIndex, const char* s); +void SEGGER_RTT_WriteWithOverwriteNoLock(unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); +unsigned SEGGER_RTT_PutChar (unsigned BufferIndex, char c); +unsigned SEGGER_RTT_PutCharSkip (unsigned BufferIndex, char c); +unsigned SEGGER_RTT_PutCharSkipNoLock (unsigned BufferIndex, char c); +unsigned SEGGER_RTT_GetAvailWriteSpace (unsigned BufferIndex); +unsigned SEGGER_RTT_GetBytesInBuffer (unsigned BufferIndex); +// +// Function macro for performance optimization +// +#define SEGGER_RTT_HASDATA(n) (_SEGGER_RTT.aDown[n].WrOff - _SEGGER_RTT.aDown[n].RdOff) + +#if RTT_USE_ASM + #define SEGGER_RTT_WriteSkipNoLock SEGGER_RTT_ASM_WriteSkipNoLock +#endif + +/********************************************************************* +* +* RTT transfer functions to send RTT data via other channels. +* +********************************************************************** +*/ +unsigned SEGGER_RTT_ReadUpBuffer (unsigned BufferIndex, void* pBuffer, unsigned BufferSize); +unsigned SEGGER_RTT_ReadUpBufferNoLock (unsigned BufferIndex, void* pData, unsigned BufferSize); +unsigned SEGGER_RTT_WriteDownBuffer (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); +unsigned SEGGER_RTT_WriteDownBufferNoLock (unsigned BufferIndex, const void* pBuffer, unsigned NumBytes); + +#define SEGGER_RTT_HASDATA_UP(n) (_SEGGER_RTT.aUp[n].WrOff - _SEGGER_RTT.aUp[n].RdOff) + +/********************************************************************* +* +* RTT "Terminal" API functions +* +********************************************************************** +*/ +int SEGGER_RTT_SetTerminal (unsigned char TerminalId); +int SEGGER_RTT_TerminalOut (unsigned char TerminalId, const char* s); + +/********************************************************************* +* +* RTT printf functions (require SEGGER_RTT_printf.c) +* +********************************************************************** +*/ +int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...); +int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList); + +#ifdef __cplusplus + } +#endif + +#endif // ifndef(SEGGER_RTT_ASM) + +/********************************************************************* +* +* Defines +* +********************************************************************** +*/ + +// +// Operating modes. Define behavior if buffer is full (not enough space for entire message) +// +#define SEGGER_RTT_MODE_NO_BLOCK_SKIP (0) // Skip. Do not block, output nothing. (Default) +#define SEGGER_RTT_MODE_NO_BLOCK_TRIM (1) // Trim: Do not block, output as much as fits. +#define SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL (2) // Block: Wait until there is space in the buffer. +#define SEGGER_RTT_MODE_MASK (3) + +// +// Control sequences, based on ANSI. +// Can be used to control color, and clear the screen +// +#define RTT_CTRL_RESET "\x1B[0m" // Reset to default colors +#define RTT_CTRL_CLEAR "\x1B[2J" // Clear screen, reposition cursor to top left + +#define RTT_CTRL_TEXT_BLACK "\x1B[2;30m" +#define RTT_CTRL_TEXT_RED "\x1B[2;31m" +#define RTT_CTRL_TEXT_GREEN "\x1B[2;32m" +#define RTT_CTRL_TEXT_YELLOW "\x1B[2;33m" +#define RTT_CTRL_TEXT_BLUE "\x1B[2;34m" +#define RTT_CTRL_TEXT_MAGENTA "\x1B[2;35m" +#define RTT_CTRL_TEXT_CYAN "\x1B[2;36m" +#define RTT_CTRL_TEXT_WHITE "\x1B[2;37m" + +#define RTT_CTRL_TEXT_BRIGHT_BLACK "\x1B[1;30m" +#define RTT_CTRL_TEXT_BRIGHT_RED "\x1B[1;31m" +#define RTT_CTRL_TEXT_BRIGHT_GREEN "\x1B[1;32m" +#define RTT_CTRL_TEXT_BRIGHT_YELLOW "\x1B[1;33m" +#define RTT_CTRL_TEXT_BRIGHT_BLUE "\x1B[1;34m" +#define RTT_CTRL_TEXT_BRIGHT_MAGENTA "\x1B[1;35m" +#define RTT_CTRL_TEXT_BRIGHT_CYAN "\x1B[1;36m" +#define RTT_CTRL_TEXT_BRIGHT_WHITE "\x1B[1;37m" + +#define RTT_CTRL_BG_BLACK "\x1B[24;40m" +#define RTT_CTRL_BG_RED "\x1B[24;41m" +#define RTT_CTRL_BG_GREEN "\x1B[24;42m" +#define RTT_CTRL_BG_YELLOW "\x1B[24;43m" +#define RTT_CTRL_BG_BLUE "\x1B[24;44m" +#define RTT_CTRL_BG_MAGENTA "\x1B[24;45m" +#define RTT_CTRL_BG_CYAN "\x1B[24;46m" +#define RTT_CTRL_BG_WHITE "\x1B[24;47m" + +#define RTT_CTRL_BG_BRIGHT_BLACK "\x1B[4;40m" +#define RTT_CTRL_BG_BRIGHT_RED "\x1B[4;41m" +#define RTT_CTRL_BG_BRIGHT_GREEN "\x1B[4;42m" +#define RTT_CTRL_BG_BRIGHT_YELLOW "\x1B[4;43m" +#define RTT_CTRL_BG_BRIGHT_BLUE "\x1B[4;44m" +#define RTT_CTRL_BG_BRIGHT_MAGENTA "\x1B[4;45m" +#define RTT_CTRL_BG_BRIGHT_CYAN "\x1B[4;46m" +#define RTT_CTRL_BG_BRIGHT_WHITE "\x1B[4;47m" + + +#endif + +/*************************** End of file ****************************/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_ASM_ARMv7M.S b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_ASM_ARMv7M.S new file mode 100644 index 00000000..3369132e --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_ASM_ARMv7M.S @@ -0,0 +1,241 @@ +/********************************************************************* +* (c) SEGGER Microcontroller GmbH * +* The Embedded Experts * +* www.segger.com * +********************************************************************** + +-------------------------- END-OF-HEADER ----------------------------- + +File : SEGGER_RTT_ASM_ARMv7M.S +Purpose : Assembler implementation of RTT functions for ARMv7M + +Additional information: + This module is written to be assembler-independent and works with + GCC and clang (Embedded Studio) and IAR. +*/ + +#define SEGGER_RTT_ASM // Used to control processed input from header file +#include "SEGGER_RTT.h" + +/********************************************************************* +* +* Defines, fixed +* +********************************************************************** +*/ +#define _CCIAR 0 +#define _CCCLANG 1 + +#if (defined __SES_ARM) || (defined __GNUC__) || (defined __clang__) + #define _CC_TYPE _CCCLANG + #define _PUB_SYM .global + #define _EXT_SYM .extern + #define _END .end + #define _WEAK .weak + #define _THUMB_FUNC .thumb_func + #define _THUMB_CODE .code 16 + #define _WORD .word + #define _SECTION(Sect, Type, AlignExp) .section Sect ##, "ax" + #define _ALIGN(Exp) .align Exp + #define _PLACE_LITS .ltorg + #define _DATA_SECT_START + #define _C_STARTUP _start + #define _STACK_END __stack_end__ + #define _RAMFUNC + // + // .text => Link to flash + // .fast => Link to RAM + // OtherSect => Usually link to RAM + // Alignment is 2^x + // +#elif defined (__IASMARM__) + #define _CC_TYPE _CCIAR + #define _PUB_SYM PUBLIC + #define _EXT_SYM EXTERN + #define _END END + #define _WEAK _WEAK + #define _THUMB_FUNC + #define _THUMB_CODE THUMB + #define _WORD DCD + #define _SECTION(Sect, Type, AlignExp) SECTION Sect ## : ## Type ## :REORDER:NOROOT ## (AlignExp) + #define _ALIGN(Exp) alignrom Exp + #define _PLACE_LITS + #define _DATA_SECT_START DATA + #define _C_STARTUP __iar_program_start + #define _STACK_END sfe(CSTACK) + #define _RAMFUNC SECTION_TYPE SHT_PROGBITS, SHF_WRITE | SHF_EXECINSTR + // + // .text => Link to flash + // .textrw => Link to RAM + // OtherSect => Usually link to RAM + // NOROOT => Allows linker to throw away the function, if not referenced + // Alignment is 2^x + // +#endif + +#if (_CC_TYPE == _CCIAR) + NAME SEGGER_RTT_ASM_ARMv7M +#else + .syntax unified +#endif + +#if defined (RTT_USE_ASM) && (RTT_USE_ASM == 1) + #define SHT_PROGBITS 0x1 + +/********************************************************************* +* +* Public / external symbols +* +********************************************************************** +*/ + + _EXT_SYM __aeabi_memcpy + _EXT_SYM __aeabi_memcpy4 + _EXT_SYM _SEGGER_RTT + + _PUB_SYM SEGGER_RTT_ASM_WriteSkipNoLock + +/********************************************************************* +* +* SEGGER_RTT_WriteSkipNoLock +* +* Function description +* Stores a specified number of characters in SEGGER RTT +* control block which is then read by the host. +* SEGGER_RTT_WriteSkipNoLock does not lock the application and +* skips all data, if the data does not fit into the buffer. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used (e.g. 0 for "Terminal"). +* pBuffer Pointer to character array. Does not need to point to a \0 terminated string. +* NumBytes Number of bytes to be stored in the SEGGER RTT control block. +* MUST be > 0!!! +* This is done for performance reasons, so no initial check has do be done. +* +* Return value +* 1: Data has been copied +* 0: No space, data has not been copied +* +* Notes +* (1) If there is not enough space in the "Up"-buffer, all data is dropped. +* (2) For performance reasons this function does not call Init() +* and may only be called after RTT has been initialized. +* Either by calling SEGGER_RTT_Init() or calling another RTT API function first. +*/ + _SECTION(.text, CODE, 2) + _ALIGN(2) + _THUMB_FUNC +SEGGER_RTT_ASM_WriteSkipNoLock: // unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pData, unsigned NumBytes) { + // + // Cases: + // 1) RdOff <= WrOff => Space until wrap-around is sufficient + // 2) RdOff <= WrOff => Space after wrap-around needed (copy in 2 chunks) + // 3) RdOff < WrOff => No space in buf + // 4) RdOff > WrOff => Space is sufficient + // 5) RdOff > WrOff => No space in buf + // + // 1) is the most common case for large buffers and assuming that J-Link reads the data fast enough + // + // Register usage: + // R0 Temporary needed as RdOff, register later on + // R1 pData + // R2 + // R3 register. Hold free for subroutine calls + // R4 + // R5 pRing->pBuffer + // R6 pRing (Points to active struct SEGGER_RTT_BUFFER_DOWN) + // R7 WrOff + // + PUSH {R4-R7} + ADD R3,R0,R0, LSL #+1 + LDR.W R0,=_SEGGER_RTT // pRing = &_SEGGER_RTT.aUp[BufferIndex]; + ADD R0,R0,R3, LSL #+3 + ADD R6,R0,#+24 + LDR R0,[R6, #+16] // RdOff = pRing->RdOff; + LDR R7,[R6, #+12] // WrOff = pRing->WrOff; + LDR R5,[R6, #+4] // pRing->pBuffer + CMP R7,R0 + BCC.N _CheckCase4 // if (RdOff <= WrOff) { => Case 1), 2) or 3) + // + // Handling for case 1, later on identical to case 4 + // + LDR R3,[R6, #+8] // Avail = pRing->SizeOfBuffer - WrOff - 1u; => Space until wrap-around (assume 1 byte not usable for case that RdOff == 0) + SUBS R4,R3,R7 // (Used in case we jump into case 2 afterwards) + SUBS R3,R4,#+1 // + CMP R3,R2 + BCC.N _CheckCase2 // if (Avail >= NumBytes) { => Case 1)? +_Case4: + ADDS R5,R7,R5 // pBuffer += WrOff + ADDS R0,R2,R7 // v = WrOff + NumBytes + // + // 2x unrolling for the copy loop that is used most of the time + // This is a special optimization for small SystemView packets and makes them even faster + // + _ALIGN(2) +_LoopCopyStraight: // memcpy(pRing->pBuffer + WrOff, pData, NumBytes); + LDRB R3,[R1], #+1 + STRB R3,[R5], #+1 // *pDest++ = *pSrc++ + SUBS R2,R2,#+1 + BEQ _CSDone + LDRB R3,[R1], #+1 + STRB R3,[R5], #+1 // *pDest++ = *pSrc++ + SUBS R2,R2,#+1 + BNE _LoopCopyStraight +_CSDone: +#if _CORE_NEEDS_DMB // Do not slow down cores that do not need a DMB instruction here + DMB // Cortex-M7 may delay memory writes and also change the order in which the writes happen. Therefore, make sure that all buffer writes are finished, before updating the in the struct +#endif + STR R0,[R6, #+12] // pRing->WrOff = WrOff + NumBytes; + MOVS R0,#+1 + POP {R4-R7} + BX LR // Return 1 +_CheckCase2: + ADDS R0,R0,R3 // Avail += RdOff; => Space incl. wrap-around + CMP R0,R2 + BCC.N _Case3 // if (Avail >= NumBytes) { => Case 2? => If not, we have case 3) (does not fit) + // + // Handling for case 2 + // + ADDS R0,R7,R5 // v = pRing->pBuffer + WrOff => Do not change pRing->pBuffer here because 2nd chunk needs org. value + SUBS R2,R2,R4 // NumBytes -= Rem; (Rem = pRing->SizeOfBuffer - WrOff; => Space until end of buffer) +_LoopCopyBeforeWrapAround: // memcpy(pRing->pBuffer + WrOff, pData, Rem); => Copy 1st chunk + LDRB R3,[R1], #+1 + STRB R3,[R0], #+1 // *pDest++ = *pSrc++ + SUBS R4,R4,#+1 + BNE _LoopCopyBeforeWrapAround + // + // Special case: First check that assumed RdOff == 0 calculated that last element before wrap-around could not be used + // But 2nd check (considering space until wrap-around and until RdOff) revealed that RdOff is not 0, so we can use the last element + // In this case, we may use a copy straight until buffer end anyway without needing to copy 2 chunks + // Therefore, check if 2nd memcpy is necessary at all + // + ADDS R4,R2,#+0 // Save (needed as counter in loop but must be written to after the loop). Also use this inst to update the flags to skip 2nd loop if possible + BEQ.N _No2ChunkNeeded // if (NumBytes) { +_LoopCopyAfterWrapAround: // memcpy(pRing->pBuffer, pData + Rem, NumBytes); + LDRB R3,[R1], #+1 // pData already points to the next src byte due to copy loop increment before this loop + STRB R3,[R5], #+1 // *pDest++ = *pSrc++ + SUBS R2,R2,#+1 + BNE _LoopCopyAfterWrapAround +_No2ChunkNeeded: +#if _CORE_NEEDS_DMB // Do not slow down cores that do not need a DMB instruction here + DMB // Cortex-M7 may delay memory writes and also change the order in which the writes happen. Therefore, make sure that all buffer writes are finished, before updating the in the struct +#endif + STR R4,[R6, #+12] // pRing->WrOff = NumBytes; => Must be written after copying data because J-Link may read control block asynchronously while writing into buffer + MOVS R0,#+1 + POP {R4-R7} + BX LR // Return 1 +_CheckCase4: + SUBS R0,R0,R7 + SUBS R0,R0,#+1 // Avail = RdOff - WrOff - 1u; + CMP R0,R2 + BCS.N _Case4 // if (Avail >= NumBytes) { => Case 4) == 1) ? => If not, we have case 5) == 3) (does not fit) +_Case3: + MOVS R0,#+0 + POP {R4-R7} + BX LR // Return 0 + _PLACE_LITS + +#endif // defined (RTT_USE_ASM) && (RTT_USE_ASM == 1) + _END + +/*************************** End of file ****************************/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Conf.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Conf.h new file mode 100644 index 00000000..15656900 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Conf.h @@ -0,0 +1,389 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2019 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* condition is met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this condition and the following disclaimer. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.82 * +* * +********************************************************************** + +---------------------------END-OF-HEADER------------------------------ +File : SEGGER_RTT_Conf.h +Purpose : Implementation of SEGGER real-time transfer (RTT) which + allows real-time communication on targets which support + debugger memory accesses while the CPU is running. +Revision: $Rev: 18601 $ + +*/ + +#ifndef SEGGER_RTT_CONF_H +#define SEGGER_RTT_CONF_H + +#ifdef __IAR_SYSTEMS_ICC__ + #include +#endif + +/********************************************************************* +* +* Defines, configurable +* +********************************************************************** +*/ +#ifndef SEGGER_RTT_MAX_NUM_UP_BUFFERS + #define SEGGER_RTT_MAX_NUM_UP_BUFFERS (3) // Max. number of up-buffers (T->H) available on this target (Default: 3) +#endif + +#ifndef SEGGER_RTT_MAX_NUM_DOWN_BUFFERS + #define SEGGER_RTT_MAX_NUM_DOWN_BUFFERS (3) // Max. number of down-buffers (H->T) available on this target (Default: 3) +#endif + +#ifndef BUFFER_SIZE_UP + #define BUFFER_SIZE_UP (1024) // Size of the buffer for terminal output of target, up to host (Default: 1k) +#endif + +#ifndef BUFFER_SIZE_DOWN + #define BUFFER_SIZE_DOWN (16) // Size of the buffer for terminal input to target from host (Usually keyboard input) (Default: 16) +#endif + +#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE + #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64u) // Size of buffer for RTT printf to bulk-send chars via RTT (Default: 64) +#endif + +#ifndef SEGGER_RTT_MODE_DEFAULT + #define SEGGER_RTT_MODE_DEFAULT SEGGER_RTT_MODE_NO_BLOCK_SKIP // Mode for pre-initialized terminal channel (buffer 0) +#endif + +/********************************************************************* +* +* RTT memcpy configuration +* +* memcpy() is good for large amounts of data, +* but the overhead is big for small amounts, which are usually stored via RTT. +* With SEGGER_RTT_MEMCPY_USE_BYTELOOP a simple byte loop can be used instead. +* +* SEGGER_RTT_MEMCPY() can be used to replace standard memcpy() in RTT functions. +* This is may be required with memory access restrictions, +* such as on Cortex-A devices with MMU. +*/ +#ifndef SEGGER_RTT_MEMCPY_USE_BYTELOOP + #define SEGGER_RTT_MEMCPY_USE_BYTELOOP 0 // 0: Use memcpy/SEGGER_RTT_MEMCPY, 1: Use a simple byte-loop +#endif +// +// Example definition of SEGGER_RTT_MEMCPY to external memcpy with GCC toolchains and Cortex-A targets +// +//#if ((defined __SES_ARM) || (defined __CROSSWORKS_ARM) || (defined __GNUC__)) && (defined (__ARM_ARCH_7A__)) +// #define SEGGER_RTT_MEMCPY(pDest, pSrc, NumBytes) SEGGER_memcpy((pDest), (pSrc), (NumBytes)) +//#endif + +// +// Target is not allowed to perform other RTT operations while string still has not been stored completely. +// Otherwise we would probably end up with a mixed string in the buffer. +// If using RTT from within interrupts, multiple tasks or multi processors, define the SEGGER_RTT_LOCK() and SEGGER_RTT_UNLOCK() function here. +// +// SEGGER_RTT_MAX_INTERRUPT_PRIORITY can be used in the sample lock routines on Cortex-M3/4. +// Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events, or cause task switches. +// When high-priority interrupts must not be masked while sending RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY needs to be adjusted accordingly. +// (Higher priority = lower priority number) +// Default value for embOS: 128u +// Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) +// In case of doubt mask all interrupts: 1 << (8 - BASEPRI_PRIO_BITS) i.e. 1 << 5 when 3 bits are implemented in NVIC +// or define SEGGER_RTT_LOCK() to completely disable interrupts. +// +#ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY + #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) // Interrupt priority to lock on SEGGER_RTT_LOCK on Cortex-M3/4 (Default: 0x20) +#endif + +/********************************************************************* +* +* RTT lock configuration for SEGGER Embedded Studio, +* Rowley CrossStudio and GCC +*/ +#if ((defined(__SES_ARM) || defined(__SES_RISCV) || defined(__CROSSWORKS_ARM) || defined(__GNUC__) || defined(__clang__)) && !defined (__CC_ARM) && !defined(WIN32)) + #if (defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_8M_BASE__)) + #define SEGGER_RTT_LOCK() { \ + unsigned int LockState; \ + __asm volatile ("mrs %0, primask \n\t" \ + "movs r1, $1 \n\t" \ + "msr primask, r1 \n\t" \ + : "=r" (LockState) \ + : \ + : "r1" \ + ); + + #define SEGGER_RTT_UNLOCK() __asm volatile ("msr primask, %0 \n\t" \ + : \ + : "r" (LockState) \ + : \ + ); \ + } + #elif (defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__)) + #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY + #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) + #endif + #define SEGGER_RTT_LOCK() { \ + unsigned int LockState; \ + __asm volatile ("mrs %0, basepri \n\t" \ + "mov r1, %1 \n\t" \ + "msr basepri, r1 \n\t" \ + : "=r" (LockState) \ + : "i"(SEGGER_RTT_MAX_INTERRUPT_PRIORITY) \ + : "r1" \ + ); + + #define SEGGER_RTT_UNLOCK() __asm volatile ("msr basepri, %0 \n\t" \ + : \ + : "r" (LockState) \ + : \ + ); \ + } + + #elif defined(__ARM_ARCH_7A__) + #define SEGGER_RTT_LOCK() { \ + unsigned int LockState; \ + __asm volatile ("mrs r1, CPSR \n\t" \ + "mov %0, r1 \n\t" \ + "orr r1, r1, #0xC0 \n\t" \ + "msr CPSR_c, r1 \n\t" \ + : "=r" (LockState) \ + : \ + : "r1" \ + ); + + #define SEGGER_RTT_UNLOCK() __asm volatile ("mov r0, %0 \n\t" \ + "mrs r1, CPSR \n\t" \ + "bic r1, r1, #0xC0 \n\t" \ + "and r0, r0, #0xC0 \n\t" \ + "orr r1, r1, r0 \n\t" \ + "msr CPSR_c, r1 \n\t" \ + : \ + : "r" (LockState) \ + : "r0", "r1" \ + ); \ + } + #elif defined(__riscv) || defined(__riscv_xlen) + #define SEGGER_RTT_LOCK() { \ + unsigned int LockState; \ + __asm volatile ("csrr %0, mstatus \n\t" \ + "csrci mstatus, 8 \n\t" \ + "andi %0, %0, 8 \n\t" \ + : "=r" (LockState) \ + : \ + : \ + ); + + #define SEGGER_RTT_UNLOCK() __asm volatile ("csrr a1, mstatus \n\t" \ + "or %0, %0, a1 \n\t" \ + "csrs mstatus, %0 \n\t" \ + : \ + : "r" (LockState) \ + : "a1" \ + ); \ + } + #else + #define SEGGER_RTT_LOCK() + #define SEGGER_RTT_UNLOCK() + #endif +#endif + +/********************************************************************* +* +* RTT lock configuration for IAR EWARM +*/ +#ifdef __ICCARM__ + #if (defined (__ARM6M__) && (__CORE__ == __ARM6M__)) || \ + (defined (__ARM8M_BASELINE__) && (__CORE__ == __ARM8M_BASELINE__)) + #define SEGGER_RTT_LOCK() { \ + unsigned int LockState; \ + LockState = __get_PRIMASK(); \ + __set_PRIMASK(1); + + #define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \ + } + #elif (defined (__ARM7EM__) && (__CORE__ == __ARM7EM__)) || \ + (defined (__ARM7M__) && (__CORE__ == __ARM7M__)) || \ + (defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) || \ + (defined (__ARM8M_MAINLINE__) && (__CORE__ == __ARM8M_MAINLINE__)) + #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY + #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) + #endif + #define SEGGER_RTT_LOCK() { \ + unsigned int LockState; \ + LockState = __get_BASEPRI(); \ + __set_BASEPRI(SEGGER_RTT_MAX_INTERRUPT_PRIORITY); + + #define SEGGER_RTT_UNLOCK() __set_BASEPRI(LockState); \ + } + #endif +#endif + +/********************************************************************* +* +* RTT lock configuration for IAR RX +*/ +#ifdef __ICCRX__ + #define SEGGER_RTT_LOCK() { \ + unsigned long LockState; \ + LockState = __get_interrupt_state(); \ + __disable_interrupt(); + + #define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \ + } +#endif + +/********************************************************************* +* +* RTT lock configuration for IAR RL78 +*/ +#ifdef __ICCRL78__ + #define SEGGER_RTT_LOCK() { \ + __istate_t LockState; \ + LockState = __get_interrupt_state(); \ + __disable_interrupt(); + + #define SEGGER_RTT_UNLOCK() __set_interrupt_state(LockState); \ + } +#endif + +/********************************************************************* +* +* RTT lock configuration for KEIL ARM +*/ +#ifdef __CC_ARM + #if (defined __TARGET_ARCH_6S_M) + #define SEGGER_RTT_LOCK() { \ + unsigned int LockState; \ + register unsigned char PRIMASK __asm( "primask"); \ + LockState = PRIMASK; \ + PRIMASK = 1u; \ + __schedule_barrier(); + + #define SEGGER_RTT_UNLOCK() PRIMASK = LockState; \ + __schedule_barrier(); \ + } + #elif (defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M)) + #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY + #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) + #endif + #define SEGGER_RTT_LOCK() { \ + unsigned int LockState; \ + register unsigned char BASEPRI __asm( "basepri"); \ + LockState = BASEPRI; \ + BASEPRI = SEGGER_RTT_MAX_INTERRUPT_PRIORITY; \ + __schedule_barrier(); + + #define SEGGER_RTT_UNLOCK() BASEPRI = LockState; \ + __schedule_barrier(); \ + } + #endif +#endif + +/********************************************************************* +* +* RTT lock configuration for TI ARM +*/ +#ifdef __TI_ARM__ + #if defined (__TI_ARM_V6M0__) + #define SEGGER_RTT_LOCK() { \ + unsigned int LockState; \ + LockState = __get_PRIMASK(); \ + __set_PRIMASK(1); + + #define SEGGER_RTT_UNLOCK() __set_PRIMASK(LockState); \ + } + #elif (defined (__TI_ARM_V7M3__) || defined (__TI_ARM_V7M4__)) + #ifndef SEGGER_RTT_MAX_INTERRUPT_PRIORITY + #define SEGGER_RTT_MAX_INTERRUPT_PRIORITY (0x20) + #endif + #define SEGGER_RTT_LOCK() { \ + unsigned int LockState; \ + LockState = _set_interrupt_priority(SEGGER_RTT_MAX_INTERRUPT_PRIORITY); + + #define SEGGER_RTT_UNLOCK() _set_interrupt_priority(LockState); \ + } + #endif +#endif + +/********************************************************************* +* +* RTT lock configuration for CCRX +*/ +#ifdef __RX + #define SEGGER_RTT_LOCK() { \ + unsigned long LockState; \ + LockState = get_psw() & 0x010000; \ + clrpsw_i(); + + #define SEGGER_RTT_UNLOCK() set_psw(get_psw() | LockState); \ + } +#endif + +/********************************************************************* +* +* RTT lock configuration for embOS Simulation on Windows +* (Can also be used for generic RTT locking with embOS) +*/ +#if defined(WIN32) || defined(SEGGER_RTT_LOCK_EMBOS) + +void OS_SIM_EnterCriticalSection(void); +void OS_SIM_LeaveCriticalSection(void); + +#define SEGGER_RTT_LOCK() { \ + OS_SIM_EnterCriticalSection(); + +#define SEGGER_RTT_UNLOCK() OS_SIM_LeaveCriticalSection(); \ + } +#endif + +/********************************************************************* +* +* RTT lock configuration fallback +*/ +#ifndef SEGGER_RTT_LOCK + #define SEGGER_RTT_LOCK() // Lock RTT (nestable) (i.e. disable interrupts) +#endif + +#ifndef SEGGER_RTT_UNLOCK + #define SEGGER_RTT_UNLOCK() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state) +#endif + +#endif +/*************************** End of file ****************************/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_GCC.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_GCC.c new file mode 100644 index 00000000..1ed77fdc --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_GCC.c @@ -0,0 +1,125 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2019 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* condition is met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this condition and the following disclaimer. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.82 * +* * +********************************************************************** + +---------------------------END-OF-HEADER------------------------------ +File : SEGGER_RTT_Syscalls_GCC.c +Purpose : Low-level functions for using printf() via RTT in GCC. + To use RTT for printf output, include this file in your + application. +Revision: $Rev: 20159 $ +---------------------------------------------------------------------- +*/ +#if (defined __GNUC__) && !(defined __SES_ARM) && !(defined __CROSSWORKS_ARM) && !(defined __ARMCC_VERSION) && !(defined __CC_ARM) + +#include // required for _write_r +#include "SEGGER_RTT.h" + + +/********************************************************************* +* +* Types +* +********************************************************************** +*/ +// +// If necessary define the _reent struct +// to match the one passed by the used standard library. +// +struct _reent; + +/********************************************************************* +* +* Function prototypes +* +********************************************************************** +*/ +int _write(int file, char *ptr, int len); +int _write_r(struct _reent *r, int file, const void *ptr, int len); + +/********************************************************************* +* +* Global functions +* +********************************************************************** +*/ + +/********************************************************************* +* +* _write() +* +* Function description +* Low-level write function. +* libc subroutines will use this system routine for output to all files, +* including stdout. +* Write data via RTT. +*/ +int _write(int file, char *ptr, int len) { + (void) file; /* Not used, avoid warning */ + SEGGER_RTT_Write(0, ptr, len); + return len; +} + +/********************************************************************* +* +* _write_r() +* +* Function description +* Low-level reentrant write function. +* libc subroutines will use this system routine for output to all files, +* including stdout. +* Write data via RTT. +*/ +int _write_r(struct _reent *r, int file, const void *ptr, int len) { + (void) file; /* Not used, avoid warning */ + (void) r; /* Not used, avoid warning */ + SEGGER_RTT_Write(0, ptr, len); + return len; +} + +#endif +/****** End Of File *************************************************/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_IAR.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_IAR.c new file mode 100644 index 00000000..fdc2b924 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_IAR.c @@ -0,0 +1,120 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2019 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* condition is met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this condition and the following disclaimer. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.82 * +* * +********************************************************************** + +---------------------------END-OF-HEADER------------------------------ +File : SEGGER_RTT_Syscalls_IAR.c +Purpose : Low-level functions for using printf() via RTT in IAR. + To use RTT for printf output, include this file in your + application and set the Library Configuration to Normal. +Revision: $Rev: 17697 $ +---------------------------------------------------------------------- +*/ +#ifdef __IAR_SYSTEMS_ICC__ + +// +// Since IAR EWARM V8 and EWRX V4, yfuns.h is considered as deprecated and LowLevelIOInterface.h +// shall be used instead. To not break any compatibility with older compiler versions, we have a +// version check in here. +// +#if ((defined __ICCARM__) && (__VER__ >= 8000000)) || ((defined __ICCRX__) && (__VER__ >= 400)) + #include +#else + #include +#endif + +#include "SEGGER_RTT.h" +#pragma module_name = "?__write" + +/********************************************************************* +* +* Function prototypes +* +********************************************************************** +*/ +size_t __write(int handle, const unsigned char * buffer, size_t size); + +/********************************************************************* +* +* Global functions +* +********************************************************************** +*/ +/********************************************************************* +* +* __write() +* +* Function description +* Low-level write function. +* Standard library subroutines will use this system routine +* for output to all files, including stdout. +* Write data via RTT. +*/ +size_t __write(int handle, const unsigned char * buffer, size_t size) { + (void) handle; /* Not used, avoid warning */ + SEGGER_RTT_Write(0, (const char*)buffer, size); + return size; +} + +/********************************************************************* +* +* __write_buffered() +* +* Function description +* Low-level write function. +* Standard library subroutines will use this system routine +* for output to all files, including stdout. +* Write data via RTT. +*/ +size_t __write_buffered(int handle, const unsigned char * buffer, size_t size) { + (void) handle; /* Not used, avoid warning */ + SEGGER_RTT_Write(0, (const char*)buffer, size); + return size; +} + +#endif +/****** End Of File *************************************************/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_KEIL.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_KEIL.c new file mode 100644 index 00000000..9e93c90c --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_KEIL.c @@ -0,0 +1,393 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2019 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* condition is met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this condition and the following disclaimer. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.82 * +* * +********************************************************************** + +---------------------------END-OF-HEADER------------------------------ +File : RTT_Syscalls_KEIL.c +Purpose : Retargeting module for KEIL MDK-CM3. + Low-level functions for using printf() via RTT +Revision: $Rev: 20159 $ +---------------------------------------------------------------------- +*/ +#if (defined __CC_ARM) || (defined __ARMCC_VERSION) + +#include +#include +#include +#include +#include + +#include "SEGGER_RTT.h" +/********************************************************************* +* +* #pragmas +* +********************************************************************** +*/ +#if __ARMCC_VERSION < 6000000 +#pragma import(__use_no_semihosting) +#endif + +#ifdef _MICROLIB + #pragma import(__use_full_stdio) +#endif + +/********************************************************************* +* +* Defines non-configurable +* +********************************************************************** +*/ + +/* Standard IO device handles - arbitrary, but any real file system handles must be + less than 0x8000. */ +#define STDIN 0x8001 // Standard Input Stream +#define STDOUT 0x8002 // Standard Output Stream +#define STDERR 0x8003 // Standard Error Stream + +/********************************************************************* +* +* Public const +* +********************************************************************** +*/ +#if __ARMCC_VERSION < 5000000 +//const char __stdin_name[] = "STDIN"; +const char __stdout_name[] = "STDOUT"; +const char __stderr_name[] = "STDERR"; +#endif + +/********************************************************************* +* +* Public code +* +********************************************************************** +*/ + +/********************************************************************* +* +* _ttywrch +* +* Function description: +* Outputs a character to the console +* +* Parameters: +* c - character to output +* +*/ +void _ttywrch(int c) { + fputc(c, stdout); // stdout + fflush(stdout); +} + +/********************************************************************* +* +* _sys_open +* +* Function description: +* Opens the device/file in order to do read/write operations +* +* Parameters: +* sName - sName of the device/file to open +* OpenMode - This parameter is currently ignored +* +* Return value: +* != 0 - Handle to the object to open, otherwise +* == 0 -"device" is not handled by this module +* +*/ +FILEHANDLE _sys_open(const char * sName, int OpenMode) { + (void)OpenMode; + // Register standard Input Output devices. + if (strcmp(sName, __stdout_name) == 0) { + return (STDOUT); + } else if (strcmp(sName, __stderr_name) == 0) { + return (STDERR); + } else + return (0); // Not implemented +} + +/********************************************************************* +* +* _sys_close +* +* Function description: +* Closes the handle to the open device/file +* +* Parameters: +* hFile - Handle to a file opened via _sys_open +* +* Return value: +* 0 - device/file closed +* +*/ +int _sys_close(FILEHANDLE hFile) { + (void)hFile; + return 0; // Not implemented +} + +/********************************************************************* +* +* _sys_write +* +* Function description: +* Writes the data to an open handle. +* Currently this function only outputs data to the console +* +* Parameters: +* hFile - Handle to a file opened via _sys_open +* pBuffer - Pointer to the data that shall be written +* NumBytes - Number of bytes to write +* Mode - The Mode that shall be used +* +* Return value: +* Number of bytes *not* written to the file/device +* +*/ +int _sys_write(FILEHANDLE hFile, const unsigned char * pBuffer, unsigned NumBytes, int Mode) { + int r = 0; + + (void)Mode; + if (hFile == STDOUT) { + SEGGER_RTT_Write(0, (const char*)pBuffer, NumBytes); + return 0; + } + return r; +} + +/********************************************************************* +* +* _sys_read +* +* Function description: +* Reads data from an open handle. +* Currently this modules does nothing. +* +* Parameters: +* hFile - Handle to a file opened via _sys_open +* pBuffer - Pointer to buffer to store the read data +* NumBytes - Number of bytes to read +* Mode - The Mode that shall be used +* +* Return value: +* Number of bytes read from the file/device +* +*/ +int _sys_read(FILEHANDLE hFile, unsigned char * pBuffer, unsigned NumBytes, int Mode) { + (void)hFile; + (void)pBuffer; + (void)NumBytes; + (void)Mode; + return (0); // Not implemented +} + +/********************************************************************* +* +* _sys_istty +* +* Function description: +* This function shall return whether the opened file +* is a console device or not. +* +* Parameters: +* hFile - Handle to a file opened via _sys_open +* +* Return value: +* 1 - Device is a console +* 0 - Device is not a console +* +*/ +int _sys_istty(FILEHANDLE hFile) { + if (hFile > 0x8000) { + return (1); + } + return (0); // Not implemented +} + +/********************************************************************* +* +* _sys_seek +* +* Function description: +* Seeks via the file to a specific position +* +* Parameters: +* hFile - Handle to a file opened via _sys_open +* Pos - +* +* Return value: +* int - +* +*/ +int _sys_seek(FILEHANDLE hFile, long Pos) { + (void)hFile; + (void)Pos; + return (0); // Not implemented +} + +/********************************************************************* +* +* _sys_ensure +* +* Function description: +* +* +* Parameters: +* hFile - Handle to a file opened via _sys_open +* +* Return value: +* int - +* +*/ +int _sys_ensure(FILEHANDLE hFile) { + (void)hFile; + return (-1); // Not implemented +} + +/********************************************************************* +* +* _sys_flen +* +* Function description: +* Returns the length of the opened file handle +* +* Parameters: +* hFile - Handle to a file opened via _sys_open +* +* Return value: +* Length of the file +* +*/ +long _sys_flen(FILEHANDLE hFile) { + (void)hFile; + return (0); // Not implemented +} + +/********************************************************************* +* +* _sys_tmpnam +* +* Function description: +* This function converts the file number fileno for a temporary +* file to a unique filename, for example, tmp0001. +* +* Parameters: +* pBuffer - Pointer to a buffer to store the name +* FileNum - file number to convert +* MaxLen - Size of the buffer +* +* Return value: +* 1 - Error +* 0 - Success +* +*/ +int _sys_tmpnam(char * pBuffer, int FileNum, unsigned MaxLen) { + (void)pBuffer; + (void)FileNum; + (void)MaxLen; + return (1); // Not implemented +} + +/********************************************************************* +* +* _sys_command_string +* +* Function description: +* This function shall execute a system command. +* +* Parameters: +* cmd - Pointer to the command string +* len - Length of the string +* +* Return value: +* == NULL - Command was not successfully executed +* == sCmd - Command was passed successfully +* +*/ +char * _sys_command_string(char * cmd, int len) { + (void)len; + return cmd; // Not implemented +} + +/********************************************************************* +* +* _sys_exit +* +* Function description: +* This function is called when the application returns from main +* +* Parameters: +* ReturnCode - Return code from the main function +* +* +*/ +void _sys_exit(int ReturnCode) { + (void)ReturnCode; + while (1); // Not implemented +} + +#if __ARMCC_VERSION >= 5000000 +/********************************************************************* +* +* stdout_putchar +* +* Function description: +* Put a character to the stdout +* +* Parameters: +* ch - Character to output +* +* +*/ +int stdout_putchar(int ch) { + (void)ch; + return ch; // Not implemented +} +#endif + +#endif +/*************************** End of file ****************************/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_SES.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_SES.c new file mode 100644 index 00000000..380a6f65 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_Syscalls_SES.c @@ -0,0 +1,252 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2019 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* condition is met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this condition and the following disclaimer. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.82 * +* * +********************************************************************** + +---------------------------END-OF-HEADER------------------------------ +File : SEGGER_RTT_Syscalls_SES.c +Purpose : Reimplementation of printf, puts and __getchar using RTT + in SEGGER Embedded Studio. + To use RTT for printf output, include this file in your + application. +Revision: $Rev: 18539 $ +---------------------------------------------------------------------- +*/ +#if (defined __SES_ARM) || (defined __SES_RISCV) || (defined __CROSSWORKS_ARM) + +#include "SEGGER_RTT.h" +#include +#include +#include "limits.h" +#include "__libc.h" +#include "__vfprintf.h" + +/********************************************************************* +* +* Defines, configurable +* +********************************************************************** +*/ +// +// Select string formatting implementation. +// +// RTT printf formatting +// - Configurable stack usage. (SEGGER_RTT_PRINTF_BUFFER_SIZE in SEGGER_RTT_Conf.h) +// - No maximum string length. +// - Limited conversion specifiers and flags. (See SEGGER_RTT_printf.c) +// Standard library printf formatting +// - Configurable formatting capabilities. +// - Full conversion specifier and flag support. +// - Maximum string length has to be known or (slightly) slower character-wise output. +// +// #define PRINTF_USE_SEGGER_RTT_FORMATTING 0 // Use standard library formatting +// #define PRINTF_USE_SEGGER_RTT_FORMATTING 1 // Use RTT formatting +// +#ifndef PRINTF_USE_SEGGER_RTT_FORMATTING + #define PRINTF_USE_SEGGER_RTT_FORMATTING 0 +#endif +// +// If using standard library formatting, +// select maximum output string buffer size or character-wise output. +// +// #define PRINTF_BUFFER_SIZE 0 // Use character-wise output +// #define PRINTF_BUFFER_SIZE 128 // Default maximum string length +// +#ifndef PRINTF_BUFFER_SIZE + #define PRINTF_BUFFER_SIZE 128 +#endif + +#if PRINTF_USE_SEGGER_RTT_FORMATTING // Use SEGGER RTT formatting implementation +/********************************************************************* +* +* Function prototypes +* +********************************************************************** +*/ +int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList); + +/********************************************************************* +* +* Global functions, printf +* +********************************************************************** +*/ +/********************************************************************* +* +* printf() +* +* Function description +* print a formatted string using RTT and SEGGER RTT formatting. +*/ +int printf(const char *fmt,...) { + int n; + va_list args; + + va_start (args, fmt); + n = SEGGER_RTT_vprintf(0, fmt, &args); + va_end(args); + return n; +} + +#elif PRINTF_BUFFER_SIZE == 0 // Use standard library formatting with character-wise output + +/********************************************************************* +* +* Static functions +* +********************************************************************** +*/ +static int _putchar(int x, __printf_tag_ptr ctx) { + (void)ctx; + SEGGER_RTT_Write(0, (char *)&x, 1); + return x; +} + +/********************************************************************* +* +* Global functions, printf +* +********************************************************************** +*/ +/********************************************************************* +* +* printf() +* +* Function description +* print a formatted string character-wise, using RTT and standard +* library formatting. +*/ +int printf(const char *fmt, ...) { + int n; + va_list args; + __printf_t iod; + + va_start(args, fmt); + iod.string = 0; + iod.maxchars = INT_MAX; + iod.output_fn = _putchar; + SEGGER_RTT_LOCK(); + n = __vfprintf(&iod, fmt, args); + SEGGER_RTT_UNLOCK(); + va_end(args); + return n; +} + +#else // Use standard library formatting with static buffer + +/********************************************************************* +* +* Global functions, printf +* +********************************************************************** +*/ +/********************************************************************* +* +* printf() +* +* Function description +* print a formatted string using RTT and standard library formatting. +*/ +int printf(const char *fmt,...) { + int n; + char aBuffer[PRINTF_BUFFER_SIZE]; + va_list args; + + va_start (args, fmt); + n = vsnprintf(aBuffer, sizeof(aBuffer), fmt, args); + if (n > (int)sizeof(aBuffer)) { + SEGGER_RTT_Write(0, aBuffer, sizeof(aBuffer)); + } else if (n > 0) { + SEGGER_RTT_Write(0, aBuffer, n); + } + va_end(args); + return n; +} +#endif + +/********************************************************************* +* +* Global functions +* +********************************************************************** +*/ +/********************************************************************* +* +* puts() +* +* Function description +* print a string using RTT. +*/ +int puts(const char *s) { + return SEGGER_RTT_WriteString(0, s); +} + +/********************************************************************* +* +* __putchar() +* +* Function description +* Write one character via RTT. +*/ +int __putchar(int x, __printf_tag_ptr ctx) { + (void)ctx; + SEGGER_RTT_Write(0, (char *)&x, 1); + return x; +} + +/********************************************************************* +* +* __getchar() +* +* Function description +* Wait for and get a character via RTT. +*/ +int __getchar() { + return SEGGER_RTT_WaitKey(); +} + +#endif +/****** End Of File *************************************************/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_printf.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_printf.c new file mode 100644 index 00000000..a987ad1a --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/rtt/SEGGER_RTT_printf.c @@ -0,0 +1,505 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH * +* The Embedded Experts * +********************************************************************** +* * +* (c) 1995 - 2019 SEGGER Microcontroller GmbH * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* condition is met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this condition and the following disclaimer. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.82 * +* * +********************************************************************** + +---------------------------END-OF-HEADER------------------------------ +File : SEGGER_RTT_printf.c +Purpose : Replacement for printf to write formatted data via RTT +Revision: $Rev: 17697 $ +---------------------------------------------------------------------- +*/ +#include "SEGGER_RTT.h" +#include "SEGGER_RTT_Conf.h" + +/********************************************************************* +* +* Defines, configurable +* +********************************************************************** +*/ + +#ifndef SEGGER_RTT_PRINTF_BUFFER_SIZE + #define SEGGER_RTT_PRINTF_BUFFER_SIZE (64) +#endif + +#include +#include + + +#define FORMAT_FLAG_LEFT_JUSTIFY (1u << 0) +#define FORMAT_FLAG_PAD_ZERO (1u << 1) +#define FORMAT_FLAG_PRINT_SIGN (1u << 2) +#define FORMAT_FLAG_ALTERNATE (1u << 3) + +/********************************************************************* +* +* Types +* +********************************************************************** +*/ + +typedef struct { + char* pBuffer; + unsigned BufferSize; + unsigned Cnt; + + int ReturnValue; + + unsigned RTTBufferIndex; +} SEGGER_RTT_PRINTF_DESC; + +/********************************************************************* +* +* Function prototypes +* +********************************************************************** +*/ + +/********************************************************************* +* +* Static code +* +********************************************************************** +*/ +/********************************************************************* +* +* _StoreChar +*/ +static void _StoreChar(SEGGER_RTT_PRINTF_DESC * p, char c) { + unsigned Cnt; + + Cnt = p->Cnt; + if ((Cnt + 1u) <= p->BufferSize) { + *(p->pBuffer + Cnt) = c; + p->Cnt = Cnt + 1u; + p->ReturnValue++; + } + // + // Write part of string, when the buffer is full + // + if (p->Cnt == p->BufferSize) { + if (SEGGER_RTT_Write(p->RTTBufferIndex, p->pBuffer, p->Cnt) != p->Cnt) { + p->ReturnValue = -1; + } else { + p->Cnt = 0u; + } + } +} + +/********************************************************************* +* +* _PrintUnsigned +*/ +static void _PrintUnsigned(SEGGER_RTT_PRINTF_DESC * pBufferDesc, unsigned v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) { + static const char _aV2C[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + unsigned Div; + unsigned Digit; + unsigned Number; + unsigned Width; + char c; + + Number = v; + Digit = 1u; + // + // Get actual field width + // + Width = 1u; + while (Number >= Base) { + Number = (Number / Base); + Width++; + } + if (NumDigits > Width) { + Width = NumDigits; + } + // + // Print leading chars if necessary + // + if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) { + if (FieldWidth != 0u) { + if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && (NumDigits == 0u)) { + c = '0'; + } else { + c = ' '; + } + while ((FieldWidth != 0u) && (Width < FieldWidth)) { + FieldWidth--; + _StoreChar(pBufferDesc, c); + if (pBufferDesc->ReturnValue < 0) { + break; + } + } + } + } + if (pBufferDesc->ReturnValue >= 0) { + // + // Compute Digit. + // Loop until Digit has the value of the highest digit required. + // Example: If the output is 345 (Base 10), loop 2 times until Digit is 100. + // + while (1) { + if (NumDigits > 1u) { // User specified a min number of digits to print? => Make sure we loop at least that often, before checking anything else (> 1 check avoids problems with NumDigits being signed / unsigned) + NumDigits--; + } else { + Div = v / Digit; + if (Div < Base) { // Is our divider big enough to extract the highest digit from value? => Done + break; + } + } + Digit *= Base; + } + // + // Output digits + // + do { + Div = v / Digit; + v -= Div * Digit; + _StoreChar(pBufferDesc, _aV2C[Div]); + if (pBufferDesc->ReturnValue < 0) { + break; + } + Digit /= Base; + } while (Digit); + // + // Print trailing spaces if necessary + // + if ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == FORMAT_FLAG_LEFT_JUSTIFY) { + if (FieldWidth != 0u) { + while ((FieldWidth != 0u) && (Width < FieldWidth)) { + FieldWidth--; + _StoreChar(pBufferDesc, ' '); + if (pBufferDesc->ReturnValue < 0) { + break; + } + } + } + } + } +} + +/********************************************************************* +* +* _PrintInt +*/ +static void _PrintInt(SEGGER_RTT_PRINTF_DESC * pBufferDesc, int v, unsigned Base, unsigned NumDigits, unsigned FieldWidth, unsigned FormatFlags) { + unsigned Width; + int Number; + + Number = (v < 0) ? -v : v; + + // + // Get actual field width + // + Width = 1u; + while (Number >= (int)Base) { + Number = (Number / (int)Base); + Width++; + } + if (NumDigits > Width) { + Width = NumDigits; + } + if ((FieldWidth > 0u) && ((v < 0) || ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN))) { + FieldWidth--; + } + + // + // Print leading spaces if necessary + // + if ((((FormatFlags & FORMAT_FLAG_PAD_ZERO) == 0u) || (NumDigits != 0u)) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u)) { + if (FieldWidth != 0u) { + while ((FieldWidth != 0u) && (Width < FieldWidth)) { + FieldWidth--; + _StoreChar(pBufferDesc, ' '); + if (pBufferDesc->ReturnValue < 0) { + break; + } + } + } + } + // + // Print sign if necessary + // + if (pBufferDesc->ReturnValue >= 0) { + if (v < 0) { + v = -v; + _StoreChar(pBufferDesc, '-'); + } else if ((FormatFlags & FORMAT_FLAG_PRINT_SIGN) == FORMAT_FLAG_PRINT_SIGN) { + _StoreChar(pBufferDesc, '+'); + } else { + + } + if (pBufferDesc->ReturnValue >= 0) { + // + // Print leading zeros if necessary + // + if (((FormatFlags & FORMAT_FLAG_PAD_ZERO) == FORMAT_FLAG_PAD_ZERO) && ((FormatFlags & FORMAT_FLAG_LEFT_JUSTIFY) == 0u) && (NumDigits == 0u)) { + if (FieldWidth != 0u) { + while ((FieldWidth != 0u) && (Width < FieldWidth)) { + FieldWidth--; + _StoreChar(pBufferDesc, '0'); + if (pBufferDesc->ReturnValue < 0) { + break; + } + } + } + } + if (pBufferDesc->ReturnValue >= 0) { + // + // Print number without sign + // + _PrintUnsigned(pBufferDesc, (unsigned)v, Base, NumDigits, FieldWidth, FormatFlags); + } + } + } +} + +/********************************************************************* +* +* Public code +* +********************************************************************** +*/ +/********************************************************************* +* +* SEGGER_RTT_vprintf +* +* Function description +* Stores a formatted string in SEGGER RTT control block. +* This data is read by the host. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal") +* sFormat Pointer to format string +* pParamList Pointer to the list of arguments for the format string +* +* Return values +* >= 0: Number of bytes which have been stored in the "Up"-buffer. +* < 0: Error +*/ +int SEGGER_RTT_vprintf(unsigned BufferIndex, const char * sFormat, va_list * pParamList) { + char c; + SEGGER_RTT_PRINTF_DESC BufferDesc; + int v; + unsigned NumDigits; + unsigned FormatFlags; + unsigned FieldWidth; + char acBuffer[SEGGER_RTT_PRINTF_BUFFER_SIZE]; + + BufferDesc.pBuffer = acBuffer; + BufferDesc.BufferSize = SEGGER_RTT_PRINTF_BUFFER_SIZE; + BufferDesc.Cnt = 0u; + BufferDesc.RTTBufferIndex = BufferIndex; + BufferDesc.ReturnValue = 0; + + do { + c = *sFormat; + sFormat++; + if (c == 0u) { + break; + } + if (c == '%') { + // + // Filter out flags + // + FormatFlags = 0u; + v = 1; + do { + c = *sFormat; + switch (c) { + case '-': FormatFlags |= FORMAT_FLAG_LEFT_JUSTIFY; sFormat++; break; + case '0': FormatFlags |= FORMAT_FLAG_PAD_ZERO; sFormat++; break; + case '+': FormatFlags |= FORMAT_FLAG_PRINT_SIGN; sFormat++; break; + case '#': FormatFlags |= FORMAT_FLAG_ALTERNATE; sFormat++; break; + default: v = 0; break; + } + } while (v); + // + // filter out field with + // + FieldWidth = 0u; + do { + c = *sFormat; + if ((c < '0') || (c > '9')) { + break; + } + sFormat++; + FieldWidth = (FieldWidth * 10u) + ((unsigned)c - '0'); + } while (1); + + // + // Filter out precision (number of digits to display) + // + NumDigits = 0u; + c = *sFormat; + if (c == '.') { + sFormat++; + do { + c = *sFormat; + if ((c < '0') || (c > '9')) { + break; + } + sFormat++; + NumDigits = NumDigits * 10u + ((unsigned)c - '0'); + } while (1); + } + // + // Filter out length modifier + // + c = *sFormat; + do { + if ((c == 'l') || (c == 'h')) { + sFormat++; + c = *sFormat; + } else { + break; + } + } while (1); + // + // Handle specifiers + // + switch (c) { + case 'c': { + char c0; + v = va_arg(*pParamList, int); + c0 = (char)v; + _StoreChar(&BufferDesc, c0); + break; + } + case 'd': + v = va_arg(*pParamList, int); + _PrintInt(&BufferDesc, v, 10u, NumDigits, FieldWidth, FormatFlags); + break; + case 'u': + v = va_arg(*pParamList, int); + _PrintUnsigned(&BufferDesc, (unsigned)v, 10u, NumDigits, FieldWidth, FormatFlags); + break; + case 'x': + case 'X': + v = va_arg(*pParamList, int); + _PrintUnsigned(&BufferDesc, (unsigned)v, 16u, NumDigits, FieldWidth, FormatFlags); + break; + case 's': + { + const char * s = va_arg(*pParamList, const char *); + do { + c = *s; + s++; + if (c == '\0') { + break; + } + _StoreChar(&BufferDesc, c); + } while (BufferDesc.ReturnValue >= 0); + } + break; + case 'p': + v = va_arg(*pParamList, int); + _PrintUnsigned(&BufferDesc, (unsigned)v, 16u, 8u, 8u, 0u); + break; + case '%': + _StoreChar(&BufferDesc, '%'); + break; + default: + break; + } + sFormat++; + } else { + _StoreChar(&BufferDesc, c); + } + } while (BufferDesc.ReturnValue >= 0); + + if (BufferDesc.ReturnValue > 0) { + // + // Write remaining data, if any + // + if (BufferDesc.Cnt != 0u) { + SEGGER_RTT_Write(BufferIndex, acBuffer, BufferDesc.Cnt); + } + BufferDesc.ReturnValue += (int)BufferDesc.Cnt; + } + return BufferDesc.ReturnValue; +} + +/********************************************************************* +* +* SEGGER_RTT_printf +* +* Function description +* Stores a formatted string in SEGGER RTT control block. +* This data is read by the host. +* +* Parameters +* BufferIndex Index of "Up"-buffer to be used. (e.g. 0 for "Terminal") +* sFormat Pointer to format string, followed by the arguments for conversion +* +* Return values +* >= 0: Number of bytes which have been stored in the "Up"-buffer. +* < 0: Error +* +* Notes +* (1) Conversion specifications have following syntax: +* %[flags][FieldWidth][.Precision]ConversionSpecifier +* (2) Supported flags: +* -: Left justify within the field width +* +: Always print sign extension for signed conversions +* 0: Pad with 0 instead of spaces. Ignored when using '-'-flag or precision +* Supported conversion specifiers: +* c: Print the argument as one char +* d: Print the argument as a signed integer +* u: Print the argument as an unsigned integer +* x: Print the argument as an hexadecimal integer +* s: Print the string pointed to by the argument +* p: Print the argument as an 8-digit hexadecimal integer. (Argument shall be a pointer to void.) +*/ +int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...) { + int r; + va_list ParamList; + + va_start(ParamList, sFormat); + r = SEGGER_RTT_vprintf(BufferIndex, sFormat, &ParamList); + va_end(ParamList); + return r; +} +/*************************** End of file ****************************/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src.zip b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src.zip new file mode 100644 index 00000000..022d4805 Binary files /dev/null and b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src.zip differ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/FreeRTOSConfig.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/FreeRTOSConfig.h new file mode 100644 index 00000000..a3116057 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/FreeRTOSConfig.h @@ -0,0 +1,161 @@ +//***************************************************************************** +// +//! @file FreeRTOSConfig.h +//! +//! @brief Configuration options for FreeRTOS +// +//***************************************************************************** + +//***************************************************************************** +// +// Copyright (c) 2020, Ambiq Micro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// Third party software included in this distribution is subject to the +// additional license terms as defined in the /docs/licenses directory. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// This is part of revision 2.4.2 of the AmbiqSuite Development Package. +// +//***************************************************************************** +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define configUSE_PREEMPTION 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 + +#ifdef AM_PART_APOLLO2 + #define configCPU_CLOCK_HZ 48000000UL +#else + #define configCPU_CLOCK_HZ 24000000UL +#endif +#define configTICK_RATE_HZ 1000 +#define configMAX_PRIORITIES 4 +#define configMINIMAL_STACK_SIZE (256) +#define configTOTAL_HEAP_SIZE (16 * 1024) +#define configMAX_TASK_NAME_LEN 16 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 + +#define configUSE_MUTEXES 0 +#define configUSE_RECURSIVE_MUTEXES 0 +#define configUSE_COUNTING_SEMAPHORES 0 +#define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ +#define configQUEUE_REGISTRY_SIZE 0 +#define configUSE_QUEUE_SETS 0 +#define configUSE_TIME_SLICING 0 +#define configUSE_NEWLIB_REENTRANT 0 +#define configENABLE_BACKWARD_COMPATIBILITY 0 + +/* Hook function related definitions. */ +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCHECK_FOR_STACK_OVERFLOW 2 +#define configUSE_MALLOC_FAILED_HOOK 1 + +/* Run time and task stats gathering related definitions. */ +#define configGENERATE_RUN_TIME_STATS 0 +#define configUSE_TRACE_FACILITY 0 +#define configUSE_STATS_FORMATTING_FUNCTIONS 0 + +/* Software timer related definitions. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY 3 +#define configTIMER_QUEUE_LENGTH 5 +#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE + +/* Interrupt nesting behaviour configuration. */ +#define configKERNEL_INTERRUPT_PRIORITY (0x7 << 5) +#define configMAX_SYSCALL_INTERRUPT_PRIORITY (0x4 << 5) +#define NVIC_configKERNEL_INTERRUPT_PRIORITY (0x7) +#define NVIC_configMAX_SYSCALL_INTERRUPT_PRIORITY (0x4) + +/* Define to trap errors during development. */ +#define configASSERT(x) if (( x ) == 0) while(1); + +/* FreeRTOS MPU specific definitions. */ +#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0 + +/* Optional functions - most linkers will remove unused functions anyway. */ +#define INCLUDE_vTaskPrioritySet 0 +#define INCLUDE_uxTaskPriorityGet 0 +#define INCLUDE_vTaskDelete 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_xResumeFromISR 0 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 0 +#define INCLUDE_xTaskGetSchedulerState 0 +#define INCLUDE_xTaskGetCurrentTaskHandle 0 +#define INCLUDE_uxTaskGetStackHighWaterMark 0 +#define INCLUDE_xTaskGetIdleTaskHandle 0 +#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0 +#define INCLUDE_pcTaskGetTaskName 0 +#define INCLUDE_eTaskGetState 0 +#define INCLUDE_xEventGroupSetBitFromISR 1 +#define INCLUDE_xTimerPendFunctionCall 1 + +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler +#define xPortSysTickHandler SysTick_Handler + +#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 1 // Enable non-SysTick based Tick +#define configUSE_TICKLESS_IDLE 2 // Ambiq specific implementation for Tickless + +#if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) +extern uint32_t am_freertos_sleep(uint32_t); +extern void am_freertos_wakeup(uint32_t); + +#define configPRE_SLEEP_PROCESSING( time ) \ + do { \ + (time) = am_freertos_sleep(time); \ + } while (0); + +#define configPOST_SLEEP_PROCESSING(time) am_freertos_wakeup(time) +#endif +/*-----------------------------------------------------------*/ +#ifndef AM_PART_APOLLO +#define AM_FREERTOS_USE_STIMER_FOR_TICK +#endif + +#ifdef AM_FREERTOS_USE_STIMER_FOR_TICK +#define configSTIMER_CLOCK_HZ 32768 +#else // Use CTimer +#define configCTIMER_CLOCK_HZ 32768 +#endif + +#ifdef __cplusplus +} +#endif + +#endif // FREERTOS_CONFIG_H + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/apollo3_service.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/apollo3_service.c new file mode 100644 index 00000000..26815dca --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/apollo3_service.c @@ -0,0 +1,373 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include "apollo3_service.h" + +#include +#include + +#include "SEGGER_RTT.h" + +#include "wsf_types.h" +#include "att_api.h" +#include "app_api.h" +#include "watch_api.h" + +#include "ble_qiot_service.h" +#include "ble_qiot_import.h" +#include "ble_qiot_config.h" + + + +// divece configs +#define PRODUCT_ID "LR5NRSX9F5" +#define DEVICE_NAME "ble01" +#define SECRET_KEY "uG2TRl0hnCNsuLgls/65Bg==" + +#define ADV_DEVICE_NAME "life_sense" + +#define ATTRIBUTE_VALUE_MAX_LEN 256 + + +#define IOT_BLE_UUID_BASE96 0xe2, 0xa4, 0x1b, 0x54, 0x93, 0xe4, 0x6a, 0xb5, \ + 0x20, 0x4e, 0xd0, 0x65 + +#define UINT16_TO_BYTES(n) ((uint8_t) (n)), ((uint8_t)((n) >> 8)) +#define UINT32_TO_BYTES(n) ((uint8_t) (n)), ((uint8_t)((n) >> 8)), ((uint8_t)((n) >> 16)), ((uint8_t)((n) >> 24)) + +#define UINT16_TO_UUID32(n) ((uint8_t) (n)), ((uint8_t)((n) >> 8)), ((uint8_t)((n) >> 16)), ((uint8_t)((n) >> 24)) +#define IOT_BLE_UUID128_BUILD(uuid) IOT_BLE_UUID_BASE96, UINT16_TO_UUID32(uuid) + +#define IOT_BLE_UUID128_SERVICE IOT_BLE_UUID128_BUILD(IOT_BLE_UUID_SERVICE) +#define IOT_BLE_UUID128_DEVICE_INFO IOT_BLE_UUID128_BUILD(IOT_BLE_UUID_DEVICE_INFO) +#define IOT_BLE_UUID128_DATA IOT_BLE_UUID128_BUILD(IOT_BLE_UUID_DATA) +#define IOT_BLE_UUID128_EVENT IOT_BLE_UUID128_BUILD(IOT_BLE_UUID_EVENT) + +uint8_t iot_service_uuid[] = {IOT_BLE_UUID128_SERVICE}; +uint16_t iot_service_uuid_len = sizeof(iot_service_uuid); + +uint8_t service_uuid[] = {UINT16_TO_BYTES(IOT_BLE_UUID_SERVICE)}; + + +// qiot device info characteristic and attribute +// uint8_t device_info_rx_char[] = {(ATT_PROP_READ | ATT_PROP_WRITE_NO_RSP | ATT_PROP_WRITE), UINT16_TO_BYTES(QIOT_DEVICE_INFO_HDL), IOT_BLE_UUID128_DEVICE_INFO}; +uint8_t device_info_rx_char[] = {(ATT_PROP_WRITE_NO_RSP), UINT16_TO_BYTES(QIOT_DEVICE_INFO_HDL), IOT_BLE_UUID128_DEVICE_INFO}; +uint16_t device_info_rx_char_len = sizeof(device_info_rx_char); + +uint8_t device_info_uuid[] = {IOT_BLE_UUID128_DEVICE_INFO}; +uint8_t device_info_attr_value[ATTRIBUTE_VALUE_MAX_LEN] = {0}; +uint16_t device_info_attr_value_len = sizeof(device_info_attr_value); + + +// qiot data characteristic and attribute +// uint8_t data_rx_char[] = {(ATT_PROP_READ | ATT_PROP_WRITE_NO_RSP | ATT_PROP_WRITE), UINT16_TO_BYTES(QIOT_DATA_HDL), IOT_BLE_UUID128_DATA}; +uint8_t data_rx_char[] = {(ATT_PROP_WRITE_NO_RSP), UINT16_TO_BYTES(QIOT_DATA_HDL), IOT_BLE_UUID128_DATA}; +uint16_t data_rx_char_len = sizeof(data_rx_char); + +uint8_t data_uuid[] = {IOT_BLE_UUID128_DATA}; +uint8_t data_attr_value[ATTRIBUTE_VALUE_MAX_LEN] = {0}; +uint16_t data_attr_value_len = sizeof(data_attr_value); + + +// qiot event characteristic and attribute +// uint8_t event_rx_char[] = {(ATT_PROP_READ | ATT_PROP_INDICATE | ATT_PROP_NOTIFY), UINT16_TO_BYTES(QIOT_EVENT_HDL), IOT_BLE_UUID128_EVENT}; +// uint8_t event_rx_char[] = {(ATT_PROP_INDICATE), UINT16_TO_BYTES(QIOT_EVENT_HDL), IOT_BLE_UUID128_EVENT}; +uint8_t event_rx_char[] = {(ATT_PROP_NOTIFY), UINT16_TO_BYTES(QIOT_EVENT_HDL), IOT_BLE_UUID128_EVENT}; +uint16_t event_rx_char_len = sizeof(event_rx_char); + +uint8_t event_uuid[] = {IOT_BLE_UUID128_EVENT}; +uint8_t event_attr_value[ATTRIBUTE_VALUE_MAX_LEN] = {0}; +uint16_t event_attr_value_len = sizeof(event_attr_value); + +uint8_t event_cccd[] = {0x00, 0x00}; +uint16_t event_cccd_len = sizeof(event_cccd); + +/* Attribute list for AMDTP group */ +static const attsAttr_t qiot_attr_list[] = +{ + { + attPrimSvcUuid, + iot_service_uuid, + &iot_service_uuid_len, + sizeof(iot_service_uuid), + 0, + ATTS_PERMIT_READ, + }, + + + // qiot device info characteristic and attribute + { + attChUuid, + device_info_rx_char, + &device_info_rx_char_len, + sizeof(device_info_rx_char), + 0, + ATTS_PERMIT_READ + }, + { + device_info_uuid, + device_info_attr_value, + &device_info_attr_value_len, + sizeof(device_info_attr_value), + (ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK), + // (ATTS_PERMIT_READ | ATTS_PERMIT_WRITE), + ATTS_PERMIT_WRITE, + }, + + + // qiot data characteristic and attribute + { + attChUuid, + data_rx_char, + &data_rx_char_len, + sizeof(data_rx_char), + 0, + ATTS_PERMIT_READ + }, + { + data_uuid, + data_attr_value, + &data_attr_value_len, + sizeof(data_attr_value), + (ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK), + // (ATTS_PERMIT_READ | ATTS_PERMIT_WRITE), + ATTS_PERMIT_WRITE, + }, + + + // qiot event characteristic and attribute + { + attChUuid, + event_rx_char, + &event_rx_char_len, + sizeof(event_rx_char), + 0, + ATTS_PERMIT_READ + }, + { + event_uuid, + event_attr_value, + &event_attr_value_len, + sizeof(event_attr_value), + // (ATTS_SET_UUID_128 | ATTS_SET_VARIABLE_LEN | ATTS_SET_WRITE_CBACK), + // (ATTS_PERMIT_READ | ATTS_PERMIT_WRITE), + 0, + 0, + }, + { + attCliChCfgUuid, + (uint8_t *) event_cccd, + (uint16_t *) &event_cccd_len, + sizeof(event_cccd), + ATTS_SET_CCC, + (ATTS_PERMIT_READ | ATTS_PERMIT_WRITE) + }, +}; + + +static attsGroup_t qiot_attr_group = +{ + NULL, + (attsAttr_t *) &qiot_attr_list, + NULL, + NULL, + QIOT_START_HDL, + QIOT_END_HDL, +}; + +uint8_t qiot_write_cback(dmConnId_t connId, uint16_t handle, uint8_t operation, + uint16_t offset, uint16_t len, uint8_t *pValue, attsAttr_t *pAttr) +{ +// SEGGER_RTT_printf(0, "id %d, hd %d, op %d, of %d \r\n", connId, handle, operation, offset); +// if(pAttr != NULL) +// { +// SEGGER_RTT_printf(0, "uuid %d %d, ml %d, set %d, per %d \r\n", +// pAttr->pUuid[0], +// pAttr->pUuid[1], +// pAttr->maxLen, +// pAttr->settings, +// pAttr->permissions); +// } + + switch (handle) + { + case QIOT_DEVICE_INFO_HDL: + ble_device_info_write_cb(pValue, len); + break; + case QIOT_DATA_HDL: + ble_lldata_write_cb(pValue, len); + break; + case QIOT_EVENT_HDL: + break; + default: + break; + } + return ATT_SUCCESS; +} + +void ble_services_add(const qiot_service_init_s *p_service) +{ + qiot_attr_group.writeCback = qiot_write_cback; + AttsAddGroup(&qiot_attr_group); + // return 0; +} + +int ble_get_product_id(char *product_id) +{ + memcpy(product_id, PRODUCT_ID, strlen(PRODUCT_ID)); + return 0; +} + +int ble_get_device_name(char *device_name) +{ + memcpy(device_name, DEVICE_NAME, strlen(DEVICE_NAME)); + return strlen(DEVICE_NAME); +} + +int ble_get_psk(char *psk) +{ + memcpy(psk, SECRET_KEY, strlen(SECRET_KEY)); + return 0; +} + +int ble_get_mac(char *mac) +{ + mac[0] = 0x99; + mac[1] = 0x98; + mac[2] = 0x97; + mac[3] = 0x96; + mac[4] = 0x95; + mac[5] = 0x94; + + return 0; +} + +// eeprom simulation +uint8_t eeprom[256] = {0}; + +int ble_write_flash(uint32_t flash_addr, const char *write_buf, uint16_t write_len) +{ + memcpy(eeprom, write_buf, write_len); + return write_len; +} + +int ble_read_flash(uint32_t flash_addr, char *read_buf, uint16_t read_len) +{ + memcpy(read_buf, eeprom, read_len); + return read_len; +} + +ble_qiot_ret_status_t ble_advertising_start(adv_info_s *adv) +{ + uint8_t adv_data[31] = {0}; + uint8_t scan_data[31] = {0}; + int adv_p = 0; + int scan_p = 0; + + // adv flag + adv_data[adv_p++] = 2;// length + adv_data[adv_p++] = DM_ADV_TYPE_FLAGS;// AD type + adv_data[adv_p++] = DM_FLAG_LE_GENERAL_DISC | DM_FLAG_LE_BREDR_NOT_SUP;// flags + + // adv deivce name + // adv_data[adv_p++] = strlen(ADV_DEVICE_NAME) + 1; // length + // adv_data[adv_p++] = DM_ADV_TYPE_LOCAL_NAME; + // strncpy(&adv_data[adv_p], ADV_DEVICE_NAME, 31 - adv_p); + // adv_p += strlen(ADV_DEVICE_NAME); + + scan_data[scan_p++] = strlen(ADV_DEVICE_NAME) + 1; // length + scan_data[scan_p++] = DM_ADV_TYPE_LOCAL_NAME; + strncpy((char *)&scan_data[scan_p], ADV_DEVICE_NAME, 31 - scan_p); + scan_p += strlen(ADV_DEVICE_NAME); + + // Complete list of 16 bit UUIDs + adv_data[adv_p++] = 3; + adv_data[adv_p++] = DM_ADV_TYPE_16_UUID; + adv_data[adv_p++] = (uint8_t)adv->uuid_info.uuids[0]; + adv_data[adv_p++] = (uint8_t)(adv->uuid_info.uuids[0] >> 8); + + // adv manufacture data + adv_data[adv_p++] = adv->manufacturer_info.adv_data_len + 3; + adv_data[adv_p++] = DM_ADV_TYPE_MANUFACTURER; + adv_data[adv_p++] = (uint8_t)adv->manufacturer_info.company_identifier; + adv_data[adv_p++] = (uint8_t)(adv->manufacturer_info.company_identifier >> 8); + memcpy(&adv_data[adv_p], adv->manufacturer_info.adv_data, adv->manufacturer_info.adv_data_len); + adv_p += adv->manufacturer_info.adv_data_len; + + // HexDump("adv", adv_data, sizeof(adv_data)); + // AppAdvSetAdValue(); + + /* set advertising and scan response data for discoverable mode */ + AppAdvSetData(APP_ADV_DATA_DISCOVERABLE, adv_p, (uint8_t *) adv_data); + // AppAdvSetData(APP_SCAN_DATA_DISCOVERABLE, sizeof(watchScanDataDisc), (uint8_t *) watchScanDataDisc); + AppAdvSetData(APP_SCAN_DATA_DISCOVERABLE, scan_p, (uint8_t *)scan_data); + + /* set advertising and scan response data for connectable mode */ + AppAdvSetData(APP_ADV_DATA_CONNECTABLE, 0, NULL); + AppAdvSetData(APP_SCAN_DATA_CONNECTABLE, 0, NULL); + + /* start advertising; automatically set connectable/discoverable mode and bondable mode */ + AppAdvStart(APP_MODE_AUTO_INIT); + + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_advertising_stop(void) +{ + AppAdvStop(); + + return BLE_QIOT_RS_OK; +} + +dmConnId_t ind_conn_id = DM_CONN_ID_NONE; + +ble_qiot_ret_status_t ble_send_notify(uint8_t *buf, uint8_t len) +{ + AttsHandleValueNtf(ind_conn_id, QIOT_EVENT_HDL, len, buf); + return BLE_QIOT_RS_OK; +} + + +static wsfTimer_t ble_qiot_timer; +ble_timer_cb p_ble_timer_cb = NULL; + +ble_timer_t ble_timer_create(uint8_t type, ble_timer_cb timeout_handle) +{ + ble_qiot_timer.handlerId = get_wsf_evt_handler(); + p_ble_timer_cb = timeout_handle; + return (ble_timer_t)&ble_qiot_timer; +} + +ble_qiot_ret_status_t ble_timer_start(ble_timer_t timer_id, uint32_t period) +{ + WsfTimerStartMs((wsfTimer_t *)timer_id, period); + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_timer_stop(ble_timer_t timer_id) +{ + WsfTimerStop((wsfTimer_t *)timer_id); + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_timer_delete(ble_timer_t timer_id) +{ + return BLE_QIOT_RS_OK; +} + +// should return ATT_MTU - 3 +uint16_t ble_get_user_data_mtu_size(void) +{ + return AttGetMtu(ind_conn_id) - 3; +} + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/apollo3_service.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/apollo3_service.h new file mode 100644 index 00000000..78884fec --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/apollo3_service.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __APOLLO3_SERVICE_H +#define __APOLLO3_SERVICE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "ble_qiot_export.h" + + +#define QIOT_START_HDL 0x0501 // do not start from 1, gap/gatt characteristic use some hdl from 1 +#define QIOT_END_HDL (QIOT_MAX_HDL - 1) + +enum +{ + QIOT_SVC_HDL = QIOT_START_HDL, + QIOT_DEVICE_INFO_CHAR_HDL, + QIOT_DEVICE_INFO_HDL, + QIOT_DATA_CHAR_HDL, + QIOT_DATA_HDL, + QIOT_EVENT_CHAR_HDL, + QIOT_EVENT_HDL, + QIOT_EVENT_CCC_HDL, + QIOT_MAX_HDL, +}; + +void ble_services_add(const qiot_service_init_s *p_service); + +#ifdef __cplusplus +} +#endif + +#endif // __APOLLO3_SERVICE_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/ble_qiot_config.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/ble_qiot_config.h new file mode 100644 index 00000000..3c8db157 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/ble_qiot_config.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_QIOT_CONFIG_H +#define QCLOUD_BLE_QIOT_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "SEGGER_RTT.h" + +#define BLE_QIOT_SDK_VERSION "1.1.0" // sdk version +#define BLE_QIOT_SDK_DEBUG 0 // sdk debug switch + +// the device broadcast is controlled by the user, but we provide a mechanism to help the device save more power. +// if you want broadcast is triggered by something like press a button instead of all the time, and the broadcast +// stopped automatically in a few minutes if the device is not bind, define BLE_QIOT_BUTTON_BROADCAST is 1 and +// BLE_QIOT_BIND_TIMEOUT is the period that broadcast stopped. +// if the device in the bound state, broadcast dose not stop automatically. +#define BLE_QIOT_BUTTON_BROADCAST 1 +#if (1 == BLE_QIOT_BUTTON_BROADCAST) +#define BLE_QIOT_BIND_TIMEOUT (2 * 60 * 1000) // unit: ms +#endif + +// some data like integer need to be transmitted in a certain byte order, defined it according to your device +#define __ORDER_LITTLE_ENDIAN__ 1234 +#define __ORDER_BIG_ENDIAN__ 4321 +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ + +#define BLE_QIOT_POST_BASE64 1 + +// in some BLE stack ble_qiot_log_hex() maybe not work, user can use there own hexdump function +#define BLE_QIOT_USER_DEFINE_HEDUMP 0 + +#if (1 == BLE_QIOT_USER_DEFINE_HEDUMP) +// add your code here like this +// #define ble_qiot_log_hex(level, hex_name, data, data_len) \ +// do { \ +// MY_RAW_LOG("\r\nble qiot dump: %s, length: %d\r\n", hex_name, data_len); \ +// MY_RAW_HEXDUMP_(data, data_len); \ +// } while(0) + +// or use your own hexdump function with same definition +// void ble_qiot_log_hex(e_ble_qiot_log_level level, const char *hex_name, const char *data, uint32_t data_len); +#endif // BLE_QIOT_USER_DEFINE_HEDUMP + +// Macro for logging a formatted string, the function must printf raw string without any color, prefix, newline or +// timestamp +#define BLE_QIOT_LOG_PRINT(...) SEGGER_RTT_printf(0, __VA_ARGS__) + +// some sdk info needs to stored on the device and the address is up to you +#define BLE_QIOT_RECORD_FLASH_ADDR 0x3f000 + +#ifdef __cplusplus +} +#endif + +#endif // QCLOUD_BLE_QIOT_CONFIG_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/ble_qiot_demo.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/ble_qiot_demo.c new file mode 100644 index 00000000..1d4ee3cc --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/ble_qiot_demo.c @@ -0,0 +1,195 @@ +//***************************************************************************** +// +//! @file ble_freertos_watch.c +//! +//! @brief ARM Cordio BLE - Concurrent Master/Slave Example. +//! +//! Purpose: This example demonstrates an BLE application in the Central role. +//! That is the BLE application operates as a slave to phone master and as the +//! master of subordinate slave devices running freertos_fit example in this SDK. +//! +//! Additional Information: +//! 1. Printing takes place over the ITM at 1M Baud. +//! 2. When the example powers up, +//! 2.A. it enters advertising mode by default to wait for connection from +//! smart phone with Time profile, Alert Notification profile and Phone +//! Alert Status profile supported. +//! 2.B. when BTN2 on Apollo3 EVB is short-pressed, if advertising is on, it +//! stops advertising first and then starts scanning when advertising is +//! stopped; if scanning is on, it stops scanning and re-start advertising +//! when scanning stops. +//! 2.C. During scanning, the device (if discovered) running freertos_fit +//! example in this SDK will be connected and scanning will be stopped. +//! 2.D. Repeat 2.B. and 2.C. above to connect to a new slave device running +//! freertos_fit example (max slaves is 3). +//! 3. when phone (iPhone is used) connects to this example, the services of Time +//! profile, Alert Notification profile and Phone Alert Status profile will be +// subscribed by the example. +// +//***************************************************************************** + +//***************************************************************************** +// +// Copyright (c) 2020, Ambiq Micro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// Third party software included in this distribution is subject to the +// additional license terms as defined in the /docs/licenses directory. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// This is part of revision 2.4.2 of the AmbiqSuite Development Package. +// +//***************************************************************************** + +//***************************************************************************** +// +// This application has a large number of common include files. For +// convenience, we'll collect them all together in a single header and include +// that everywhere. +// +//***************************************************************************** +#include "ble_qiot_demo.h" +#include "rtos.h" + +#include "SEGGER_RTT.h" + +#include "ble_qiot_export.h" + +//***************************************************************************** +// +// Enable printing to the console. +// +//***************************************************************************** +void +enable_print_interface(void) +{ + // + // Initialize a debug printing interface. + // + am_bsp_itm_printf_enable(); +} + +//***************************************************************************** +// +// Main Function +// +//***************************************************************************** +int +main(void) +{ + SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL); + // SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_SKIP); + SEGGER_RTT_WriteString(0, ">>>> Tencent ble qiot demo start <<<<\r\n"); + + // + // Set the clock frequency + // + am_hal_clkgen_control(AM_HAL_CLKGEN_CONTROL_SYSCLK_MAX, 0); + + // + // Set the default cache configuration + // + am_hal_cachectrl_config(&am_hal_cachectrl_defaults); + am_hal_cachectrl_enable(); + +#ifndef NOFPU + // + // Enable the floating point module, and configure the core for lazy + // stacking. + // + am_hal_sysctrl_fpu_enable(); + am_hal_sysctrl_fpu_stacking_enable(true); +#else + am_hal_sysctrl_fpu_disable(); +#endif + + // + // Configure the board for low power. + // + am_bsp_low_power_init(); + + // Turn off unused Flash & SRAM + +#ifdef AM_PART_APOLLO + // + // SRAM bank power setting. + // Need to match up with actual SRAM usage for the program + // Current usage is between 32K and 40K - so disabling upper 3 banks + // + am_hal_mcuctrl_sram_power_set(AM_HAL_MCUCTRL_SRAM_POWER_DOWN_5 | + AM_HAL_MCUCTRL_SRAM_POWER_DOWN_6 | + AM_HAL_MCUCTRL_SRAM_POWER_DOWN_7, + AM_HAL_MCUCTRL_SRAM_POWER_DOWN_5 | + AM_HAL_MCUCTRL_SRAM_POWER_DOWN_6 | + AM_HAL_MCUCTRL_SRAM_POWER_DOWN_7); + +#if 0 // Not turning off the Flash as it may be needed to download the image + // + // Flash bank power set. + // + am_hal_mcuctrl_flash_power_set(AM_HAL_MCUCTRL_FLASH_POWER_DOWN_1); +#endif +#endif // AM_PART_APOLLO + +#ifdef AM_PART_APOLLO2 +#if 0 // Not turning off the Flash as it may be needed to download the image + am_hal_pwrctrl_memory_enable(AM_HAL_PWRCTRL_MEMEN_FLASH512K); +#endif + am_hal_pwrctrl_memory_enable(AM_HAL_PWRCTRL_MEMEN_SRAM64K); +#endif // AM_PART_APOLLO2 + + // + // Enable printing to the console. + // +#ifdef AM_DEBUG_PRINTF + enable_print_interface(); +#endif + + // + // Initialize plotting interface. + // + am_util_debug_printf("FreeRTOS Watch Example\n"); + + // ble_services_add(service_info); + // ble_qiot_explorer_init(); + // conn_params_init(); + + // + // Run the application. + // + run_tasks(); + + // + // We shouldn't ever get here. + // + while (1) + { + } + +} + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/ble_qiot_demo.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/ble_qiot_demo.h new file mode 100644 index 00000000..f8fe264b --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/ble_qiot_demo.h @@ -0,0 +1,89 @@ +//***************************************************************************** +// +//! @file freertos_fit.h +//! +//! @brief Global includes for the freertos_fit app. +// +//***************************************************************************** + +//***************************************************************************** +// +// Copyright (c) 2020, Ambiq Micro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// Third party software included in this distribution is subject to the +// additional license terms as defined in the /docs/licenses directory. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// This is part of revision 2.4.2 of the AmbiqSuite Development Package. +// +//***************************************************************************** + +#ifndef FREERTOS_WATCH_H +#define FREERTOS_WATCH_H + +//***************************************************************************** +// +// Required built-ins. +// +//***************************************************************************** +#include +#include +#include +#include + +//***************************************************************************** +// +// Standard AmbiqSuite includes. +// +//***************************************************************************** +#include "am_mcu_apollo.h" +#include "am_bsp.h" +#include "am_util.h" + +//***************************************************************************** +// +// FreeRTOS include files. +// +//***************************************************************************** +#include "FreeRTOS.h" +#include "task.h" +#include "portmacro.h" +#include "portable.h" +#include "semphr.h" +#include "event_groups.h" +//#include "rtos.h" + +//***************************************************************************** +// +// Task include files. +// +//***************************************************************************** +#include "radio_task.h" + +#endif // FREERTOS_FIT_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/hci_apollo_config.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/hci_apollo_config.h new file mode 100644 index 00000000..de73ac9e --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/hci_apollo_config.h @@ -0,0 +1,77 @@ +//***************************************************************************** +// +//! @file hci_apollo_config.h +//! +//! @brief This file describes the physical aspects of the HCI conection. +// +//***************************************************************************** + +//***************************************************************************** +// +// Copyright (c) 2020, Ambiq Micro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// Third party software included in this distribution is subject to the +// additional license terms as defined in the /docs/licenses directory. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// This is part of revision 2.4.2 of the AmbiqSuite Development Package. +// +//***************************************************************************** + +#include +#include "am_bsp.h" + +#ifndef HCI_APOLLO_CONFIG_H +#define HCI_APOLLO_CONFIG_H + +//***************************************************************************** +// +// Pin numbers and configuration. +// +// NOTE: RTS, CTS, and RESET are implemented as GPIOs, so no "CFG" field is +// needed. +// +//***************************************************************************** +//#define HCI_APOLLO_POWER_PIN AM_BSP_GPIO_EM9304_POWER +//#define HCI_APOLLO_POWER_CFG AM_BSP_GPIO_CFG_EM9304_POWER + +#define HCI_APOLLO_RESET_PIN AM_BSP_GPIO_EM9304_RESET + +//***************************************************************************** +// +// Other options. +// +// These options are provided in case your board setup is a little more +// unusual. Most boards shouldn't need these features. If in doubt, leave all +// of these features disabled. +// +//***************************************************************************** +#define HCI_APOLLO_CFG_OVERRIDE_ISR 1 // Override the exactle UART ISR + +#endif // HCI_APOLLO_CONFIG_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/radio_task.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/radio_task.c new file mode 100644 index 00000000..893021ae --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/radio_task.c @@ -0,0 +1,403 @@ +//***************************************************************************** +// +//! @file radio_task.c +//! +//! @brief Task to handle radio operation. +//! +//***************************************************************************** + +//***************************************************************************** +// +// Copyright (c) 2020, Ambiq Micro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// Third party software included in this distribution is subject to the +// additional license terms as defined in the /docs/licenses directory. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// This is part of revision 2.4.2 of the AmbiqSuite Development Package. +// +//***************************************************************************** + +//***************************************************************************** +// +// Global includes for this project. +// +//***************************************************************************** +#include "ble_qiot_demo.h" + +//***************************************************************************** +// +// WSF standard includes. +// +//***************************************************************************** +#include "wsf_types.h" +#include "wsf_trace.h" +#include "wsf_buf.h" +#include "wsf_timer.h" + +//***************************************************************************** +// +// Includes for operating the ExactLE stack. +// +//***************************************************************************** +#include "hci_handler.h" +#include "dm_handler.h" +#include "l2c_handler.h" +#include "att_handler.h" +#include "smp_handler.h" +#include "l2c_api.h" +#include "att_api.h" +#include "smp_api.h" +#include "app_api.h" +#include "hci_core.h" +#include "hci_drv.h" +#include "hci_drv_apollo.h" +#include "hci_drv_apollo3.h" +#include "hci_apollo_config.h" + +#include "wsf_msg.h" + +//***************************************************************************** +// +// +//***************************************************************************** +#include "watch_api.h" +#include "app_ui.h" + +//***************************************************************************** +// +// Radio task handle. +// +//***************************************************************************** +TaskHandle_t radio_task_handle; + +//***************************************************************************** +// +// Function prototypes +// +//***************************************************************************** +void exactle_stack_init(void); +void button_handler(wsfEventMask_t event, wsfMsgHdr_t *pMsg); +void setup_buttons(void); +//***************************************************************************** +// +// Timer for buttons. +// +//***************************************************************************** +wsfHandlerId_t ButtonHandlerId; +wsfTimer_t ButtonTimer; + +//***************************************************************************** +// +// WSF buffer pools. +// +//***************************************************************************** +#define WSF_BUF_POOLS 4 + +// Important note: the size of g_pui32BufMem should includes both overhead of internal +// buffer management structure, wsfBufPool_t (up to 16 bytes for each pool), and pool +// description (e.g. g_psPoolDescriptors below). + +// Memory for the buffer pool +// extra AMOTA_PACKET_SIZE bytes for OTA handling +static uint32_t g_pui32BufMem[ + (WSF_BUF_POOLS*16 + + 16*8 + 32*4 + 64*6 + 280*8) / sizeof(uint32_t)]; + +// Default pool descriptor. +static wsfBufPoolDesc_t g_psPoolDescriptors[WSF_BUF_POOLS] = +{ + { 16, 8 }, + { 32, 4 }, + { 64, 6 }, + { 280, 8 } +}; + +//***************************************************************************** +// +// Tracking variable for the scheduler timer. +// +//***************************************************************************** + +void radio_timer_handler(void); + + + +//***************************************************************************** +// +// Poll the buttons. +// +//***************************************************************************** +void +button_handler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) +{ + // + // Restart the button timer. + // + WsfTimerStartMs(&ButtonTimer, 10); + + // + // Every time we get a button timer tick, check all of our buttons. + // + am_devices_button_array_tick(am_bsp_psButtons, AM_BSP_NUM_BUTTONS); + + // + // If we got a a press, do something with it. + // + if ( am_devices_button_released(am_bsp_psButtons[0]) ) + { + am_util_debug_printf("Got Button 0 Press\n"); + AppUiBtnTest(APP_UI_BTN_1_SHORT); + } + + if ( am_devices_button_released(am_bsp_psButtons[1]) ) + { + am_util_debug_printf("Got Button 1 Press\n"); + AppUiBtnTest(APP_UI_BTN_1_SHORT); + } + + if ( am_devices_button_released(am_bsp_psButtons[2]) ) + { + am_util_debug_printf("Got Button 2 Press\n"); + } +} + + + +//***************************************************************************** +// +// Sets up a button interface. +// +//***************************************************************************** +void +setup_buttons(void) +{ + // + // Enable the buttons for user interaction. + // + am_devices_button_array_init(am_bsp_psButtons, AM_BSP_NUM_BUTTONS); + + // + // Start a timer. + // + ButtonTimer.handlerId = ButtonHandlerId; + WsfTimerStartSec(&ButtonTimer, 2); +} + + +//***************************************************************************** +// +// Initialization for the ExactLE stack. +// +//***************************************************************************** +void +exactle_stack_init(void) +{ + wsfHandlerId_t handlerId; + uint16_t wsfBufMemLen; + // + // Set up timers for the WSF scheduler. + // + WsfOsInit(); + WsfTimerInit(); + + // + // Initialize a buffer pool for WSF dynamic memory needs. + // + wsfBufMemLen = WsfBufInit(sizeof(g_pui32BufMem), (uint8_t *)g_pui32BufMem, WSF_BUF_POOLS, + g_psPoolDescriptors); + + if (wsfBufMemLen > sizeof(g_pui32BufMem)) + { + am_util_debug_printf("Memory pool is too small by %d\r\n", + wsfBufMemLen - sizeof(g_pui32BufMem)); + } + + // + // Initialize the WSF security service. + // + SecInit(); + SecAesInit(); + SecCmacInit(); + SecEccInit(); + + // + // Set up callback functions for the various layers of the ExactLE stack. + // + handlerId = WsfOsSetNextHandler(HciHandler); + HciHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(DmHandler); + DmDevVsInit(0); + DmAdvInit(); + DmScanInit(); + DmConnInit(); + DmConnMasterInit(); + DmConnSlaveInit(); + DmSecInit(); + DmSecLescInit(); + DmPrivInit(); + DmHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(L2cSlaveHandler); + L2cSlaveHandlerInit(handlerId); + L2cInit(); + L2cSlaveInit(); + L2cMasterInit(); + + handlerId = WsfOsSetNextHandler(AttHandler); + AttHandlerInit(handlerId); + AttsInit(); + AttsIndInit(); + AttcInit(); + + handlerId = WsfOsSetNextHandler(SmpHandler); + SmpHandlerInit(handlerId); + SmpiInit(); + SmpiScInit(); + SmprInit(); + SmprScInit(); + HciSetMaxRxAclLen(251); + + handlerId = WsfOsSetNextHandler(AppHandler); + AppHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(WatchHandler); + WatchHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(HciDrvHandler); + HciDrvHandlerInit(handlerId); + + ButtonHandlerId = WsfOsSetNextHandler(button_handler); + +} + +//***************************************************************************** +// +// UART interrupt handler. +// +//***************************************************************************** +void +am_uart_isr(void) +{ + uint32_t ui32Status; + + // + // Read and save the interrupt status, but clear out the status register. + // + ui32Status = UARTn(0)->MIS; + UARTn(0)->IEC = ui32Status; + + // + // Allow the HCI driver to respond to the interrupt. + // + //HciDrvUartISR(ui32Status); + + // Signal radio task to run + + WsfTaskSetReady(0, 0); +} + +//***************************************************************************** +// +// Interrupt handler for BLE +// +//***************************************************************************** +void +am_ble_isr(void) +{ + + HciDrvIntService(); + + // Signal radio task to run + + WsfTaskSetReady(0, 0); +} + +//***************************************************************************** +// +// Perform initial setup for the radio task. +// +//***************************************************************************** +void +RadioTaskSetup(void) +{ + am_util_debug_printf("RadioTask: setup\r\n"); + + + NVIC_SetPriority(BLE_IRQn, NVIC_configMAX_SYSCALL_INTERRUPT_PRIORITY); + + // + // Boot the radio. + // + HciDrvRadioBoot(1); +} + +//***************************************************************************** +// +// Short Description. +// +//***************************************************************************** +void +RadioTask(void *pvParameters) +{ +#if WSF_TRACE_ENABLED == TRUE + // + // Enable ITM + // + am_util_debug_printf("Starting wicentric trace:\n\n"); +#endif + + // + // Initialize the main ExactLE stack. + // + exactle_stack_init(); + + // + // Prep the buttons for use + // + + setup_buttons(); + + // + // Start the "Ancs" profile. + // + WatchStart(); + + while (1) + { + + // + // Calculate the elapsed time from our free-running timer, and update + // the software timers in the WSF scheduler. + // + wsfOsDispatcher(); + + } +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/radio_task.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/radio_task.h new file mode 100644 index 00000000..1bc0f544 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/radio_task.h @@ -0,0 +1,65 @@ +//***************************************************************************** +// +//! @file radio_task.h +//! +//! @brief Functions and variables related to the radio task. +//! +//***************************************************************************** + +//***************************************************************************** +// +// Copyright (c) 2020, Ambiq Micro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// Third party software included in this distribution is subject to the +// additional license terms as defined in the /docs/licenses directory. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// This is part of revision 2.4.2 of the AmbiqSuite Development Package. +// +//***************************************************************************** + +#ifndef RADIO_TASK_H +#define RADIO_TASK_H + +//***************************************************************************** +// +// Radio task handle. +// +//***************************************************************************** +extern TaskHandle_t radio_task_handle; + +//***************************************************************************** +// +// External function definitions. +// +//***************************************************************************** +extern void RadioTaskSetup(void); +extern void RadioTask(void *pvParameters); + +#endif // RADIO_TASK_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/rtos.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/rtos.c new file mode 100644 index 00000000..a6ca4494 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/rtos.c @@ -0,0 +1,214 @@ +//***************************************************************************** +// +//! @file rtos.c +//! +//! @brief Essential functions to make the RTOS run correctly. +//! +//! These functions are required by the RTOS for ticking, sleeping, and basic +//! error checking. +// +//***************************************************************************** + +//***************************************************************************** +// +// Copyright (c) 2020, Ambiq Micro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// Third party software included in this distribution is subject to the +// additional license terms as defined in the /docs/licenses directory. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// This is part of revision 2.4.2 of the AmbiqSuite Development Package. +// +//***************************************************************************** + +#include +#include + +#include "am_mcu_apollo.h" +#include "am_bsp.h" + +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "portmacro.h" +#include "portable.h" +#include "ble_qiot_demo.h" + +//***************************************************************************** +// +// Task handle for the initial setup task. +// +//***************************************************************************** +TaskHandle_t xSetupTask; + +//***************************************************************************** +// +// Interrupt handler for the CTIMER module. +// +//***************************************************************************** +void +am_ctimer_isr(void) +{ + uint32_t ui32Status; + + // + // Check the timer interrupt status. + // + ui32Status = am_hal_ctimer_int_status_get(false); + am_hal_ctimer_int_clear(ui32Status); + + // + // Run handlers for the various possible timer events. + // + am_hal_ctimer_int_service(ui32Status); +} + +//***************************************************************************** +// +// Sleep function called from FreeRTOS IDLE task. +// Do necessary application specific Power down operations here +// Return 0 if this function also incorporates the WFI, else return value same +// as idleTime +// +//***************************************************************************** +uint32_t am_freertos_sleep(uint32_t idleTime) +{ + am_hal_sysctrl_sleep(AM_HAL_SYSCTRL_SLEEP_DEEP); + return 0; +} + +//***************************************************************************** +// +// Recovery function called from FreeRTOS IDLE task, after waking up from Sleep +// Do necessary 'wakeup' operations here, e.g. to power up/enable peripherals etc. +// +//***************************************************************************** +void am_freertos_wakeup(uint32_t idleTime) +{ + return; +} + + +//***************************************************************************** +// +// FreeRTOS debugging functions. +// +//***************************************************************************** +void +vApplicationMallocFailedHook(void) +{ + // + // Called if a call to pvPortMalloc() fails because there is insufficient + // free memory available in the FreeRTOS heap. pvPortMalloc() is called + // internally by FreeRTOS API functions that create tasks, queues, software + // timers, and semaphores. The size of the FreeRTOS heap is set by the + // configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. + // + while (1); +} + +void +vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName) +{ + (void) pcTaskName; + (void) pxTask; + + // + // Run time stack overflow checking is performed if + // configconfigCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook + // function is called if a stack overflow is detected. + // + while (1) + { + __asm("BKPT #0\n") ; // Break into the debugger + } +} + +//***************************************************************************** +// +// High priority task to run immediately after the scheduler starts. +// +// This task is used for any global initialization that must occur after the +// scheduler starts, but before any functional tasks are running. This can be +// useful for enabling events, semaphores, and other global, RTOS-specific +// features. +// +//***************************************************************************** +void +setup_task(void *pvParameters) +{ + // + // Print a debug message. + // + am_util_debug_printf("Running setup tasks...\r\n"); + + // + // Run setup functions. + // + RadioTaskSetup(); + + // + // Create the functional tasks + // + xTaskCreate(RadioTask, "RadioTask", 512, 0, 3, &radio_task_handle); + + // + // The setup operations are complete, so suspend the setup task now. + // + vTaskSuspend(NULL); + + while (1); +} + +//***************************************************************************** +// +// Initializes all tasks +// +//***************************************************************************** +void +run_tasks(void) +{ + // + // Set some interrupt priorities before we create tasks or start the scheduler. + // + // Note: Timer priority is handled by the FreeRTOS kernel, so we won't + // touch it here. + // + + // + // Create essential tasks. + // + xTaskCreate(setup_task, "Setup", 512, 0, 3, &xSetupTask); + + // + // Start the scheduler. + // + vTaskStartScheduler(); +} + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/rtos.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/rtos.h new file mode 100644 index 00000000..9a107b67 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/rtos.h @@ -0,0 +1,75 @@ +//***************************************************************************** +// +//! @file rtos.h +//! +//! @brief Essential functions to make the RTOS run +// +//***************************************************************************** + +//***************************************************************************** +// +// Copyright (c) 2020, Ambiq Micro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// Third party software included in this distribution is subject to the +// additional license terms as defined in the /docs/licenses directory. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// This is part of revision 2.4.2 of the AmbiqSuite Development Package. +// +//***************************************************************************** +#ifndef RTOS_H +#define RTOS_H + +#ifdef __cplusplus +extern "C" +{ +#endif +//***************************************************************************** +// +// Macro definitions +// +//***************************************************************************** + +// External variable definitions +// +//***************************************************************************** + +//***************************************************************************** +// +// External function definitions +// +//***************************************************************************** +void run_tasks(void); + +#ifdef __cplusplus +} +#endif + +#endif // RTOS_H + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/watch_api.h b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/watch_api.h new file mode 100644 index 00000000..a961884d --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/watch_api.h @@ -0,0 +1,80 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Watch sample application interface. + * + * Copyright (c) 2011-2018 Arm Ltd. + * + * Copyright (c) 2019 Packetcraft, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*************************************************************************************************/ +#ifndef WATCH_API_H +#define WATCH_API_H + +#include "wsf_os.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************************************** + Function Declarations +**************************************************************************************************/ +/*************************************************************************************************/ +/*! + * \brief Start the application. + * + * \return None. + */ +/*************************************************************************************************/ +void WatchStart(void); + +/*************************************************************************************************/ +/*! + * \brief Application handler init function called during system initialization. + * + * \param handlerID WSF handler ID for App. + * + * \return None. + */ +/*************************************************************************************************/ +void WatchHandlerInit(wsfHandlerId_t handlerId); + + +/*************************************************************************************************/ +/*! + * \brief WSF event handler for the application. + * + * \param event WSF event mask. + * \param pMsg WSF message. + * + * \return None. + */ +/*************************************************************************************************/ +void WatchHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg); + +/** + * @brief Get the handler object of WSF event handler for the application + * + * @return wsfHandlerId_t + */ +wsfHandlerId_t get_wsf_evt_handler(void); + +#ifdef __cplusplus +}; +#endif + +#endif /* WATCH_API_H */ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/watch_main.c b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/watch_main.c new file mode 100644 index 00000000..43298f3f --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/lifesense/src/watch_main.c @@ -0,0 +1,1527 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Watch sample application for the following profiles: + * Time profile client + * Alert Notification profile client + * Phone Alert Status profile client + * + * Copyright (c) 2011-2019 Arm Ltd. + * + * Copyright (c) 2019 Packetcraft, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*************************************************************************************************/ + +#include +#include "wsf_types.h" +#include "util/bstream.h" +#include "wsf_msg.h" +#include "wsf_trace.h" +#include "wsf_assert.h" +#include "hci_api.h" +#include "dm_api.h" +#include "att_api.h" +#include "smp_api.h" +#include "app_cfg.h" +#include "app_api.h" +#include "app_db.h" +#include "app_ui.h" +#include "app_main.h" +#include "svc_core.h" +#include "svc_ch.h" +#include "gatt/gatt_api.h" +#include "tipc/tipc_api.h" +#include "anpc/anpc_api.h" +#include "paspc/paspc_api.h" +#include "hrpc/hrpc_api.h" +#include "dis/dis_api.h" + +#include "ble_qiot_llsync_device.h" +#include "ble_qiot_service.h" +#include "ble_qiot_import.h" +#include "ble_qiot_config.h" +#include "apollo3_service.h" + +/************************************************************************************************** + Local Variables +**************************************************************************************************/ +typedef enum +{ + WATCH_SCAN_NONE, + WATCH_SCAN_START, + WATCH_SCANNING +} eWatchScanState; +/*! application control block */ +static struct +{ + uint16_t hdlMasterList[APP_DB_HDL_LIST_LEN]; /*! Cached handle list in master role */ + uint16_t hdlSlaveList[APP_DB_HDL_LIST_LEN]; /*! Cached handle list in slave role */ + wsfHandlerId_t handlerId; /*! WSF hander ID */ + uint8_t discState; /*! Service discovery state */ + eWatchScanState scan_state; + bool_t autoConnect; /*! TRUE if auto-connecting */ +} watchCb; + +/*! \brief application connection information */ +typedef struct +{ + appDbHdl_t dbHdl; /*! Device database record handle type */ + uint8_t addrType; /*! Type of address of device to connect to */ + bdAddr_t addr; /*! Address of device to connect to */ + bool_t doConnect; /*! TRUE to issue connect on scan complete */ + int8_t rssi; /*! RSSI of discovered remote device */ +} watchConnInfo_t; + +watchConnInfo_t watchConnInfo; + +/************************************************************************************************** + Configurable Parameters +**************************************************************************************************/ + +/*! configurable parameters for advertising */ +static const appAdvCfg_t watchAdvCfg = + { + {0, 0, 0}, /*! Advertising durations in ms */ + {160, 800, 0} /*! Advertising intervals in 0.625 ms units */ +}; + +/*! configurable parameters for slave */ +static const appSlaveCfg_t watchSlaveCfg = + { + 1, /*! Maximum connections */ +}; + +/*! configurable parameters for security */ +static const appSecCfg_t watchSecCfg = + { + DM_AUTH_BOND_FLAG, /*! Authentication and bonding flags */ + 0, /*! Initiator key distribution flags */ + DM_KEY_DIST_LTK, /*! Responder key distribution flags */ + FALSE, /*! TRUE if Out-of-band pairing data is present */ + FALSE /*! TRUE to initiate security upon connection */ +}; + +/*! configurable parameters for connection parameter update */ +static const appUpdateCfg_t watchUpdateCfg = + { + 0, /*! Connection idle period in ms before attempting + connection parameter update; set to zero to disable */ + 600, /*! Minimum connection interval in 1.25ms units */ + 800, /*! Maximum connection interval in 1.25ms units */ + 3, /*! Connection latency */ + 600, /*! Supervision timeout in 10ms units */ + 5 /*! Number of update attempts before giving up */ +}; + +/*! Connection parameters */ +static const hciConnSpec_t watchConnCfg = + { + 160, /*! Minimum connection interval in 1.25ms units */ + 160, /*! Maximum connection interval in 1.25ms units */ + 0, /*! Connection latency */ + 600, /*! Supervision timeout in 10ms units */ + 0, /*! Unused */ + 0 /*! Unused */ +}; + +/*! SMP security parameter configuration */ +/* Configuration structure */ +static const smpCfg_t watchSmpCfg = + { + 3000, /*! 'Repeated attempts' timeout in msec */ + SMP_IO_NO_IN_NO_OUT, /*! I/O Capability */ + 7, /*! Minimum encryption key length */ + 16, /*! Maximum encryption key length */ + 3, /*! Attempts to trigger 'repeated attempts' timeout */ + 0, /*! Device authentication requirements */ + 64000, /*! Maximum repeated attempts timeout in msec */ + 64000, /*! Time msec before attemptExp decreases */ + 2 /*! Repeated attempts multiplier exponent */ +}; + +/*! Configurable parameters for service and characteristic discovery */ +static const appDiscCfg_t watchDiscCfg = + { + FALSE, /*! TRUE to wait for a secure connection before initiating discovery */ + FALSE /*! TRUE to fall back on database hash to verify handles when no bond exists. */ +}; + +static const appCfg_t watchAppCfg = + { + TRUE, /*! TRUE to abort service discovery if service not found */ + TRUE /*! TRUE to disconnect if ATT transaction times out */ +}; + +/*! configurable parameters for master */ +static const appMasterCfg_t watchMasterCfg = + { + 96, /*! The scan interval, in 0.625 ms units */ + 48, /*! The scan window, in 0.625 ms units */ + 4000, /*! The scan duration in ms */ + DM_DISC_MODE_NONE, /*! The GAP discovery mode */ + DM_SCAN_TYPE_ACTIVE /*! The scan type (active or passive) */ +}; + +/************************************************************************************************** + Advertising Data +**************************************************************************************************/ + +/*! advertising data, discoverable mode */ +static const uint8_t watchAdvDataDisc[] = + { + /*! flags */ + 2, /*! length */ + DM_ADV_TYPE_FLAGS, /*! AD type */ + DM_FLAG_LE_LIMITED_DISC | /*! flags */ + DM_FLAG_LE_BREDR_NOT_SUP, + + /*! tx power */ + 2, /*! length */ + DM_ADV_TYPE_TX_POWER, /*! AD type */ + 0, /*! tx power */ + + /*! manufacturer specific data */ + 3, /*! length */ + DM_ADV_TYPE_MANUFACTURER, /*! AD type */ + UINT16_TO_BYTES(HCI_ID_ARM), /*! company ID */ + + /*! service solicitation UUID list */ + 7, /*! length */ + DM_ADV_TYPE_16_SOLICIT, /*! AD type */ + UINT16_TO_BYTES(ATT_UUID_CURRENT_TIME_SERVICE), + UINT16_TO_BYTES(ATT_UUID_ALERT_NOTIF_SERVICE), + UINT16_TO_BYTES(ATT_UUID_PHONE_ALERT_SERVICE)}; + +/*! scan data, discoverable mode */ +static const uint8_t watchScanDataDisc[] = + { + /*! device name */ + 6, /*! length */ + DM_ADV_TYPE_LOCAL_NAME, /*! AD type */ + 'W', + 'a', + 't', + 'c', + 'h'}; + +/************************************************************************************************** + ATT Client Discovery Data +**************************************************************************************************/ + +/*! Discovery states: enumeration of services to be discovered */ +enum +{ + WATCH_DISC_SLAVE_GATT_SVC, /* GATT service */ + WATCH_DISC_SLAVE_CTS_SVC, /* Current Time service */ + WATCH_DISC_SLAVE_ANS_SVC, /* Alert Notification service */ + WATCH_DISC_SLAVE_PASS_SVC, /* Phone Alert Status service */ + WATCH_DISC_SLAVE_SVC_MAX /* Discovery complete */ +}; + +/*! Discovery states: enumeration of services to be discovered in the master role */ +enum +{ + WATCH_DISC_MASTER_GATT_SVC, /* GATT service */ + WATCH_DISC_MASTER_DIS_SVC, /* Device Information service */ + WATCH_DISC_MASTER_HRS_SVC, /* Heart Rate service */ +}; + +/*! the Client handle list, watchCb.hdlList[], is set as follows: + * + * ------------------------------- <- WATCH_DISC_GATT_START + * | GATT handles | + * |... | + * ------------------------------- <- WATCH_DISC_CTS_START + * | CTS handles | + * | ... | + * ------------------------------- <- WATCH_DISC_ANS_START + * | ANS handles | + * | ... | + * ------------------------------- <- WATCH_DISC_PASS_START + * | PASS handles | + * | ... | + * ------------------------------- + */ + +/*! Start of each service's handles in the the handle list */ +#define WATCH_DISC_GATT_START 0 +#define WATCH_DISC_CTS_START (WATCH_DISC_GATT_START + GATT_HDL_LIST_LEN) +#define WATCH_DISC_ANS_START (WATCH_DISC_CTS_START + TIPC_CTS_HDL_LIST_LEN) +#define WATCH_DISC_PASS_START (WATCH_DISC_ANS_START + ANPC_ANS_HDL_LIST_LEN) +#define WATCH_DISC_SLAVE_HDL_LIST_LEN (WATCH_DISC_PASS_START + PASPC_PASS_HDL_LIST_LEN) + +/*! Pointers into handle list for each service's handles */ +static uint16_t *pWatchSlvGattHdlList = &watchCb.hdlSlaveList[WATCH_DISC_GATT_START]; +static uint16_t *pWatchCtsHdlList = &watchCb.hdlSlaveList[WATCH_DISC_CTS_START]; +static uint16_t *pWatchAnsHdlList = &watchCb.hdlSlaveList[WATCH_DISC_ANS_START]; +static uint16_t *pWatchPassHdlList = &watchCb.hdlSlaveList[WATCH_DISC_PASS_START]; + +/* Start of cached heart rate service handles; begins after GATT - Master Role */ +#define WATCH_DISC_DISC_START (WATCH_DISC_GATT_START + GATT_HDL_LIST_LEN) +#define WATCH_DISC_HRS_START (WATCH_DISC_DISC_START + DIS_HDL_LIST_LEN) +#define WATCH_DISC_MASTER_HDL_LIST_LEN (WATCH_DISC_HRS_START + HRPC_HRS_HDL_LIST_LEN) + +/*! Pointers into handle list heart rate service handles - Master Role */ +static uint16_t *pWatchMstGattHdlList = &watchCb.hdlMasterList[WATCH_DISC_GATT_START]; +static uint16_t *pWatchDisHdlList = &watchCb.hdlMasterList[WATCH_DISC_DISC_START]; +static uint16_t *pWatchHrsHdlList = &watchCb.hdlMasterList[WATCH_DISC_HRS_START]; + +/* sanity check: make sure handle list length is <= app db handle list length */ +WSF_CT_ASSERT(WATCH_DISC_SLAVE_HDL_LIST_LEN <= APP_DB_HDL_LIST_LEN); +WSF_CT_ASSERT(WATCH_DISC_MASTER_HDL_LIST_LEN <= APP_DB_HDL_LIST_LEN); + +/************************************************************************************************** + ATT Client Configuration Data +**************************************************************************************************/ + +/* + * Data for configuration after service discovery + */ + +/* Default value for CCC indications */ +static const uint8_t watchCccIndVal[] = {UINT16_TO_BYTES(ATT_CLIENT_CFG_INDICATE)}; + +/* Default value for CCC notifications */ +static const uint8_t watchCccNtfVal[] = {UINT16_TO_BYTES(ATT_CLIENT_CFG_NOTIFY)}; + +/* Default value for Client Supported Features (enable Robust Caching) */ +static const uint8_t watchCsfVal[1] = {ATTS_CSF_ROBUST_CACHING}; + +/* ANS Control point value for "Enable New Alert Notification" */ +static const uint8_t watchAncpEnNewVal[] = {CH_ANCP_ENABLE_NEW, CH_ALERT_CAT_ID_ALL}; + +/* ANS Control point value for "Notify New Alert Immediately" */ +static const uint8_t watchAncpNotNewVal[] = {CH_ANCP_NOTIFY_NEW, CH_ALERT_CAT_ID_ALL}; + +/* ANS Control point value for "Enable Unread Alert Status Notification" */ +static const uint8_t watchAncpEnUnrVal[] = {CH_ANCP_ENABLE_UNREAD, CH_ALERT_CAT_ID_ALL}; + +/* ANS Control point value for "Notify Unread Alert Status Immediately" */ +static const uint8_t watchAncpNotUnrVal[] = {CH_ANCP_NOTIFY_UNREAD, CH_ALERT_CAT_ID_ALL}; + +/* HRS Control point "Reset Energy Expended" */ +static const uint8_t watchHrsRstEnExp[] = {CH_HRCP_RESET_ENERGY_EXP}; + +/* List of characteristics to configure after service discovery */ +static const attcDiscCfg_t watchDiscSlaveCfgList[] = + { + /* Read: CTS Current time */ + {NULL, 0, (TIPC_CTS_CT_HDL_IDX + WATCH_DISC_CTS_START)}, + + /* Read: CTS Local time information */ + {NULL, 0, (TIPC_CTS_LTI_HDL_IDX + WATCH_DISC_CTS_START)}, + + /* Read: CTS Reference time information */ + {NULL, 0, (TIPC_CTS_RTI_HDL_IDX + WATCH_DISC_CTS_START)}, + + /* Read: ANS Supported new alert category */ + {NULL, 0, (ANPC_ANS_SNAC_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Read: ANS Supported unread alert category */ + {NULL, 0, (ANPC_ANS_SUAC_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Read: PASS Alert status */ + {NULL, 0, (PASPC_PASS_AS_HDL_IDX + WATCH_DISC_PASS_START)}, + + /* Read: PASS Ringer setting */ + {NULL, 0, (PASPC_PASS_RS_HDL_IDX + WATCH_DISC_PASS_START)}, + + /* Write: GATT service changed ccc descriptor */ + {watchCccIndVal, sizeof(watchCccIndVal), (GATT_SC_CCC_HDL_IDX + WATCH_DISC_GATT_START)}, + + /* Write: GATT client supported features */ + {watchCsfVal, sizeof(watchCsfVal), (GATT_CSF_HDL_IDX + WATCH_DISC_GATT_START)}, + + /* Write: CTS Current time ccc descriptor */ + {watchCccNtfVal, sizeof(watchCccNtfVal), (TIPC_CTS_CT_CCC_HDL_IDX + WATCH_DISC_CTS_START)}, + + /* Write: ANS New alert ccc descriptor */ + {watchCccNtfVal, sizeof(watchCccNtfVal), (ANPC_ANS_NA_CCC_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Write: ANS Unread alert status ccc descriptor */ + {watchCccNtfVal, sizeof(watchCccNtfVal), (ANPC_ANS_UAS_CCC_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Write: PASS Alert status ccc descriptor */ + {watchCccNtfVal, sizeof(watchCccNtfVal), (PASPC_PASS_AS_CCC_HDL_IDX + WATCH_DISC_PASS_START)}, + + /* Write: PASS Ringer setting ccc descriptor */ + {watchCccNtfVal, sizeof(watchCccNtfVal), (PASPC_PASS_RS_CCC_HDL_IDX + WATCH_DISC_PASS_START)}, + + /* Write: ANS Control point "Enable New Alert Notification" */ + {watchAncpEnNewVal, sizeof(watchAncpEnNewVal), (ANPC_ANS_ANCP_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Write: ANS Control point "Notify New Alert Immediately" */ + {watchAncpNotNewVal, sizeof(watchAncpNotNewVal), (ANPC_ANS_ANCP_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Write: ANS Control point "Enable Unread Alert Status Notification" */ + {watchAncpEnUnrVal, sizeof(watchAncpEnUnrVal), (ANPC_ANS_ANCP_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Write: ANS Control point "Notify Unread Alert Status Immediately" */ + {watchAncpNotUnrVal, sizeof(watchAncpNotUnrVal), (ANPC_ANS_ANCP_HDL_IDX + WATCH_DISC_ANS_START)}}; + +/* Characteristic configuration list length */ +#define WATCH_DISC_SLAVE_CFG_LIST_LEN (sizeof(watchDiscSlaveCfgList) / sizeof(attcDiscCfg_t)) + +/* sanity check: make sure configuration list length is <= handle list length */ +WSF_CT_ASSERT(WATCH_DISC_SLAVE_CFG_LIST_LEN <= WATCH_DISC_SLAVE_HDL_LIST_LEN); + +/* List of characteristics to configure after service discovery - Master Role */ +static const attcDiscCfg_t watchDiscMasterCfgList[] = + { + /* Write: GATT client supported features */ + {watchCsfVal, sizeof(watchCsfVal), (GATT_CSF_HDL_IDX + WATCH_DISC_GATT_START)}, + + /* Read: DIS Manufacturer name string */ + {NULL, 0, DIS_MFNS_HDL_IDX}, + + /* Read: DIS Model number string */ + {NULL, 0, DIS_MNS_HDL_IDX}, + + /* Read: DIS Serial number string */ + {NULL, 0, DIS_SNS_HDL_IDX}, + + /* Read: DIS Hardware revision string */ + {NULL, 0, DIS_HRS_HDL_IDX}, + + /* Read: DIS Firmware revision string */ + {NULL, 0, DIS_FRS_HDL_IDX}, + + /* Read: DIS Software revision string */ + {NULL, 0, DIS_SRS_HDL_IDX}, + + /* Read: DIS System ID */ + {NULL, 0, DIS_SID_HDL_IDX}, + + /* Read: HRS Body sensor location */ + {NULL, 0, HRPC_HRS_BSL_HDL_IDX}, + + /* Write: HRS Control point "Reset Energy Expended" */ + {watchHrsRstEnExp, sizeof(watchHrsRstEnExp), HRPC_HRS_HRCP_HDL_IDX + WATCH_DISC_HRS_START}, + + /* Write: HRS Heart rate measurement CCC descriptor */ + {watchCccNtfVal, sizeof(watchCccNtfVal), HRPC_HRS_HRM_CCC_HDL_IDX + WATCH_DISC_HRS_START}, +}; + +/* Characteristic configuration list length */ +#define WATCH_DISC_MASTER_CFG_LIST_LEN (sizeof(watchDiscMasterCfgList) / sizeof(attcDiscCfg_t)) + +/* sanity check: make sure configuration list length is <= handle list length */ +WSF_CT_ASSERT(WATCH_DISC_MASTER_CFG_LIST_LEN <= WATCH_DISC_MASTER_CFG_LIST_LEN); + +/* + * Data for configuration on connection setup + */ + +/* List of characteristics to configure on connection setup */ +static const attcDiscCfg_t watchDiscConnCfgList[] = + { + /* Read: ANS Supported new alert category */ + {NULL, 0, (ANPC_ANS_SNAC_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Read: ANS Supported unread alert category */ + {NULL, 0, (ANPC_ANS_SUAC_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Read: PASS Alert status */ + {NULL, 0, (PASPC_PASS_AS_HDL_IDX + WATCH_DISC_PASS_START)}, + + /* Write: ANS Control point "Enable New Alert Notification" */ + {watchAncpEnNewVal, sizeof(watchAncpEnNewVal), (ANPC_ANS_ANCP_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Write: ANS Control point "Notify New Alert Immediately" */ + {watchAncpNotNewVal, sizeof(watchAncpNotNewVal), (ANPC_ANS_ANCP_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Write: ANS Control point "Enable Unread Alert Status Notification" */ + {watchAncpEnUnrVal, sizeof(watchAncpEnUnrVal), (ANPC_ANS_ANCP_HDL_IDX + WATCH_DISC_ANS_START)}, + + /* Write: ANS Control point "Notify Unread Alert Status Immediately" */ + {watchAncpNotUnrVal, sizeof(watchAncpNotUnrVal), (ANPC_ANS_ANCP_HDL_IDX + WATCH_DISC_ANS_START)}}; + +/* Characteristic configuration list length */ +#define WATCH_DISC_CONN_CFG_LIST_LEN (sizeof(watchDiscConnCfgList) / sizeof(attcDiscCfg_t)) + +/* sanity check: make sure configuration list length is <= handle list length */ +WSF_CT_ASSERT(WATCH_DISC_CONN_CFG_LIST_LEN <= WATCH_DISC_SLAVE_HDL_LIST_LEN); + +/************************************************************************************************** + ATT Server Data +**************************************************************************************************/ + +/*! enumeration of client characteristic configuration descriptors used in local ATT server */ +enum +{ + WATCH_GATT_SC_CCC_IDX, /*! GATT service, service changed characteristic */ + QIOT_EVENT_CCC_IDX, // add QIOT_EVENT_CCC_IDX + WATCH_NUM_CCC_IDX /*! Number of ccc's */ +}; + +/*! client characteristic configuration descriptors settings, indexed by ccc enumeration */ +static const attsCccSet_t watchCccSet[WATCH_NUM_CCC_IDX] = +{ + /* cccd handle value range security level */ + {GATT_SC_CH_CCC_HDL, ATT_CLIENT_CFG_INDICATE, DM_SEC_LEVEL_ENC}, /* WATCH_GATT_SC_CCC_IDX */ + + {QIOT_EVENT_CCC_HDL, ATT_CLIENT_CFG_NOTIFY, DM_SEC_LEVEL_NONE}, // QIOT_EVENT_CCC_IDX +}; + +extern ble_timer_cb p_ble_timer_cb; + +enum +{ + BLE_QIOT_TIMER_IND = 0x600, // be careful do not repeat with other event handle +}; + +/** + * @brief Get the handler object of WSF event handler for the application + * + * @return wsfHandlerId_t + */ +wsfHandlerId_t get_wsf_evt_handler(void) +{ + return watchCb.handlerId; +} + + +/*************************************************************************************************/ +/*! + * \brief Application DM callback. + * + * \param pDmEvt DM callback event + * + * \return None. + */ +/*************************************************************************************************/ +static void watchDmCback(dmEvt_t *pDmEvt) +{ + dmEvt_t *pMsg; + uint16_t len; + uint16_t reportLen; + + len = DmSizeOfEvt(pDmEvt); + + if (pDmEvt->hdr.event == DM_SCAN_REPORT_IND) + { + reportLen = pDmEvt->scanReport.len; + } + else + { + reportLen = 0; + } + + if ((pMsg = WsfMsgAlloc(len + reportLen)) != NULL) + { + memcpy(pMsg, pDmEvt, len); + + if (pDmEvt->hdr.event == DM_SCAN_REPORT_IND) + { + pMsg->scanReport.pData = (uint8_t *)((uint8_t *)pMsg + len); + memcpy(pMsg->scanReport.pData, pDmEvt->scanReport.pData, reportLen); + } + + WsfMsgSend(watchCb.handlerId, pMsg); + } +} + +/*************************************************************************************************/ +/*! + * \brief Application ATT callback. + * + * \param pEvt ATT callback event + * + * \return None. + */ +/*************************************************************************************************/ +static void watchAttCback(attEvt_t *pEvt) +{ + attEvt_t *pMsg; + + if ((pMsg = WsfMsgAlloc(sizeof(attEvt_t) + pEvt->valueLen)) != NULL) + { + memcpy(pMsg, pEvt, sizeof(attEvt_t)); + pMsg->pValue = (uint8_t *)(pMsg + 1); + memcpy(pMsg->pValue, pEvt->pValue, pEvt->valueLen); + WsfMsgSend(watchCb.handlerId, pMsg); + } +} + +/*************************************************************************************************/ +/*! + * \brief Perform actions on scan start. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void watchScanStart(dmEvt_t *pMsg) +{ + if (pMsg->hdr.status == HCI_SUCCESS) + { + watchCb.scan_state = WATCH_SCANNING; + // set it to lowest possible value of RSSI + watchConnInfo.rssi = -128; + } +} + +/*************************************************************************************************/ +/*! + * \brief Perform actions on scan stop. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void watchScanStop(dmEvt_t *pMsg) +{ + if (pMsg->hdr.status == HCI_SUCCESS) + { + watchCb.scan_state = WATCH_SCAN_NONE; + watchCb.autoConnect = FALSE; + + /* Open connection */ + if (watchConnInfo.doConnect) + { + AppConnOpen(watchConnInfo.addrType, watchConnInfo.addr, watchConnInfo.dbHdl); + watchConnInfo.doConnect = FALSE; + } + else + { + AppAdvStart(APP_MODE_AUTO_INIT); + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Handle a scan report. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void watchScanReport(dmEvt_t *pMsg) +{ + uint8_t device_name[32] = {0}; + uint32_t name_length; + uint8_t *pData; + appDbHdl_t dbHdl; + bool_t connect = FALSE; + + /* disregard if not scanning or autoconnecting */ + if ((watchCb.scan_state == WATCH_SCAN_NONE) || !watchCb.autoConnect) + { + return; + } + + if ((pData = DmFindAdType(DM_ADV_TYPE_LOCAL_NAME, pMsg->scanReport.len, + pMsg->scanReport.pData))) + { + name_length = *pData; + name_length--; + + memcpy(device_name, pData + 2, name_length); + } + else if ((pData = DmFindAdType(DM_ADV_TYPE_SHORT_NAME, pMsg->scanReport.len, + pMsg->scanReport.pData))) + { + name_length = *pData; + name_length--; + + memcpy(device_name, pData + 2, name_length); + } + + WsfTrace("Found: 0x%02x:%02x:%02x:%02x:%02x:%02x rssi: %d %s", + pMsg->scanReport.addr[5], + pMsg->scanReport.addr[4], + pMsg->scanReport.addr[3], + pMsg->scanReport.addr[2], + pMsg->scanReport.addr[1], + pMsg->scanReport.addr[0], + pMsg->scanReport.rssi, + device_name); + + /* if we already have a bond with this device then connect to it */ + if ((dbHdl = AppDbFindByAddr(pMsg->scanReport.addrType, pMsg->scanReport.addr)) != APP_DB_HDL_NONE) + { + /* if this is a directed advertisement where the initiator address is an RPA */ + if (DM_RAND_ADDR_RPA(pMsg->scanReport.directAddr, pMsg->scanReport.directAddrType)) + { + /* resolve direct address to see if it's addressed to us */ + AppMasterResolveAddr(pMsg, dbHdl, APP_RESOLVE_DIRECT_RPA); + } + else + { + connect = TRUE; + } + } + /* if the peer device uses an RPA */ + else if (DM_RAND_ADDR_RPA(pMsg->scanReport.addr, pMsg->scanReport.addrType)) + { + /* resolve advertiser's RPA to see if we already have a bond with this device */ + AppMasterResolveAddr(pMsg, APP_DB_HDL_NONE, APP_RESOLVE_ADV_RPA); + } + else + { + /* find Service UUID list; if full list not found search for partial */ + if ((pData = DmFindAdType(DM_ADV_TYPE_16_UUID, pMsg->scanReport.len, + pMsg->scanReport.pData)) == NULL) + { + pData = DmFindAdType(DM_ADV_TYPE_16_UUID_PART, pMsg->scanReport.len, + pMsg->scanReport.pData); + } + + /* if found and length checks out ok */ + if (pData != NULL && pData[DM_AD_LEN_IDX] >= (ATT_16_UUID_LEN + 1)) + { + uint8_t len = pData[DM_AD_LEN_IDX] - 1; + pData += DM_AD_DATA_IDX; + + while ((!connect) && (len >= ATT_16_UUID_LEN)) + { + /* Connect if heart rate service is included */ + if (BYTES_UINT16_CMP(pData, ATT_UUID_HEART_RATE_SERVICE)) + { + connect = TRUE; + break; + } + + pData += ATT_16_UUID_LEN; + len -= ATT_16_UUID_LEN; + } + } + } + + if (connect) + { + + if (pMsg->scanReport.rssi > watchConnInfo.rssi) + { + watchConnInfo.rssi = pMsg->scanReport.rssi; + + /* connect will start after scanning stops with expiration + * of scan timer. + */ + + /* Store peer information for connect on scan stop */ + watchConnInfo.addrType = DmHostAddrType(pMsg->scanReport.addrType); + memcpy(watchConnInfo.addr, pMsg->scanReport.addr, sizeof(bdAddr_t)); + watchConnInfo.dbHdl = dbHdl; + watchConnInfo.doConnect = TRUE; + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Application ATTS client characteristic configuration callback. + * + * \param pDmEvt DM callback event + * + * \return None. + */ +/*************************************************************************************************/ +static void watchCccCback(attsCccEvt_t *pEvt) +{ + attsCccEvt_t *pMsg; + appDbHdl_t dbHdl; + + /* If CCC not set from initialization and there's a device record and currently bonded */ + if ((pEvt->handle != ATT_HANDLE_NONE) && + ((dbHdl = AppDbGetHdl((dmConnId_t)pEvt->hdr.param)) != APP_DB_HDL_NONE) && + AppCheckBonded((dmConnId_t)pEvt->hdr.param)) + { + /* Store value in device database. */ + AppDbSetCccTblValue(dbHdl, pEvt->idx, pEvt->value); + } + + if ((pMsg = WsfMsgAlloc(sizeof(attsCccEvt_t))) != NULL) + { + memcpy(pMsg, pEvt, sizeof(attsCccEvt_t)); + WsfMsgSend(watchCb.handlerId, pMsg); + } +} + +/*************************************************************************************************/ +/*! + * \brief Perform UI actions on connection open. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void watchOpen(dmEvt_t *pMsg) +{ + if (pMsg->connOpen.role == DM_ROLE_SLAVE) + { + /* if not bonded send a security request on connection open; devices must pair before + * service discovery will be initiated + */ + if (AppDbCheckBonded() == FALSE) + { + DmSecSlaveReq((dmConnId_t)pMsg->hdr.param, pAppSecCfg->auth); + } + } + else + { + + AppAdvStart(APP_MODE_AUTO_INIT); + } +} + +/*************************************************************************************************/ +/*! + * \brief Set up advertising and other procedures that need to be performed after + * device reset. + * + * \param pMsg Pointer to DM callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void watchSetup(dmEvt_t *pMsg) +{ + /* set advertising and scan response data for discoverable mode */ + AppAdvSetData(APP_ADV_DATA_DISCOVERABLE, sizeof(watchAdvDataDisc), (uint8_t *)watchAdvDataDisc); + AppAdvSetData(APP_SCAN_DATA_DISCOVERABLE, sizeof(watchScanDataDisc), (uint8_t *)watchScanDataDisc); + + /* set advertising and scan response data for connectable mode */ + AppAdvSetData(APP_ADV_DATA_CONNECTABLE, 0, NULL); + AppAdvSetData(APP_SCAN_DATA_CONNECTABLE, 0, NULL); + + /* start advertising; automatically set connectable/discoverable mode and bondable mode */ + AppAdvStart(APP_MODE_AUTO_INIT); + + DmConnSetConnSpec((hciConnSpec_t *)&watchConnCfg); +} + +/*************************************************************************************************/ +/*! + * \brief Process a received ATT read response, notification, or indication when connected in + * the slave role. + * + * \param pMsg Pointer to ATT callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void watchSlaveValueUpdate(attEvt_t *pMsg) +{ + if (pMsg->hdr.status == ATT_SUCCESS) + { + /* determine which profile the handle belongs to; start with most likely */ + + /* alert notification */ + if (AnpcAnsValueUpdate(pWatchAnsHdlList, pMsg) == ATT_SUCCESS) + { + return; + } + /* phone alert status */ + if (PaspcPassValueUpdate(pWatchPassHdlList, pMsg) == ATT_SUCCESS) + { + return; + } + + /* current time */ + if (TipcCtsValueUpdate(pWatchCtsHdlList, pMsg) == ATT_SUCCESS) + { + return; + } + + /* GATT */ + if (GattValueUpdate(pWatchSlvGattHdlList, pMsg) == ATT_SUCCESS) + { + return; + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Process a received ATT read response, notification, or indication when connected in + * the master role to a heart rate profile sensor. + * + * \param pMsg Pointer to ATT callback event message. + * + * \return None. + */ +/*************************************************************************************************/ +static void watchMasterValueUpdate(attEvt_t *pMsg) +{ + if (pMsg->hdr.status == ATT_SUCCESS) + { + /* determine which profile the handle belongs to; start with most likely */ + + /* heart rate */ + if (HrpcHrsValueUpdate(pWatchHrsHdlList, pMsg) == ATT_SUCCESS) + { + return; + } + + /* device information */ + if (DisValueUpdate(pWatchDisHdlList, pMsg) == ATT_SUCCESS) + { + return; + } + + /* GATT */ + if (GattValueUpdate(pWatchMstGattHdlList, pMsg) == ATT_SUCCESS) + { + return; + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Loop through the open connection ID list and find the first connection for the given role + * + * \param pConnIdList Buffer with the connection IDs (must be DM_CONN_MAX bytes). + * \param role Role to look for. + * + * \return None. + */ +/*************************************************************************************************/ +static dmConnId_t watchGetConnIdByRole(dmConnId_t *pConnIdList, uint8_t role) +{ + uint8_t i; + + for (i = 0; i < DM_CONN_MAX; i++) + { + if (pConnIdList[i] != DM_CONN_ID_NONE) + { + if (DmConnRole(pConnIdList[i]) == role) + { + return pConnIdList[i]; + } + } + } + + return DM_CONN_ID_NONE; +} + +/*************************************************************************************************/ +/*! + * \brief Button press callback. + * + * \param btn Button press. + * + * \return None. + */ +/*************************************************************************************************/ +static void watchBtnCback(uint8_t btn) +{ + dmConnId_t slaveConnId, masterConnId; + static uint8_t ringer = CH_RCP_SILENT; + dmConnId_t connIdList[DM_CONN_MAX]; + + AppConnOpenList(connIdList); + + slaveConnId = watchGetConnIdByRole(connIdList, DM_ROLE_SLAVE); + masterConnId = watchGetConnIdByRole(connIdList, DM_ROLE_MASTER); + + APP_TRACE_INFO3("btn: %d - master conn id: %d - slave conn id: %d", btn, masterConnId, slaveConnId); + + // as long as button 1 is short pressed, we'll scan and connect to + // a new fit device. + if (1) + { + /* No connection as a master */ + switch (btn) + { + case APP_UI_BTN_1_SHORT: + /* if scanning cancel scanning */ + if (watchCb.scan_state != WATCH_SCAN_NONE) + { + AppScanStop(); + } + /* else auto connect */ + else if (!watchCb.autoConnect) + { + watchCb.autoConnect = TRUE; + watchConnInfo.doConnect = FALSE; + watchCb.scan_state = WATCH_SCAN_START; + + if (AppSlaveIsAdvertising()) + { + AppAdvStop(); + } + else + { + AppScanStart(watchMasterCfg.discMode, watchMasterCfg.scanType, + watchMasterCfg.scanDuration); + } + } + return; + + case APP_UI_BTN_1_LONG: + /* clear bonded device info */ + AppClearAllBondingInfo(); + return; + + default: + break; + } + } + + if (slaveConnId == DM_CONN_ID_NONE) + { + /* No connection as a slave */ + switch (btn) + { + case APP_UI_BTN_2_SHORT: + /* start or restart advertising */ + AppAdvStart(APP_MODE_AUTO_INIT); + return; + + case APP_UI_BTN_2_MED: + /* enter discoverable and bondable mode mode */ + AppSetBondable(TRUE); + AppAdvStart(APP_MODE_DISCOVERABLE); + return; + + case APP_UI_BTN_2_LONG: + /* clear all bonding info */ + AppSlaveClearAllBondingInfo(); + + /* restart advertising */ + AppAdvStart(APP_MODE_AUTO_INIT); + return; + + default: + break; + } + } + else + { + /* Active connection to a slave */ + switch (btn) + { + case APP_UI_BTN_2_SHORT: + /* mute ringer once */ + PaspcPassControl(slaveConnId, pWatchPassHdlList[PASPC_PASS_RCP_HDL_IDX], CH_RCP_MUTE_ONCE); + return; + + case APP_UI_BTN_2_MED: + /* toggle between silencing ringer and enabling ringer */ + PaspcPassControl(slaveConnId, pWatchPassHdlList[PASPC_PASS_RCP_HDL_IDX], ringer); + ringer = (ringer == CH_RCP_SILENT) ? CH_RCP_CANCEL_SILENT : CH_RCP_SILENT; + return; + + case APP_UI_BTN_2_LONG: + /* disconnect slave connection */ + AppConnClose(slaveConnId); + break; + + default: + break; + } + } +} + +/*************************************************************************************************/ +/*! + * \brief Discovery callback. + * + * \param connId Connection identifier. + * \param status Service or configuration status. + * + * \return None. + */ +/*************************************************************************************************/ +static void watchDiscCback(dmConnId_t connId, uint8_t status) +{ + switch (status) + { + case APP_DISC_INIT: + /* set handle list when initialization requested */ + if (DmConnRole(connId) == DM_ROLE_MASTER) + { + AppDiscSetHdlList(connId, WATCH_DISC_MASTER_HDL_LIST_LEN, watchCb.hdlMasterList); + } + else + { + AppDiscSetHdlList(connId, WATCH_DISC_SLAVE_HDL_LIST_LEN, watchCb.hdlSlaveList); + } + break; + + case APP_DISC_READ_DATABASE_HASH: + /* Read peer's database hash */ + AppDiscReadDatabaseHash(connId); + break; + + case APP_DISC_SEC_REQUIRED: + /* request security */ + if (DmConnRole(connId) == DM_ROLE_MASTER) + { + AppMasterSecurityReq(connId); + } + else + { + AppSlaveSecurityReq(connId); + } + break; + + case APP_DISC_START: + /* initialize discovery state */ + if (DmConnRole(connId) == DM_ROLE_MASTER) + { + /* discover GATT service - master role */ + watchCb.discState = WATCH_DISC_MASTER_GATT_SVC; + GattDiscover(connId, pWatchMstGattHdlList); + } + else + { + /* discover GATT service - slave role */ + watchCb.discState = WATCH_DISC_SLAVE_GATT_SVC; + GattDiscover(connId, pWatchSlvGattHdlList); + } + + break; + + case APP_DISC_FAILED: + case APP_DISC_CMPL: + /* next discovery state */ + watchCb.discState++; + + if (DmConnRole(connId) == DM_ROLE_MASTER) + { + if (watchCb.discState == WATCH_DISC_MASTER_DIS_SVC) + { + /* discover device information service */ + DisDiscover(connId, pWatchDisHdlList); + } + else if (watchCb.discState == WATCH_DISC_MASTER_HRS_SVC) + { + /* discover heart rate service */ + HrpcHrsDiscover(connId, pWatchHrsHdlList); + } + else + { + /* discovery complete */ + AppDiscComplete(connId, APP_DISC_CMPL); + + /* start configuration */ + AppDiscConfigure(connId, APP_DISC_CFG_START, WATCH_DISC_MASTER_CFG_LIST_LEN, + (attcDiscCfg_t *)watchDiscMasterCfgList, + WATCH_DISC_MASTER_HDL_LIST_LEN, watchCb.hdlMasterList); + } + } + else + { + if (watchCb.discState == WATCH_DISC_SLAVE_CTS_SVC) + { + /* discover current time service */ + TipcCtsDiscover(connId, pWatchCtsHdlList); + } + else if (watchCb.discState == WATCH_DISC_SLAVE_ANS_SVC) + { + /* discover alert notification service */ + AnpcAnsDiscover(connId, pWatchAnsHdlList); + } + else if (watchCb.discState == WATCH_DISC_SLAVE_PASS_SVC) + { + /* discover phone alert status service */ + PaspcPassDiscover(connId, pWatchPassHdlList); + } + else + { + /* discovery complete */ + AppDiscComplete(connId, APP_DISC_CMPL); + + /* start configuration */ + AppDiscConfigure(connId, APP_DISC_CFG_START, WATCH_DISC_SLAVE_CFG_LIST_LEN, + (attcDiscCfg_t *)watchDiscSlaveCfgList, + WATCH_DISC_SLAVE_HDL_LIST_LEN, watchCb.hdlSlaveList); + } + } + break; + + case APP_DISC_CFG_START: + if (DmConnRole(connId) == DM_ROLE_MASTER) + { + /* start configuration */ + AppDiscConfigure(connId, APP_DISC_CFG_START, WATCH_DISC_MASTER_CFG_LIST_LEN, + (attcDiscCfg_t *)watchDiscMasterCfgList, + WATCH_DISC_MASTER_HDL_LIST_LEN, watchCb.hdlMasterList); + } + else + { + /* start configuration */ + AppDiscConfigure(connId, APP_DISC_CFG_START, WATCH_DISC_SLAVE_CFG_LIST_LEN, + (attcDiscCfg_t *)watchDiscSlaveCfgList, + WATCH_DISC_SLAVE_HDL_LIST_LEN, watchCb.hdlSlaveList); + } + break; + + case APP_DISC_CFG_CMPL: + AppDiscComplete(connId, status); + break; + + case APP_DISC_CFG_CONN_START: + if (DmConnRole(connId) == DM_ROLE_SLAVE) + { + /* start connection setup configuration */ + AppDiscConfigure(connId, APP_DISC_CFG_CONN_START, WATCH_DISC_CONN_CFG_LIST_LEN, + (attcDiscCfg_t *)watchDiscConnCfgList, + WATCH_DISC_CONN_CFG_LIST_LEN, watchCb.hdlSlaveList); + } + break; + + default: + break; + } +} + + +void qiot_notify_enable(dmConnId_t connId) +{ + extern dmConnId_t ind_conn_id; + ind_conn_id = connId; + return; +} + +void qiot_notify_disable(dmConnId_t connId) +{ + extern dmConnId_t ind_conn_id; + ind_conn_id = DM_CONN_ID_NONE; + return; +} + +static void qiot_proc_ccc_state(attsCccEvt_t *pMsg) +{ + // APP_TRACE_INFO3("ccc state ind value:%d handle:%d idx:%d", pMsg->ccc.value, pMsg->ccc.handle, pMsg->ccc.idx); + SEGGER_RTT_printf(0, "ccc state ind value:%d handle:%d idx:%d \r\n", pMsg->value, pMsg->handle, pMsg->idx); + + if (pMsg->idx == QIOT_EVENT_CCC_IDX) + { + if (pMsg->value == ATT_CLIENT_CFG_NOTIFY) + { + qiot_notify_enable((dmConnId_t)pMsg->hdr.param); + } + else + { + qiot_notify_disable((dmConnId_t)pMsg->hdr.param); + } + return; + } +} + +/*************************************************************************************************/ +/*! + * \brief Process messages from the event handler. + * + * \param pMsg Pointer to message. + * + * \return None. + */ +/*************************************************************************************************/ +static void watchProcMsg(dmEvt_t *pMsg) +{ + uint8_t uiEvent = APP_UI_NONE; + + SEGGER_RTT_printf(0, "get event %d\r\n", __LINE__, pMsg->hdr.event); + + switch (pMsg->hdr.event) + { + case ATTC_READ_RSP: + case ATTC_HANDLE_VALUE_NTF: + case ATTC_HANDLE_VALUE_IND: + if (DmConnRole((dmConnId_t)pMsg->hdr.param) == DM_ROLE_MASTER) + { + watchMasterValueUpdate((attEvt_t *)pMsg); + } + else + { + watchSlaveValueUpdate((attEvt_t *)pMsg); + } + break; + + case BLE_QIOT_TIMER_IND: + SEGGER_RTT_printf(0, "get timer event\r\n"); + if(NULL != p_ble_timer_cb) + { + p_ble_timer_cb(NULL); + } + break; + + case ATTS_CCC_STATE_IND: + qiot_proc_ccc_state((attsCccEvt_t *)pMsg); + break; + case ATTS_HANDLE_VALUE_CNF: + if(ATT_SUCCESS != pMsg->hdr.status) + { + // see att_defs.h + SEGGER_RTT_printf(0, "event %d, error status %d \r\n", pMsg->hdr.event, pMsg->hdr.status); + } + break; + + case ATT_MTU_UPDATE_IND: + // APP_TRACE_INFO1("Negotiated MTU %d", ((attEvt_t *)pMsg)->mtu); + SEGGER_RTT_printf(0, "Negotiated MTU %d \r\n", ((attEvt_t *)pMsg)->mtu); + break; + + case DM_PHY_UPDATE_IND: + SEGGER_RTT_printf(0, "GAP PHY UPDATE REQUEST not support yet!\r\n"); + break; + + case DM_RESET_CMPL_IND: + AttsCalculateDbHash(); + // watchSetup(pMsg); + + ble_qiot_advertising_start(); + DmConnSetConnSpec((hciConnSpec_t *)&watchConnCfg); + + uiEvent = APP_UI_RESET_CMPL; + break; + + case DM_ADV_START_IND: + uiEvent = APP_UI_ADV_START; + break; + + case DM_ADV_STOP_IND: + if (watchCb.scan_state == WATCH_SCAN_START) + { + AppScanStart(watchMasterCfg.discMode, watchMasterCfg.scanType, + watchMasterCfg.scanDuration); + } + else + { + AppAdvStart(APP_MODE_AUTO_INIT); + uiEvent = APP_UI_ADV_STOP; + } + break; + + case DM_SCAN_START_IND: + watchScanStart(pMsg); + uiEvent = APP_UI_SCAN_START; + break; + + case DM_SCAN_STOP_IND: + watchScanStop(pMsg); + uiEvent = APP_UI_SCAN_STOP; + break; + + case DM_SCAN_REPORT_IND: + watchScanReport(pMsg); + break; + + case DM_CONN_OPEN_IND: + watchOpen(pMsg); + uiEvent = APP_UI_CONN_OPEN; + ble_gap_connect_cb(); + break; + + case DM_CONN_CLOSE_IND: + // only when the connection we as slave is closed + ble_gap_disconnect_cb(); + if (pMsg->connOpen.role == DM_ROLE_SLAVE) + { + AppAdvStart(APP_MODE_AUTO_INIT); + } + uiEvent = APP_UI_CONN_CLOSE; + break; + + case DM_SEC_PAIR_CMPL_IND: + DmSecGenerateEccKeyReq(); + uiEvent = APP_UI_SEC_PAIR_CMPL; + break; + + case DM_SEC_PAIR_FAIL_IND: + DmSecGenerateEccKeyReq(); + uiEvent = APP_UI_SEC_PAIR_FAIL; + break; + + case DM_SEC_ENCRYPT_IND: + uiEvent = APP_UI_SEC_ENCRYPT; + break; + + case DM_SEC_ENCRYPT_FAIL_IND: + uiEvent = APP_UI_SEC_ENCRYPT_FAIL; + break; + + case DM_SEC_AUTH_REQ_IND: + AppHandlePasskey(&pMsg->authReq); + break; + + case DM_PRIV_CLEAR_RES_LIST_IND: + APP_TRACE_INFO1("Clear resolving list status 0x%02x", pMsg->hdr.status); + break; + + case DM_VENDOR_SPEC_CMD_CMPL_IND: + { +#if defined(AM_PART_APOLLO) || defined(AM_PART_APOLLO2) + + uint8_t *param_ptr = &pMsg->vendorSpecCmdCmpl.param[0]; + + switch (pMsg->vendorSpecCmdCmpl.opcode) + { + case 0xFC20: //read at address + { + uint32_t read_value; + + BSTREAM_TO_UINT32(read_value, param_ptr); + + APP_TRACE_INFO3("VSC 0x%0x complete status %x param %x", + pMsg->vendorSpecCmdCmpl.opcode, + pMsg->hdr.status, + read_value); + } + + break; + default: + APP_TRACE_INFO2("VSC 0x%0x complete status %x", + pMsg->vendorSpecCmdCmpl.opcode, + pMsg->hdr.status); + break; + } + +#endif + } + break; + + default: + break; + } + + if (uiEvent != APP_UI_NONE) + { + AppUiAction(uiEvent); + } +} + +/*************************************************************************************************/ +/*! + * \brief Application handler init function called during system initialization. + * + * \param handlerID WSF handler ID. + * + * \return None. + */ +/*************************************************************************************************/ +void WatchHandlerInit(wsfHandlerId_t handlerId) +{ + APP_TRACE_INFO0("WatchHandlerInit"); + + /* store handler ID */ + watchCb.handlerId = handlerId; + + /* Set configuration pointers */ + pAppMasterCfg = (appMasterCfg_t *)&watchMasterCfg; + pAppSlaveCfg = (appSlaveCfg_t *)&watchSlaveCfg; + pAppAdvCfg = (appAdvCfg_t *)&watchAdvCfg; + pAppSecCfg = (appSecCfg_t *)&watchSecCfg; + pAppUpdateCfg = (appUpdateCfg_t *)&watchUpdateCfg; + pAppDiscCfg = (appDiscCfg_t *)&watchDiscCfg; + pAppCfg = (appCfg_t *)&watchAppCfg; + + /* Set stack configuration pointers */ + pSmpCfg = (smpCfg_t *)&watchSmpCfg; + + /* Initialize application framework */ + AppMasterInit(); + AppSlaveInit(); + AppDiscInit(); +} + +/*************************************************************************************************/ +/*! + * \brief WSF event handler for application. + * + * \param event WSF event mask. + * \param pMsg WSF message. + * + * \return None. + */ +/*************************************************************************************************/ +void WatchHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) +{ + if (pMsg != NULL) + { + APP_TRACE_INFO1("Watch got evt %d", pMsg->event); + + /* process ATT messages */ + if (pMsg->event <= ATT_CBACK_END) + { + /* process discovery-related ATT messages */ + AppDiscProcAttMsg((attEvt_t *)pMsg); + + /* process server-related ATT messages */ + AppServerProcAttMsg(pMsg); + } + /* process DM messages */ + else if (pMsg->event <= DM_CBACK_END) + { + if (pMsg->param == DM_CONN_ID_NONE || DmConnRole((dmConnId_t)pMsg->param) == DM_ROLE_MASTER) + { + /* process advertising and connection-related messages */ + AppMasterProcDmMsg((dmEvt_t *)pMsg); + + /* process security-related messages */ + AppMasterSecProcDmMsg((dmEvt_t *)pMsg); + } + + if (pMsg->param == DM_CONN_ID_NONE || DmConnRole((dmConnId_t)pMsg->param) == DM_ROLE_SLAVE) + { + /* process advertising and connection-related messages */ + AppSlaveProcDmMsg((dmEvt_t *)pMsg); + + /* process security-related messages */ + AppSlaveSecProcDmMsg((dmEvt_t *)pMsg); + } + + /* process discovery-related messages */ + AppDiscProcDmMsg((dmEvt_t *)pMsg); + } + + /* perform profile and user interface-related operations */ + watchProcMsg((dmEvt_t *)pMsg); + } +} + +/*************************************************************************************************/ +/*! + * \brief Start the application. + * + * \return None. + */ +/*************************************************************************************************/ +void WatchStart(void) +{ + /* Register for stack callbacks */ + DmRegister(watchDmCback); + DmConnRegister(DM_CLIENT_ID_APP, watchDmCback); + AttRegister(watchAttCback); + AttConnRegister(AppServerConnCback); + AttsCccRegister(WATCH_NUM_CCC_IDX, (attsCccSet_t *)watchCccSet, watchCccCback); + + /* Register for app framework button callbacks */ + AppUiBtnRegister(watchBtnCback); + + /* Register for app framework discovery callbacks */ + AppDiscRegister(watchDiscCback); + + /* Initialize attribute server database */ + SvcCoreAddGroup(); + + // AttsAddGroup(NULL); + // ble_services_add(NULL); + ble_qiot_explorer_init(); + + /* Reset the device */ + DmDevReset(); +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/date_template/ble_qiot_template.c b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/date_template/ble_qiot_template.c new file mode 100644 index 00000000..c58e079d --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/date_template/ble_qiot_template.c @@ -0,0 +1,535 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_template.h" + +#include +#include + +#include "ble_qiot_export.h" +#include "ble_qiot_common.h" +#include "ble_qiot_param_check.h" +#include "ble_qiot_ble_device.h" + +static uint8_t sg_test_power_switch = false; + +static int ble_property_power_switch_set(const char *data, uint16_t len) +{ + ble_qiot_log_d("set property power_switch %d", *(uint8_t *)data); + property_power_switch(data, len); + sg_test_power_switch = data[0]; + + return 0; +} + +static int ble_property_power_switch_get(char *data, uint16_t buf_len) +{ + ble_qiot_log_d("get property power_switch %d", sg_test_power_switch); + data[0] = sg_test_power_switch; + + return sizeof(uint8_t); +} + +static uint16_t sg_test_color = 0; + +static int ble_property_color_set(const char *data, uint16_t len) +{ + uint16_t color_value = 0; + + memcpy(&color_value, data, sizeof(uint16_t)); + color_value = NTOHS(color_value); + ble_qiot_log_d("set property color %d", color_value); + sg_test_color = color_value; + + return 0; +} + +static int ble_property_color_get(char *data, uint16_t buf_len) +{ + uint16_t color_value = 0; + + ble_qiot_log_d("get property color %d", color_value); + color_value = HTONS(sg_test_color); + memcpy(data, &color_value, sizeof(uint16_t)); + + return sizeof(uint16_t); +} + +static int sg_test_brightness = 0; + +static int ble_property_brightness_set(const char *data, uint16_t len) +{ + int brightness_value = 0; + + memcpy(&brightness_value, data, sizeof(int)); + brightness_value = NTOHL(brightness_value); + + if ((brightness_value < BLE_QIOT_PROPERTY_BRIGHTNESS_MIN) || + (brightness_value > BLE_QIOT_PROPERTY_BRIGHTNESS_MAX)) { + ble_qiot_log_e("invalid brightness value %d", brightness_value); + return -1; + } + + ble_qiot_log_d("set property brightness %d", brightness_value); + sg_test_brightness = brightness_value; + + return 0; +} + +static int ble_property_brightness_get(char *data, uint16_t buf_len) +{ + int brightness_value = 0; + + ble_qiot_log_d("get property brightness %d", sg_test_brightness); + brightness_value = HTONL(sg_test_brightness); + memcpy(data, &brightness_value, sizeof(int)); + + return sizeof(uint32_t); +} + +static char sg_test_name[100 + 1] = "default name"; + +static int ble_property_name_set(const char *data, uint16_t len) +{ + ble_qiot_log_d("set property name %.*s", len, data); + if (len > sizeof(sg_test_name) - 1) { + ble_qiot_log_d("too long name"); + return -1; + } + memset(sg_test_name, 0, sizeof(sg_test_name)); + memcpy(sg_test_name, data, len); + + return 0; +} + +static int ble_property_name_get(char *data, uint16_t buf_len) +{ + int i = 0; + + ble_qiot_log_d("get property name %s", sg_test_name); + if (0 == strncmp("default name", sg_test_name, sizeof("default name") - 1)) { + for (i = 0; i < 26 * 3; i++) { + data[i] = 'a' + (i % 26); + } + return i; + } else { + memcpy(data, sg_test_name, strlen(sg_test_name)); + return strlen(sg_test_name); + } +} + +static ble_property_t sg_ble_property_array[BLE_QIOT_PROPERTY_ID_BUTT] = { + {ble_property_power_switch_set, ble_property_power_switch_get, BLE_QIOT_PROPERTY_AUTH_RW, BLE_QIOT_DATA_TYPE_BOOL}, + {ble_property_color_set, ble_property_color_get, BLE_QIOT_PROPERTY_AUTH_RW, BLE_QIOT_DATA_TYPE_ENUM}, + {ble_property_brightness_set, ble_property_brightness_get, BLE_QIOT_PROPERTY_AUTH_RW, BLE_QIOT_DATA_TYPE_INT}, + {ble_property_name_set, ble_property_name_get, BLE_QIOT_PROPERTY_AUTH_RW, BLE_QIOT_DATA_TYPE_STRING}, +}; + +static bool ble_check_space_enough_by_type(uint8_t type, uint16_t left_size) +{ + switch (type) { + case BLE_QIOT_DATA_TYPE_BOOL: + return left_size >= sizeof(uint8_t); + case BLE_QIOT_DATA_TYPE_INT: + case BLE_QIOT_DATA_TYPE_FLOAT: + case BLE_QIOT_DATA_TYPE_TIME: + return left_size >= sizeof(uint32_t); + case BLE_QIOT_DATA_TYPE_ENUM: + return left_size >= sizeof(uint16_t); + default: + // string length is unknow, default true + return true; + } +} + +static uint16_t ble_check_ret_value_by_type(uint8_t type, uint16_t buf_len, uint16_t ret_val) +{ + switch (type) { + case BLE_QIOT_DATA_TYPE_BOOL: + return ret_val <= sizeof(uint8_t); + case BLE_QIOT_DATA_TYPE_INT: + case BLE_QIOT_DATA_TYPE_FLOAT: + case BLE_QIOT_DATA_TYPE_TIME: + return ret_val <= sizeof(uint32_t); + case BLE_QIOT_DATA_TYPE_ENUM: + return ret_val <= sizeof(uint16_t); + default: + // string length is unknow, default true + return ret_val <= buf_len; + } +} + +uint8_t ble_get_property_type_by_id(uint8_t id) +{ + if (id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + return sg_ble_property_array[id].type; +} + +int ble_user_property_set_data(const e_ble_tlv *tlv) +{ + POINTER_SANITY_CHECK(tlv, BLE_QIOT_RS_ERR_PARA); + if (tlv->id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", tlv->id); + return BLE_QIOT_RS_ERR; + } + + if (NULL != sg_ble_property_array[tlv->id].set_cb) { + if (0 != sg_ble_property_array[tlv->id].set_cb(tlv->val, tlv->len)) { + ble_qiot_log_e("set property id %d failed", tlv->id); + return BLE_QIOT_RS_ERR; + } else { + return BLE_QIOT_RS_OK; + } + } + ble_qiot_log_e("invalid set callback, id %d", tlv->id); + + return BLE_QIOT_RS_ERR; +} + +int ble_user_property_get_data_by_id(uint8_t id, char *buf, uint16_t buf_len) +{ + int ret_len = 0; + + POINTER_SANITY_CHECK(buf, BLE_QIOT_RS_ERR_PARA); + if (id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", id); + return -1; + } + + if (NULL != sg_ble_property_array[id].get_cb) { + if (!ble_check_space_enough_by_type(sg_ble_property_array[id].type, buf_len)) { + ble_qiot_log_e("not enough space get property id %d data", id); + return -1; + } + ret_len = sg_ble_property_array[id].get_cb(buf, buf_len); + if (ret_len < 0) { + ble_qiot_log_e("get property id %d data failed", id); + return -1; + } else { + if (ble_check_ret_value_by_type(sg_ble_property_array[id].type, buf_len, ret_len)) { + return ret_len; + } else { + ble_qiot_log_e("property id %d length invalid, type %d", id, sg_ble_property_array[id].type); + return -1; + } + } + } + ble_qiot_log_e("invalid callback, property id %d", id); + + return 0; +} + +int ble_user_property_report_reply_handle(uint8_t result) +{ + ble_qiot_log_d("report reply result %d", result); + if (0 == result) { + report_reply_blink(); + } + + return BLE_QIOT_RS_OK; +} + +static int ble_event_get_status_report_status(char *buf, uint16_t buf_len) +{ + buf[0] = 1; + + return 1; +} + +static int ble_event_get_status_report_message(char *buf, uint16_t buf_len) +{ + int i = 0; + + for (i = 0; i < 26 * 3; i++) { + buf[i] = 'a' + (i % 26); + } + + return i; +} + +static ble_event_param sg_ble_event_status_report_array[BLE_QIOT_EVENT_STATUS_REPORT_PARAM_ID_BUTT] = { + {ble_event_get_status_report_status, BLE_QIOT_DATA_TYPE_BOOL}, + {ble_event_get_status_report_message, BLE_QIOT_DATA_TYPE_STRING}, +}; + +static int ble_event_get_low_voltage_voltage(char *data, uint16_t buf_len) +{ + float tmp = 1.0; + + memcpy(data, &tmp, sizeof(float)); + + return sizeof(float); +} + +static ble_event_param sg_ble_event_low_voltage_array[BLE_QIOT_EVENT_LOW_VOLTAGE_PARAM_ID_BUTT] = { + {ble_event_get_low_voltage_voltage, BLE_QIOT_DATA_TYPE_FLOAT}, +}; + +static int ble_event_get_hardware_fault_name(char *data, uint16_t buf_len) +{ + memcpy(data, "hardware_fault", sizeof("hardware_fault") - 1); + + return sizeof("hardware_fault") - 1; +} + +static int ble_event_get_hardware_fault_error_code(char *data, uint16_t buf_len) +{ + int error_code = HTONL(1024); + + memcpy(data, &error_code, sizeof(int)); + + return sizeof(int); +} + +static ble_event_param sg_ble_event_hardware_fault_array[BLE_QIOT_EVENT_HARDWARE_FAULT_PARAM_ID_BUTT] = { + {ble_event_get_hardware_fault_name, BLE_QIOT_DATA_TYPE_STRING}, + {ble_event_get_hardware_fault_error_code, BLE_QIOT_DATA_TYPE_INT}, +}; + +static ble_event_t sg_ble_event_array[BLE_QIOT_EVENT_ID_BUTT] = { + {sg_ble_event_status_report_array, sizeof(sg_ble_event_status_report_array) / sizeof(ble_event_param)}, + {sg_ble_event_low_voltage_array, sizeof(sg_ble_event_low_voltage_array) / sizeof(ble_event_param)}, + {sg_ble_event_hardware_fault_array, sizeof(sg_ble_event_hardware_fault_array) / sizeof(ble_event_param)}, +}; + +int ble_event_get_id_array_size(uint8_t event_id) +{ + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return -1; + } + + return sg_ble_event_array[event_id].array_size; +} + +uint8_t ble_event_get_param_id_type(uint8_t event_id, uint8_t param_id) +{ + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (param_id >= sg_ble_event_array[event_id].array_size) { + ble_qiot_log_e("invalid param id %d", param_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_event_array[event_id].event_array[param_id].type; +} + +int ble_event_get_data_by_id(uint8_t event_id, uint8_t param_id, char *out_buf, uint16_t buf_len) +{ + int ret_len = 0; + + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return -1; + } + if (param_id >= sg_ble_event_array[event_id].array_size) { + ble_qiot_log_e("invalid param id %d", param_id); + return -1; + } + if (NULL == sg_ble_event_array[event_id].event_array[param_id].get_cb) { + ble_qiot_log_e("invalid callback, event id %d, param id %d", event_id, param_id); + return 0; + } + + if (!ble_check_space_enough_by_type(sg_ble_event_array[event_id].event_array[param_id].type, buf_len)) { + ble_qiot_log_e("not enough space get data, event id %d, param id %d", event_id, param_id); + return -1; + } + ret_len = sg_ble_event_array[event_id].event_array[param_id].get_cb(out_buf, buf_len); + if (ret_len < 0) { + ble_qiot_log_e("get event data failed, event id %d, param id %d", event_id, param_id); + return -1; + } else { + if (ble_check_ret_value_by_type(sg_ble_event_array[event_id].event_array[param_id].type, buf_len, ret_len)) { + return ret_len; + } else { + ble_qiot_log_e("evnet data length invalid, event id %d, param id %d, type %d", event_id, param_id, + sg_ble_event_array[event_id].event_array[param_id].type); + return -1; + } + } +} + +int ble_user_event_reply_handle(uint8_t event_id, uint8_t result) +{ + ble_qiot_log_d("event id %d, reply result %d", event_id, result); + + return BLE_QIOT_RS_OK; +} + +static int ble_action_handle_loop_input_cb(e_ble_tlv *input_param_array, uint8_t input_array_size, + uint8_t *output_id_array) +{ + int result = 0; + + if (NULL == input_param_array || NULL == output_id_array) { + ble_qiot_log_e("invalid param"); + return -1; + } + + report_reply_blink(); + for (int i = 0; i < input_array_size; i++) { + ble_qiot_log_d("id %d", input_param_array[i].id); + } + + memcpy(&result, input_param_array[0].val, sizeof(int)); + result = NTOHL(result); + ble_qiot_log_d("id %d, val %d", input_param_array[0].id, result); + action_led_blink(result); + + output_id_array[BLE_QIOT_ACTION_LOOP_OUTPUT_ID_RESULT] = true; + + return 0; +} + +static int ble_action_handle_loop_output_cb(uint8_t output_id, char *buf, uint16_t buf_len) +{ + int data_len = 0; + int i = 0; + + switch (output_id) { + case BLE_QIOT_ACTION_LOOP_OUTPUT_ID_RESULT: + for (i = 0; i < 26 * 3; i++) { + buf[i] = 'a' + (i % 26); + } + data_len = i; + break; + default: + break; + } + return data_len; +} + +static uint8_t sg_ble_action_loop_input_type_array[BLE_QIOT_ACTION_LOOP_INPUT_ID_BUTT] = { + BLE_QIOT_DATA_TYPE_INT, +}; + +static uint8_t sg_ble_action_loop_output_type_array[BLE_QIOT_ACTION_LOOP_OUTPUT_ID_BUTT] = { + BLE_QIOT_DATA_TYPE_STRING, +}; + +static ble_action_t sg_ble_action_array[BLE_QIOT_ACTION_ID_BUTT] = { + {ble_action_handle_loop_input_cb, ble_action_handle_loop_output_cb, sg_ble_action_loop_input_type_array, + sg_ble_action_loop_output_type_array, sizeof(sg_ble_action_loop_input_type_array) / sizeof(uint8_t), + sizeof(sg_ble_action_loop_output_type_array) / sizeof(uint8_t)}, +}; + +uint8_t ble_action_get_intput_type_by_id(uint8_t action_id, uint8_t input_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (input_id >= sg_ble_event_array[action_id].array_size) { + ble_qiot_log_e("invalid input id %d", input_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_action_array[action_id].input_type_array[input_id]; +} + +uint8_t ble_action_get_output_type_by_id(uint8_t action_id, uint8_t output_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (output_id >= sg_ble_event_array[action_id].array_size) { + ble_qiot_log_e("invalid output id %d", output_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_action_array[action_id].output_type_array[output_id]; +} + +int ble_action_get_input_id_size(uint8_t action_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + return sg_ble_action_array[action_id].input_id_size; +} + +int ble_action_get_output_id_size(uint8_t action_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + return sg_ble_action_array[action_id].output_id_size; +} + +int ble_action_user_handle_input_param(uint8_t action_id, e_ble_tlv *input_param_array, uint8_t input_array_size, + uint8_t *output_id_array) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + if (NULL != sg_ble_action_array[action_id].input_cb) { + if (0 != sg_ble_action_array[action_id].input_cb(input_param_array, input_array_size, output_id_array)) { + ble_qiot_log_e("input handle error"); + return -1; + } + } + + return 0; +} + +int ble_action_user_handle_output_param(uint8_t action_id, uint8_t output_id, char *buf, uint16_t buf_len) +{ + int ret_len = 0; + + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + if (NULL == sg_ble_action_array[action_id].output_cb) { + ble_qiot_log_e("invalid callback, action id %d", action_id); + return 0; + } + + if (!ble_check_space_enough_by_type(sg_ble_action_array[action_id].output_type_array[output_id], buf_len)) { + ble_qiot_log_e("not enough space get data, action id %d, output id %d", action_id, output_id); + return -1; + } + + ret_len = sg_ble_action_array[action_id].output_cb(output_id, buf, buf_len); + if (ret_len < 0) { + ble_qiot_log_e("get action data failed, action id %d, output id %d", action_id, output_id); + return -1; + } else { + if (ble_check_ret_value_by_type(sg_ble_action_array[action_id].output_type_array[output_id], buf_len, + ret_len)) { + return ret_len; + } else { + ble_qiot_log_e("action data length invalid, action id %d, output id %d", action_id, output_id); + return -1; + } + } +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/date_template/ble_qiot_template.h b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/date_template/ble_qiot_template.h new file mode 100644 index 00000000..76fdbd0c --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/date_template/ble_qiot_template.h @@ -0,0 +1,294 @@ +/* +* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. +* Licensed under the MIT License (the "License"); you may not use this file except in +* compliance with the License. You may obtain a copy of the License at +* http://opensource.org/licenses/MIT +* Unless required by applicable law or agreed to in writing, software distributed under the License is +* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +* either express or implied. See the License for the specific language governing permissions and +* limitations under the License. +* +*/ +#ifndef BLE_QIOT_TEMPLATE_H_ +#define BLE_QIOT_TEMPLATE_H_ +#ifdef __cplusplus +extern "C"{ +#endif + +#include + + +// data type in template, corresponding to type in json file +enum { + BLE_QIOT_DATA_TYPE_BOOL = 0, + BLE_QIOT_DATA_TYPE_INT, + BLE_QIOT_DATA_TYPE_STRING, + BLE_QIOT_DATA_TYPE_FLOAT, + BLE_QIOT_DATA_TYPE_ENUM, + BLE_QIOT_DATA_TYPE_TIME, + BLE_QIOT_DATA_TYPE_BUTT, +}; + +// message type, reference data template +enum { + BLE_QIOT_MSG_TYPE_PROPERTY = 0, + BLE_QIOT_MSG_TYPE_EVENT, + BLE_QIOT_MSG_TYPE_ACTION, + BLE_QIOT_MSG_TYPE_BUTT, +}; + +// define property authority, not used +enum { + BLE_QIOT_PROPERTY_AUTH_RW = 0, + BLE_QIOT_PROPERTY_AUTH_READ, + BLE_QIOT_PROPERTY_AUTH_BUTT, +}; + +// define reply result +enum { + BLE_QIOT_REPLY_SUCCESS = 0, + BLE_QIOT_REPLY_FAIL, + BLE_QIOT_REPLY_DATA_ERR, + BLE_QIOT_REPLY_BUTT, +}; + +// define message flow direction +enum { + BLE_QIOT_EFFECT_REQUEST = 0, + BLE_QIOT_EFFECT_REPLY, + BLE_QIOT_EFFECT_BUTT, +}; + +// define message type that from server to device +enum { + BLE_QIOT_DATA_DOWN_REPORT_REPLY = 0, + BLE_QIOT_DATA_DOWN_CONTROL, + BLE_QIOT_DATA_DOWN_GET_STATUS_REPLY, + BLE_QIOT_DATA_DOWN_ACTION, + BLE_QIOT_DATA_DOWN_EVENT_REPLY, +}; + +// define message type that from device to server +enum { + BLE_QIOT_EVENT_UP_PROPERTY_REPORT = 0, + BLE_QIOT_EVENT_UP_CONTROL_REPLY, + BLE_QIOT_EVENT_UP_GET_STATUS, + BLE_QIOT_EVENT_UP_EVENT_POST, + BLE_QIOT_EVENT_UP_ACTION_REPLY, + BLE_QIOT_EVENT_UP_BIND_SIGN_RET, + BLE_QIOT_EVENT_UP_CONN_SIGN_RET, + BLE_QIOT_EVENT_UP_UNBIND_SIGN_RET, + BLE_QIOT_EVENT_UP_REPORT_MTU, + BLE_QIOT_EVENT_UP_BUTT, +}; + +// msg header define, bit 7-6 is msg type, bit 5 means request or reply, bit 4 - 0 is id +#define BLE_QIOT_PARSE_MSG_HEAD_TYPE(_C) (((_C) & 0XFF) >> 6) +#define BLE_QIOT_PARSE_MSG_HEAD_EFFECT(_C) ((((_C) & 0XFF) & 0X20) ? BLE_QIOT_EFFECT_REPLY : BLE_QIOT_EFFECT_REQUEST) +#define BLE_QIOT_PARSE_MSG_HEAD_ID(_C) ((_C) & 0X1F) +#define BLE_QIOT_PACKAGE_MSG_HEAD(_TYPE, _REPLY, _ID) (((_TYPE) << 6) | (((_REPLY) == BLE_QIOT_EFFECT_REPLY) << 5) | ((_ID) & 0X1F)) + +// tlv header define, bit 7 - 5 is type, bit 4 - 0 depends on type of data template +#define BLE_QIOT_PARSE_TLV_HEAD_TYPE(_C) (((_C) & 0XFF) >> 5) +#define BLE_QIOT_PARSE_TLV_HEAD_ID(_C) ((_C) & 0X1F) +#define BLE_QIOT_PACKAGE_TLV_HEAD(_TYPE, _ID) (((_TYPE) << 5) | ((_ID) & 0X1F)) + + +// define tlv struct +typedef struct{ + uint8_t type; + uint8_t id; + uint16_t len; + char *val; +}e_ble_tlv; +#define BLE_QIOT_INCLUDE_PROPERTY + +// define property id +enum { + BLE_QIOT_PROPERTY_ID_POWER_SWITCH = 0, + BLE_QIOT_PROPERTY_ID_COLOR, + BLE_QIOT_PROPERTY_ID_BRIGHTNESS, + BLE_QIOT_PROPERTY_ID_NAME, + BLE_QIOT_PROPERTY_ID_BUTT, +}; + +// define property color enum +enum { + BLE_QIOT_PROPERTY_COLOR_RED = 0, + BLE_QIOT_PROPERTY_COLOR_GREEN = 1, + BLE_QIOT_PROPERTY_COLOR_BLUE = 2, + BLE_QIOT_PROPERTY_COLOR_BUTT = 3, +}; + +// define brightness attributes +#define BLE_QIOT_PROPERTY_BRIGHTNESS_STEP (1) +#define BLE_QIOT_PROPERTY_BRIGHTNESS_MIN (0) +#define BLE_QIOT_PROPERTY_BRIGHTNESS_MAX (100) +#define BLE_QIOT_PROPERTY_BRIGHTNESS_START (1) + +// define name length limit +#define BLE_QIOT_PROPERTY_NAME_LEN_MIN (0) +#define BLE_QIOT_PROPERTY_NAME_LEN_MAX (640) + +// define property set handle return 0 if success, other is error +// sdk call the function that inform the server data to the device +typedef int (*property_set_cb)(const char *data, uint16_t len); + +// define property get handle. return the data length obtained, -1 is error, 0 is no data +// sdk call the function fetch user data and send to the server, the data should wrapped by user adn skd just transmit +typedef int (*property_get_cb)(char *buf, uint16_t buf_len); + +// each property have a struct ble_property_t, make up a array named sg_ble_property_array +typedef struct{ + property_set_cb set_cb; //set callback + property_get_cb get_cb; //get callback + uint8_t authority; //property authority + uint8_t type; //data type +}ble_property_t; +#define BLE_QIOT_INCLUDE_EVENT + +// define event id +enum { + BLE_QIOT_EVENT_ID_STATUS_REPORT = 0, + BLE_QIOT_EVENT_ID_LOW_VOLTAGE, + BLE_QIOT_EVENT_ID_HARDWARE_FAULT, + BLE_QIOT_EVENT_ID_BUTT, +}; + +// define param id for event status_report +enum { + BLE_QIOT_EVENT_STATUS_REPORT_PARAM_ID_STATUS = 0, + BLE_QIOT_EVENT_STATUS_REPORT_PARAM_ID_MESSAGE, + BLE_QIOT_EVENT_STATUS_REPORT_PARAM_ID_BUTT, +}; + +// define range for param message +#define BLE_QIOT_EVENT_STATUS_REPORT_MESSAGE_LEN_MIN (0) +#define BLE_QIOT_EVENT_STATUS_REPORT_MESSAGE_LEN_MAX (64) + +// define param id for event low_voltage +enum { + BLE_QIOT_EVENT_LOW_VOLTAGE_PARAM_ID_VOLTAGE = 0, + BLE_QIOT_EVENT_LOW_VOLTAGE_PARAM_ID_BUTT, +}; + +// define param voltage attributes +#define BLE_QIOT_EVENT_LOW_VOLTAGE_VOLTAGE_STEP (1) +#define BLE_QIOT_EVENT_LOW_VOLTAGE_VOLTAGE_MIN (0.0) +#define BLE_QIOT_EVENT_LOW_VOLTAGE_VOLTAGE_MAX (24.0) +#define BLE_QIOT_EVENT_LOW_VOLTAGE_VOLTAGE_START (1) + +// define param id for event hardware_fault +enum { + BLE_QIOT_EVENT_HARDWARE_FAULT_PARAM_ID_NAME = 0, + BLE_QIOT_EVENT_HARDWARE_FAULT_PARAM_ID_ERROR_CODE, + BLE_QIOT_EVENT_HARDWARE_FAULT_PARAM_ID_BUTT, +}; + +// define range for param name +#define BLE_QIOT_EVENT_HARDWARE_FAULT_NAME_LEN_MIN (0) +#define BLE_QIOT_EVENT_HARDWARE_FAULT_NAME_LEN_MAX (64) + +// define param error_code attributes +#define BLE_QIOT_EVENT_HARDWARE_FAULT_ERROR_CODE_STEP (1) +#define BLE_QIOT_EVENT_HARDWARE_FAULT_ERROR_CODE_MIN (0) +#define BLE_QIOT_EVENT_HARDWARE_FAULT_ERROR_CODE_MAX (2000) +#define BLE_QIOT_EVENT_HARDWARE_FAULT_ERROR_CODE_START (1) + +// define event get handle. return the data length obtained, -1 is error, 0 is no data +// sdk call the function fetch user data and send to the server, the data should wrapped by user adn skd just transmit +typedef int (*event_get_cb)(char *buf, uint16_t buf_len); + +// each param have a struct ble_event_param, make up a array for the event +typedef struct{ + event_get_cb get_cb; //get param data callback + uint8_t type; //param type +}ble_event_param; + +// a array named sg_ble_event_array is composed by all the event array +typedef struct{ + ble_event_param *event_array; //array of params data + uint8_t array_size; //array size +}ble_event_t; +#define BLE_QIOT_INCLUDE_ACTION + +// define action id +enum { + BLE_QIOT_ACTION_ID_LOOP = 0, + BLE_QIOT_ACTION_ID_BUTT, +}; + +// define input id for action loop +enum { + BLE_QIOT_ACTION_LOOP_INPUT_ID_INTERVAL = 0, + BLE_QIOT_ACTION_LOOP_INPUT_ID_BUTT, +}; + +// define output id for action loop +enum { + BLE_QIOT_ACTION_LOOP_OUTPUT_ID_RESULT = 0, + BLE_QIOT_ACTION_LOOP_OUTPUT_ID_BUTT, +}; +#define BLE_QIOT_ACTION_INPUT_LOOP_INTERVAL_MIN (0) +#define BLE_QIOT_ACTION_INPUT_LOOP_INTERVAL_MAX (100) +#define BLE_QIOT_ACTION_INPUT_LOOP_INTERVAL_START (0) +#define BLE_QIOT_ACTION_INPUT_LOOP_INTERVAL_STEP (1) + +// define output id result attributes +#define BLE_QIOT_ACTION_OUTPUT_LOOP_RESULT_LEN_MIN (0) +#define BLE_QIOT_ACTION_OUTPUT_LOOP_RESULT_LEN_MAX (320) + +// define max input id and output id in all of input id and output id above +#define BLE_QIOT_ACTION_INPUT_ID_BUTT 1 +#define BLE_QIOT_ACTION_OUTPUT_ID_BUTT 1 + +// define action input handle, return 0 is success, other is error. +// input_param_array carry the data from server, include input id, data length ,data val +// input_array_size means how many input id +// output_id_array filling with output id numbers that need obtained, sdk will traverse it and call the action_output_handle to obtained data +typedef int (*action_input_handle)(e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array); + +// define action output handle, return length of the data, 0 is no data, -1 is error +// output_id means which id data should be obtained +typedef int (*action_output_handle)(uint8_t output_id, char *buf, uint16_t buf_len); + +// each action have a struct ble_action_t, make up a array named sg_ble_action_array +typedef struct{ + action_input_handle input_cb; //handle input data + action_output_handle output_cb; // get output data in the callback + uint8_t *input_type_array; //type array for input id + uint8_t *output_type_array; //type array for output id + uint8_t input_id_size; //numbers of input id + uint8_t output_id_size; //numbers of output id +}ble_action_t; +// property module +#ifdef BLE_QIOT_INCLUDE_PROPERTY +uint8_t ble_get_property_type_by_id(uint8_t id); +int ble_user_property_set_data(const e_ble_tlv *tlv); +int ble_user_property_get_data_by_id(uint8_t id, char *buf, uint16_t buf_len); +int ble_user_property_report_reply_handle(uint8_t result); +#endif + +// event module +#ifdef BLE_QIOT_INCLUDE_EVENT +int ble_event_get_id_array_size(uint8_t event_id); +uint8_t ble_event_get_param_id_type(uint8_t event_id, uint8_t param_id); +int ble_event_get_data_by_id(uint8_t event_id, uint8_t param_id, char *out_buf, uint16_t buf_len); +int ble_user_event_reply_handle(uint8_t event_id, uint8_t result); +#endif + +// action module +#ifdef BLE_QIOT_INCLUDE_ACTION +uint8_t ble_action_get_intput_type_by_id(uint8_t action_id, uint8_t input_id); +uint8_t ble_action_get_output_type_by_id(uint8_t action_id, uint8_t output_id); +int ble_action_get_input_id_size(uint8_t action_id); +int ble_action_get_output_id_size(uint8_t action_id); +int ble_action_user_handle_input_param(uint8_t action_id, e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array); +int ble_action_user_handle_output_param(uint8_t action_id, uint8_t output_id, char *buf, uint16_t buf_len); +#endif + + +#ifdef __cplusplus +} +#endif +#endif //BLE_QIOT_TEMPLATE_H_ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/date_template/nrf52832.json b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/date_template/nrf52832.json new file mode 100644 index 00000000..e313f550 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/date_template/nrf52832.json @@ -0,0 +1,183 @@ +{ + "version": "1.0", + "profile": { + "ProductId": "DHZX03IQAZ", + "CategoryId": "141" + }, + "properties": [ + { + "id": "power_switch", + "name": "电灯开关", + "desc": "控制电灯开灭", + "required": true, + "mode": "rw", + "define": { + "type": "bool", + "mapping": { + "0": "关", + "1": "开" + } + } + }, + { + "id": "color", + "name": "颜色", + "desc": "灯光颜色", + "mode": "rw", + "define": { + "type": "enum", + "mapping": { + "0": "Red", + "1": "Green", + "2": "Blue" + } + } + }, + { + "id": "brightness", + "name": "亮度", + "desc": "灯光亮度", + "mode": "rw", + "define": { + "type": "int", + "unit": "%", + "step": "1", + "min": "0", + "max": "100", + "start": "1" + } + }, + { + "id": "name", + "name": "灯位置名称", + "desc": "灯位置名称:书房、客厅等", + "mode": "rw", + "define": { + "type": "string", + "min": "0", + "max": "640" + }, + "required": false + } + ], + "events": [ + { + "id": "status_report", + "name": "DeviceStatus", + "desc": "Report the device status", + "type": "info", + "required": false, + "params": [ + { + "id": "status", + "name": "running_state", + "desc": "Report current device running state", + "define": { + "type": "bool", + "mapping": { + "0": "normal", + "1": "fault" + } + } + }, + { + "id": "message", + "name": "Message", + "desc": "Some extra message", + "define": { + "type": "string", + "min": "0", + "max": "64" + } + } + ] + }, + { + "id": "low_voltage", + "name": "LowVoltage", + "desc": "Alert for device voltage is low", + "type": "alert", + "required": false, + "params": [ + { + "id": "voltage", + "name": "Voltage", + "desc": "Current voltage", + "define": { + "type": "float", + "unit": "V", + "step": "1", + "min": "0.0", + "max": "24.0", + "start": "1" + } + } + ] + }, + { + "id": "hardware_fault", + "name": "Hardware_fault", + "desc": "Report hardware fault", + "type": "fault", + "required": false, + "params": [ + { + "id": "name", + "name": "Name", + "desc": "Name like: memory,tf card, censors ...", + "define": { + "type": "string", + "min": "0", + "max": "64" + } + }, + { + "id": "error_code", + "name": "Error_Code", + "desc": "Error code for fault", + "define": { + "type": "int", + "unit": "", + "step": "1", + "min": "0", + "max": "2000", + "start": "1" + } + } + ] + } + ], + "actions": [ + { + "id": "loop", + "name": "loop", + "desc": "", + "input": [ + { + "id": "interval", + "name": "interval", + "define": { + "type": "int", + "min": "0", + "max": "100", + "start": "0", + "step": "1", + "unit": "" + } + } + ], + "output": [ + { + "id": "result", + "name": "result", + "define": { + "type": "string", + "min": "0", + "max": "320" + } + } + ], + "required": false + } + ] +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/ble_qiot_ble_device.c b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/ble_qiot_ble_device.c new file mode 100644 index 00000000..57536749 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/ble_qiot_ble_device.c @@ -0,0 +1,313 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#include "ble_qiot_export.h" +#include "ble_qiot_service.h" +#include "ble_qiot_import.h" +#include "nrf52832_xxaa_service.h" + +// add std head file here +#include + +// add ble qiot head file here +#include "ble_qiot_import.h" + +// add sdk head file here +#include "nordic_common.h" +#include "nrf.h" +#include "app_error.h" +#include "ble.h" +#include "ble_err.h" +#include "ble_gap.h" +#include "ble_hci.h" +#include "ble_srv_common.h" +#include "ble_advdata.h" +#include "ble_conn_params.h" +#include "nrf_sdh.h" +#include "nrf_sdh_ble.h" +#include "boards.h" +#include "app_timer.h" +#include "app_button.h" +#include "nrf_ble_gatt.h" +#include "nrf_ble_qwr.h" +#include "nrf_pwr_mgmt.h" +#include "nrf_delay.h" +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +#include "nrf_log_default_backends.h" +#include "ble_qiot_config.h" + +#include "flash_storage.h" + +// divece info which defined in explorer platform +#define PRODUCT_ID "LR5NRSX9F5" +#define DEVICE_NAME "ble01" +#define SECRET_KEY "uG2TRl0hnCNsuLgls/65Bg==" + +static uint8_t m_adv_handle = + BLE_GAP_ADV_SET_HANDLE_NOT_SET; /**< Advertising handle used to identify an advertising set. */ +static uint8_t m_enc_advdata[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; /**< Buffer for storing an encoded advertising set. */ +static uint8_t m_enc_scan_response_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; /**< Buffer for storing an encoded scan data. */ + +/**@brief Struct that contains pointers to the encoded advertising data. */ +static ble_gap_adv_data_t m_adv_data = { + .adv_data = {.p_data = m_enc_advdata, .len = BLE_GAP_ADV_SET_DATA_SIZE_MAX}, + .scan_rsp_data = {.p_data = m_enc_scan_response_data, .len = BLE_GAP_ADV_SET_DATA_SIZE_MAX + + }}; + +int ble_get_product_id(char *product_id) +{ + memcpy(product_id, PRODUCT_ID, strlen(PRODUCT_ID)); + + return 0; +} + +int ble_get_device_name(char *device_name) +{ + memcpy(device_name, DEVICE_NAME, strlen(DEVICE_NAME)); + + return strlen(DEVICE_NAME); +} + +int ble_get_psk(char *psk) +{ + memcpy(psk, SECRET_KEY, strlen(SECRET_KEY)); + + return 0; +} + +int ble_get_mac(char *mac) +{ + uint32_t err_code; + ble_gap_addr_t mac_info; + + err_code = sd_ble_gap_addr_get(&mac_info); + if (NRF_SUCCESS != err_code) { + NRF_LOG_ERROR("Get MAC error, ret %d", err_code); + return err_code; + } + mac[0] = mac_info.addr[5]; + mac[1] = mac_info.addr[4]; + mac[2] = mac_info.addr[3]; + mac[3] = mac_info.addr[2]; + mac[4] = mac_info.addr[1]; + mac[5] = mac_info.addr[0]; + + return 0; +} + +int ble_write_flash(uint32_t flash_addr, const char *write_buf, uint16_t write_len) +{ + return fstorage_write(flash_addr, write_len, write_buf); +} + +int ble_read_flash(uint32_t flash_addr, char *read_buf, uint16_t read_len) +{ + return fstorage_read(flash_addr, read_len, read_buf); +} + +ble_qiot_ret_status_t ble_advertising_start(adv_info_s *adv) +{ + ret_code_t err_code; + + ble_gap_adv_params_t adv_params; + ble_advdata_t advdata; + + // set Scan Response data, here set service uuid + ble_advdata_t srdata; + memset(&srdata, 0, sizeof(srdata)); + ble_uuid_t adv_uuids[1]; + adv_uuids[0].uuid = adv->uuid_info.uuids[0]; + adv_uuids[0].type = BLE_UUID_TYPE_BLE; + srdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]); + srdata.uuids_complete.p_uuids = adv_uuids; + err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len); + APP_ERROR_CHECK(err_code); + + // Build and set advertising data. + memset(&advdata, 0, sizeof(advdata)); + advdata.name_type = BLE_ADVDATA_FULL_NAME; + advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE; + + // set Advertising Data + ble_advdata_manuf_data_t manf_data; + memset(&manf_data, 0, sizeof(manf_data)); + manf_data.company_identifier = adv->manufacturer_info.company_identifier; + manf_data.data.size = adv->manufacturer_info.adv_data_len; + manf_data.data.p_data = adv->manufacturer_info.adv_data; + advdata.p_manuf_specific_data = &manf_data; + + err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len); + APP_ERROR_CHECK(err_code); + + // Set advertising parameters. + memset(&adv_params, 0, sizeof(adv_params)); + + adv_params.primary_phy = BLE_GAP_PHY_1MBPS; + adv_params.duration = APP_ADV_DURATION; + adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED; + adv_params.p_peer_addr = NULL; + adv_params.filter_policy = BLE_GAP_ADV_FP_ANY; + adv_params.interval = APP_ADV_INTERVAL; + + err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params); + if (NRF_SUCCESS != err_code) { + NRF_LOG_ERROR("sd_ble_gap_adv_set_configure error, ret %d", err_code); + return BLE_QIOT_RS_ERR; + } + + err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG); + if (NRF_SUCCESS != err_code) { + NRF_LOG_ERROR("sd_ble_gap_adv_start error, ret %d", err_code); + return BLE_QIOT_RS_ERR; + } + + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_advertising_stop(void) +{ + ret_code_t err_code; + + err_code = sd_ble_gap_adv_stop(m_adv_handle); + if (NRF_SUCCESS != err_code) { + NRF_LOG_ERROR("sd_ble_gap_adv_stop error, ret %d", err_code); + return BLE_QIOT_RS_ERR; + } + + return BLE_QIOT_RS_OK; +} + +// define a static timer used in bind for example, a good way is used malloc +APP_TIMER_DEF(ble_bind_timer); + +ble_timer_t ble_timer_create(uint8_t type, ble_timer_cb timeout_handle) +{ + app_timer_create((app_timer_id_t const *)&ble_bind_timer, + type == BLE_TIMER_ONE_SHOT_TYPE ? APP_TIMER_MODE_SINGLE_SHOT : APP_TIMER_MODE_REPEATED, + (app_timer_timeout_handler_t)timeout_handle); + NRF_LOG_INFO("create timer id %p", (ble_timer_t)ble_bind_timer); + + return (ble_timer_t)ble_bind_timer; +} + +ble_qiot_ret_status_t ble_timer_start(ble_timer_t timer_id, uint32_t period) +{ + ret_code_t ret = 0; + + ret = app_timer_start((app_timer_id_t)timer_id, APP_TIMER_TICKS(period), NULL); + NRF_LOG_INFO("start timer id %p, tick %d, ret %d", timer_id, APP_TIMER_TICKS(period), ret); + + return 0 == ret ? BLE_QIOT_RS_OK : BLE_QIOT_RS_ERR; +} + +ble_qiot_ret_status_t ble_timer_stop(ble_timer_t timer_id) +{ + ret_code_t ret = 0; + + ret = app_timer_stop(timer_id); + NRF_LOG_INFO("stop timer id %p, ret %d", timer_id, ret); + + return 0 == ret ? BLE_QIOT_RS_OK : BLE_QIOT_RS_ERR; +} + +ble_qiot_ret_status_t ble_timer_delete(ble_timer_t timer_id) +{ + // do nothing + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_send_notify(uint8_t *buf, uint8_t len) +{ + ret_code_t err_code; + ble_gatts_hvx_params_t params; + uint16_t data_len = len; + ble_priv_cfg_s * p_cfg; + + p_cfg = ble_get_priv_cfg(); + + memset(¶ms, 0, sizeof(params)); + params.type = BLE_GATT_HVX_NOTIFICATION; + params.handle = p_cfg->event_char_handle.value_handle; // handle, corresponds to the same characteristic + params.p_data = buf; + params.p_len = &data_len; // do not large than length set in characteristic + + err_code = sd_ble_gatts_hvx(p_cfg->conn_handle, ¶ms); + if (NRF_SUCCESS != err_code) { + NRF_LOG_ERROR("sd_ble_gatts_hvx error, ret %d", err_code); + return BLE_QIOT_RS_ERR; + } + + return BLE_QIOT_RS_OK; +} + +// should return ATT_MTU - 3 +uint16_t ble_get_user_data_mtu_size(void) +{ + ble_priv_cfg_s *p_cfg; + nrf_ble_gatt_t *p_gatt; + + p_cfg = ble_get_priv_cfg(); + p_gatt = ble_get_gatt_instance(); + + return nrf_ble_gatt_eff_mtu_get(p_gatt, p_cfg->conn_handle) - 3; +} + +void property_power_switch(const char *data, uint16_t len) +{ + if (data[0]) { + bsp_board_led_on(BSP_BOARD_LED_0); + NRF_LOG_INFO("Received LED ON!"); + } else { + bsp_board_led_off(BSP_BOARD_LED_0); + NRF_LOG_INFO("Received LED OFF!"); + } + return; +} + +void action_led_blink(int ms) +{ + bsp_board_led_on(BSP_BOARD_LED_1); + nrf_delay_ms(ms); + bsp_board_led_off(BSP_BOARD_LED_1); + nrf_delay_ms(ms); + bsp_board_led_on(BSP_BOARD_LED_1); + nrf_delay_ms(ms); + bsp_board_led_off(BSP_BOARD_LED_1); + nrf_delay_ms(ms); + bsp_board_led_on(BSP_BOARD_LED_1); + nrf_delay_ms(ms); + bsp_board_led_off(BSP_BOARD_LED_1); +} + +void report_reply_blink(void) +{ + bsp_board_led_on(BSP_BOARD_LED_2); + nrf_delay_ms(200); + bsp_board_led_off(BSP_BOARD_LED_2); + nrf_delay_ms(200); + bsp_board_led_on(BSP_BOARD_LED_2); + nrf_delay_ms(200); + bsp_board_led_off(BSP_BOARD_LED_2); +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/ble_qiot_ble_device.h b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/ble_qiot_ble_device.h new file mode 100644 index 00000000..d6f69c50 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/ble_qiot_ble_device.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_QIOT_DEVICE_H +#define QCLOUD_BLE_QIOT_DEVICE_H + +#ifdef __cplusplus +extern "C" { +#endif + +void property_power_switch(const char *data, uint16_t len); +void report_reply_blink(void); +void action_led_blink(int ms); +#ifdef __cplusplus +} +#endif + +#endif // QCLOUD_BLE_QIOT_DEVICE_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/ble_qiot_config.h b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/ble_qiot_config.h new file mode 100644 index 00000000..8b41cf07 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/ble_qiot_config.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_QIOT_CONFIG_H +#define QCLOUD_BLE_QIOT_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define BLE_QIOT_SDK_VERSION "1.2.0" // sdk version +#define BLE_QIOT_SDK_DEBUG 0 // sdk debug switch + +// the device broadcast is controlled by the user, but we provide a mechanism to help the device save more power. +// if you want broadcast is triggered by something like press a button instead of all the time, and the broadcast +// stopped automatically in a few minutes if the device is not bind, define BLE_QIOT_BUTTON_BROADCAST is 1 and +// BLE_QIOT_BIND_TIMEOUT is the period that broadcast stopped. +// if the device in the bound state, broadcast dose not stop automatically. +#define BLE_QIOT_BUTTON_BROADCAST 1 +#if (1 == BLE_QIOT_BUTTON_BROADCAST) +#define BLE_QIOT_BIND_TIMEOUT (2 * 60 * 1000) // unit: ms +#endif + +// some data like integer need to be transmitted in a certain byte order, defined it according to your device +#define __ORDER_LITTLE_ENDIAN__ 1234 +#define __ORDER_BIG_ENDIAN__ 4321 +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ + +// the following definition will affect the stack that LLSync used,the minimum value tested is +// 2048(BLE_QIOT_EVENT_MAX_SIZE is 128, BLE_QIOT_EVENT_BUF_SIZE is 23 ) the max length that llsync event data, depends +// on the length of user data reported to Tencent Lianlian at a time +#define BLE_QIOT_EVENT_MAX_SIZE (512) +// the minimum between BLE_QIOT_EVENT_MAX_SIZE and mtu +#define BLE_QIOT_EVENT_BUF_SIZE (256) + +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +#include "nrf_log_default_backends.h" + +// in some BLE stack ble_qiot_log_hex() maybe not work, user can use there own hexdump function +#define BLE_QIOT_USER_DEFINE_HEDUMP 1 + +#if (1 == BLE_QIOT_USER_DEFINE_HEDUMP) +#define ble_qiot_log_hex(level, hex_name, data, data_len) \ + do { \ + NRF_LOG_INFO("\r\nble qiot dump: %s, length: %d\r\n", hex_name, data_len); \ + NRF_LOG_RAW_HEXDUMP_INFO(data, data_len); \ + } while (0) +#endif // BLE_QIOT_USER_DEFINE_HEDUMP + +// Macro for logging a formatted string, the function must printf raw string without any color, prefix, newline or +// timestamp +#define BLE_QIOT_LOG_PRINT(...) NRF_LOG_RAW_INFO(__VA_ARGS__) + +// nrf52832xxAA Flash size is 512KB, nrf52832xxAB Flash size is 512KB, be carefol of the address! +#define BLE_QIOT_RECORD_FLASH_ADDR 0x7e000 // qiot data storage address +#define BLE_QIOT_RECORD_FLASH_PAGESIZE 4096 // flash page size, see chip datasheet +#define BLE_QIOT_RECORD_FLASH_PAGENUM 2 // how many pages qiot use + +#define APP_BLE_OBSERVER_PRIO 3 /**< Application's BLE observer priority. You shouldn't need to modify this value. */ +#define APP_BLE_CONN_CFG_TAG 1 /**< A tag identifying the SoftDevice BLE configuration. */ + +#define APP_ADV_INTERVAL 64 /**< The advertising interval (in units of 0.625 ms; this value corresponds to 40 ms). */ +#define APP_ADV_DURATION \ + BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED /**< The advertising time-out (in units of seconds). When set to 0, we will \ + never time out. */ + +#ifdef __cplusplus +} +#endif + +#endif // QCLOUD_BLE_QIOT_CONFIG_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/flash_storage.c b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/flash_storage.c new file mode 100644 index 00000000..0803a2da --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/flash_storage.c @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "flash_storage.h" +#include "ble_qiot_config.h" +#include "nrf_fstorage.h" +#include "nrf_sdh.h" +#include "nrf_sdh_ble.h" +#include "nrf_fstorage_sd.h" +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +#include "nrf_log_default_backends.h" +#include + +static void fstorage_evt_handler(nrf_fstorage_evt_t *p_evt); + +NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) = { + /* Set a handler for fstorage events. */ + .evt_handler = fstorage_evt_handler, + + /* These below are the boundaries of the flash space assigned to this instance of fstorage. + * You must set these manually, even at runtime, before nrf_fstorage_init() is called. + * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the + * last page of flash available to write data. */ + .start_addr = 0x7e000, + .end_addr = 0x7ffff, +}; + +static void *p_write_buf = NULL; + +void fstorage_init(void) +{ + nrf_fstorage_api_t *p_fs_api; + ret_code_t rc; + +#ifdef SOFTDEVICE_PRESENT + NRF_LOG_INFO("SoftDevice is present."); + NRF_LOG_INFO("Initializing nrf_fstorage_sd implementation..."); + /* Initialize an fstorage instance using the nrf_fstorage_sd backend. + * nrf_fstorage_sd uses the SoftDevice to write to flash. This implementation can safely be + * used whenever there is a SoftDevice, regardless of its status (enabled/disabled). */ + p_fs_api = &nrf_fstorage_sd; +#else + NRF_LOG_INFO("SoftDevice not present."); + NRF_LOG_INFO("Initializing nrf_fstorage_nvmc implementation..."); + /* Initialize an fstorage instance using the nrf_fstorage_nvmc backend. + * nrf_fstorage_nvmc uses the NVMC peripheral. This implementation can be used when the + * SoftDevice is disabled or not present. + * + * Using this implementation when the SoftDevice is enabled results in a hardfault. */ + p_fs_api = &nrf_fstorage_nvmc; +#endif + + p_write_buf = NULL; + rc = nrf_fstorage_init(&fstorage, p_fs_api, NULL); + APP_ERROR_CHECK(rc); +} + +/**@brief Helper function to obtain the last address on the last page of the on-chip flash that + * can be used to write user data. + * It is possible to set the start and end addresses of an fstorage instance at runtime. + * They can be set multiple times, should it be needed. The helper function below can + * be used to determine the last address on the last page of flash memory available to + * store data. + */ +/* +static uint32_t nrf5_flash_end_addr_get() +{ + uint32_t const bootloader_addr = NRF_UICR->NRFFW[0]; + uint32_t const page_sz = NRF_FICR->CODEPAGESIZE; + uint32_t const code_sz = NRF_FICR->CODESIZE; + + return (bootloader_addr != 0xFFFFFFFF ? + bootloader_addr : (code_sz * page_sz)); +} +*/ + +/**@brief Sleep until an event is received. */ +static void power_manage(void) +{ +#ifdef SOFTDEVICE_PRESENT + (void)sd_app_evt_wait(); +#else + __WFE(); +#endif +} + +int fstorage_read(uint32_t addr, uint32_t read_len, void *p_data) +{ + ret_code_t rc; + + /* Read data. */ + rc = nrf_fstorage_read(&fstorage, addr, p_data, read_len); + if (rc != NRF_SUCCESS) { + NRF_LOG_ERROR("nrf_fstorage_read() returned: %s\n", nrf_strerror_get(rc)); + return 0; + } + + return read_len; +} + +static uint32_t round_up_u32(uint32_t len) +{ + if (len % sizeof(uint32_t)) { + return (len + sizeof(uint32_t) - (len % sizeof(uint32_t))); + } + + return len; +} + +int fstorage_erase(uint32_t addr) +{ + ret_code_t rc; + + rc = nrf_fstorage_erase(&fstorage, addr, BLE_QIOT_RECORD_FLASH_PAGENUM, NULL); + if (rc != NRF_SUCCESS) { + NRF_LOG_ERROR("nrf_fstorage_erase() returned: %s\n", nrf_strerror_get(rc)); + return rc; + } + + return 0; +} + +int fstorage_write(uint32_t addr, uint32_t write_len, void const *p_data) +{ + /* The following code snippet make sure that the length of the data we are writing to flash + * is a multiple of the program unit of the flash peripheral (4 bytes). + */ + uint32_t len = round_up_u32(write_len); + ret_code_t rc; + + rc = nrf_fstorage_erase(&fstorage, addr, BLE_QIOT_RECORD_FLASH_PAGENUM, NULL); + if (rc != NRF_SUCCESS) { + NRF_LOG_ERROR("nrf_fstorage_erase() returned: %s\n", nrf_strerror_get(rc)); + } + + /* Copy the data to write in flash. + * Because the fstorage interface is asynchrounous, the data must be kept in memory before get + * the NRF_FSTORAGE_EVT_WRITE_RESULT event. This memory will be free in fstorage_evt_handler(). + */ + p_write_buf = (void *)malloc(len); + if (NULL == p_write_buf) { + NRF_LOG_ERROR("fstorage_write() malloc size %d error", len); + return 0; + } + + memset(p_write_buf, 0, len); + memcpy(p_write_buf, p_data, write_len); + + rc = nrf_fstorage_write(&fstorage, addr, p_write_buf, len, NULL); + if (rc != NRF_SUCCESS) { + NRF_LOG_ERROR("nrf_fstorage_write() returned: %s\n", nrf_strerror_get(rc)); + return 0; + } + + return write_len; +} + +static void fstorage_evt_handler(nrf_fstorage_evt_t *p_evt) +{ + if (p_evt->result != NRF_SUCCESS) { + NRF_LOG_INFO("fstorage event received: ERROR while executing an fstorage operation."); + return; + } + + switch (p_evt->id) { + case NRF_FSTORAGE_EVT_WRITE_RESULT: { + free(p_write_buf); + p_write_buf = NULL; + NRF_LOG_INFO("fstorage event received: wrote %d bytes at address 0x%x.", p_evt->len, p_evt->addr); + } break; + + case NRF_FSTORAGE_EVT_ERASE_RESULT: { + NRF_LOG_INFO("fstorage event received: erased %d page from address 0x%x.", p_evt->len, p_evt->addr); + } break; + + default: + break; + } +} + +/** + * @brief While fstorage is busy, sleep and wait for an event. + * + * @param p_fstorage nrf_fstorage_t obj + */ +void wait_for_flash_ready(nrf_fstorage_t const *p_fstorage) +{ + /* While fstorage is busy, sleep and wait for an event. */ + while (nrf_fstorage_is_busy(p_fstorage)) { + power_manage(); + } +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/flash_storage.h b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/flash_storage.h new file mode 100644 index 00000000..e48b251e --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/flash_storage.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +/** + * @brief initialize of flash storage + * + */ +void fstorage_init(void); + +/** + * @brief read data from flash + * + * @param addr read address from flash + * @param read_len length of data to read + * @param p_data point to read buf + * @return read length is success, other is error + */ +int fstorage_read(uint32_t addr, uint32_t read_len, void *p_data); + +/** + * @brief write data to flash, must erase before write + * + * @param addr write address in flash + * @param write_len length of data to write + * @param p_data point to write buf + * @return write length is success, other is error + */ +int fstorage_write(uint32_t addr, uint32_t write_len, void const *p_data); + +/** + * @brief erase one page + * + * @param addr address must align to page. For example, one page is 4096 bytes, + * you want to erase address 0x1020, you should set address 0x1000 + * @return 0 is succcess, other is error + */ +int fstorage_erase(uint32_t addr); diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/nrf52832_xxaa_service.c b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/nrf52832_xxaa_service.c new file mode 100644 index 00000000..abac8ca7 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/nrf52832_xxaa_service.c @@ -0,0 +1,333 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "nrf52832_xxaa_service.h" + +#include +#include + +#include "nordic_common.h" +#include "nrf.h" +#include "app_error.h" +#include "ble.h" +#include "ble_err.h" +#include "ble_hci.h" +#include "ble_srv_common.h" +#include "ble_advdata.h" +#include "ble_conn_params.h" +#include "nrf_sdh.h" +#include "nrf_sdh_ble.h" +#include "boards.h" +#include "app_timer.h" +#include "app_button.h" +#include "nrf_ble_gatt.h" +#include "nrf_ble_qwr.h" +#include "nrf_pwr_mgmt.h" + +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +#include "nrf_log_default_backends.h" + +#include "ble_qiot_service.h" +#include "ble_qiot_import.h" + +BLE_PRIV_DEF(priv_cfg); +NRF_BLE_GATT_DEF(m_gatt); /**< GATT module instance. */ + +#define ATTRIBUTE_VALUE_MAX_LEN 256 + +ble_priv_cfg_s *ble_get_priv_cfg(void) +{ + return &priv_cfg; +} + +nrf_ble_gatt_t *ble_get_gatt_instance(void) +{ + return &m_gatt; +} + +// on_write event +static void on_write(ble_priv_cfg_s *p_cfg, ble_evt_t const *p_ble_evt) +{ + ble_gatts_evt_write_t const *p_evt_write = &p_ble_evt->evt.gatts_evt.params.write; + + // print raw data for debug + NRF_LOG_INFO("dump write data, len %d", p_evt_write->len); + NRF_LOG_RAW_HEXDUMP_INFO(p_evt_write->data, p_evt_write->len); + + if ((p_evt_write->handle == p_cfg->device_info_char_handle.value_handle) && + (p_cfg->iot_device_info_write_handler != NULL)) { + p_cfg->iot_device_info_write_handler(p_evt_write->data, p_evt_write->len); + } else if ((p_evt_write->handle == p_cfg->data_char_handle.value_handle) && + (p_cfg->iot_data_write_handler != NULL)) { + p_cfg->iot_data_write_handler(p_evt_write->data, p_evt_write->len); + } +} + +void iot_on_ble_evt(ble_evt_t const *p_ble_evt, void *p_context) +{ + ret_code_t err_code; + ble_priv_cfg_s *p_cfg = (ble_priv_cfg_s *)p_context; + + NRF_LOG_INFO("evt_id %d", p_ble_evt->header.evt_id); + switch (p_ble_evt->header.evt_id) { + case BLE_GAP_EVT_CONNECTED: + // on_connect(p_hrs, p_ble_evt); + NRF_LOG_INFO("Connected"); + p_cfg->conn_handle = p_ble_evt->evt.gap_evt.conn_handle; + ble_gap_connect_cb(); + break; + + case BLE_GAP_EVT_DISCONNECTED: + // on_disconnect(p_hrs, p_ble_evt); + NRF_LOG_INFO("Disconnected"); + p_cfg->conn_handle = BLE_CONN_HANDLE_INVALID; + ble_gap_disconnect_cb(); + + break; + + case BLE_GATTS_EVT_WRITE: + on_write(p_cfg, p_ble_evt); + break; + + case BLE_GATTS_EVT_SYS_ATTR_MISSING: + // No system attributes have been stored. + err_code = sd_ble_gatts_sys_attr_set(p_cfg->conn_handle, NULL, 0, 0); + APP_ERROR_CHECK(err_code); + // NRF_LOG_INFO("err_code %d", err_code); + break; + + case BLE_GATTS_EVT_HVC: + NRF_LOG_INFO("indication response %d", p_ble_evt->evt.gatts_evt.params.hvn_tx_complete.count); + break; +#if defined(S132) + case BLE_GAP_EVT_PHY_UPDATE_REQUEST: { + NRF_LOG_DEBUG("PHY update request."); + ble_gap_phys_t const phys = { + .rx_phys = BLE_GAP_PHY_AUTO, + .tx_phys = BLE_GAP_PHY_AUTO, + }; + err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys); + APP_ERROR_CHECK(err_code); + } break; +#endif + + default: + // No implementation needed. + break; + } +} + +// add services and characteristic +void ble_services_add(const qiot_service_init_s *p_service) +{ + ret_code_t err_code; + + ble_uuid_t service_uuid; + ble_uuid128_t ble_uuid128; + + ble_gatts_char_md_t char_md; + ble_gatts_attr_t attr_char_value; + ble_uuid_t char_uuid; + ble_gatts_attr_md_t attr_md; + ble_gatts_attr_md_t user_descr_attr_md; + ble_gatts_attr_md_t cccd_md; + + ble_priv_cfg_s *p_cfg; + + p_cfg = ble_get_priv_cfg(); + + /*************************************************************************/ + // if it's necessary to save those configuration in private configuration + p_cfg->iot_device_info_write_handler = p_service->device_info.on_write; + p_cfg->iot_data_write_handler = p_service->data.on_write; + + /*************************************************************************/ + // add service + + // set uuid128 to ble stack, return uuid type + memcpy(ble_uuid128.uuid128, p_service->service_uuid128, sizeof(ble_uuid128.uuid128)); + err_code = sd_ble_uuid_vs_add(&ble_uuid128, &p_cfg->uuid_type); + + // set service uuid + service_uuid.type = p_cfg->uuid_type; + service_uuid.uuid = IOT_BLE_UUID_SERVICE; + + err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &service_uuid, &p_cfg->service_handle); + if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("err at file %s, line %d, err_code %d \n", __FILE__, __LINE__, err_code); + return; + } + + /*************************************************************************/ + // set device info characteristic, uuid 0xFEE1 + memset(&char_md, 0, sizeof(char_md)); + memset(&attr_char_value, 0, sizeof(attr_char_value)); + memset(&char_uuid, 0, sizeof(char_uuid)); + memset(&attr_md, 0, sizeof(attr_md)); + memset(&user_descr_attr_md, 0, sizeof(user_descr_attr_md)); + memset(&cccd_md, 0, sizeof(cccd_md)); + + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm); + // BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&cccd_md.write_perm); + cccd_md.rd_auth = 0; + cccd_md.wr_auth = 0; + cccd_md.vlen = 1; + cccd_md.vloc = BLE_GATTS_VLOC_STACK; + + char_md.char_props.broadcast = ((p_service->device_info.gatt_char_props & GATT_CHAR_BROADCAST) ? 1 : 0); + char_md.char_props.read = ((p_service->device_info.gatt_char_props & GATT_CHAR_READ) ? 1 : 0); + char_md.char_props.write_wo_resp = ((p_service->device_info.gatt_char_props & GATT_CHAR_WRITE_WO_RESP) ? 1 : 0); + char_md.char_props.write = ((p_service->device_info.gatt_char_props & GATT_CHAR_WRITE) ? 1 : 0); + char_md.char_props.notify = ((p_service->device_info.gatt_char_props & GATT_CHAR_NOTIFY) ? 1 : 0); + char_md.char_props.indicate = ((p_service->device_info.gatt_char_props & GATT_CHAR_INDICATE) ? 1 : 0); + char_md.char_props.auth_signed_wr = ((p_service->device_info.gatt_char_props & GATT_CHAR_AUTH_SIGNED_WR) ? 1 : 0); + + char_md.p_char_pf = NULL; + char_md.p_user_desc_md = NULL; + char_md.p_cccd_md = &cccd_md; + char_md.p_sccd_md = NULL; + + char_uuid.type = p_cfg->uuid_type; + char_uuid.uuid = p_service->device_info.uuid16; + + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); + attr_md.vloc = BLE_GATTS_VLOC_STACK; + attr_md.rd_auth = 0; + attr_md.wr_auth = 0; + attr_md.vlen = 1; + + attr_char_value.p_uuid = &char_uuid; + attr_char_value.p_attr_md = &attr_md; + attr_char_value.init_len = sizeof(uint8_t); + attr_char_value.init_offs = 0; + attr_char_value.max_len = sizeof(uint8_t) * ATTRIBUTE_VALUE_MAX_LEN; + attr_char_value.p_value = NULL; + + err_code = sd_ble_gatts_characteristic_add(p_cfg->service_handle, &char_md, &attr_char_value, + &p_cfg->device_info_char_handle); + if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("err at file %s, line %d, err_code %d \n", __FILE__, __LINE__, err_code); + return; + } + + /*************************************************************************/ + // set data characteristic, uuid 0xFEE2 + memset(&char_md, 0, sizeof(char_md)); + memset(&attr_char_value, 0, sizeof(attr_char_value)); + memset(&char_uuid, 0, sizeof(char_uuid)); + memset(&attr_md, 0, sizeof(attr_md)); + memset(&user_descr_attr_md, 0, sizeof(user_descr_attr_md)); + memset(&cccd_md, 0, sizeof(cccd_md)); + + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm); + // BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&cccd_md.write_perm); + cccd_md.rd_auth = 0; + cccd_md.wr_auth = 0; + cccd_md.vlen = 1; + cccd_md.vloc = BLE_GATTS_VLOC_STACK; + + char_md.char_props.broadcast = ((p_service->data.gatt_char_props & GATT_CHAR_BROADCAST) ? 1 : 0); + char_md.char_props.read = ((p_service->data.gatt_char_props & GATT_CHAR_READ) ? 1 : 0); + char_md.char_props.write_wo_resp = ((p_service->data.gatt_char_props & GATT_CHAR_WRITE_WO_RESP) ? 1 : 0); + char_md.char_props.write = ((p_service->data.gatt_char_props & GATT_CHAR_WRITE) ? 1 : 0); + char_md.char_props.notify = ((p_service->data.gatt_char_props & GATT_CHAR_NOTIFY) ? 1 : 0); + char_md.char_props.indicate = ((p_service->data.gatt_char_props & GATT_CHAR_INDICATE) ? 1 : 0); + char_md.char_props.auth_signed_wr = ((p_service->data.gatt_char_props & GATT_CHAR_AUTH_SIGNED_WR) ? 1 : 0); + + char_md.p_char_pf = NULL; + char_md.p_user_desc_md = NULL; + char_md.p_cccd_md = &cccd_md; + char_md.p_sccd_md = NULL; + + char_uuid.type = p_cfg->uuid_type; + char_uuid.uuid = p_service->data.uuid16; + + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); + attr_md.vloc = BLE_GATTS_VLOC_STACK; + attr_md.rd_auth = 0; + attr_md.wr_auth = 0; + attr_md.vlen = 1; + + attr_char_value.p_uuid = &char_uuid; + attr_char_value.p_attr_md = &attr_md; + attr_char_value.init_len = sizeof(uint8_t); + attr_char_value.init_offs = 0; + attr_char_value.max_len = sizeof(uint8_t) * ATTRIBUTE_VALUE_MAX_LEN; + attr_char_value.p_value = NULL; + + err_code = + sd_ble_gatts_characteristic_add(p_cfg->service_handle, &char_md, &attr_char_value, &p_cfg->data_char_handle); + if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("err at file %s, line %d, err_code %d \n", __FILE__, __LINE__, err_code); + return; + } + + /*************************************************************************/ + // set event characteristic, uuid 0xFEE3 + memset(&char_md, 0, sizeof(char_md)); + memset(&attr_char_value, 0, sizeof(attr_char_value)); + memset(&char_uuid, 0, sizeof(char_uuid)); + memset(&attr_md, 0, sizeof(attr_md)); + memset(&user_descr_attr_md, 0, sizeof(user_descr_attr_md)); + memset(&cccd_md, 0, sizeof(cccd_md)); + + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm); + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm); + // BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&cccd_md.write_perm); + cccd_md.rd_auth = 0; + cccd_md.wr_auth = 0; + cccd_md.vlen = 1; + cccd_md.vloc = BLE_GATTS_VLOC_STACK; + + char_md.char_props.broadcast = ((p_service->event.gatt_char_props & GATT_CHAR_BROADCAST) ? 1 : 0); + char_md.char_props.read = ((p_service->event.gatt_char_props & GATT_CHAR_READ) ? 1 : 0); + char_md.char_props.write_wo_resp = ((p_service->event.gatt_char_props & GATT_CHAR_WRITE_WO_RESP) ? 1 : 0); + char_md.char_props.write = ((p_service->event.gatt_char_props & GATT_CHAR_WRITE) ? 1 : 0); + char_md.char_props.notify = ((p_service->event.gatt_char_props & GATT_CHAR_NOTIFY) ? 1 : 0); + char_md.char_props.indicate = ((p_service->event.gatt_char_props & GATT_CHAR_INDICATE) ? 1 : 0); + char_md.char_props.auth_signed_wr = ((p_service->event.gatt_char_props & GATT_CHAR_AUTH_SIGNED_WR) ? 1 : 0); + + char_md.p_char_pf = NULL; + char_md.p_user_desc_md = NULL; + char_md.p_cccd_md = &cccd_md; + char_md.p_sccd_md = NULL; + + char_uuid.type = p_cfg->uuid_type; + char_uuid.uuid = p_service->event.uuid16; + + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); + attr_md.vloc = BLE_GATTS_VLOC_STACK; + attr_md.rd_auth = 0; + attr_md.wr_auth = 0; + attr_md.vlen = 1; + + attr_char_value.p_uuid = &char_uuid; + attr_char_value.p_attr_md = &attr_md; + // attr_char_value.init_len = sizeof(uint8_t); + attr_char_value.init_len = sizeof(uint8_t) * 10; + attr_char_value.init_offs = 0; + attr_char_value.max_len = sizeof(uint8_t) * ATTRIBUTE_VALUE_MAX_LEN; + attr_char_value.p_value = "hello"; + + err_code = + sd_ble_gatts_characteristic_add(p_cfg->service_handle, &char_md, &attr_char_value, &p_cfg->event_char_handle); + if (err_code != NRF_SUCCESS) { + NRF_LOG_ERROR("err at file %s, line %d, err_code %d \n", __FILE__, __LINE__, err_code); + return; + } +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/nrf52832_xxaa_service.h b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/nrf52832_xxaa_service.h new file mode 100644 index 00000000..eccfcead --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/hal/nrf52832_xxaa_service.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __NRF52832_XXAA_SERVICE_H +#define __NRF52832_XXAA_SERVICE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "ble.h" +#include "ble_srv_common.h" +#include "ble_qiot_export.h" +#include "nrf_sdh_ble.h" +#include "nrf_ble_gatt.h" + +#define BLE_PRIV_DEF(_name) \ + static ble_priv_cfg_s _name; \ + NRF_SDH_BLE_OBSERVER(_name##_obs, BLE_LBS_BLE_OBSERVER_PRIO, iot_on_ble_evt, &_name) + +typedef struct _ble_priv_cfg_s ble_priv_cfg_s; + +typedef void (*indi_resp_cb)(uint8_t res); + +// save BLE service configuration, such as handle, callback function, and so on, you can edit it as your requirements +struct _ble_priv_cfg_s { + uint16_t service_handle; + uint8_t uuid_type; // UUID type for the service. + + ble_gatts_char_handles_t device_info_char_handle; + ble_gatts_char_handles_t data_char_handle; + ble_gatts_char_handles_t event_char_handle; + + // characteristic write callback function + ble_on_write_cb iot_device_info_write_handler; + ble_on_write_cb iot_data_write_handler; + + uint16_t conn_handle; /**< Handle of the current connection (as provided by the BLE stack, is + BLE_CONN_HANDLE_INVALID if not in a connection). */ +}; + +ble_priv_cfg_s *ble_get_priv_cfg(void); +nrf_ble_gatt_t *ble_get_gatt_instance(void); +void iot_on_ble_evt(ble_evt_t const *p_ble_evt, void *p_context); +void ble_services_add(const qiot_service_init_s *p_service); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/main.c b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/main.c new file mode 100644 index 00000000..c490b3ec --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/main.c @@ -0,0 +1,425 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include "nordic_common.h" +#include "nrf.h" +#include "app_error.h" +#include "ble.h" +#include "ble_err.h" +#include "ble_hci.h" +#include "ble_srv_common.h" +#include "ble_advdata.h" +#include "ble_conn_params.h" +#include "nrf_sdh.h" +#include "nrf_sdh_ble.h" +#include "boards.h" +#include "app_timer.h" +#include "app_button.h" +#include "nrf_ble_gatt.h" +#include "nrf_ble_qwr.h" +#include "nrf_pwr_mgmt.h" +#include "nrf_delay.h" + +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +#include "nrf_log_default_backends.h" + +#include "nrf52832_xxaa_service.h" +#include "ble_qiot_llsync_device.h" +#include "ble_qiot_service.h" +#include "ble_qiot_import.h" +#include "ble_qiot_config.h" + +#include "flash_storage.h" + +#define USER_BUTTON_BUTTON1 \ + BSP_BUTTON_0 /**< Button that will trigger the notification event with the LED Button Service */ +#define USER_BUTTON_BUTTON2 \ + BSP_BUTTON_1 /**< Button that will trigger the notification event with the LED Button Service */ +#define USER_BUTTON_BUTTON3 \ + BSP_BUTTON_2 /**< Button that will trigger the notification event with the LED Button Service */ +#define USER_BUTTON_BUTTON4 \ + BSP_BUTTON_3 /**< Button that will trigger the notification event with the LED Button Service */ + +#define GAP_DEVICE_NAME "IoT" + +#define MIN_CONN_INTERVAL MSEC_TO_UNITS(100, UNIT_1_25_MS) /**< Minimum acceptable connection interval (0.5 seconds). \ + */ +#define MAX_CONN_INTERVAL MSEC_TO_UNITS(200, UNIT_1_25_MS) /**< Maximum acceptable connection interval (1 second). */ +#define SLAVE_LATENCY 0 /**< Slave latency. */ +#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /**< Connection supervisory time-out (4 seconds). */ + +#define FIRST_CONN_PARAMS_UPDATE_DELAY \ + APP_TIMER_TICKS(20000) /**< Time from initiating event (connect or start of notification) to first time \ + sd_ble_gap_conn_param_update is called (15 seconds). */ +#define NEXT_CONN_PARAMS_UPDATE_DELAY \ + APP_TIMER_TICKS( \ + 5000) /**< Time between each call to sd_ble_gap_conn_param_update after the first call (5 seconds). */ +#define MAX_CONN_PARAMS_UPDATE_COUNT 3 /**< Number of attempts before giving up the connection parameter negotiation. \ + */ + +#define BUTTON_DETECTION_DELAY \ + APP_TIMER_TICKS( \ + 50) /**< Delay from a GPIOTE event until a button is reported as pushed (in number of timer ticks). */ + +#define DEAD_BEEF \ + 0xDEADBEEF /**< Value used as error code on stack dump, can be used to identify stack location on stack unwind. */ + +NRF_BLE_QWR_DEF(m_qwr); /**< Context for the Queued Write module.*/ + +/**@brief Function for assert macro callback. + * + * @details This function will be called in case of an assert in the SoftDevice. + * + * @warning This handler is an example only and does not fit a final product. You need to analyze + * how your product is supposed to react in case of Assert. + * @warning On assert from the SoftDevice, the system can only recover on reset. + * + * @param[in] line_num Line number of the failing ASSERT call. + * @param[in] p_file_name File name of the failing ASSERT call. + */ +void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name) +{ + app_error_handler(DEAD_BEEF, line_num, p_file_name); +} + +/**@brief Function for the LEDs initialization. + * + * @details Initializes all LEDs used by the application. + */ +static void leds_init(void) +{ + bsp_board_init(BSP_INIT_LEDS); +} + +/**@brief Function for the Timer initialization. + * + * @details Initializes the timer module. + */ +static void timers_init(void) +{ + // Initialize timer module, making it use the scheduler + ret_code_t err_code = app_timer_init(); + APP_ERROR_CHECK(err_code); +} + +/**@brief Function for the GAP initialization. + * + * @details This function sets up all the necessary GAP (Generic Access Profile) parameters of the + * device including the device name, appearance, and the preferred connection parameters. + */ +static void gap_params_init(void) +{ + ret_code_t err_code; + ble_gap_conn_params_t gap_conn_params; + ble_gap_conn_sec_mode_t sec_mode; + + BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); + + err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *)GAP_DEVICE_NAME, strlen(GAP_DEVICE_NAME)); + APP_ERROR_CHECK(err_code); + + memset(&gap_conn_params, 0, sizeof(gap_conn_params)); + + gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL; + gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL; + gap_conn_params.slave_latency = SLAVE_LATENCY; + gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT; + + err_code = sd_ble_gap_ppcp_set(&gap_conn_params); + APP_ERROR_CHECK(err_code); +} + +/**@brief Function for initializing the GATT module. + */ +static void gatt_init(void) +{ + nrf_ble_gatt_t *p_gatt; + + p_gatt = ble_get_gatt_instance(); + ret_code_t err_code = nrf_ble_gatt_init(p_gatt, NULL); + APP_ERROR_CHECK(err_code); +} + +/**@brief Function for handling Queued Write Module errors. + * + * @details A pointer to this function will be passed to each service which may need to inform the + * application about an error. + * + * @param[in] nrf_error Error code containing information about what went wrong. + */ +static void nrf_qwr_error_handler(uint32_t nrf_error) +{ + APP_ERROR_HANDLER(nrf_error); +} + +/**@brief Function for initializing services that will be used by the application. + */ +static void services_init(void) +{ + ret_code_t err_code; + // ble_lbs_init_t init = {0}; + nrf_ble_qwr_init_t qwr_init = {0}; + + // Initialize Queued Write Module. + qwr_init.error_handler = nrf_qwr_error_handler; + + err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init); + APP_ERROR_CHECK(err_code); +} + +/**@brief Function for handling the Connection Parameters Module. + * + * @details This function will be called for all events in the Connection Parameters Module that + * are passed to the application. + * + * @note All this function does is to disconnect. This could have been done by simply + * setting the disconnect_on_fail config parameter, but instead we use the event + * handler mechanism to demonstrate its use. + * + * @param[in] p_evt Event received from the Connection Parameters Module. + */ +static void on_conn_params_evt(ble_conn_params_evt_t *p_evt) +{ + ret_code_t err_code; + ble_priv_cfg_s *p_cfg; + + p_cfg = ble_get_priv_cfg(); + if (p_evt->evt_type == BLE_CONN_PARAMS_EVT_FAILED) { + err_code = sd_ble_gap_disconnect(p_cfg->conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE); + APP_ERROR_CHECK(err_code); + } +} + +/**@brief Function for handling a Connection Parameters error. + * + * @param[in] nrf_error Error code containing information about what went wrong. + */ +static void conn_params_error_handler(uint32_t nrf_error) +{ + APP_ERROR_HANDLER(nrf_error); +} + +/**@brief Function for initializing the Connection Parameters module. + */ +static void conn_params_init(void) +{ + ret_code_t err_code; + ble_conn_params_init_t cp_init; + + memset(&cp_init, 0, sizeof(cp_init)); + + cp_init.p_conn_params = NULL; + cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY; + cp_init.next_conn_params_update_delay = NEXT_CONN_PARAMS_UPDATE_DELAY; + cp_init.max_conn_params_update_count = MAX_CONN_PARAMS_UPDATE_COUNT; + cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID; + cp_init.disconnect_on_fail = false; + cp_init.evt_handler = on_conn_params_evt; + cp_init.error_handler = conn_params_error_handler; + + err_code = ble_conn_params_init(&cp_init); + APP_ERROR_CHECK(err_code); +} + +/**@brief Function for initializing the BLE stack. + * + * @details Initializes the SoftDevice and the BLE event interrupt. + */ +static void ble_stack_init(void) +{ + ret_code_t err_code; + + err_code = nrf_sdh_enable_request(); + APP_ERROR_CHECK(err_code); + + // Configure the BLE stack using the default settings. + // Fetch the start address of the application RAM. + uint32_t ram_start = 0; + err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start); + APP_ERROR_CHECK(err_code); + + // Enable BLE stack. + err_code = nrf_sdh_ble_enable(&ram_start); + APP_ERROR_CHECK(err_code); +} + +void ble_iot_button1_change(uint8_t button_action) +{ + static uint8_t last_button_action = 0; + + if (last_button_action == 1 && button_action == 0) { + ble_qiot_advertising_start(); + } + last_button_action = button_action; +} + +void ble_iot_button2_change(uint8_t button_action) +{ + static uint8_t last_button_action = 0; + static int button2_index = 0; + + if (last_button_action == 1 && button_action == 0) { + NRF_LOG_INFO("event id %d", button2_index % 3); + ble_event_post(button2_index % 3); + button2_index++; + } + last_button_action = button_action; +} + +void ble_iot_button3_change(uint8_t button_action) +{ + static uint8_t last_button_action = 0; + + if (last_button_action == 1 && button_action == 0) { + NRF_LOG_INFO("erase flash at addr 0x%X", BLE_QIOT_RECORD_FLASH_ADDR); + fstorage_erase(BLE_QIOT_RECORD_FLASH_ADDR); + } + last_button_action = button_action; +} + +void ble_iot_button4_change(uint8_t button_action) +{ + static uint8_t last_button_action = 0; + static int button4_index = 1; + + if (last_button_action == 1 && button_action == 0) { + if (button4_index % 2 == 0) { + NRF_LOG_INFO("get status"); + ble_event_get_status(); + } else { + NRF_LOG_INFO("report property"); + ble_event_report_property(); + } + button4_index++; + } + last_button_action = button_action; +} + +/**@brief Function for handling events from the button handler module. + * + * @param[in] pin_no The pin that the event applies to. + * @param[in] button_action The button action (press/release). + */ +static void button_event_handler(uint8_t pin_no, uint8_t button_action) +{ + // ret_code_t err_code; + + NRF_LOG_INFO("button --> %d %d", pin_no, button_action); + + switch (pin_no) { + case USER_BUTTON_BUTTON1: + ble_iot_button1_change(button_action); + break; + + case USER_BUTTON_BUTTON2: + ble_iot_button2_change(button_action); + break; + + case USER_BUTTON_BUTTON3: + ble_iot_button3_change(button_action); + break; + + case USER_BUTTON_BUTTON4: + ble_iot_button4_change(button_action); + break; + + default: + APP_ERROR_HANDLER(pin_no); + break; + } +} + +/**@brief Function for initializing the button handler module. + */ +static void buttons_init(void) +{ + ret_code_t err_code; + + // The array must be static because a pointer to it will be saved in the button handler module. + static app_button_cfg_t buttons[] = { + {USER_BUTTON_BUTTON1, false, BUTTON_PULL, button_event_handler}, + {USER_BUTTON_BUTTON2, false, BUTTON_PULL, button_event_handler}, + {USER_BUTTON_BUTTON3, false, BUTTON_PULL, button_event_handler}, + {USER_BUTTON_BUTTON4, false, BUTTON_PULL, button_event_handler}, + }; + + err_code = app_button_init(buttons, ARRAY_SIZE(buttons), BUTTON_DETECTION_DELAY); + APP_ERROR_CHECK(err_code); + + err_code = app_button_enable(); + APP_ERROR_CHECK(err_code); +} + +static void log_init(void) +{ + ret_code_t err_code = NRF_LOG_INIT(NULL); + APP_ERROR_CHECK(err_code); + + NRF_LOG_DEFAULT_BACKENDS_INIT(); +} + +/**@brief Function for initializing power management. + */ +static void power_management_init(void) +{ + ret_code_t err_code; + err_code = nrf_pwr_mgmt_init(); + APP_ERROR_CHECK(err_code); +} + +/**@brief Function for handling the idle state (main loop). + * + * @details If there is no pending log operation, then sleep until next the next event occurs. + */ +static void idle_state_handle(void) +{ + if (NRF_LOG_PROCESS() == false) { + nrf_pwr_mgmt_run(); + } +} + +/**@brief Function for application main entry. + */ +int main(void) +{ + // Initialize. + log_init(); + leds_init(); + timers_init(); + buttons_init(); + power_management_init(); + ble_stack_init(); + gap_params_init(); + gatt_init(); + services_init(); + + fstorage_init(); + ble_qiot_explorer_init(); +#if (1 == BLE_QIOT_BUTTON_BROADCAST) + if (E_LLSYNC_BIND_SUCC == llsync_bind_state_get()) +#endif + { + ble_qiot_advertising_start(); + } + conn_params_init(); + + // Start execution. + NRF_LOG_INFO("Blinky example started."); + + // Enter main loop. + for (;;) { + idle_state_handle(); + } +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/.gitignore b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/.gitignore new file mode 100644 index 00000000..ba65b13a --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/.gitignore @@ -0,0 +1 @@ +/_build/ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/Device/nRF52832_xxAA/arm_startup_nrf52.s b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/Device/nRF52832_xxAA/arm_startup_nrf52.s new file mode 100644 index 00000000..62da8608 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/Device/nRF52832_xxAA/arm_startup_nrf52.s @@ -0,0 +1,371 @@ +; Copyright (c) 2009-2018 ARM Limited. All rights reserved. +; +; SPDX-License-Identifier: Apache-2.0 +; +; Licensed under the Apache License, Version 2.0 (the License); you may +; not use this file except in compliance with the License. +; You may obtain a copy of the License at +; +; www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, software +; distributed under the License is distributed on an AS IS BASIS, WITHOUT +; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; See the License for the specific language governing permissions and +; limitations under the License. +; +; NOTICE: This file has been modified by Nordic Semiconductor ASA. + + IF :DEF: __STARTUP_CONFIG +#ifdef __STARTUP_CONFIG +#include "startup_config.h" +#ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT +#define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 +#endif +#endif + ENDIF + + IF :DEF: __STARTUP_CONFIG +Stack_Size EQU __STARTUP_CONFIG_STACK_SIZE + ELIF :DEF: __STACK_SIZE +Stack_Size EQU __STACK_SIZE + ELSE +Stack_Size EQU 8192 + ENDIF + + IF :DEF: __STARTUP_CONFIG +Stack_Align EQU __STARTUP_CONFIG_STACK_ALIGNEMENT + ELSE +Stack_Align EQU 3 + ENDIF + + AREA STACK, NOINIT, READWRITE, ALIGN=Stack_Align +Stack_Mem SPACE Stack_Size +__initial_sp + + IF :DEF: __STARTUP_CONFIG +Heap_Size EQU __STARTUP_CONFIG_HEAP_SIZE + ELIF :DEF: __HEAP_SIZE +Heap_Size EQU __HEAP_SIZE + ELSE +Heap_Size EQU 8192 + ENDIF + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + PRESERVE8 + THUMB + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler + DCD NMI_Handler + DCD HardFault_Handler + DCD MemoryManagement_Handler + DCD BusFault_Handler + DCD UsageFault_Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler + DCD DebugMon_Handler + DCD 0 ; Reserved + DCD PendSV_Handler + DCD SysTick_Handler + + ; External Interrupts + DCD POWER_CLOCK_IRQHandler + DCD RADIO_IRQHandler + DCD UARTE0_UART0_IRQHandler + DCD SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler + DCD SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler + DCD NFCT_IRQHandler + DCD GPIOTE_IRQHandler + DCD SAADC_IRQHandler + DCD TIMER0_IRQHandler + DCD TIMER1_IRQHandler + DCD TIMER2_IRQHandler + DCD RTC0_IRQHandler + DCD TEMP_IRQHandler + DCD RNG_IRQHandler + DCD ECB_IRQHandler + DCD CCM_AAR_IRQHandler + DCD WDT_IRQHandler + DCD RTC1_IRQHandler + DCD QDEC_IRQHandler + DCD COMP_LPCOMP_IRQHandler + DCD SWI0_EGU0_IRQHandler + DCD SWI1_EGU1_IRQHandler + DCD SWI2_EGU2_IRQHandler + DCD SWI3_EGU3_IRQHandler + DCD SWI4_EGU4_IRQHandler + DCD SWI5_EGU5_IRQHandler + DCD TIMER3_IRQHandler + DCD TIMER4_IRQHandler + DCD PWM0_IRQHandler + DCD PDM_IRQHandler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD MWU_IRQHandler + DCD PWM1_IRQHandler + DCD PWM2_IRQHandler + DCD SPIM2_SPIS2_SPI2_IRQHandler + DCD RTC2_IRQHandler + DCD I2S_IRQHandler + DCD FPU_IRQHandler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + +; Reset Handler + + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + + + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemoryManagement_Handler\ + PROC + EXPORT MemoryManagement_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT POWER_CLOCK_IRQHandler [WEAK] + EXPORT RADIO_IRQHandler [WEAK] + EXPORT UARTE0_UART0_IRQHandler [WEAK] + EXPORT SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler [WEAK] + EXPORT SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler [WEAK] + EXPORT NFCT_IRQHandler [WEAK] + EXPORT GPIOTE_IRQHandler [WEAK] + EXPORT SAADC_IRQHandler [WEAK] + EXPORT TIMER0_IRQHandler [WEAK] + EXPORT TIMER1_IRQHandler [WEAK] + EXPORT TIMER2_IRQHandler [WEAK] + EXPORT RTC0_IRQHandler [WEAK] + EXPORT TEMP_IRQHandler [WEAK] + EXPORT RNG_IRQHandler [WEAK] + EXPORT ECB_IRQHandler [WEAK] + EXPORT CCM_AAR_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT RTC1_IRQHandler [WEAK] + EXPORT QDEC_IRQHandler [WEAK] + EXPORT COMP_LPCOMP_IRQHandler [WEAK] + EXPORT SWI0_EGU0_IRQHandler [WEAK] + EXPORT SWI1_EGU1_IRQHandler [WEAK] + EXPORT SWI2_EGU2_IRQHandler [WEAK] + EXPORT SWI3_EGU3_IRQHandler [WEAK] + EXPORT SWI4_EGU4_IRQHandler [WEAK] + EXPORT SWI5_EGU5_IRQHandler [WEAK] + EXPORT TIMER3_IRQHandler [WEAK] + EXPORT TIMER4_IRQHandler [WEAK] + EXPORT PWM0_IRQHandler [WEAK] + EXPORT PDM_IRQHandler [WEAK] + EXPORT MWU_IRQHandler [WEAK] + EXPORT PWM1_IRQHandler [WEAK] + EXPORT PWM2_IRQHandler [WEAK] + EXPORT SPIM2_SPIS2_SPI2_IRQHandler [WEAK] + EXPORT RTC2_IRQHandler [WEAK] + EXPORT I2S_IRQHandler [WEAK] + EXPORT FPU_IRQHandler [WEAK] +POWER_CLOCK_IRQHandler +RADIO_IRQHandler +UARTE0_UART0_IRQHandler +SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler +SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler +NFCT_IRQHandler +GPIOTE_IRQHandler +SAADC_IRQHandler +TIMER0_IRQHandler +TIMER1_IRQHandler +TIMER2_IRQHandler +RTC0_IRQHandler +TEMP_IRQHandler +RNG_IRQHandler +ECB_IRQHandler +CCM_AAR_IRQHandler +WDT_IRQHandler +RTC1_IRQHandler +QDEC_IRQHandler +COMP_LPCOMP_IRQHandler +SWI0_EGU0_IRQHandler +SWI1_EGU1_IRQHandler +SWI2_EGU2_IRQHandler +SWI3_EGU3_IRQHandler +SWI4_EGU4_IRQHandler +SWI5_EGU5_IRQHandler +TIMER3_IRQHandler +TIMER4_IRQHandler +PWM0_IRQHandler +PDM_IRQHandler +MWU_IRQHandler +PWM1_IRQHandler +PWM2_IRQHandler +SPIM2_SPIS2_SPI2_IRQHandler +RTC2_IRQHandler +I2S_IRQHandler +FPU_IRQHandler + B . + ENDP + ALIGN + +; User Initial Stack & Heap + + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap PROC + + LDR R0, = Heap_Mem + LDR R1, = (Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + ENDP + + ALIGN + + ENDIF + + END diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/Device/nRF52832_xxAA/startup_config.h b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/Device/nRF52832_xxAA/startup_config.h new file mode 100644 index 00000000..b9e9ae39 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/Device/nRF52832_xxAA/startup_config.h @@ -0,0 +1,51 @@ +/* + +Copyright (c) 2010 - 2018, Nordic Semiconductor ASA All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of Nordic Semiconductor ASA nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +/* Configure stack size, stack alignement and heap size with a header file instead of project settings or modification of Nordic provided assembler files. Modify this file as needed. */ + +/* In order to make use this file, + 1. For Keil uVision IDE, in the Options for Target -> Asm tab, define symbol __STARTUP_CONFIG and use the additional assembler option --cpreproc in Misc Control text box. + 2. For GCC compiling, add extra assembly option -D__STARTUP_CONFIG. + 3. For IAR Embedded Workbench define symbol __STARTUP_CONFIG in the Assembler options and define symbol __STARTUP_CONFIG=1 in the linker options. +*/ + +/* This file is a template and should be copied to the project directory. */ + +/* Define size of stack. Size must be multiple of 4. */ +#define __STARTUP_CONFIG_STACK_SIZE 0x1000 + +/* Define alignement of stack. Alignment will be 2 to the power of __STARTUP_CONFIG_STACK_ALIGNEMENT. Since calling convention requires that the stack is aligned to 8-bytes when a function is called, the minimum __STARTUP_CONFIG_STACK_ALIGNEMENT is therefore 3. */ +#define __STARTUP_CONFIG_STACK_ALIGNEMENT 3 + +/* Define size of heap. Size must be multiple of 4. */ +#define __STARTUP_CONFIG_HEAP_SIZE 0x1000 + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/Device/nRF52832_xxAA/system_nrf52.c b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/Device/nRF52832_xxAA/system_nrf52.c new file mode 100644 index 00000000..be6abbf2 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/Device/nRF52832_xxAA/system_nrf52.c @@ -0,0 +1,373 @@ +/* + +Copyright (c) 2009-2018 ARM Limited. All rights reserved. + + SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, Version 2.0 (the License); you may +not use this file except in compliance with the License. +You may obtain a copy of the License at + + www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an AS IS BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +NOTICE: This file has been modified by Nordic Semiconductor ASA. + +*/ + +/* NOTE: Template files (including this one) are application specific and therefore expected to + be copied into the application project folder prior to its use! */ + +#include +#include +#include "nrf.h" +#include "system_nrf52.h" + +/*lint ++flb "Enter library region" */ + +#define __SYSTEM_CLOCK_64M (64000000UL) + +static bool errata_12(void); +static bool errata_16(void); +static bool errata_31(void); +static bool errata_32(void); +static bool errata_36(void); +static bool errata_37(void); +static bool errata_57(void); +static bool errata_66(void); +static bool errata_108(void); +static bool errata_136(void); +static bool errata_182(void); + + +#if defined ( __CC_ARM ) + uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M; +#elif defined ( __ICCARM__ ) + __root uint32_t SystemCoreClock = __SYSTEM_CLOCK_64M; +#elif defined ( __GNUC__ ) + uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK_64M; +#endif + +void SystemCoreClockUpdate(void) +{ + SystemCoreClock = __SYSTEM_CLOCK_64M; +} + +void SystemInit(void) +{ + /* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product + Specification to see which one). */ + #if defined (ENABLE_SWO) + CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; + NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos; + NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + #endif + + /* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product + Specification to see which ones). */ + #if defined (ENABLE_TRACE) + CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; + NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos; + NRF_P0->PIN_CNF[14] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + NRF_P0->PIN_CNF[15] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + NRF_P0->PIN_CNF[16] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + NRF_P0->PIN_CNF[20] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + #endif + + /* Workaround for Errata 12 "COMP: Reference ladder not correctly calibrated" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_12()){ + *(volatile uint32_t *)0x40013540 = (*(uint32_t *)0x10000324 & 0x00001F00) >> 8; + } + + /* Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU IDLE" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_16()){ + *(volatile uint32_t *)0x4007C074 = 3131961357ul; + } + + /* Workaround for Errata 31 "CLOCK: Calibration values are not correctly loaded from FICR at reset" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_31()){ + *(volatile uint32_t *)0x4000053C = ((*(volatile uint32_t *)0x10000244) & 0x0000E000) >> 13; + } + + /* Workaround for Errata 32 "DIF: Debug session automatically enables TracePort pins" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_32()){ + CoreDebug->DEMCR &= ~CoreDebug_DEMCR_TRCENA_Msk; + } + + /* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_36()){ + NRF_CLOCK->EVENTS_DONE = 0; + NRF_CLOCK->EVENTS_CTTO = 0; + NRF_CLOCK->CTIV = 0; + } + + /* Workaround for Errata 37 "RADIO: Encryption engine is slow by default" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_37()){ + *(volatile uint32_t *)0x400005A0 = 0x3; + } + + /* Workaround for Errata 57 "NFCT: NFC Modulation amplitude" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_57()){ + *(volatile uint32_t *)0x40005610 = 0x00000005; + *(volatile uint32_t *)0x40005688 = 0x00000001; + *(volatile uint32_t *)0x40005618 = 0x00000000; + *(volatile uint32_t *)0x40005614 = 0x0000003F; + } + + /* Workaround for Errata 66 "TEMP: Linearity specification not met with default settings" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_66()){ + NRF_TEMP->A0 = NRF_FICR->TEMP.A0; + NRF_TEMP->A1 = NRF_FICR->TEMP.A1; + NRF_TEMP->A2 = NRF_FICR->TEMP.A2; + NRF_TEMP->A3 = NRF_FICR->TEMP.A3; + NRF_TEMP->A4 = NRF_FICR->TEMP.A4; + NRF_TEMP->A5 = NRF_FICR->TEMP.A5; + NRF_TEMP->B0 = NRF_FICR->TEMP.B0; + NRF_TEMP->B1 = NRF_FICR->TEMP.B1; + NRF_TEMP->B2 = NRF_FICR->TEMP.B2; + NRF_TEMP->B3 = NRF_FICR->TEMP.B3; + NRF_TEMP->B4 = NRF_FICR->TEMP.B4; + NRF_TEMP->B5 = NRF_FICR->TEMP.B5; + NRF_TEMP->T0 = NRF_FICR->TEMP.T0; + NRF_TEMP->T1 = NRF_FICR->TEMP.T1; + NRF_TEMP->T2 = NRF_FICR->TEMP.T2; + NRF_TEMP->T3 = NRF_FICR->TEMP.T3; + NRF_TEMP->T4 = NRF_FICR->TEMP.T4; + } + + /* Workaround for Errata 108 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_108()){ + *(volatile uint32_t *)0x40000EE4 = *(volatile uint32_t *)0x10000258 & 0x0000004F; + } + + /* Workaround for Errata 136 "System: Bits in RESETREAS are set when they should not be" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_136()){ + if (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk){ + NRF_POWER->RESETREAS = ~POWER_RESETREAS_RESETPIN_Msk; + } + } + + /* Workaround for Errata 182 "RADIO: Fixes for anomalies #102, #106, and #107 do not take effect" found at the Errata document + for your device located at https://www.nordicsemi.com/DocLib */ + if (errata_182()){ + *(volatile uint32_t *) 0x4000173C |= (0x1 << 10); + } + + /* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the + * compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit + * operations are not used in your code. */ + #if (__FPU_USED == 1) + SCB->CPACR |= (3UL << 20) | (3UL << 22); + __DSB(); + __ISB(); + #endif + + /* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined, + two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as + normal GPIOs. */ + #if defined (CONFIG_NFCT_PINS_AS_GPIOS) + if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){ + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} + NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} + NVIC_SystemReset(); + } + #endif + + /* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not + defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be + reserved for PinReset and not available as normal GPIO. */ + #if defined (CONFIG_GPIO_AS_PINRESET) + if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) || + ((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){ + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} + NRF_UICR->PSELRESET[0] = 21; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} + NRF_UICR->PSELRESET[1] = 21; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} + NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; + while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} + NVIC_SystemReset(); + } + #endif + + SystemCoreClockUpdate(); +} + + +static bool errata_12(void) +{ + if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ + return true; + } + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){ + return true; + } + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ + return true; + } + } + + return false; +} + +static bool errata_16(void) +{ + if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ + return true; + } + } + + return false; +} + +static bool errata_31(void) +{ + if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ + return true; + } + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){ + return true; + } + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ + return true; + } + } + + return false; +} + +static bool errata_32(void) +{ + if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ + return true; + } + } + + return false; +} + +static bool errata_36(void) +{ + if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ + return true; + } + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){ + return true; + } + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ + return true; + } + } + + return false; +} + +static bool errata_37(void) +{ + if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ + return true; + } + } + + return false; +} + +static bool errata_57(void) +{ + if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ + return true; + } + } + + return false; +} + +static bool errata_66(void) +{ + if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ + return true; + } + } + + return false; +} + + +static bool errata_108(void) +{ + if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ + return true; + } + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){ + return true; + } + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ + return true; + } + } + + return false; +} + + +static bool errata_136(void) +{ + if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x6) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0)){ + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30){ + return true; + } + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40){ + return true; + } + if (((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x50){ + return true; + } + } + + return false; +} + + +static bool errata_182(void) +{ + if (*(uint32_t *)0x10000130ul == 0x6ul){ + if (*(uint32_t *)0x10000134ul == 0x6ul){ + return true; + } + } + + return false; +} + + +/*lint --flb "Leave library region" */ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/RTE_Components.h b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/RTE_Components.h new file mode 100644 index 00000000..0e3920c2 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/RTE/RTE_Components.h @@ -0,0 +1,20 @@ + +/* + * Auto generated Run-Time-Environment Component Configuration File + * *** Do not modify ! *** + * + * Project: 'ble_app_blinky_pca10040_s132' + * Target: 'nrf52832_xxaa' + */ + +#ifndef RTE_COMPONENTS_H +#define RTE_COMPONENTS_H + + +/* + * Define the Device Header File: + */ +#define CMSIS_device_header "nrf.h" + + +#endif /* RTE_COMPONENTS_H */ diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/ble_app_blinky_pca10040_s132.uvprojx b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/ble_app_blinky_pca10040_s132.uvprojx new file mode 100644 index 00000000..926951e5 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/arm5_no_packs/ble_app_blinky_pca10040_s132.uvprojx @@ -0,0 +1,6268 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + nrf52832_xxaa + 0x4 + ARM-ADS + 5060061::V5.06 update 1 (build 61)::ARMCC + + + nRF52832_xxAA + Nordic Semiconductor + NordicSemiconductor.nRF_DeviceFamilyPack.8.24.1 + http://developer.nordicsemi.com/nRF5_SDK/pieces/nRF_DeviceFamilyPack/ + IROM(0x00000000,0x80000) IRAM(0x20000000,0x10000) CPUTYPE("Cortex-M4") FPU2 CLOCK(64000000) ELITTLE + + + + 0 + $$Device:nRF52832_xxAA$Device\Include\nrf.h + + + + + + + + + + ..\..\..\..\..\..\modules\nrfx\mdk\nrf52.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\_build\ + nrf52832_xxaa + 1 + 0 + 1 + 1 + 1 + .\_build\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + + + + SARMCM3.DLL + -MPU + TCM.DLL + -pCM4 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + "" () + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M4" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 2 + 0 + 0 + 8 + 1 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x10000 + + + 1 + 0x0 + 0x80000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x26000 + 0x5a000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20003000 + 0xc000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 4 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + + --reduce_paths + BOARD_PCA10040 CONFIG_GPIO_AS_PINRESET FLOAT_ABI_HARD NRF52 NRF52832_XXAA NRF52_PAN_74 NRF_SD_BLE_API_VERSION=6 S132 SOFTDEVICE_PRESENT SWI_DISABLE0 __HEAP_SIZE=8192 __STACK_SIZE=8192 + + ..\..\..\config;..\..\..\..\..\..\components;..\..\..\..\..\..\components\ble\ble_advertising;..\..\..\..\..\..\components\ble\ble_dtm;..\..\..\..\..\..\components\ble\ble_racp;..\..\..\..\..\..\components\ble\ble_services\ble_ancs_c;..\..\..\..\..\..\components\ble\ble_services\ble_ans_c;..\..\..\..\..\..\components\ble\ble_services\ble_bas;..\..\..\..\..\..\components\ble\ble_services\ble_bas_c;..\..\..\..\..\..\components\ble\ble_services\ble_cscs;..\..\..\..\..\..\components\ble\ble_services\ble_cts_c;..\..\..\..\..\..\components\ble\ble_services\ble_dfu;..\..\..\..\..\..\components\ble\ble_services\ble_dis;..\..\..\..\..\..\components\ble\ble_services\ble_gls;..\..\..\..\..\..\components\ble\ble_services\ble_hids;..\..\..\..\..\..\components\ble\ble_services\ble_hrs;..\..\..\..\..\..\components\ble\ble_services\ble_hrs_c;..\..\..\..\..\..\components\ble\ble_services\ble_hts;..\..\..\..\..\..\components\ble\ble_services\ble_ias;..\..\..\..\..\..\components\ble\ble_services\ble_ias_c;..\..\..\..\..\..\components\ble\ble_services\ble_lbs;..\..\..\..\..\..\components\ble\ble_services\ble_lbs_c;..\..\..\..\..\..\components\ble\ble_services\ble_lls;..\..\..\..\..\..\components\ble\ble_services\ble_nus;..\..\..\..\..\..\components\ble\ble_services\ble_nus_c;..\..\..\..\..\..\components\ble\ble_services\ble_rscs;..\..\..\..\..\..\components\ble\ble_services\ble_rscs_c;..\..\..\..\..\..\components\ble\ble_services\ble_tps;..\..\..\..\..\..\components\ble\common;..\..\..\..\..\..\components\ble\nrf_ble_gatt;..\..\..\..\..\..\components\ble\nrf_ble_qwr;..\..\..\..\..\..\components\ble\peer_manager;..\..\..\..\..\..\components\boards;..\..\..\..\..\..\components\libraries\atomic;..\..\..\..\..\..\components\libraries\atomic_fifo;..\..\..\..\..\..\components\libraries\atomic_flags;..\..\..\..\..\..\components\libraries\balloc;..\..\..\..\..\..\components\libraries\bootloader\ble_dfu;..\..\..\..\..\..\components\libraries\button;..\..\..\..\..\..\components\libraries\cli;..\..\..\..\..\..\components\libraries\crc16;..\..\..\..\..\..\components\libraries\crc32;..\..\..\..\..\..\components\libraries\crypto;..\..\..\..\..\..\components\libraries\csense;..\..\..\..\..\..\components\libraries\csense_drv;..\..\..\..\..\..\components\libraries\delay;..\..\..\..\..\..\components\libraries\ecc;..\..\..\..\..\..\components\libraries\experimental_section_vars;..\..\..\..\..\..\components\libraries\experimental_task_manager;..\..\..\..\..\..\components\libraries\fds;..\..\..\..\..\..\components\libraries\fstorage;..\..\..\..\..\..\components\libraries\gfx;..\..\..\..\..\..\components\libraries\gpiote;..\..\..\..\..\..\components\libraries\hardfault;..\..\..\..\..\..\components\libraries\hci;..\..\..\..\..\..\components\libraries\led_softblink;..\..\..\..\..\..\components\libraries\log;..\..\..\..\..\..\components\libraries\log\src;..\..\..\..\..\..\components\libraries\low_power_pwm;..\..\..\..\..\..\components\libraries\mem_manager;..\..\..\..\..\..\components\libraries\memobj;..\..\..\..\..\..\components\libraries\mpu;..\..\..\..\..\..\components\libraries\mutex;..\..\..\..\..\..\components\libraries\pwm;..\..\..\..\..\..\components\libraries\pwr_mgmt;..\..\..\..\..\..\components\libraries\queue;..\..\..\..\..\..\components\libraries\ringbuf;..\..\..\..\..\..\components\libraries\scheduler;..\..\..\..\..\..\components\libraries\sdcard;..\..\..\..\..\..\components\libraries\slip;..\..\..\..\..\..\components\libraries\sortlist;..\..\..\..\..\..\components\libraries\spi_mngr;..\..\..\..\..\..\components\libraries\stack_guard;..\..\..\..\..\..\components\libraries\strerror;..\..\..\..\..\..\components\libraries\svc;..\..\..\..\..\..\components\libraries\timer;..\..\..\..\..\..\components\libraries\twi_mngr;..\..\..\..\..\..\components\libraries\twi_sensor;..\..\..\..\..\..\components\libraries\usbd;..\..\..\..\..\..\components\libraries\usbd\class\audio;..\..\..\..\..\..\components\libraries\usbd\class\cdc;..\..\..\..\..\..\components\libraries\usbd\class\cdc\acm;..\..\..\..\..\..\components\libraries\usbd\class\hid;..\..\..\..\..\..\components\libraries\usbd\class\hid\generic;..\..\..\..\..\..\components\libraries\usbd\class\hid\kbd;..\..\..\..\..\..\components\libraries\usbd\class\hid\mouse;..\..\..\..\..\..\components\libraries\usbd\class\msc;..\..\..\..\..\..\components\libraries\util;..\..\..\..\..\..\components\nfc\ndef\conn_hand_parser;..\..\..\..\..\..\components\nfc\ndef\conn_hand_parser\ac_rec_parser;..\..\..\..\..\..\components\nfc\ndef\conn_hand_parser\ble_oob_advdata_parser;..\..\..\..\..\..\components\nfc\ndef\conn_hand_parser\le_oob_rec_parser;..\..\..\..\..\..\components\nfc\ndef\connection_handover\ac_rec;..\..\..\..\..\..\components\nfc\ndef\connection_handover\ble_oob_advdata;..\..\..\..\..\..\components\nfc\ndef\connection_handover\ble_pair_lib;..\..\..\..\..\..\components\nfc\ndef\connection_handover\ble_pair_msg;..\..\..\..\..\..\components\nfc\ndef\connection_handover\common;..\..\..\..\..\..\components\nfc\ndef\connection_handover\ep_oob_rec;..\..\..\..\..\..\components\nfc\ndef\connection_handover\hs_rec;..\..\..\..\..\..\components\nfc\ndef\connection_handover\le_oob_rec;..\..\..\..\..\..\components\nfc\ndef\generic\message;..\..\..\..\..\..\components\nfc\ndef\generic\record;..\..\..\..\..\..\components\nfc\ndef\launchapp;..\..\..\..\..\..\components\nfc\ndef\parser\message;..\..\..\..\..\..\components\nfc\ndef\parser\record;..\..\..\..\..\..\components\nfc\ndef\text;..\..\..\..\..\..\components\nfc\ndef\uri;..\..\..\..\..\..\components\nfc\t2t_lib;..\..\..\..\..\..\components\nfc\t2t_parser;..\..\..\..\..\..\components\nfc\t4t_lib;..\..\..\..\..\..\components\nfc\t4t_parser\apdu;..\..\..\..\..\..\components\nfc\t4t_parser\cc_file;..\..\..\..\..\..\components\nfc\t4t_parser\hl_detection_procedure;..\..\..\..\..\..\components\nfc\t4t_parser\tlv;..\..\..\..\..\..\components\softdevice\common;..\..\..\..\..\..\components\softdevice\s132\headers;..\..\..\..\..\..\components\softdevice\s132\headers\nrf52;..\..\..\..\..\..\external\fprintf;..\..\..\..\..\..\external\segger_rtt;..\..\..\..\..\..\external\utf_converter;..\..\..\..\..\..\integration\nrfx;..\..\..\..\..\..\integration\nrfx\legacy;..\..\..\..\..\..\modules\nrfx;..\..\..\..\..\..\modules\nrfx\drivers\include;..\..\..\..\..\..\modules\nrfx\hal;..\..\..\..\..\..\modules\nrfx\mdk;..\config;..\..\..\qcloud_iot_explorer_ble\inc;..\..\..\qcloud_iot_explorer_ble\src\internal_inc;..\..\..\..\..\..\components\libraries\cli\uart;..\..\..\..\..\..\components\libraries\fstorage;..\..\..\hal;..\..\..\date_template + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + --cpreproc_opts=-DBOARD_PCA10040,-DCONFIG_GPIO_AS_PINRESET,-DFLOAT_ABI_HARD,-DNRF52,-DNRF52832_XXAA,-DNRF52_PAN_74,-DNRF_SD_BLE_API_VERSION=6,-DS132,-DSOFTDEVICE_PRESENT,-DSWI_DISABLE0,-D__HEAP_SIZE=8192,-D__STACK_SIZE=8192 + BOARD_PCA10040 CONFIG_GPIO_AS_PINRESET FLOAT_ABI_HARD NRF52 NRF52832_XXAA NRF52_PAN_74 NRF_SD_BLE_API_VERSION=6 S132 SOFTDEVICE_PRESENT SWI_DISABLE0 __HEAP_SIZE=8192 __STACK_SIZE=8192 + + ..\..\..\config;..\..\..\..\..\..\components;..\..\..\..\..\..\components\ble\ble_advertising;..\..\..\..\..\..\components\ble\ble_dtm;..\..\..\..\..\..\components\ble\ble_racp;..\..\..\..\..\..\components\ble\ble_services\ble_ancs_c;..\..\..\..\..\..\components\ble\ble_services\ble_ans_c;..\..\..\..\..\..\components\ble\ble_services\ble_bas;..\..\..\..\..\..\components\ble\ble_services\ble_bas_c;..\..\..\..\..\..\components\ble\ble_services\ble_cscs;..\..\..\..\..\..\components\ble\ble_services\ble_cts_c;..\..\..\..\..\..\components\ble\ble_services\ble_dfu;..\..\..\..\..\..\components\ble\ble_services\ble_dis;..\..\..\..\..\..\components\ble\ble_services\ble_gls;..\..\..\..\..\..\components\ble\ble_services\ble_hids;..\..\..\..\..\..\components\ble\ble_services\ble_hrs;..\..\..\..\..\..\components\ble\ble_services\ble_hrs_c;..\..\..\..\..\..\components\ble\ble_services\ble_hts;..\..\..\..\..\..\components\ble\ble_services\ble_ias;..\..\..\..\..\..\components\ble\ble_services\ble_ias_c;..\..\..\..\..\..\components\ble\ble_services\ble_lbs;..\..\..\..\..\..\components\ble\ble_services\ble_lbs_c;..\..\..\..\..\..\components\ble\ble_services\ble_lls;..\..\..\..\..\..\components\ble\ble_services\ble_nus;..\..\..\..\..\..\components\ble\ble_services\ble_nus_c;..\..\..\..\..\..\components\ble\ble_services\ble_rscs;..\..\..\..\..\..\components\ble\ble_services\ble_rscs_c;..\..\..\..\..\..\components\ble\ble_services\ble_tps;..\..\..\..\..\..\components\ble\common;..\..\..\..\..\..\components\ble\nrf_ble_gatt;..\..\..\..\..\..\components\ble\nrf_ble_qwr;..\..\..\..\..\..\components\ble\peer_manager;..\..\..\..\..\..\components\boards;..\..\..\..\..\..\components\libraries\atomic;..\..\..\..\..\..\components\libraries\atomic_fifo;..\..\..\..\..\..\components\libraries\atomic_flags;..\..\..\..\..\..\components\libraries\balloc;..\..\..\..\..\..\components\libraries\bootloader\ble_dfu;..\..\..\..\..\..\components\libraries\button;..\..\..\..\..\..\components\libraries\cli;..\..\..\..\..\..\components\libraries\crc16;..\..\..\..\..\..\components\libraries\crc32;..\..\..\..\..\..\components\libraries\crypto;..\..\..\..\..\..\components\libraries\csense;..\..\..\..\..\..\components\libraries\csense_drv;..\..\..\..\..\..\components\libraries\delay;..\..\..\..\..\..\components\libraries\ecc;..\..\..\..\..\..\components\libraries\experimental_section_vars;..\..\..\..\..\..\components\libraries\experimental_task_manager;..\..\..\..\..\..\components\libraries\fds;..\..\..\..\..\..\components\libraries\fstorage;..\..\..\..\..\..\components\libraries\gfx;..\..\..\..\..\..\components\libraries\gpiote;..\..\..\..\..\..\components\libraries\hardfault;..\..\..\..\..\..\components\libraries\hci;..\..\..\..\..\..\components\libraries\led_softblink;..\..\..\..\..\..\components\libraries\log;..\..\..\..\..\..\components\libraries\log\src;..\..\..\..\..\..\components\libraries\low_power_pwm;..\..\..\..\..\..\components\libraries\mem_manager;..\..\..\..\..\..\components\libraries\memobj;..\..\..\..\..\..\components\libraries\mpu;..\..\..\..\..\..\components\libraries\mutex;..\..\..\..\..\..\components\libraries\pwm;..\..\..\..\..\..\components\libraries\pwr_mgmt;..\..\..\..\..\..\components\libraries\queue;..\..\..\..\..\..\components\libraries\ringbuf;..\..\..\..\..\..\components\libraries\scheduler;..\..\..\..\..\..\components\libraries\sdcard;..\..\..\..\..\..\components\libraries\slip;..\..\..\..\..\..\components\libraries\sortlist;..\..\..\..\..\..\components\libraries\spi_mngr;..\..\..\..\..\..\components\libraries\stack_guard;..\..\..\..\..\..\components\libraries\strerror;..\..\..\..\..\..\components\libraries\svc;..\..\..\..\..\..\components\libraries\timer;..\..\..\..\..\..\components\libraries\twi_mngr;..\..\..\..\..\..\components\libraries\twi_sensor;..\..\..\..\..\..\components\libraries\usbd;..\..\..\..\..\..\components\libraries\usbd\class\audio;..\..\..\..\..\..\components\libraries\usbd\class\cdc;..\..\..\..\..\..\components\libraries\usbd\class\cdc\acm;..\..\..\..\..\..\components\libraries\usbd\class\hid;..\..\..\..\..\..\components\libraries\usbd\class\hid\generic;..\..\..\..\..\..\components\libraries\usbd\class\hid\kbd;..\..\..\..\..\..\components\libraries\usbd\class\hid\mouse;..\..\..\..\..\..\components\libraries\usbd\class\msc;..\..\..\..\..\..\components\libraries\util;..\..\..\..\..\..\components\nfc\ndef\conn_hand_parser;..\..\..\..\..\..\components\nfc\ndef\conn_hand_parser\ac_rec_parser;..\..\..\..\..\..\components\nfc\ndef\conn_hand_parser\ble_oob_advdata_parser;..\..\..\..\..\..\components\nfc\ndef\conn_hand_parser\le_oob_rec_parser;..\..\..\..\..\..\components\nfc\ndef\connection_handover\ac_rec;..\..\..\..\..\..\components\nfc\ndef\connection_handover\ble_oob_advdata;..\..\..\..\..\..\components\nfc\ndef\connection_handover\ble_pair_lib;..\..\..\..\..\..\components\nfc\ndef\connection_handover\ble_pair_msg;..\..\..\..\..\..\components\nfc\ndef\connection_handover\common;..\..\..\..\..\..\components\nfc\ndef\connection_handover\ep_oob_rec;..\..\..\..\..\..\components\nfc\ndef\connection_handover\hs_rec;..\..\..\..\..\..\components\nfc\ndef\connection_handover\le_oob_rec;..\..\..\..\..\..\components\nfc\ndef\generic\message;..\..\..\..\..\..\components\nfc\ndef\generic\record;..\..\..\..\..\..\components\nfc\ndef\launchapp;..\..\..\..\..\..\components\nfc\ndef\parser\message;..\..\..\..\..\..\components\nfc\ndef\parser\record;..\..\..\..\..\..\components\nfc\ndef\text;..\..\..\..\..\..\components\nfc\ndef\uri;..\..\..\..\..\..\components\nfc\t2t_lib;..\..\..\..\..\..\components\nfc\t2t_parser;..\..\..\..\..\..\components\nfc\t4t_lib;..\..\..\..\..\..\components\nfc\t4t_parser\apdu;..\..\..\..\..\..\components\nfc\t4t_parser\cc_file;..\..\..\..\..\..\components\nfc\t4t_parser\hl_detection_procedure;..\..\..\..\..\..\components\nfc\t4t_parser\tlv;..\..\..\..\..\..\components\softdevice\common;..\..\..\..\..\..\components\softdevice\s132\headers;..\..\..\..\..\..\components\softdevice\s132\headers\nrf52;..\..\..\..\..\..\external\fprintf;..\..\..\..\..\..\external\segger_rtt;..\..\..\..\..\..\external\utf_converter;..\..\..\..\..\..\integration\nrfx;..\..\..\..\..\..\integration\nrfx\legacy;..\..\..\..\..\..\modules\nrfx;..\..\..\..\..\..\modules\nrfx\drivers\include;..\..\..\..\..\..\modules\nrfx\hal;..\..\..\..\..\..\modules\nrfx\mdk;..\config;..\..\..\hal + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + + + + --diag_suppress 6330 + + + + + + + + Application + + + main.c + 1 + ..\..\..\main.c + + + sdk_config.h + 5 + ..\config\sdk_config.h + + + + + Board Definition + + + boards.c + 1 + ..\..\..\..\..\..\components\boards\boards.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + UTF8/UTF16 converter + + + utf.c + 1 + ..\..\..\..\..\..\external\utf_converter\utf.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + nRF_BLE + + + ble_advdata.c + 1 + ..\..\..\..\..\..\components\ble\common\ble_advdata.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + ble_conn_params.c + 1 + ..\..\..\..\..\..\components\ble\common\ble_conn_params.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + ble_conn_state.c + 1 + ..\..\..\..\..\..\components\ble\common\ble_conn_state.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + ble_srv_common.c + 1 + ..\..\..\..\..\..\components\ble\common\ble_srv_common.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_ble_gatt.c + 1 + ..\..\..\..\..\..\components\ble\nrf_ble_gatt\nrf_ble_gatt.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_ble_qwr.c + 1 + ..\..\..\..\..\..\components\ble\nrf_ble_qwr\nrf_ble_qwr.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + nRF_Drivers + + + nrf_drv_clock.c + 1 + ..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_clock.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_drv_uart.c + 1 + ..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_uart.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_atomic.c + 1 + ..\..\..\..\..\..\modules\nrfx\soc\nrfx_atomic.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_clock.c + 1 + ..\..\..\..\..\..\modules\nrfx\drivers\src\nrfx_clock.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_gpiote.c + 1 + ..\..\..\..\..\..\modules\nrfx\drivers\src\nrfx_gpiote.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_prs.c + 1 + ..\..\..\..\..\..\modules\nrfx\drivers\src\prs\nrfx_prs.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_uart.c + 1 + ..\..\..\..\..\..\modules\nrfx\drivers\src\nrfx_uart.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_uarte.c + 1 + ..\..\..\..\..\..\modules\nrfx\drivers\src\nrfx_uarte.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + nRF_Libraries + + + app_button.c + 1 + ..\..\..\..\..\..\components\libraries\button\app_button.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_error.c + 1 + ..\..\..\..\..\..\components\libraries\util\app_error.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_error_handler_keil.c + 1 + ..\..\..\..\..\..\components\libraries\util\app_error_handler_keil.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_error_weak.c + 1 + ..\..\..\..\..\..\components\libraries\util\app_error_weak.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_scheduler.c + 1 + ..\..\..\..\..\..\components\libraries\scheduler\app_scheduler.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_timer.c + 1 + ..\..\..\..\..\..\components\libraries\timer\app_timer.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_util_platform.c + 1 + ..\..\..\..\..\..\components\libraries\util\app_util_platform.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + hardfault_implementation.c + 1 + ..\..\..\..\..\..\components\libraries\hardfault\hardfault_implementation.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_assert.c + 1 + ..\..\..\..\..\..\components\libraries\util\nrf_assert.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_atfifo.c + 1 + ..\..\..\..\..\..\components\libraries\atomic_fifo\nrf_atfifo.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_atflags.c + 1 + ..\..\..\..\..\..\components\libraries\atomic_flags\nrf_atflags.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_atomic.c + 1 + ..\..\..\..\..\..\components\libraries\atomic\nrf_atomic.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_balloc.c + 1 + ..\..\..\..\..\..\components\libraries\balloc\nrf_balloc.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_fprintf.c + 1 + ..\..\..\..\..\..\external\fprintf\nrf_fprintf.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_fprintf_format.c + 1 + ..\..\..\..\..\..\external\fprintf\nrf_fprintf_format.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_memobj.c + 1 + ..\..\..\..\..\..\components\libraries\memobj\nrf_memobj.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_pwr_mgmt.c + 1 + ..\..\..\..\..\..\components\libraries\pwr_mgmt\nrf_pwr_mgmt.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_ringbuf.c + 1 + ..\..\..\..\..\..\components\libraries\ringbuf\nrf_ringbuf.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_section_iter.c + 1 + ..\..\..\..\..\..\components\libraries\experimental_section_vars\nrf_section_iter.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_strerror.c + 1 + ..\..\..\..\..\..\components\libraries\strerror\nrf_strerror.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_fstorage.c + 1 + ..\..\..\..\..\..\components\libraries\fstorage\nrf_fstorage.c + + + nrf_fstorage_sd.c + 1 + ..\..\..\..\..\..\components\libraries\fstorage\nrf_fstorage_sd.c + + + + + nRF_Log + + + nrf_log_backend_rtt.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_backend_rtt.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_log_backend_serial.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_backend_serial.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_log_backend_uart.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_backend_uart.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_log_default_backends.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_default_backends.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_log_frontend.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_frontend.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_log_str_formatter.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_str_formatter.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + nRF_Segger_RTT + + + SEGGER_RTT.c + 1 + ..\..\..\..\..\..\external\segger_rtt\SEGGER_RTT.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + SEGGER_RTT_Syscalls_KEIL.c + 1 + ..\..\..\..\..\..\external\segger_rtt\SEGGER_RTT_Syscalls_KEIL.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + SEGGER_RTT_printf.c + 1 + ..\..\..\..\..\..\external\segger_rtt\SEGGER_RTT_printf.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + nRF_SoftDevice + + + nrf_sdh.c + 1 + ..\..\..\..\..\..\components\softdevice\common\nrf_sdh.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_sdh_ble.c + 1 + ..\..\..\..\..\..\components\softdevice\common\nrf_sdh_ble.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_sdh_soc.c + 1 + ..\..\..\..\..\..\components\softdevice\common\nrf_sdh_soc.c + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + qcloud_iot_explorer_ble + + + ble_qiot_llsync_data.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_data.c + + + ble_qiot_llsync_device.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_device.c + + + ble_qiot_llsync_event.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_event.c + + + ble_qiot_utils_hmac.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_hmac.c + + + ble_qiot_utils_log.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_log.c + + + ble_qiot_utils_sha1.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_sha1.c + + + ble_qiot_utils_base64.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_base64.c + + + ble_qiot_utils_md5.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_md5.c + + + ble_qiot_service.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\core\ble_qiot_service.c + + + ble_qiot_ble_device.c + 1 + ..\..\..\hal\ble_qiot_ble_device.c + + + flash_storage.c + 1 + ..\..\..\hal\flash_storage.c + + + nrf52832_xxaa_service.c + 1 + ..\..\..\hal\nrf52832_xxaa_service.c + + + ble_qiot_template.c + 1 + ..\..\..\date_template\ble_qiot_template.c + + + + + ::CMSIS + + + ::Device + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + + + + + + + + + + + + + + flash_s132_nrf52_6.1.1_softdevice + 0x4 + ARM-ADS + + + nRF52832_xxAA + Nordic Semiconductor + NordicSemiconductor.nRF_DeviceFamilyPack.8.24.1 + http://developer.nordicsemi.com/nRF5_SDK/pieces/nRF_DeviceFamilyPack/ + IROM(0x00000000,0x80000) IRAM(0x20000000,0x10000) CPUTYPE("Cortex-M4") FPU2 CLOCK(64000000) ELITTLE + + + + 0 + $$Device:nRF52832_xxAA$Device\Include\nrf.h + + + + + + + + + + $$Device:nRF52832_xxAA$SVD\nrf52.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + ..\..\..\..\..\..\components\softdevice\s132\hex\ + s132_nrf52_6.1.1_softdevice.hex + 1 + 0 + 1 + 1 + 1 + .\_build\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 0 + attrib +R $H\* + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + + + + + SARMCM3.DLL + -MPU + TCM.DLL + -pCM4 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4099 + + 1 + Segger\JL2CM3.dll + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M4" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 2 + 0 + 0 + 8 + 1 + 0 + 0 + 0 + 3 + 3 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x10000 + + + 1 + 0x0 + 0x80000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x26000 + 0x5a000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x200022b8 + 0xdd48 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 4 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + + --reduce_paths + __HEAP_SIZE=8192 __STACK_SIZE=8192 + + ..\..\..\config;..\config + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + --cpreproc_opts=-D__HEAP_SIZE=8192,-D__STACK_SIZE=8192 + __HEAP_SIZE=8192 __STACK_SIZE=8192 + + ..\..\..\config;..\config + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + + + + --diag_suppress 6330 + + + + + + + + Application + + + main.c + 1 + ..\..\..\main.c + + + sdk_config.h + 5 + ..\config\sdk_config.h + + + + + Board Definition + + + boards.c + 1 + ..\..\..\..\..\..\components\boards\boards.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + UTF8/UTF16 converter + + + utf.c + 1 + ..\..\..\..\..\..\external\utf_converter\utf.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + nRF_BLE + + + ble_advdata.c + 1 + ..\..\..\..\..\..\components\ble\common\ble_advdata.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + ble_conn_params.c + 1 + ..\..\..\..\..\..\components\ble\common\ble_conn_params.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + ble_conn_state.c + 1 + ..\..\..\..\..\..\components\ble\common\ble_conn_state.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + ble_srv_common.c + 1 + ..\..\..\..\..\..\components\ble\common\ble_srv_common.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_ble_gatt.c + 1 + ..\..\..\..\..\..\components\ble\nrf_ble_gatt\nrf_ble_gatt.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_ble_qwr.c + 1 + ..\..\..\..\..\..\components\ble\nrf_ble_qwr\nrf_ble_qwr.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + nRF_Drivers + + + nrf_drv_clock.c + 1 + ..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_clock.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_drv_uart.c + 1 + ..\..\..\..\..\..\integration\nrfx\legacy\nrf_drv_uart.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_atomic.c + 1 + ..\..\..\..\..\..\modules\nrfx\soc\nrfx_atomic.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_clock.c + 1 + ..\..\..\..\..\..\modules\nrfx\drivers\src\nrfx_clock.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_gpiote.c + 1 + ..\..\..\..\..\..\modules\nrfx\drivers\src\nrfx_gpiote.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_prs.c + 1 + ..\..\..\..\..\..\modules\nrfx\drivers\src\prs\nrfx_prs.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_uart.c + 1 + ..\..\..\..\..\..\modules\nrfx\drivers\src\nrfx_uart.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrfx_uarte.c + 1 + ..\..\..\..\..\..\modules\nrfx\drivers\src\nrfx_uarte.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + nRF_Libraries + + + app_button.c + 1 + ..\..\..\..\..\..\components\libraries\button\app_button.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_error.c + 1 + ..\..\..\..\..\..\components\libraries\util\app_error.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_error_handler_keil.c + 1 + ..\..\..\..\..\..\components\libraries\util\app_error_handler_keil.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_error_weak.c + 1 + ..\..\..\..\..\..\components\libraries\util\app_error_weak.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_scheduler.c + 1 + ..\..\..\..\..\..\components\libraries\scheduler\app_scheduler.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_timer.c + 1 + ..\..\..\..\..\..\components\libraries\timer\app_timer.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + app_util_platform.c + 1 + ..\..\..\..\..\..\components\libraries\util\app_util_platform.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + hardfault_implementation.c + 1 + ..\..\..\..\..\..\components\libraries\hardfault\hardfault_implementation.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_assert.c + 1 + ..\..\..\..\..\..\components\libraries\util\nrf_assert.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_atfifo.c + 1 + ..\..\..\..\..\..\components\libraries\atomic_fifo\nrf_atfifo.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_atflags.c + 1 + ..\..\..\..\..\..\components\libraries\atomic_flags\nrf_atflags.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_atomic.c + 1 + ..\..\..\..\..\..\components\libraries\atomic\nrf_atomic.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_balloc.c + 1 + ..\..\..\..\..\..\components\libraries\balloc\nrf_balloc.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_fprintf.c + 1 + ..\..\..\..\..\..\external\fprintf\nrf_fprintf.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_fprintf_format.c + 1 + ..\..\..\..\..\..\external\fprintf\nrf_fprintf_format.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_memobj.c + 1 + ..\..\..\..\..\..\components\libraries\memobj\nrf_memobj.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_pwr_mgmt.c + 1 + ..\..\..\..\..\..\components\libraries\pwr_mgmt\nrf_pwr_mgmt.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_ringbuf.c + 1 + ..\..\..\..\..\..\components\libraries\ringbuf\nrf_ringbuf.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_section_iter.c + 1 + ..\..\..\..\..\..\components\libraries\experimental_section_vars\nrf_section_iter.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_strerror.c + 1 + ..\..\..\..\..\..\components\libraries\strerror\nrf_strerror.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_fstorage.c + 1 + ..\..\..\..\..\..\components\libraries\fstorage\nrf_fstorage.c + + + nrf_fstorage_sd.c + 1 + ..\..\..\..\..\..\components\libraries\fstorage\nrf_fstorage_sd.c + + + + + nRF_Log + + + nrf_log_backend_rtt.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_backend_rtt.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_log_backend_serial.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_backend_serial.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_log_backend_uart.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_backend_uart.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_log_default_backends.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_default_backends.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_log_frontend.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_frontend.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_log_str_formatter.c + 1 + ..\..\..\..\..\..\components\libraries\log\src\nrf_log_str_formatter.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + nRF_Segger_RTT + + + SEGGER_RTT.c + 1 + ..\..\..\..\..\..\external\segger_rtt\SEGGER_RTT.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + SEGGER_RTT_Syscalls_KEIL.c + 1 + ..\..\..\..\..\..\external\segger_rtt\SEGGER_RTT_Syscalls_KEIL.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + SEGGER_RTT_printf.c + 1 + ..\..\..\..\..\..\external\segger_rtt\SEGGER_RTT_printf.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + nRF_SoftDevice + + + nrf_sdh.c + 1 + ..\..\..\..\..\..\components\softdevice\common\nrf_sdh.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_sdh_ble.c + 1 + ..\..\..\..\..\..\components\softdevice\common\nrf_sdh_ble.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + nrf_sdh_soc.c + 1 + ..\..\..\..\..\..\components\softdevice\common\nrf_sdh_soc.c + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + + + + + + qcloud_iot_explorer_ble + + + ble_qiot_llsync_data.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_data.c + + + ble_qiot_llsync_device.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_device.c + + + ble_qiot_llsync_event.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\core\ble_qiot_llsync_event.c + + + ble_qiot_utils_hmac.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_hmac.c + + + ble_qiot_utils_log.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_log.c + + + ble_qiot_utils_sha1.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_sha1.c + + + ble_qiot_utils_base64.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_base64.c + + + ble_qiot_utils_md5.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\utils\ble_qiot_utils_md5.c + + + ble_qiot_service.c + 1 + ..\..\..\qcloud_iot_explorer_ble\src\core\ble_qiot_service.c + + + ble_qiot_ble_device.c + 1 + ..\..\..\hal\ble_qiot_ble_device.c + + + flash_storage.c + 1 + ..\..\..\hal\flash_storage.c + + + nrf52832_xxaa_service.c + 1 + ..\..\..\hal\nrf52832_xxaa_service.c + + + ble_qiot_template.c + 1 + ..\..\..\date_template\ble_qiot_template.c + + + + + ::CMSIS + + + 0 + 0 + 0 + 0 + 0 + 0 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + + + + + + + + + + + + ::Device + + + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 2 + 2 + 2 + 11 + + + 1 + + + + 2 + 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 0 + 0 + 2 + 2 + + + + + + + + + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + RTE\Device\nRF52832_xxAA\arm_startup_nrf52.s + + + + + + + + + RTE\Device\nRF52832_xxAA\startup_config.h + + + + + + + + + RTE\Device\nRF52832_xxAA\system_nrf52.c + + + + + + + + + + +
diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/config/sdk_config.h b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/config/sdk_config.h new file mode 100644 index 00000000..3be0d0c5 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/pca10040/s132/config/sdk_config.h @@ -0,0 +1,11760 @@ +/** + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + + +#ifndef SDK_CONFIG_H +#define SDK_CONFIG_H +// <<< Use Configuration Wizard in Context Menu >>>\n +#ifdef USE_APP_CONFIG +#include "app_config.h" +#endif +// nRF_BLE + +//========================================================== +// BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module + + +#ifndef BLE_ADVERTISING_ENABLED +#define BLE_ADVERTISING_ENABLED 0 +#endif + +// BLE_DTM_ENABLED - ble_dtm - Module for testing RF/PHY using DTM commands + + +#ifndef BLE_DTM_ENABLED +#define BLE_DTM_ENABLED 0 +#endif + +// BLE_RACP_ENABLED - ble_racp - Record Access Control Point library + + +#ifndef BLE_RACP_ENABLED +#define BLE_RACP_ENABLED 0 +#endif + +// NRF_BLE_CONN_PARAMS_ENABLED - ble_conn_params - Initiating and executing a connection parameters negotiation procedure +//========================================================== +#ifndef NRF_BLE_CONN_PARAMS_ENABLED +#define NRF_BLE_CONN_PARAMS_ENABLED 1 +#endif +// NRF_BLE_CONN_PARAMS_MAX_SLAVE_LATENCY_DEVIATION - The largest acceptable deviation in slave latency. +// The largest deviation (+ or -) from the requested slave latency that will not be renegotiated. + +#ifndef NRF_BLE_CONN_PARAMS_MAX_SLAVE_LATENCY_DEVIATION +#define NRF_BLE_CONN_PARAMS_MAX_SLAVE_LATENCY_DEVIATION 499 +#endif + +// NRF_BLE_CONN_PARAMS_MAX_SUPERVISION_TIMEOUT_DEVIATION - The largest acceptable deviation (in 10 ms units) in supervision timeout. +// The largest deviation (+ or -, in 10 ms units) from the requested supervision timeout that will not be renegotiated. + +#ifndef NRF_BLE_CONN_PARAMS_MAX_SUPERVISION_TIMEOUT_DEVIATION +#define NRF_BLE_CONN_PARAMS_MAX_SUPERVISION_TIMEOUT_DEVIATION 65535 +#endif + +// + +// NRF_BLE_GATT_ENABLED - nrf_ble_gatt - GATT module + + +#ifndef NRF_BLE_GATT_ENABLED +#define NRF_BLE_GATT_ENABLED 1 +#endif + +// NRF_BLE_QWR_ENABLED - nrf_ble_qwr - Queued writes support module (prepare/execute write) +//========================================================== +#ifndef NRF_BLE_QWR_ENABLED +#define NRF_BLE_QWR_ENABLED 1 +#endif +// NRF_BLE_QWR_MAX_ATTR - Maximum number of attribute handles that can be registered. This number must be adjusted according to the number of attributes for which Queued Writes will be enabled. If it is zero, the module will reject all Queued Write requests. +#ifndef NRF_BLE_QWR_MAX_ATTR +#define NRF_BLE_QWR_MAX_ATTR 0 +#endif + +// + +// PEER_MANAGER_ENABLED - peer_manager - Peer Manager +//========================================================== +#ifndef PEER_MANAGER_ENABLED +#define PEER_MANAGER_ENABLED 0 +#endif +// PM_MAX_REGISTRANTS - Number of event handlers that can be registered. +#ifndef PM_MAX_REGISTRANTS +#define PM_MAX_REGISTRANTS 3 +#endif + +// PM_FLASH_BUFFERS - Number of internal buffers for flash operations. +// Decrease this value to lower RAM usage. + +#ifndef PM_FLASH_BUFFERS +#define PM_FLASH_BUFFERS 4 +#endif + +// PM_CENTRAL_ENABLED - Enable/disable central-specific Peer Manager functionality. + + +// Enable/disable central-specific Peer Manager functionality. + +#ifndef PM_CENTRAL_ENABLED +#define PM_CENTRAL_ENABLED 1 +#endif + +// PM_SERVICE_CHANGED_ENABLED - Enable/disable the service changed management for GATT server in Peer Manager. + + +// If not using a GATT server, or using a server wihout a service changed characteristic, +// disable this to save code space. + +#ifndef PM_SERVICE_CHANGED_ENABLED +#define PM_SERVICE_CHANGED_ENABLED 1 +#endif + +// PM_PEER_RANKS_ENABLED - Enable/disable the peer rank management in Peer Manager. + + +// Set this to false to save code space if not using the peer rank API. + +#ifndef PM_PEER_RANKS_ENABLED +#define PM_PEER_RANKS_ENABLED 1 +#endif + +// PM_LESC_ENABLED - Enable/disable LESC support in Peer Manager. + + +// If set to true, you need to call nrf_ble_lesc_request_handler() in the main loop to respond to LESC-related BLE events. If LESC support is not required, set this to false to save code space. + +#ifndef PM_LESC_ENABLED +#define PM_LESC_ENABLED 0 +#endif + +// PM_RA_PROTECTION_ENABLED - Enable/disable protection against repeated pairing attempts in Peer Manager. +//========================================================== +#ifndef PM_RA_PROTECTION_ENABLED +#define PM_RA_PROTECTION_ENABLED 0 +#endif +// PM_RA_PROTECTION_TRACKED_PEERS_NUM - Maximum number of peers whose authorization status can be tracked. +#ifndef PM_RA_PROTECTION_TRACKED_PEERS_NUM +#define PM_RA_PROTECTION_TRACKED_PEERS_NUM 8 +#endif + +// PM_RA_PROTECTION_MIN_WAIT_INTERVAL - Minimum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MIN_WAIT_INTERVAL +#define PM_RA_PROTECTION_MIN_WAIT_INTERVAL 4000 +#endif + +// PM_RA_PROTECTION_MAX_WAIT_INTERVAL - Maximum waiting interval (in ms) before a new pairing attempt can be initiated. +#ifndef PM_RA_PROTECTION_MAX_WAIT_INTERVAL +#define PM_RA_PROTECTION_MAX_WAIT_INTERVAL 64000 +#endif + +// PM_RA_PROTECTION_REWARD_PERIOD - Reward period (in ms). +// The waiting interval is gradually decreased when no new failed pairing attempts are made during reward period. + +#ifndef PM_RA_PROTECTION_REWARD_PERIOD +#define PM_RA_PROTECTION_REWARD_PERIOD 10000 +#endif + +// + +// PM_HANDLER_SEC_DELAY_MS - Delay before starting security. +// This might be necessary for interoperability reasons, especially as peripheral. + +#ifndef PM_HANDLER_SEC_DELAY_MS +#define PM_HANDLER_SEC_DELAY_MS 0 +#endif + +// + +// +//========================================================== + +// nRF_BLE_Services + +//========================================================== +// BLE_ANCS_C_ENABLED - ble_ancs_c - Apple Notification Service Client + + +#ifndef BLE_ANCS_C_ENABLED +#define BLE_ANCS_C_ENABLED 0 +#endif + +// BLE_ANS_C_ENABLED - ble_ans_c - Alert Notification Service Client + + +#ifndef BLE_ANS_C_ENABLED +#define BLE_ANS_C_ENABLED 0 +#endif + +// BLE_BAS_C_ENABLED - ble_bas_c - Battery Service Client + + +#ifndef BLE_BAS_C_ENABLED +#define BLE_BAS_C_ENABLED 0 +#endif + +// BLE_BAS_ENABLED - ble_bas - Battery Service +//========================================================== +#ifndef BLE_BAS_ENABLED +#define BLE_BAS_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_BAS_CONFIG_LOG_ENABLED +#define BLE_BAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_BAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_BAS_CONFIG_LOG_LEVEL +#define BLE_BAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_BAS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_BAS_CONFIG_INFO_COLOR +#define BLE_BAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_BAS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_BAS_CONFIG_DEBUG_COLOR +#define BLE_BAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_CSCS_ENABLED - ble_cscs - Cycling Speed and Cadence Service + + +#ifndef BLE_CSCS_ENABLED +#define BLE_CSCS_ENABLED 0 +#endif + +// BLE_CTS_C_ENABLED - ble_cts_c - Current Time Service Client + + +#ifndef BLE_CTS_C_ENABLED +#define BLE_CTS_C_ENABLED 0 +#endif + +// BLE_DIS_ENABLED - ble_dis - Device Information Service + + +#ifndef BLE_DIS_ENABLED +#define BLE_DIS_ENABLED 0 +#endif + +// BLE_GLS_ENABLED - ble_gls - Glucose Service + + +#ifndef BLE_GLS_ENABLED +#define BLE_GLS_ENABLED 0 +#endif + +// BLE_HIDS_ENABLED - ble_hids - Human Interface Device Service + + +#ifndef BLE_HIDS_ENABLED +#define BLE_HIDS_ENABLED 0 +#endif + +// BLE_HRS_C_ENABLED - ble_hrs_c - Heart Rate Service Client + + +#ifndef BLE_HRS_C_ENABLED +#define BLE_HRS_C_ENABLED 0 +#endif + +// BLE_HRS_ENABLED - ble_hrs - Heart Rate Service + + +#ifndef BLE_HRS_ENABLED +#define BLE_HRS_ENABLED 0 +#endif + +// BLE_HTS_ENABLED - ble_hts - Health Thermometer Service + + +#ifndef BLE_HTS_ENABLED +#define BLE_HTS_ENABLED 0 +#endif + +// BLE_IAS_C_ENABLED - ble_ias_c - Immediate Alert Service Client + + +#ifndef BLE_IAS_C_ENABLED +#define BLE_IAS_C_ENABLED 0 +#endif + +// BLE_IAS_ENABLED - ble_ias - Immediate Alert Service +//========================================================== +#ifndef BLE_IAS_ENABLED +#define BLE_IAS_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_IAS_CONFIG_LOG_ENABLED +#define BLE_IAS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_IAS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_IAS_CONFIG_LOG_LEVEL +#define BLE_IAS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_IAS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_IAS_CONFIG_INFO_COLOR +#define BLE_IAS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_IAS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_IAS_CONFIG_DEBUG_COLOR +#define BLE_IAS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_LBS_C_ENABLED - ble_lbs_c - Nordic LED Button Service Client + + +#ifndef BLE_LBS_C_ENABLED +#define BLE_LBS_C_ENABLED 0 +#endif + +// BLE_LBS_ENABLED - ble_lbs - LED Button Service + + +#ifndef BLE_LBS_ENABLED +#define BLE_LBS_ENABLED 1 +#endif + +// BLE_LLS_ENABLED - ble_lls - Link Loss Service + + +#ifndef BLE_LLS_ENABLED +#define BLE_LLS_ENABLED 0 +#endif + +// BLE_NUS_C_ENABLED - ble_nus_c - Nordic UART Central Service + + +#ifndef BLE_NUS_C_ENABLED +#define BLE_NUS_C_ENABLED 0 +#endif + +// BLE_NUS_ENABLED - ble_nus - Nordic UART Service +//========================================================== +#ifndef BLE_NUS_ENABLED +#define BLE_NUS_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef BLE_NUS_CONFIG_LOG_ENABLED +#define BLE_NUS_CONFIG_LOG_ENABLED 0 +#endif +// BLE_NUS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef BLE_NUS_CONFIG_LOG_LEVEL +#define BLE_NUS_CONFIG_LOG_LEVEL 3 +#endif + +// BLE_NUS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_NUS_CONFIG_INFO_COLOR +#define BLE_NUS_CONFIG_INFO_COLOR 0 +#endif + +// BLE_NUS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef BLE_NUS_CONFIG_DEBUG_COLOR +#define BLE_NUS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// BLE_RSCS_C_ENABLED - ble_rscs_c - Running Speed and Cadence Client + + +#ifndef BLE_RSCS_C_ENABLED +#define BLE_RSCS_C_ENABLED 0 +#endif + +// BLE_RSCS_ENABLED - ble_rscs - Running Speed and Cadence Service + + +#ifndef BLE_RSCS_ENABLED +#define BLE_RSCS_ENABLED 0 +#endif + +// BLE_TPS_ENABLED - ble_tps - TX Power Service + + +#ifndef BLE_TPS_ENABLED +#define BLE_TPS_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Core + +//========================================================== +// NRF_MPU_LIB_ENABLED - nrf_mpu_lib - Module for MPU +//========================================================== +#ifndef NRF_MPU_LIB_ENABLED +#define NRF_MPU_LIB_ENABLED 0 +#endif +// NRF_MPU_LIB_CLI_CMDS - Enable CLI commands specific to the module. + + +#ifndef NRF_MPU_LIB_CLI_CMDS +#define NRF_MPU_LIB_CLI_CMDS 0 +#endif + +// + +// NRF_STACK_GUARD_ENABLED - nrf_stack_guard - Stack guard +//========================================================== +#ifndef NRF_STACK_GUARD_ENABLED +#define NRF_STACK_GUARD_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_SIZE - Size of the stack guard. + +// <5=> 32 bytes +// <6=> 64 bytes +// <7=> 128 bytes +// <8=> 256 bytes +// <9=> 512 bytes +// <10=> 1024 bytes +// <11=> 2048 bytes +// <12=> 4096 bytes + +#ifndef NRF_STACK_GUARD_CONFIG_SIZE +#define NRF_STACK_GUARD_CONFIG_SIZE 7 +#endif + +// + +// +//========================================================== + +// nRF_Crypto + +//========================================================== +// NRF_CRYPTO_ENABLED - nrf_crypto - Cryptography library. +//========================================================== +#ifndef NRF_CRYPTO_ENABLED +#define NRF_CRYPTO_ENABLED 1 +#endif +// NRF_CRYPTO_ALLOCATOR - Memory allocator + + +// Choose memory allocator used by nrf_crypto. Default is alloca if possible or nrf_malloc otherwise. If 'User macros' are selected, the user has to create 'nrf_crypto_allocator.h' file that contains NRF_CRYPTO_ALLOC, NRF_CRYPTO_FREE, and NRF_CRYPTO_ALLOC_ON_STACK. +// <0=> Default +// <1=> User macros +// <2=> On stack (alloca) +// <3=> C dynamic memory (malloc) +// <4=> SDK Memory Manager (nrf_malloc) + +#ifndef NRF_CRYPTO_ALLOCATOR +#define NRF_CRYPTO_ALLOCATOR 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ENABLED - Enable the ARM Cryptocell CC310 reduced backend. + +// The CC310 hardware-accelerated cryptography backend with reduced functionality and footprint (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP224R1_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310_BL. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED - CC310_BL SHA-256 hash functionality. + + +// CC310_BL backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation + + +// Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian +// Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU! + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE +#define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096 +#endif + +// NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310 bl. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_BL_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CC310_ENABLED - Enable the ARM Cryptocell CC310 backend. + +// The CC310 hardware-accelerated cryptography backend (only available on nRF52840). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CC310_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED - Enable the AES CBC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED - Enable the AES CTR mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED - Enable the AES ECB mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED - Enable the AES CBC_MAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED - Enable the AES CMAC mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED - Enable the AES CCM mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED - Enable the AES CCM* mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_AES_CCM_STAR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED - Enable the secp160r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED - Enable the secp160r2 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160R2_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED - Enable the secp192r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED - Enable the secp224r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED - Enable the secp256r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED - Enable the secp384r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED - Enable the secp521r1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED - Enable the secp160k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP160K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED - Enable the secp192k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED - Enable the secp224k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED - Enable the secp256k1 elliptic curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED - Enable the Curve25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED - Enable the Ed25519 curve support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED - CC310 SHA-256 hash functionality. + + +// CC310 backend implementation for hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED - CC310 SHA-512 hash functionality + + +// CC310 backend implementation for SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED - CC310 HMAC using SHA-256 + + +// CC310 backend implementation for HMAC using hardware-accelerated SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED - CC310 HMAC using SHA-512 + + +// CC310 backend implementation for HMAC using SHA-512 (in software). + +#ifndef NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_HMAC_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED - Enable RNG support using CC310. + + +#ifndef NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_RNG_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED - Enable Interrupts while support using CC310. + + +// Select a library version compatible with the configuration. When interrupts are disable, a version named _noint must be used + +#ifndef NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED +#define NRF_CRYPTO_BACKEND_CC310_INTERRUPTS_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_CIFRA_ENABLED - Enable the Cifra backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_CIFRA_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED - Enable the AES EAX mode using Cifra. + + +#ifndef NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED +#define NRF_CRYPTO_BACKEND_CIFRA_AES_EAX_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED - Enable the mbed TLS backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED - Enable the AES CBC mode mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED - Enable the AES CTR mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CTR_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED - Enable the AES CFB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CFB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED - Enable the AES ECB mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_ECB_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED - Enable the AES CBC MAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CBC_MAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED - Enable the AES CMAC mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CMAC_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED - Enable the AES CCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_CCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED - Enable the AES GCM mode using mbed TLS. + + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_AES_GCM_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED - Enable secp384r1 (NIST 384-bit) curve + + +// Enable this setting if you need secp384r1 (NIST 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED - Enable secp521r1 (NIST 521-bit) curve + + +// Enable this setting if you need secp521r1 (NIST 521-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP521R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED - Enable secp192k1 (Koblitz 192-bit) curve + + +// Enable this setting if you need secp192k1 (Koblitz 192-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP192K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED - Enable secp224k1 (Koblitz 224-bit) curve + + +// Enable this setting if you need secp224k1 (Koblitz 224-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP224K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_SECP256K1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED - Enable bp256r1 (Brainpool 256-bit) curve + + +// Enable this setting if you need bp256r1 (Brainpool 256-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED - Enable bp384r1 (Brainpool 384-bit) curve + + +// Enable this setting if you need bp384r1 (Brainpool 384-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP384R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED - Enable bp512r1 (Brainpool 512-bit) curve + + +// Enable this setting if you need bp512r1 (Brainpool 512-bit) support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_BP512R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED - Enable Curve25519 curve + + +// Enable this setting if you need Curve25519 support using MBEDTLS + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED - Enable mbed TLS SHA-256 hash functionality. + + +// mbed TLS backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED - Enable mbed TLS SHA-512 hash functionality. + + +// mbed TLS backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED - Enable mbed TLS HMAC using SHA-256. + + +// mbed TLS backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED - Enable mbed TLS HMAC using SHA-512. + + +// mbed TLS backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_MBEDTLS_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED - Enable the micro-ecc backend. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED - Enable secp192r1 (NIST 192-bit) curve + + +// Enable this setting if you need secp192r1 (NIST 192-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP192R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED - Enable secp224r1 (NIST 224-bit) curve + + +// Enable this setting if you need secp224r1 (NIST 224-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP224R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED - Enable secp256r1 (NIST 256-bit) curve + + +// Enable this setting if you need secp256r1 (NIST 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED - Enable secp256k1 (Koblitz 256-bit) curve + + +// Enable this setting if you need secp256k1 (Koblitz 256-bit) support using micro-ecc + +#ifndef NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED +#define NRF_CRYPTO_BACKEND_MICRO_ECC_ECC_SECP256K1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED - Enable the nRF HW RNG backend. + +// The nRF HW backend provide access to RNG peripheral in nRF5x devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED - Enable mbed TLS CTR-DRBG algorithm. + + +// Enable mbed TLS CTR-DRBG standardized by NIST (NIST SP 800-90A Rev. 1). The nRF HW RNG is used as an entropy source for seeding. + +#ifndef NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_NRF_SW_ENABLED - Enable the legacy nRFx sw for crypto. + +// The nRF SW cryptography backend (only used in bootloader context). +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED - nRF SW hash backend support for SHA-256 + + +// The nRF SW backend provide access to nRF SDK legacy hash implementation of SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_NRF_SW_HASH_SHA256_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OBERON_ENABLED - Enable the Oberon backend + +// The Oberon backend +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OBERON_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED - Enable the CHACHA-POLY mode using Oberon. + + +#ifndef NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_CHACHA_POLY_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED - Enable secp256r1 curve + + +// Enable this setting if you need secp256r1 curve support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_SECP256R1_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED - Enable Curve25519 ECDH + + +// Enable this setting if you need Curve25519 ECDH support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_CURVE25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED - Enable Ed25519 signature scheme + + +// Enable this setting if you need Ed25519 support using Oberon library + +#ifndef NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_ECC_ED25519_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED - Oberon SHA-256 hash functionality + + +// Oberon backend implementation for SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED - Oberon SHA-512 hash functionality + + +// Oberon backend implementation for SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HASH_SHA512_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED - Oberon HMAC using SHA-256 + + +// Oberon backend implementation for HMAC using SHA-256. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA256_ENABLED 1 +#endif + +// NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED - Oberon HMAC using SHA-512 + + +// Oberon backend implementation for HMAC using SHA-512. + +#ifndef NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED +#define NRF_CRYPTO_BACKEND_OBERON_HMAC_SHA512_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_BACKEND_OPTIGA_ENABLED - Enable the nrf_crypto Optiga Trust X backend. + +// Enables the nrf_crypto backend for Optiga Trust X devices. +//========================================================== +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ENABLED 0 +#endif +// NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED - Optiga backend support for RNG + + +// The Optiga backend provide external chip RNG. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_RNG_ENABLED 0 +#endif + +// NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED - Optiga backend support for ECC secp256r1 + + +// The Optiga backend provide external chip ECC using secp256r1. + +#ifndef NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED +#define NRF_CRYPTO_BACKEND_OPTIGA_ECC_SECP256R1_ENABLED 1 +#endif + +// + +// NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED - Big-endian byte order in raw Curve25519 data + + +// Enable big-endian byte order in Curve25519 API, if set to 1. Use little-endian, if set to 0. + +#ifndef NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED +#define NRF_CRYPTO_CURVE25519_BIG_ENDIAN_ENABLED 0 +#endif + +// + +// +//========================================================== + +// nRF_DFU + +//========================================================== +// ble_dfu - Device Firmware Update + +//========================================================== +// BLE_DFU_ENABLED - Enable DFU Service. + + +#ifndef BLE_DFU_ENABLED +#define BLE_DFU_ENABLED 0 +#endif + +// NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS - Buttonless DFU supports bonds. + + +#ifndef NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS +#define NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers + +//========================================================== +// COMP_ENABLED - nrf_drv_comp - COMP peripheral driver - legacy layer +//========================================================== +#ifndef COMP_ENABLED +#define COMP_ENABLED 0 +#endif +// COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef COMP_CONFIG_REF +#define COMP_CONFIG_REF 1 +#endif + +// COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef COMP_CONFIG_MAIN_MODE +#define COMP_CONFIG_MAIN_MODE 0 +#endif + +// COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef COMP_CONFIG_SPEED_MODE +#define COMP_CONFIG_SPEED_MODE 2 +#endif + +// COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef COMP_CONFIG_HYST +#define COMP_CONFIG_HYST 0 +#endif + +// COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef COMP_CONFIG_ISOURCE +#define COMP_CONFIG_ISOURCE 0 +#endif + +// COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef COMP_CONFIG_INPUT +#define COMP_CONFIG_INPUT 0 +#endif + +// COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef COMP_CONFIG_IRQ_PRIORITY +#define COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// EGU_ENABLED - nrf_drv_swi - SWI(EGU) peripheral driver - legacy layer + + +#ifndef EGU_ENABLED +#define EGU_ENABLED 0 +#endif + +// GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer +//========================================================== +#ifndef GPIOTE_ENABLED +#define GPIOTE_ENABLED 1 +#endif +// GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 4 +#endif + +// GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef GPIOTE_CONFIG_IRQ_PRIORITY +#define GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// I2S_ENABLED - nrf_drv_i2s - I2S peripheral driver - legacy layer +//========================================================== +#ifndef I2S_ENABLED +#define I2S_ENABLED 0 +#endif +// I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef I2S_CONFIG_SCK_PIN +#define I2S_CONFIG_SCK_PIN 31 +#endif + +// I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef I2S_CONFIG_LRCK_PIN +#define I2S_CONFIG_LRCK_PIN 30 +#endif + +// I2S_CONFIG_MCK_PIN - MCK pin +#ifndef I2S_CONFIG_MCK_PIN +#define I2S_CONFIG_MCK_PIN 255 +#endif + +// I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef I2S_CONFIG_SDOUT_PIN +#define I2S_CONFIG_SDOUT_PIN 29 +#endif + +// I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef I2S_CONFIG_SDIN_PIN +#define I2S_CONFIG_SDIN_PIN 28 +#endif + +// I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef I2S_CONFIG_MASTER +#define I2S_CONFIG_MASTER 0 +#endif + +// I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef I2S_CONFIG_FORMAT +#define I2S_CONFIG_FORMAT 0 +#endif + +// I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef I2S_CONFIG_ALIGN +#define I2S_CONFIG_ALIGN 0 +#endif + +// I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef I2S_CONFIG_SWIDTH +#define I2S_CONFIG_SWIDTH 1 +#endif + +// I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef I2S_CONFIG_CHANNELS +#define I2S_CONFIG_CHANNELS 1 +#endif + +// I2S_CONFIG_MCK_SETUP - MCK behavior + +// <0=> Disabled +// <2147483648=> 32MHz/2 +// <1342177280=> 32MHz/3 +// <1073741824=> 32MHz/4 +// <805306368=> 32MHz/5 +// <671088640=> 32MHz/6 +// <536870912=> 32MHz/8 +// <402653184=> 32MHz/10 +// <369098752=> 32MHz/11 +// <285212672=> 32MHz/15 +// <268435456=> 32MHz/16 +// <201326592=> 32MHz/21 +// <184549376=> 32MHz/23 +// <142606336=> 32MHz/30 +// <138412032=> 32MHz/31 +// <134217728=> 32MHz/32 +// <100663296=> 32MHz/42 +// <68157440=> 32MHz/63 +// <34340864=> 32MHz/125 + +#ifndef I2S_CONFIG_MCK_SETUP +#define I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// I2S_CONFIG_RATIO - MCK/LRCK ratio + +// <0=> 32x +// <1=> 48x +// <2=> 64x +// <3=> 96x +// <4=> 128x +// <5=> 192x +// <6=> 256x +// <7=> 384x +// <8=> 512x + +#ifndef I2S_CONFIG_RATIO +#define I2S_CONFIG_RATIO 2000 +#endif + +// I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef I2S_CONFIG_IRQ_PRIORITY +#define I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef I2S_CONFIG_LOG_ENABLED +#define I2S_CONFIG_LOG_ENABLED 0 +#endif +// I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef I2S_CONFIG_LOG_LEVEL +#define I2S_CONFIG_LOG_LEVEL 3 +#endif + +// I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef I2S_CONFIG_INFO_COLOR +#define I2S_CONFIG_INFO_COLOR 0 +#endif + +// I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef I2S_CONFIG_DEBUG_COLOR +#define I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// LPCOMP_ENABLED - nrf_drv_lpcomp - LPCOMP peripheral driver - legacy layer +//========================================================== +#ifndef LPCOMP_ENABLED +#define LPCOMP_ENABLED 0 +#endif +// LPCOMP_CONFIG_REFERENCE - Reference voltage + +// <0=> Supply 1/8 +// <1=> Supply 2/8 +// <2=> Supply 3/8 +// <3=> Supply 4/8 +// <4=> Supply 5/8 +// <5=> Supply 6/8 +// <6=> Supply 7/8 +// <8=> Supply 1/16 (nRF52) +// <9=> Supply 3/16 (nRF52) +// <10=> Supply 5/16 (nRF52) +// <11=> Supply 7/16 (nRF52) +// <12=> Supply 9/16 (nRF52) +// <13=> Supply 11/16 (nRF52) +// <14=> Supply 13/16 (nRF52) +// <15=> Supply 15/16 (nRF52) +// <7=> External Ref 0 +// <65543=> External Ref 1 + +#ifndef LPCOMP_CONFIG_REFERENCE +#define LPCOMP_CONFIG_REFERENCE 3 +#endif + +// LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef LPCOMP_CONFIG_DETECTION +#define LPCOMP_CONFIG_DETECTION 2 +#endif + +// LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef LPCOMP_CONFIG_INPUT +#define LPCOMP_CONFIG_INPUT 0 +#endif + +// LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef LPCOMP_CONFIG_HYST +#define LPCOMP_CONFIG_HYST 0 +#endif + +// LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef LPCOMP_CONFIG_IRQ_PRIORITY +#define LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver +//========================================================== +#ifndef NRFX_CLOCK_ENABLED +#define NRFX_CLOCK_ENABLED 1 +#endif +// NRFX_CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef NRFX_CLOCK_CONFIG_LF_SRC +#define NRFX_CLOCK_CONFIG_LF_SRC 1 +#endif + +// NRFX_CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY +#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED +#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL +#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_CLOCK_CONFIG_INFO_COLOR +#define NRFX_CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_CLOCK_CONFIG_DEBUG_COLOR +#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_COMP_ENABLED - nrfx_comp - COMP peripheral driver +//========================================================== +#ifndef NRFX_COMP_ENABLED +#define NRFX_COMP_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_REF - Reference voltage + +// <0=> Internal 1.2V +// <1=> Internal 1.8V +// <2=> Internal 2.4V +// <4=> VDD +// <7=> ARef + +#ifndef NRFX_COMP_CONFIG_REF +#define NRFX_COMP_CONFIG_REF 1 +#endif + +// NRFX_COMP_CONFIG_MAIN_MODE - Main mode + +// <0=> Single ended +// <1=> Differential + +#ifndef NRFX_COMP_CONFIG_MAIN_MODE +#define NRFX_COMP_CONFIG_MAIN_MODE 0 +#endif + +// NRFX_COMP_CONFIG_SPEED_MODE - Speed mode + +// <0=> Low power +// <1=> Normal +// <2=> High speed + +#ifndef NRFX_COMP_CONFIG_SPEED_MODE +#define NRFX_COMP_CONFIG_SPEED_MODE 2 +#endif + +// NRFX_COMP_CONFIG_HYST - Hystheresis + +// <0=> No +// <1=> 50mV + +#ifndef NRFX_COMP_CONFIG_HYST +#define NRFX_COMP_CONFIG_HYST 0 +#endif + +// NRFX_COMP_CONFIG_ISOURCE - Current Source + +// <0=> Off +// <1=> 2.5 uA +// <2=> 5 uA +// <3=> 10 uA + +#ifndef NRFX_COMP_CONFIG_ISOURCE +#define NRFX_COMP_CONFIG_ISOURCE 0 +#endif + +// NRFX_COMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_INPUT +#define NRFX_COMP_CONFIG_INPUT 0 +#endif + +// NRFX_COMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_COMP_CONFIG_IRQ_PRIORITY +#define NRFX_COMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_COMP_CONFIG_LOG_ENABLED +#define NRFX_COMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_COMP_CONFIG_LOG_LEVEL +#define NRFX_COMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_COMP_CONFIG_INFO_COLOR +#define NRFX_COMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_COMP_CONFIG_DEBUG_COLOR +#define NRFX_COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver +//========================================================== +#ifndef NRFX_GPIOTE_ENABLED +#define NRFX_GPIOTE_ENABLED 1 +#endif +// NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins +#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1 +#endif + +// NRFX_GPIOTE_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY +#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED +#define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL +#define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_GPIOTE_CONFIG_INFO_COLOR +#define NRFX_GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_GPIOTE_CONFIG_DEBUG_COLOR +#define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_I2S_ENABLED - nrfx_i2s - I2S peripheral driver +//========================================================== +#ifndef NRFX_I2S_ENABLED +#define NRFX_I2S_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_SCK_PIN - SCK pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SCK_PIN +#define NRFX_I2S_CONFIG_SCK_PIN 31 +#endif + +// NRFX_I2S_CONFIG_LRCK_PIN - LRCK pin <1-31> + + +#ifndef NRFX_I2S_CONFIG_LRCK_PIN +#define NRFX_I2S_CONFIG_LRCK_PIN 30 +#endif + +// NRFX_I2S_CONFIG_MCK_PIN - MCK pin +#ifndef NRFX_I2S_CONFIG_MCK_PIN +#define NRFX_I2S_CONFIG_MCK_PIN 255 +#endif + +// NRFX_I2S_CONFIG_SDOUT_PIN - SDOUT pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDOUT_PIN +#define NRFX_I2S_CONFIG_SDOUT_PIN 29 +#endif + +// NRFX_I2S_CONFIG_SDIN_PIN - SDIN pin <0-31> + + +#ifndef NRFX_I2S_CONFIG_SDIN_PIN +#define NRFX_I2S_CONFIG_SDIN_PIN 28 +#endif + +// NRFX_I2S_CONFIG_MASTER - Mode + +// <0=> Master +// <1=> Slave + +#ifndef NRFX_I2S_CONFIG_MASTER +#define NRFX_I2S_CONFIG_MASTER 0 +#endif + +// NRFX_I2S_CONFIG_FORMAT - Format + +// <0=> I2S +// <1=> Aligned + +#ifndef NRFX_I2S_CONFIG_FORMAT +#define NRFX_I2S_CONFIG_FORMAT 0 +#endif + +// NRFX_I2S_CONFIG_ALIGN - Alignment + +// <0=> Left +// <1=> Right + +#ifndef NRFX_I2S_CONFIG_ALIGN +#define NRFX_I2S_CONFIG_ALIGN 0 +#endif + +// NRFX_I2S_CONFIG_SWIDTH - Sample width (bits) + +// <0=> 8 +// <1=> 16 +// <2=> 24 + +#ifndef NRFX_I2S_CONFIG_SWIDTH +#define NRFX_I2S_CONFIG_SWIDTH 1 +#endif + +// NRFX_I2S_CONFIG_CHANNELS - Channels + +// <0=> Stereo +// <1=> Left +// <2=> Right + +#ifndef NRFX_I2S_CONFIG_CHANNELS +#define NRFX_I2S_CONFIG_CHANNELS 1 +#endif + +// NRFX_I2S_CONFIG_MCK_SETUP - MCK behavior + +// <0=> Disabled +// <2147483648=> 32MHz/2 +// <1342177280=> 32MHz/3 +// <1073741824=> 32MHz/4 +// <805306368=> 32MHz/5 +// <671088640=> 32MHz/6 +// <536870912=> 32MHz/8 +// <402653184=> 32MHz/10 +// <369098752=> 32MHz/11 +// <285212672=> 32MHz/15 +// <268435456=> 32MHz/16 +// <201326592=> 32MHz/21 +// <184549376=> 32MHz/23 +// <142606336=> 32MHz/30 +// <138412032=> 32MHz/31 +// <134217728=> 32MHz/32 +// <100663296=> 32MHz/42 +// <68157440=> 32MHz/63 +// <34340864=> 32MHz/125 + +#ifndef NRFX_I2S_CONFIG_MCK_SETUP +#define NRFX_I2S_CONFIG_MCK_SETUP 536870912 +#endif + +// NRFX_I2S_CONFIG_RATIO - MCK/LRCK ratio + +// <0=> 32x +// <1=> 48x +// <2=> 64x +// <3=> 96x +// <4=> 128x +// <5=> 192x +// <6=> 256x +// <7=> 384x +// <8=> 512x + +#ifndef NRFX_I2S_CONFIG_RATIO +#define NRFX_I2S_CONFIG_RATIO 2000 +#endif + +// NRFX_I2S_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_I2S_CONFIG_IRQ_PRIORITY +#define NRFX_I2S_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_I2S_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_I2S_CONFIG_LOG_ENABLED +#define NRFX_I2S_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_I2S_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_I2S_CONFIG_LOG_LEVEL +#define NRFX_I2S_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_I2S_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_I2S_CONFIG_INFO_COLOR +#define NRFX_I2S_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_I2S_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_I2S_CONFIG_DEBUG_COLOR +#define NRFX_I2S_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_LPCOMP_ENABLED - nrfx_lpcomp - LPCOMP peripheral driver +//========================================================== +#ifndef NRFX_LPCOMP_ENABLED +#define NRFX_LPCOMP_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_REFERENCE - Reference voltage + +// <0=> Supply 1/8 +// <1=> Supply 2/8 +// <2=> Supply 3/8 +// <3=> Supply 4/8 +// <4=> Supply 5/8 +// <5=> Supply 6/8 +// <6=> Supply 7/8 +// <8=> Supply 1/16 (nRF52) +// <9=> Supply 3/16 (nRF52) +// <10=> Supply 5/16 (nRF52) +// <11=> Supply 7/16 (nRF52) +// <12=> Supply 9/16 (nRF52) +// <13=> Supply 11/16 (nRF52) +// <14=> Supply 13/16 (nRF52) +// <15=> Supply 15/16 (nRF52) +// <7=> External Ref 0 +// <65543=> External Ref 1 + +#ifndef NRFX_LPCOMP_CONFIG_REFERENCE +#define NRFX_LPCOMP_CONFIG_REFERENCE 3 +#endif + +// NRFX_LPCOMP_CONFIG_DETECTION - Detection + +// <0=> Crossing +// <1=> Up +// <2=> Down + +#ifndef NRFX_LPCOMP_CONFIG_DETECTION +#define NRFX_LPCOMP_CONFIG_DETECTION 2 +#endif + +// NRFX_LPCOMP_CONFIG_INPUT - Analog input + +// <0=> 0 +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_INPUT +#define NRFX_LPCOMP_CONFIG_INPUT 0 +#endif + +// NRFX_LPCOMP_CONFIG_HYST - Hysteresis + + +#ifndef NRFX_LPCOMP_CONFIG_HYST +#define NRFX_LPCOMP_CONFIG_HYST 0 +#endif + +// NRFX_LPCOMP_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_LPCOMP_CONFIG_IRQ_PRIORITY +#define NRFX_LPCOMP_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_LPCOMP_CONFIG_LOG_ENABLED +#define NRFX_LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_LPCOMP_CONFIG_LOG_LEVEL +#define NRFX_LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_LPCOMP_CONFIG_INFO_COLOR +#define NRFX_LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_LPCOMP_CONFIG_DEBUG_COLOR +#define NRFX_LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PDM_ENABLED - nrfx_pdm - PDM peripheral driver +//========================================================== +#ifndef NRFX_PDM_ENABLED +#define NRFX_PDM_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef NRFX_PDM_CONFIG_MODE +#define NRFX_PDM_CONFIG_MODE 1 +#endif + +// NRFX_PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef NRFX_PDM_CONFIG_EDGE +#define NRFX_PDM_CONFIG_EDGE 0 +#endif + +// NRFX_PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef NRFX_PDM_CONFIG_CLOCK_FREQ +#define NRFX_PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// NRFX_PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PDM_CONFIG_IRQ_PRIORITY +#define NRFX_PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PDM_CONFIG_LOG_ENABLED +#define NRFX_PDM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PDM_CONFIG_LOG_LEVEL +#define NRFX_PDM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PDM_CONFIG_INFO_COLOR +#define NRFX_PDM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PDM_CONFIG_DEBUG_COLOR +#define NRFX_PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_POWER_ENABLED - nrfx_power - POWER peripheral driver +//========================================================== +#ifndef NRFX_POWER_ENABLED +#define NRFX_POWER_ENABLED 0 +#endif +// NRFX_POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_POWER_CONFIG_IRQ_PRIORITY +#define NRFX_POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCEN +#define NRFX_POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// NRFX_POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef NRFX_POWER_CONFIG_DEFAULT_DCDCENHV +#define NRFX_POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// NRFX_PPI_ENABLED - nrfx_ppi - PPI peripheral allocator +//========================================================== +#ifndef NRFX_PPI_ENABLED +#define NRFX_PPI_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PPI_CONFIG_LOG_ENABLED +#define NRFX_PPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PPI_CONFIG_LOG_LEVEL +#define NRFX_PPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PPI_CONFIG_INFO_COLOR +#define NRFX_PPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PPI_CONFIG_DEBUG_COLOR +#define NRFX_PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PRS_ENABLED - nrfx_prs - Peripheral Resource Sharing module +//========================================================== +#ifndef NRFX_PRS_ENABLED +#define NRFX_PRS_ENABLED 1 +#endif +// NRFX_PRS_BOX_0_ENABLED - Enables box 0 in the module. + + +#ifndef NRFX_PRS_BOX_0_ENABLED +#define NRFX_PRS_BOX_0_ENABLED 0 +#endif + +// NRFX_PRS_BOX_1_ENABLED - Enables box 1 in the module. + + +#ifndef NRFX_PRS_BOX_1_ENABLED +#define NRFX_PRS_BOX_1_ENABLED 0 +#endif + +// NRFX_PRS_BOX_2_ENABLED - Enables box 2 in the module. + + +#ifndef NRFX_PRS_BOX_2_ENABLED +#define NRFX_PRS_BOX_2_ENABLED 0 +#endif + +// NRFX_PRS_BOX_3_ENABLED - Enables box 3 in the module. + + +#ifndef NRFX_PRS_BOX_3_ENABLED +#define NRFX_PRS_BOX_3_ENABLED 0 +#endif + +// NRFX_PRS_BOX_4_ENABLED - Enables box 4 in the module. + + +#ifndef NRFX_PRS_BOX_4_ENABLED +#define NRFX_PRS_BOX_4_ENABLED 1 +#endif + +// NRFX_PRS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PRS_CONFIG_LOG_ENABLED +#define NRFX_PRS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PRS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PRS_CONFIG_LOG_LEVEL +#define NRFX_PRS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PRS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PRS_CONFIG_INFO_COLOR +#define NRFX_PRS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PRS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PRS_CONFIG_DEBUG_COLOR +#define NRFX_PRS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver +//========================================================== +#ifndef NRFX_PWM_ENABLED +#define NRFX_PWM_ENABLED 0 +#endif +// NRFX_PWM0_ENABLED - Enable PWM0 instance + + +#ifndef NRFX_PWM0_ENABLED +#define NRFX_PWM0_ENABLED 0 +#endif + +// NRFX_PWM1_ENABLED - Enable PWM1 instance + + +#ifndef NRFX_PWM1_ENABLED +#define NRFX_PWM1_ENABLED 0 +#endif + +// NRFX_PWM2_ENABLED - Enable PWM2 instance + + +#ifndef NRFX_PWM2_ENABLED +#define NRFX_PWM2_ENABLED 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN +#define NRFX_PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK - Base clock + +// <0=> 16 MHz +// <1=> 8 MHz +// <2=> 4 MHz +// <3=> 2 MHz +// <4=> 1 MHz +// <5=> 500 kHz +// <6=> 250 kHz +// <7=> 125 kHz + +#ifndef NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK +#define NRFX_PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE +#define NRFX_PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE +#define NRFX_PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE +#define NRFX_PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef NRFX_PWM_DEFAULT_CONFIG_STEP_MODE +#define NRFX_PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_PWM_CONFIG_LOG_ENABLED +#define NRFX_PWM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_PWM_CONFIG_LOG_LEVEL +#define NRFX_PWM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PWM_CONFIG_INFO_COLOR +#define NRFX_PWM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_PWM_CONFIG_DEBUG_COLOR +#define NRFX_PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE - EGU instance used by the nRF52 Anomaly 109 workaround for PWM. + +// <0=> EGU0 +// <1=> EGU1 +// <2=> EGU2 +// <3=> EGU3 +// <4=> EGU4 +// <5=> EGU5 + +#ifndef NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// NRFX_QDEC_ENABLED - nrfx_qdec - QDEC peripheral driver +//========================================================== +#ifndef NRFX_QDEC_ENABLED +#define NRFX_QDEC_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_REPORTPER - Report period + +// <0=> 10 Samples +// <1=> 40 Samples +// <2=> 80 Samples +// <3=> 120 Samples +// <4=> 160 Samples +// <5=> 200 Samples +// <6=> 240 Samples +// <7=> 280 Samples + +#ifndef NRFX_QDEC_CONFIG_REPORTPER +#define NRFX_QDEC_CONFIG_REPORTPER 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLEPER - Sample period + +// <0=> 128 us +// <1=> 256 us +// <2=> 512 us +// <3=> 1024 us +// <4=> 2048 us +// <5=> 4096 us +// <6=> 8192 us +// <7=> 16384 us + +#ifndef NRFX_QDEC_CONFIG_SAMPLEPER +#define NRFX_QDEC_CONFIG_SAMPLEPER 7 +#endif + +// NRFX_QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_A +#define NRFX_QDEC_CONFIG_PIO_A 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_B +#define NRFX_QDEC_CONFIG_PIO_B 31 +#endif + +// NRFX_QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef NRFX_QDEC_CONFIG_PIO_LED +#define NRFX_QDEC_CONFIG_PIO_LED 31 +#endif + +// NRFX_QDEC_CONFIG_LEDPRE - LED pre +#ifndef NRFX_QDEC_CONFIG_LEDPRE +#define NRFX_QDEC_CONFIG_LEDPRE 511 +#endif + +// NRFX_QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef NRFX_QDEC_CONFIG_LEDPOL +#define NRFX_QDEC_CONFIG_LEDPOL 1 +#endif + +// NRFX_QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef NRFX_QDEC_CONFIG_DBFEN +#define NRFX_QDEC_CONFIG_DBFEN 0 +#endif + +// NRFX_QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef NRFX_QDEC_CONFIG_SAMPLE_INTEN +#define NRFX_QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// NRFX_QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_QDEC_CONFIG_IRQ_PRIORITY +#define NRFX_QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_QDEC_CONFIG_LOG_ENABLED +#define NRFX_QDEC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_QDEC_CONFIG_LOG_LEVEL +#define NRFX_QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_QDEC_CONFIG_INFO_COLOR +#define NRFX_QDEC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_QDEC_CONFIG_DEBUG_COLOR +#define NRFX_QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver +//========================================================== +#ifndef NRFX_RNG_ENABLED +#define NRFX_RNG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef NRFX_RNG_CONFIG_ERROR_CORRECTION +#define NRFX_RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// NRFX_RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RNG_CONFIG_IRQ_PRIORITY +#define NRFX_RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RNG_CONFIG_LOG_ENABLED +#define NRFX_RNG_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RNG_CONFIG_LOG_LEVEL +#define NRFX_RNG_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_RNG_CONFIG_INFO_COLOR +#define NRFX_RNG_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_RNG_CONFIG_DEBUG_COLOR +#define NRFX_RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_RTC_ENABLED - nrfx_rtc - RTC peripheral driver +//========================================================== +#ifndef NRFX_RTC_ENABLED +#define NRFX_RTC_ENABLED 0 +#endif +// NRFX_RTC0_ENABLED - Enable RTC0 instance + + +#ifndef NRFX_RTC0_ENABLED +#define NRFX_RTC0_ENABLED 0 +#endif + +// NRFX_RTC1_ENABLED - Enable RTC1 instance + + +#ifndef NRFX_RTC1_ENABLED +#define NRFX_RTC1_ENABLED 0 +#endif + +// NRFX_RTC2_ENABLED - Enable RTC2 instance + + +#ifndef NRFX_RTC2_ENABLED +#define NRFX_RTC2_ENABLED 0 +#endif + +// NRFX_RTC_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRFX_RTC_MAXIMUM_LATENCY_US +#define NRFX_RTC_MAXIMUM_LATENCY_US 2000 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_FREQUENCY +#define NRFX_RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef NRFX_RTC_DEFAULT_CONFIG_RELIABLE +#define NRFX_RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_RTC_CONFIG_LOG_ENABLED +#define NRFX_RTC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_RTC_CONFIG_LOG_LEVEL +#define NRFX_RTC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_RTC_CONFIG_INFO_COLOR +#define NRFX_RTC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_RTC_CONFIG_DEBUG_COLOR +#define NRFX_RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver +//========================================================== +#ifndef NRFX_SAADC_ENABLED +#define NRFX_SAADC_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef NRFX_SAADC_CONFIG_RESOLUTION +#define NRFX_SAADC_CONFIG_RESOLUTION 1 +#endif + +// NRFX_SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef NRFX_SAADC_CONFIG_OVERSAMPLE +#define NRFX_SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// NRFX_SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef NRFX_SAADC_CONFIG_LP_MODE +#define NRFX_SAADC_CONFIG_LP_MODE 0 +#endif + +// NRFX_SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SAADC_CONFIG_IRQ_PRIORITY +#define NRFX_SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SAADC_CONFIG_LOG_ENABLED +#define NRFX_SAADC_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SAADC_CONFIG_LOG_LEVEL +#define NRFX_SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SAADC_CONFIG_INFO_COLOR +#define NRFX_SAADC_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SAADC_CONFIG_DEBUG_COLOR +#define NRFX_SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver +//========================================================== +#ifndef NRFX_SPIM_ENABLED +#define NRFX_SPIM_ENABLED 0 +#endif +// NRFX_SPIM0_ENABLED - Enable SPIM0 instance + + +#ifndef NRFX_SPIM0_ENABLED +#define NRFX_SPIM0_ENABLED 0 +#endif + +// NRFX_SPIM1_ENABLED - Enable SPIM1 instance + + +#ifndef NRFX_SPIM1_ENABLED +#define NRFX_SPIM1_ENABLED 0 +#endif + +// NRFX_SPIM2_ENABLED - Enable SPIM2 instance + + +#ifndef NRFX_SPIM2_ENABLED +#define NRFX_SPIM2_ENABLED 0 +#endif + +// NRFX_SPIM_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPIM_MISO_PULL_CFG +#define NRFX_SPIM_MISO_PULL_CFG 1 +#endif + +// NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIM_CONFIG_LOG_ENABLED +#define NRFX_SPIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIM_CONFIG_LOG_LEVEL +#define NRFX_SPIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPIM_CONFIG_INFO_COLOR +#define NRFX_SPIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPIM_CONFIG_DEBUG_COLOR +#define NRFX_SPIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPIS_ENABLED - nrfx_spis - SPIS peripheral driver +//========================================================== +#ifndef NRFX_SPIS_ENABLED +#define NRFX_SPIS_ENABLED 0 +#endif +// NRFX_SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef NRFX_SPIS0_ENABLED +#define NRFX_SPIS0_ENABLED 0 +#endif + +// NRFX_SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef NRFX_SPIS1_ENABLED +#define NRFX_SPIS1_ENABLED 0 +#endif + +// NRFX_SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef NRFX_SPIS2_ENABLED +#define NRFX_SPIS2_ENABLED 0 +#endif + +// NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_DEF +#define NRFX_SPIS_DEFAULT_DEF 255 +#endif + +// NRFX_SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef NRFX_SPIS_DEFAULT_ORC +#define NRFX_SPIS_DEFAULT_ORC 255 +#endif + +// NRFX_SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPIS_CONFIG_LOG_ENABLED +#define NRFX_SPIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPIS_CONFIG_LOG_LEVEL +#define NRFX_SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPIS_CONFIG_INFO_COLOR +#define NRFX_SPIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPIS_CONFIG_DEBUG_COLOR +#define NRFX_SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_SPI_ENABLED - nrfx_spi - SPI peripheral driver +//========================================================== +#ifndef NRFX_SPI_ENABLED +#define NRFX_SPI_ENABLED 0 +#endif +// NRFX_SPI0_ENABLED - Enable SPI0 instance + + +#ifndef NRFX_SPI0_ENABLED +#define NRFX_SPI0_ENABLED 0 +#endif + +// NRFX_SPI1_ENABLED - Enable SPI1 instance + + +#ifndef NRFX_SPI1_ENABLED +#define NRFX_SPI1_ENABLED 0 +#endif + +// NRFX_SPI2_ENABLED - Enable SPI2 instance + + +#ifndef NRFX_SPI2_ENABLED +#define NRFX_SPI2_ENABLED 0 +#endif + +// NRFX_SPI_MISO_PULL_CFG - MISO pin pull configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRFX_SPI_MISO_PULL_CFG +#define NRFX_SPI_MISO_PULL_CFG 1 +#endif + +// NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SPI_CONFIG_LOG_ENABLED +#define NRFX_SPI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SPI_CONFIG_LOG_LEVEL +#define NRFX_SPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPI_CONFIG_INFO_COLOR +#define NRFX_SPI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SPI_CONFIG_DEBUG_COLOR +#define NRFX_SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_SWI_ENABLED - nrfx_swi - SWI/EGU peripheral allocator +//========================================================== +#ifndef NRFX_SWI_ENABLED +#define NRFX_SWI_ENABLED 0 +#endif +// NRFX_EGU_ENABLED - Enable EGU support + + +#ifndef NRFX_EGU_ENABLED +#define NRFX_EGU_ENABLED 0 +#endif + +// NRFX_SWI0_DISABLED - Exclude SWI0 from being utilized by the driver + + +#ifndef NRFX_SWI0_DISABLED +#define NRFX_SWI0_DISABLED 0 +#endif + +// NRFX_SWI1_DISABLED - Exclude SWI1 from being utilized by the driver + + +#ifndef NRFX_SWI1_DISABLED +#define NRFX_SWI1_DISABLED 0 +#endif + +// NRFX_SWI2_DISABLED - Exclude SWI2 from being utilized by the driver + + +#ifndef NRFX_SWI2_DISABLED +#define NRFX_SWI2_DISABLED 0 +#endif + +// NRFX_SWI3_DISABLED - Exclude SWI3 from being utilized by the driver + + +#ifndef NRFX_SWI3_DISABLED +#define NRFX_SWI3_DISABLED 0 +#endif + +// NRFX_SWI4_DISABLED - Exclude SWI4 from being utilized by the driver + + +#ifndef NRFX_SWI4_DISABLED +#define NRFX_SWI4_DISABLED 0 +#endif + +// NRFX_SWI5_DISABLED - Exclude SWI5 from being utilized by the driver + + +#ifndef NRFX_SWI5_DISABLED +#define NRFX_SWI5_DISABLED 0 +#endif + +// NRFX_SWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_SWI_CONFIG_LOG_ENABLED +#define NRFX_SWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_SWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_SWI_CONFIG_LOG_LEVEL +#define NRFX_SWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_SWI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SWI_CONFIG_INFO_COLOR +#define NRFX_SWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_SWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_SWI_CONFIG_DEBUG_COLOR +#define NRFX_SWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TIMER_ENABLED - nrfx_timer - TIMER periperal driver +//========================================================== +#ifndef NRFX_TIMER_ENABLED +#define NRFX_TIMER_ENABLED 0 +#endif +// NRFX_TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef NRFX_TIMER0_ENABLED +#define NRFX_TIMER0_ENABLED 0 +#endif + +// NRFX_TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef NRFX_TIMER1_ENABLED +#define NRFX_TIMER1_ENABLED 0 +#endif + +// NRFX_TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef NRFX_TIMER2_ENABLED +#define NRFX_TIMER2_ENABLED 0 +#endif + +// NRFX_TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef NRFX_TIMER3_ENABLED +#define NRFX_TIMER3_ENABLED 0 +#endif + +// NRFX_TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef NRFX_TIMER4_ENABLED +#define NRFX_TIMER4_ENABLED 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY - Timer frequency if in Timer mode + +// <0=> 16 MHz +// <1=> 8 MHz +// <2=> 4 MHz +// <3=> 2 MHz +// <4=> 1 MHz +// <5=> 500 kHz +// <6=> 250 kHz +// <7=> 125 kHz +// <8=> 62.5 kHz +// <9=> 31.25 kHz + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_MODE +#define NRFX_TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define NRFX_TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TIMER_CONFIG_LOG_ENABLED +#define NRFX_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TIMER_CONFIG_LOG_LEVEL +#define NRFX_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TIMER_CONFIG_INFO_COLOR +#define NRFX_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TIMER_CONFIG_DEBUG_COLOR +#define NRFX_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver +//========================================================== +#ifndef NRFX_TWIM_ENABLED +#define NRFX_TWIM_ENABLED 0 +#endif +// NRFX_TWIM0_ENABLED - Enable TWIM0 instance + + +#ifndef NRFX_TWIM0_ENABLED +#define NRFX_TWIM0_ENABLED 0 +#endif + +// NRFX_TWIM1_ENABLED - Enable TWIM1 instance + + +#ifndef NRFX_TWIM1_ENABLED +#define NRFX_TWIM1_ENABLED 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIM_CONFIG_LOG_ENABLED +#define NRFX_TWIM_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIM_CONFIG_LOG_LEVEL +#define NRFX_TWIM_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWIM_CONFIG_INFO_COLOR +#define NRFX_TWIM_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWIM_CONFIG_DEBUG_COLOR +#define NRFX_TWIM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// NRFX_TWIS_ENABLED - nrfx_twis - TWIS peripheral driver +//========================================================== +#ifndef NRFX_TWIS_ENABLED +#define NRFX_TWIS_ENABLED 0 +#endif +// NRFX_TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef NRFX_TWIS0_ENABLED +#define NRFX_TWIS0_ENABLED 0 +#endif + +// NRFX_TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef NRFX_TWIS1_ENABLED +#define NRFX_TWIS1_ENABLED 0 +#endif + +// NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// Optimization flag. Registers used by TWIS are shared by other peripherals. Normally, during initialization driver tries to clear all registers to known state before doing the initialization itself. This gives initialization safe procedure, no matter when it would be called. If you activate TWIS only once and do never uninitialize it - set this flag to 1 what gives more optimal code. + +#ifndef NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// NRFX_TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// Synchronous mode would be used in specific situations. And it uses some additional code and data memory to safely process state machine by polling it in status functions. If this functionality is not required it may be disabled to free some resources. + +#ifndef NRFX_TWIS_NO_SYNC_MODE +#define NRFX_TWIS_NO_SYNC_MODE 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR0 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef NRFX_TWIS_DEFAULT_CONFIG_ADDR1 +#define NRFX_TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL +#define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWIS_CONFIG_LOG_ENABLED +#define NRFX_TWIS_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWIS_CONFIG_LOG_LEVEL +#define NRFX_TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWIS_CONFIG_INFO_COLOR +#define NRFX_TWIS_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWIS_CONFIG_DEBUG_COLOR +#define NRFX_TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver +//========================================================== +#ifndef NRFX_TWI_ENABLED +#define NRFX_TWI_ENABLED 0 +#endif +// NRFX_TWI0_ENABLED - Enable TWI0 instance + + +#ifndef NRFX_TWI0_ENABLED +#define NRFX_TWI0_ENABLED 0 +#endif + +// NRFX_TWI1_ENABLED - Enable TWI1 instance + + +#ifndef NRFX_TWI1_ENABLED +#define NRFX_TWI1_ENABLED 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY +#define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_TWI_CONFIG_LOG_ENABLED +#define NRFX_TWI_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_TWI_CONFIG_LOG_LEVEL +#define NRFX_TWI_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWI_CONFIG_INFO_COLOR +#define NRFX_TWI_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_TWI_CONFIG_DEBUG_COLOR +#define NRFX_TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver +//========================================================== +#ifndef NRFX_UARTE_ENABLED +#define NRFX_UARTE_ENABLED 1 +#endif +// NRFX_UARTE0_ENABLED - Enable UARTE0 instance +#ifndef NRFX_UARTE0_ENABLED +#define NRFX_UARTE0_ENABLED 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_HWFC +#define NRFX_UARTE_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_PARITY +#define NRFX_UARTE_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3862528=> 14400 baud +// <5152768=> 19200 baud +// <7716864=> 28800 baud +// <8388608=> 31250 baud +// <10289152=> 38400 baud +// <15007744=> 56000 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UARTE_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UARTE_CONFIG_LOG_ENABLED +#define NRFX_UARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UARTE_CONFIG_LOG_LEVEL +#define NRFX_UARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_UARTE_CONFIG_INFO_COLOR +#define NRFX_UARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_UARTE_CONFIG_DEBUG_COLOR +#define NRFX_UARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver +//========================================================== +#ifndef NRFX_UART_ENABLED +#define NRFX_UART_ENABLED 1 +#endif +// NRFX_UART0_ENABLED - Enable UART0 instance +#ifndef NRFX_UART0_ENABLED +#define NRFX_UART0_ENABLED 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef NRFX_UART_DEFAULT_CONFIG_HWFC +#define NRFX_UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef NRFX_UART_DEFAULT_CONFIG_PARITY +#define NRFX_UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// NRFX_UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3866624=> 14400 baud +// <5152768=> 19200 baud +// <7729152=> 28800 baud +// <8388608=> 31250 baud +// <10309632=> 38400 baud +// <15007744=> 56000 baud +// <15462400=> 57600 baud +// <20615168=> 76800 baud +// <30924800=> 115200 baud +// <61845504=> 230400 baud +// <67108864=> 250000 baud +// <123695104=> 460800 baud +// <247386112=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRFX_UART_DEFAULT_CONFIG_BAUDRATE +#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE 30924800 +#endif + +// NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_UART_CONFIG_LOG_ENABLED +#define NRFX_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_UART_CONFIG_LOG_LEVEL +#define NRFX_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_UART_CONFIG_INFO_COLOR +#define NRFX_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_UART_CONFIG_DEBUG_COLOR +#define NRFX_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRFX_WDT_ENABLED - nrfx_wdt - WDT peripheral driver +//========================================================== +#ifndef NRFX_WDT_ENABLED +#define NRFX_WDT_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode + +// <1=> Run in SLEEP, Pause in HALT +// <8=> Pause in SLEEP, Run in HALT +// <9=> Run in SLEEP and HALT +// <0=> Pause in SLEEP and HALT + +#ifndef NRFX_WDT_CONFIG_BEHAVIOUR +#define NRFX_WDT_CONFIG_BEHAVIOUR 1 +#endif + +// NRFX_WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef NRFX_WDT_CONFIG_RELOAD_VALUE +#define NRFX_WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// NRFX_WDT_CONFIG_NO_IRQ - Remove WDT IRQ handling from WDT driver + +// <0=> Include WDT IRQ handling +// <1=> Remove WDT IRQ handling + +#ifndef NRFX_WDT_CONFIG_NO_IRQ +#define NRFX_WDT_CONFIG_NO_IRQ 0 +#endif + +// NRFX_WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef NRFX_WDT_CONFIG_IRQ_PRIORITY +#define NRFX_WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRFX_WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRFX_WDT_CONFIG_LOG_ENABLED +#define NRFX_WDT_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_WDT_CONFIG_LOG_LEVEL +#define NRFX_WDT_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_WDT_CONFIG_INFO_COLOR +#define NRFX_WDT_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_WDT_CONFIG_DEBUG_COLOR +#define NRFX_WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// + +// NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer +//========================================================== +#ifndef NRF_CLOCK_ENABLED +#define NRF_CLOCK_ENABLED 1 +#endif +// CLOCK_CONFIG_LF_SRC - LF Clock Source + +// <0=> RC +// <1=> XTAL +// <2=> Synth +// <131073=> External Low Swing +// <196609=> External Full Swing + +#ifndef CLOCK_CONFIG_LF_SRC +#define CLOCK_CONFIG_LF_SRC 1 +#endif + +// CLOCK_CONFIG_LF_CAL_ENABLED - Calibration enable for LF Clock Source + + +#ifndef CLOCK_CONFIG_LF_CAL_ENABLED +#define CLOCK_CONFIG_LF_CAL_ENABLED 0 +#endif + +// CLOCK_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef CLOCK_CONFIG_IRQ_PRIORITY +#define CLOCK_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// PDM_ENABLED - nrf_drv_pdm - PDM peripheral driver - legacy layer +//========================================================== +#ifndef PDM_ENABLED +#define PDM_ENABLED 0 +#endif +// PDM_CONFIG_MODE - Mode + +// <0=> Stereo +// <1=> Mono + +#ifndef PDM_CONFIG_MODE +#define PDM_CONFIG_MODE 1 +#endif + +// PDM_CONFIG_EDGE - Edge + +// <0=> Left falling +// <1=> Left rising + +#ifndef PDM_CONFIG_EDGE +#define PDM_CONFIG_EDGE 0 +#endif + +// PDM_CONFIG_CLOCK_FREQ - Clock frequency + +// <134217728=> 1000k +// <138412032=> 1032k (default) +// <142606336=> 1067k + +#ifndef PDM_CONFIG_CLOCK_FREQ +#define PDM_CONFIG_CLOCK_FREQ 138412032 +#endif + +// PDM_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef PDM_CONFIG_IRQ_PRIORITY +#define PDM_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// POWER_ENABLED - nrf_drv_power - POWER peripheral driver - legacy layer +//========================================================== +#ifndef POWER_ENABLED +#define POWER_ENABLED 0 +#endif +// POWER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef POWER_CONFIG_IRQ_PRIORITY +#define POWER_CONFIG_IRQ_PRIORITY 6 +#endif + +// POWER_CONFIG_DEFAULT_DCDCEN - The default configuration of main DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef POWER_CONFIG_DEFAULT_DCDCEN +#define POWER_CONFIG_DEFAULT_DCDCEN 0 +#endif + +// POWER_CONFIG_DEFAULT_DCDCENHV - The default configuration of High Voltage DCDC regulator + + +// This settings means only that components for DCDC regulator are installed and it can be enabled. + +#ifndef POWER_CONFIG_DEFAULT_DCDCENHV +#define POWER_CONFIG_DEFAULT_DCDCENHV 0 +#endif + +// + +// PPI_ENABLED - nrf_drv_ppi - PPI peripheral driver - legacy layer + + +#ifndef PPI_ENABLED +#define PPI_ENABLED 0 +#endif + +// PWM_ENABLED - nrf_drv_pwm - PWM peripheral driver - legacy layer +//========================================================== +#ifndef PWM_ENABLED +#define PWM_ENABLED 0 +#endif +// PWM_DEFAULT_CONFIG_OUT0_PIN - Out0 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT0_PIN +#define PWM_DEFAULT_CONFIG_OUT0_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT1_PIN - Out1 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT1_PIN +#define PWM_DEFAULT_CONFIG_OUT1_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT2_PIN - Out2 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT2_PIN +#define PWM_DEFAULT_CONFIG_OUT2_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_OUT3_PIN - Out3 pin <0-31> + + +#ifndef PWM_DEFAULT_CONFIG_OUT3_PIN +#define PWM_DEFAULT_CONFIG_OUT3_PIN 31 +#endif + +// PWM_DEFAULT_CONFIG_BASE_CLOCK - Base clock + +// <0=> 16 MHz +// <1=> 8 MHz +// <2=> 4 MHz +// <3=> 2 MHz +// <4=> 1 MHz +// <5=> 500 kHz +// <6=> 250 kHz +// <7=> 125 kHz + +#ifndef PWM_DEFAULT_CONFIG_BASE_CLOCK +#define PWM_DEFAULT_CONFIG_BASE_CLOCK 4 +#endif + +// PWM_DEFAULT_CONFIG_COUNT_MODE - Count mode + +// <0=> Up +// <1=> Up and Down + +#ifndef PWM_DEFAULT_CONFIG_COUNT_MODE +#define PWM_DEFAULT_CONFIG_COUNT_MODE 0 +#endif + +// PWM_DEFAULT_CONFIG_TOP_VALUE - Top value +#ifndef PWM_DEFAULT_CONFIG_TOP_VALUE +#define PWM_DEFAULT_CONFIG_TOP_VALUE 1000 +#endif + +// PWM_DEFAULT_CONFIG_LOAD_MODE - Load mode + +// <0=> Common +// <1=> Grouped +// <2=> Individual +// <3=> Waveform + +#ifndef PWM_DEFAULT_CONFIG_LOAD_MODE +#define PWM_DEFAULT_CONFIG_LOAD_MODE 0 +#endif + +// PWM_DEFAULT_CONFIG_STEP_MODE - Step mode + +// <0=> Auto +// <1=> Triggered + +#ifndef PWM_DEFAULT_CONFIG_STEP_MODE +#define PWM_DEFAULT_CONFIG_STEP_MODE 0 +#endif + +// PWM_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef PWM_DEFAULT_CONFIG_IRQ_PRIORITY +#define PWM_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// PWM0_ENABLED - Enable PWM0 instance + + +#ifndef PWM0_ENABLED +#define PWM0_ENABLED 0 +#endif + +// PWM1_ENABLED - Enable PWM1 instance + + +#ifndef PWM1_ENABLED +#define PWM1_ENABLED 0 +#endif + +// PWM2_ENABLED - Enable PWM2 instance + + +#ifndef PWM2_ENABLED +#define PWM2_ENABLED 0 +#endif + +// PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for PWM. + +// The workaround uses interrupts to wake up the CPU and ensure +// it is active when PWM is about to start a DMA transfer. For +// initial transfer, done when a playback is started via PPI, +// a specific EGU instance is used to generate the interrupt. +// During the playback, the PWM interrupt triggered on SEQEND +// event of a preceding sequence is used to protect the transfer +// done for the next sequence to be played. +//========================================================== +#ifndef PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif +// PWM_NRF52_ANOMALY_109_EGU_INSTANCE - EGU instance used by the nRF52 Anomaly 109 workaround for PWM. + +// <0=> EGU0 +// <1=> EGU1 +// <2=> EGU2 +// <3=> EGU3 +// <4=> EGU4 +// <5=> EGU5 + +#ifndef PWM_NRF52_ANOMALY_109_EGU_INSTANCE +#define PWM_NRF52_ANOMALY_109_EGU_INSTANCE 5 +#endif + +// + +// + +// QDEC_ENABLED - nrf_drv_qdec - QDEC peripheral driver - legacy layer +//========================================================== +#ifndef QDEC_ENABLED +#define QDEC_ENABLED 0 +#endif +// QDEC_CONFIG_REPORTPER - Report period + +// <0=> 10 Samples +// <1=> 40 Samples +// <2=> 80 Samples +// <3=> 120 Samples +// <4=> 160 Samples +// <5=> 200 Samples +// <6=> 240 Samples +// <7=> 280 Samples + +#ifndef QDEC_CONFIG_REPORTPER +#define QDEC_CONFIG_REPORTPER 0 +#endif + +// QDEC_CONFIG_SAMPLEPER - Sample period + +// <0=> 128 us +// <1=> 256 us +// <2=> 512 us +// <3=> 1024 us +// <4=> 2048 us +// <5=> 4096 us +// <6=> 8192 us +// <7=> 16384 us + +#ifndef QDEC_CONFIG_SAMPLEPER +#define QDEC_CONFIG_SAMPLEPER 7 +#endif + +// QDEC_CONFIG_PIO_A - A pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_A +#define QDEC_CONFIG_PIO_A 31 +#endif + +// QDEC_CONFIG_PIO_B - B pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_B +#define QDEC_CONFIG_PIO_B 31 +#endif + +// QDEC_CONFIG_PIO_LED - LED pin <0-31> + + +#ifndef QDEC_CONFIG_PIO_LED +#define QDEC_CONFIG_PIO_LED 31 +#endif + +// QDEC_CONFIG_LEDPRE - LED pre +#ifndef QDEC_CONFIG_LEDPRE +#define QDEC_CONFIG_LEDPRE 511 +#endif + +// QDEC_CONFIG_LEDPOL - LED polarity + +// <0=> Active low +// <1=> Active high + +#ifndef QDEC_CONFIG_LEDPOL +#define QDEC_CONFIG_LEDPOL 1 +#endif + +// QDEC_CONFIG_DBFEN - Debouncing enable + + +#ifndef QDEC_CONFIG_DBFEN +#define QDEC_CONFIG_DBFEN 0 +#endif + +// QDEC_CONFIG_SAMPLE_INTEN - Sample ready interrupt enable + + +#ifndef QDEC_CONFIG_SAMPLE_INTEN +#define QDEC_CONFIG_SAMPLE_INTEN 0 +#endif + +// QDEC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef QDEC_CONFIG_IRQ_PRIORITY +#define QDEC_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// QSPI_ENABLED - nrf_drv_qspi - QSPI peripheral driver - legacy layer +//========================================================== +#ifndef QSPI_ENABLED +#define QSPI_ENABLED 0 +#endif +// QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns). <0-255> + + +#ifndef QSPI_CONFIG_SCK_DELAY +#define QSPI_CONFIG_SCK_DELAY 1 +#endif + +// QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. +#ifndef QSPI_CONFIG_XIP_OFFSET +#define QSPI_CONFIG_XIP_OFFSET 0 +#endif + +// QSPI_CONFIG_READOC - Number of data lines and opcode used for reading. + +// <0=> FastRead +// <1=> Read2O +// <2=> Read2IO +// <3=> Read4O +// <4=> Read4IO + +#ifndef QSPI_CONFIG_READOC +#define QSPI_CONFIG_READOC 0 +#endif + +// QSPI_CONFIG_WRITEOC - Number of data lines and opcode used for writing. + +// <0=> PP +// <1=> PP2O +// <2=> PP4O +// <3=> PP4IO + +#ifndef QSPI_CONFIG_WRITEOC +#define QSPI_CONFIG_WRITEOC 0 +#endif + +// QSPI_CONFIG_ADDRMODE - Addressing mode. + +// <0=> 24bit +// <1=> 32bit + +#ifndef QSPI_CONFIG_ADDRMODE +#define QSPI_CONFIG_ADDRMODE 0 +#endif + +// QSPI_CONFIG_MODE - SPI mode. + +// <0=> Mode 0 +// <1=> Mode 1 + +#ifndef QSPI_CONFIG_MODE +#define QSPI_CONFIG_MODE 0 +#endif + +// QSPI_CONFIG_FREQUENCY - Frequency divider. + +// <0=> 32MHz/1 +// <1=> 32MHz/2 +// <2=> 32MHz/3 +// <3=> 32MHz/4 +// <4=> 32MHz/5 +// <5=> 32MHz/6 +// <6=> 32MHz/7 +// <7=> 32MHz/8 +// <8=> 32MHz/9 +// <9=> 32MHz/10 +// <10=> 32MHz/11 +// <11=> 32MHz/12 +// <12=> 32MHz/13 +// <13=> 32MHz/14 +// <14=> 32MHz/15 +// <15=> 32MHz/16 + +#ifndef QSPI_CONFIG_FREQUENCY +#define QSPI_CONFIG_FREQUENCY 15 +#endif + +// QSPI_PIN_SCK - SCK pin value. +#ifndef QSPI_PIN_SCK +#define QSPI_PIN_SCK NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_CSN - CSN pin value. +#ifndef QSPI_PIN_CSN +#define QSPI_PIN_CSN NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO0 - IO0 pin value. +#ifndef QSPI_PIN_IO0 +#define QSPI_PIN_IO0 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO1 - IO1 pin value. +#ifndef QSPI_PIN_IO1 +#define QSPI_PIN_IO1 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO2 - IO2 pin value. +#ifndef QSPI_PIN_IO2 +#define QSPI_PIN_IO2 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_PIN_IO3 - IO3 pin value. +#ifndef QSPI_PIN_IO3 +#define QSPI_PIN_IO3 NRF_QSPI_PIN_NOT_CONNECTED +#endif + +// QSPI_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef QSPI_CONFIG_IRQ_PRIORITY +#define QSPI_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// RNG_ENABLED - nrf_drv_rng - RNG peripheral driver - legacy layer +//========================================================== +#ifndef RNG_ENABLED +#define RNG_ENABLED 0 +#endif +// RNG_CONFIG_ERROR_CORRECTION - Error correction + + +#ifndef RNG_CONFIG_ERROR_CORRECTION +#define RNG_CONFIG_ERROR_CORRECTION 1 +#endif + +// RNG_CONFIG_POOL_SIZE - Pool size +#ifndef RNG_CONFIG_POOL_SIZE +#define RNG_CONFIG_POOL_SIZE 64 +#endif + +// RNG_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef RNG_CONFIG_IRQ_PRIORITY +#define RNG_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// RTC_ENABLED - nrf_drv_rtc - RTC peripheral driver - legacy layer +//========================================================== +#ifndef RTC_ENABLED +#define RTC_ENABLED 0 +#endif +// RTC_DEFAULT_CONFIG_FREQUENCY - Frequency <16-32768> + + +#ifndef RTC_DEFAULT_CONFIG_FREQUENCY +#define RTC_DEFAULT_CONFIG_FREQUENCY 32768 +#endif + +// RTC_DEFAULT_CONFIG_RELIABLE - Ensures safe compare event triggering + + +#ifndef RTC_DEFAULT_CONFIG_RELIABLE +#define RTC_DEFAULT_CONFIG_RELIABLE 0 +#endif + +// RTC_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef RTC_DEFAULT_CONFIG_IRQ_PRIORITY +#define RTC_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// RTC0_ENABLED - Enable RTC0 instance + + +#ifndef RTC0_ENABLED +#define RTC0_ENABLED 0 +#endif + +// RTC1_ENABLED - Enable RTC1 instance + + +#ifndef RTC1_ENABLED +#define RTC1_ENABLED 0 +#endif + +// RTC2_ENABLED - Enable RTC2 instance + + +#ifndef RTC2_ENABLED +#define RTC2_ENABLED 0 +#endif + +// NRF_MAXIMUM_LATENCY_US - Maximum possible time[us] in highest priority interrupt +#ifndef NRF_MAXIMUM_LATENCY_US +#define NRF_MAXIMUM_LATENCY_US 2000 +#endif + +// + +// SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer +//========================================================== +#ifndef SAADC_ENABLED +#define SAADC_ENABLED 0 +#endif +// SAADC_CONFIG_RESOLUTION - Resolution + +// <0=> 8 bit +// <1=> 10 bit +// <2=> 12 bit +// <3=> 14 bit + +#ifndef SAADC_CONFIG_RESOLUTION +#define SAADC_CONFIG_RESOLUTION 1 +#endif + +// SAADC_CONFIG_OVERSAMPLE - Sample period + +// <0=> Disabled +// <1=> 2x +// <2=> 4x +// <3=> 8x +// <4=> 16x +// <5=> 32x +// <6=> 64x +// <7=> 128x +// <8=> 256x + +#ifndef SAADC_CONFIG_OVERSAMPLE +#define SAADC_CONFIG_OVERSAMPLE 0 +#endif + +// SAADC_CONFIG_LP_MODE - Enabling low power mode + + +#ifndef SAADC_CONFIG_LP_MODE +#define SAADC_CONFIG_LP_MODE 0 +#endif + +// SAADC_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef SAADC_CONFIG_IRQ_PRIORITY +#define SAADC_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// SPIS_ENABLED - nrf_drv_spis - SPIS peripheral driver - legacy layer +//========================================================== +#ifndef SPIS_ENABLED +#define SPIS_ENABLED 0 +#endif +// SPIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef SPIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define SPIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// SPIS_DEFAULT_MODE - Mode + +// <0=> MODE_0 +// <1=> MODE_1 +// <2=> MODE_2 +// <3=> MODE_3 + +#ifndef SPIS_DEFAULT_MODE +#define SPIS_DEFAULT_MODE 0 +#endif + +// SPIS_DEFAULT_BIT_ORDER - SPIS default bit order + +// <0=> MSB first +// <1=> LSB first + +#ifndef SPIS_DEFAULT_BIT_ORDER +#define SPIS_DEFAULT_BIT_ORDER 0 +#endif + +// SPIS_DEFAULT_DEF - SPIS default DEF character <0-255> + + +#ifndef SPIS_DEFAULT_DEF +#define SPIS_DEFAULT_DEF 255 +#endif + +// SPIS_DEFAULT_ORC - SPIS default ORC character <0-255> + + +#ifndef SPIS_DEFAULT_ORC +#define SPIS_DEFAULT_ORC 255 +#endif + +// SPIS0_ENABLED - Enable SPIS0 instance + + +#ifndef SPIS0_ENABLED +#define SPIS0_ENABLED 0 +#endif + +// SPIS1_ENABLED - Enable SPIS1 instance + + +#ifndef SPIS1_ENABLED +#define SPIS1_ENABLED 0 +#endif + +// SPIS2_ENABLED - Enable SPIS2 instance + + +#ifndef SPIS2_ENABLED +#define SPIS2_ENABLED 0 +#endif + +// SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 Anomaly 109 workaround for SPIS. + + +// The workaround uses a GPIOTE channel to generate interrupts +// on falling edges detected on the CSN line. This will make +// the CPU active for the moment when SPIS starts DMA transfers, +// and this way the transfers will be protected. +// This workaround uses GPIOTE driver, so this driver must be +// enabled as well. + +#ifndef SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer +//========================================================== +#ifndef SPI_ENABLED +#define SPI_ENABLED 0 +#endif +// SPI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY +#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// NRF_SPI_DRV_MISO_PULLUP_CFG - MISO PIN pull-up configuration. + +// <0=> NRF_GPIO_PIN_NOPULL +// <1=> NRF_GPIO_PIN_PULLDOWN +// <3=> NRF_GPIO_PIN_PULLUP + +#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG +#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 +#endif + +// SPI0_ENABLED - Enable SPI0 instance +//========================================================== +#ifndef SPI0_ENABLED +#define SPI0_ENABLED 0 +#endif +// SPI0_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI0_USE_EASY_DMA +#define SPI0_USE_EASY_DMA 1 +#endif + +// + +// SPI1_ENABLED - Enable SPI1 instance +//========================================================== +#ifndef SPI1_ENABLED +#define SPI1_ENABLED 0 +#endif +// SPI1_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI1_USE_EASY_DMA +#define SPI1_USE_EASY_DMA 1 +#endif + +// + +// SPI2_ENABLED - Enable SPI2 instance +//========================================================== +#ifndef SPI2_ENABLED +#define SPI2_ENABLED 0 +#endif +// SPI2_USE_EASY_DMA - Use EasyDMA + + +#ifndef SPI2_USE_EASY_DMA +#define SPI2_USE_EASY_DMA 1 +#endif + +// + +// SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for SPIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// a start event of zero-length transmission to start the clock. This +// ensures that the DMA transfer will be executed without issues and +// that the proper transfer will be started. See more in the Errata +// document or Anomaly 109 Addendum located at +// https://infocenter.nordicsemi.com/ + +#ifndef SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// TIMER_ENABLED - nrf_drv_timer - TIMER periperal driver - legacy layer +//========================================================== +#ifndef TIMER_ENABLED +#define TIMER_ENABLED 0 +#endif +// TIMER_DEFAULT_CONFIG_FREQUENCY - Timer frequency if in Timer mode + +// <0=> 16 MHz +// <1=> 8 MHz +// <2=> 4 MHz +// <3=> 2 MHz +// <4=> 1 MHz +// <5=> 500 kHz +// <6=> 250 kHz +// <7=> 125 kHz +// <8=> 62.5 kHz +// <9=> 31.25 kHz + +#ifndef TIMER_DEFAULT_CONFIG_FREQUENCY +#define TIMER_DEFAULT_CONFIG_FREQUENCY 0 +#endif + +// TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation + +// <0=> Timer +// <1=> Counter + +#ifndef TIMER_DEFAULT_CONFIG_MODE +#define TIMER_DEFAULT_CONFIG_MODE 0 +#endif + +// TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width + +// <0=> 16 bit +// <1=> 8 bit +// <2=> 24 bit +// <3=> 32 bit + +#ifndef TIMER_DEFAULT_CONFIG_BIT_WIDTH +#define TIMER_DEFAULT_CONFIG_BIT_WIDTH 0 +#endif + +// TIMER_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef TIMER_DEFAULT_CONFIG_IRQ_PRIORITY +#define TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// TIMER0_ENABLED - Enable TIMER0 instance + + +#ifndef TIMER0_ENABLED +#define TIMER0_ENABLED 0 +#endif + +// TIMER1_ENABLED - Enable TIMER1 instance + + +#ifndef TIMER1_ENABLED +#define TIMER1_ENABLED 0 +#endif + +// TIMER2_ENABLED - Enable TIMER2 instance + + +#ifndef TIMER2_ENABLED +#define TIMER2_ENABLED 0 +#endif + +// TIMER3_ENABLED - Enable TIMER3 instance + + +#ifndef TIMER3_ENABLED +#define TIMER3_ENABLED 0 +#endif + +// TIMER4_ENABLED - Enable TIMER4 instance + + +#ifndef TIMER4_ENABLED +#define TIMER4_ENABLED 0 +#endif + +// + +// TWIS_ENABLED - nrf_drv_twis - TWIS peripheral driver - legacy layer +//========================================================== +#ifndef TWIS_ENABLED +#define TWIS_ENABLED 0 +#endif +// TWIS0_ENABLED - Enable TWIS0 instance + + +#ifndef TWIS0_ENABLED +#define TWIS0_ENABLED 0 +#endif + +// TWIS1_ENABLED - Enable TWIS1 instance + + +#ifndef TWIS1_ENABLED +#define TWIS1_ENABLED 0 +#endif + +// TWIS_ASSUME_INIT_AFTER_RESET_ONLY - Assume that any instance would be initialized only once + + +// Optimization flag. Registers used by TWIS are shared by other peripherals. Normally, during initialization driver tries to clear all registers to known state before doing the initialization itself. This gives initialization safe procedure, no matter when it would be called. If you activate TWIS only once and do never uninitialize it - set this flag to 1 what gives more optimal code. + +#ifndef TWIS_ASSUME_INIT_AFTER_RESET_ONLY +#define TWIS_ASSUME_INIT_AFTER_RESET_ONLY 0 +#endif + +// TWIS_NO_SYNC_MODE - Remove support for synchronous mode + + +// Synchronous mode would be used in specific situations. And it uses some additional code and data memory to safely process state machine by polling it in status functions. If this functionality is not required it may be disabled to free some resources. + +#ifndef TWIS_NO_SYNC_MODE +#define TWIS_NO_SYNC_MODE 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR0 - Address0 +#ifndef TWIS_DEFAULT_CONFIG_ADDR0 +#define TWIS_DEFAULT_CONFIG_ADDR0 0 +#endif + +// TWIS_DEFAULT_CONFIG_ADDR1 - Address1 +#ifndef TWIS_DEFAULT_CONFIG_ADDR1 +#define TWIS_DEFAULT_CONFIG_ADDR1 0 +#endif + +// TWIS_DEFAULT_CONFIG_SCL_PULL - SCL pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef TWIS_DEFAULT_CONFIG_SCL_PULL +#define TWIS_DEFAULT_CONFIG_SCL_PULL 0 +#endif + +// TWIS_DEFAULT_CONFIG_SDA_PULL - SDA pin pull configuration + +// <0=> Disabled +// <1=> Pull down +// <3=> Pull up + +#ifndef TWIS_DEFAULT_CONFIG_SDA_PULL +#define TWIS_DEFAULT_CONFIG_SDA_PULL 0 +#endif + +// TWIS_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef TWIS_DEFAULT_CONFIG_IRQ_PRIORITY +#define TWIS_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer +//========================================================== +#ifndef TWI_ENABLED +#define TWI_ENABLED 0 +#endif +// TWI_DEFAULT_CONFIG_FREQUENCY - Frequency + +// <26738688=> 100k +// <67108864=> 250k +// <104857600=> 400k + +#ifndef TWI_DEFAULT_CONFIG_FREQUENCY +#define TWI_DEFAULT_CONFIG_FREQUENCY 26738688 +#endif + +// TWI_DEFAULT_CONFIG_CLR_BUS_INIT - Enables bus clearing procedure during init + + +#ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT +#define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 0 +#endif + +// TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit + + +#ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT +#define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0 +#endif + +// TWI_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef TWI_DEFAULT_CONFIG_IRQ_PRIORITY +#define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// TWI0_ENABLED - Enable TWI0 instance +//========================================================== +#ifndef TWI0_ENABLED +#define TWI0_ENABLED 0 +#endif +// TWI0_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI0_USE_EASY_DMA +#define TWI0_USE_EASY_DMA 0 +#endif + +// + +// TWI1_ENABLED - Enable TWI1 instance +//========================================================== +#ifndef TWI1_ENABLED +#define TWI1_ENABLED 0 +#endif +// TWI1_USE_EASY_DMA - Use EasyDMA (if present) + + +#ifndef TWI1_USE_EASY_DMA +#define TWI1_USE_EASY_DMA 0 +#endif + +// + +// TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED - Enables nRF52 anomaly 109 workaround for TWIM. + + +// The workaround uses interrupts to wake up the CPU by catching +// the start event of zero-frequency transmission, clear the +// peripheral, set desired frequency, start the peripheral, and +// the proper transmission. See more in the Errata document or +// Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/ + +#ifndef TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED +#define TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0 +#endif + +// + +// UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer +//========================================================== +#ifndef UART_ENABLED +#define UART_ENABLED 1 +#endif +// UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef UART_DEFAULT_CONFIG_HWFC +#define UART_DEFAULT_CONFIG_HWFC 0 +#endif + +// UART_DEFAULT_CONFIG_PARITY - Parity + +// <0=> Excluded +// <14=> Included + +#ifndef UART_DEFAULT_CONFIG_PARITY +#define UART_DEFAULT_CONFIG_PARITY 0 +#endif + +// UART_DEFAULT_CONFIG_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3862528=> 14400 baud +// <5152768=> 19200 baud +// <7716864=> 28800 baud +// <10289152=> 38400 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef UART_DEFAULT_CONFIG_BAUDRATE +#define UART_DEFAULT_CONFIG_BAUDRATE 30801920 +#endif + +// UART_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef UART_DEFAULT_CONFIG_IRQ_PRIORITY +#define UART_DEFAULT_CONFIG_IRQ_PRIORITY 6 +#endif + +// UART_EASY_DMA_SUPPORT - Driver supporting EasyDMA + + +#ifndef UART_EASY_DMA_SUPPORT +#define UART_EASY_DMA_SUPPORT 1 +#endif + +// UART_LEGACY_SUPPORT - Driver supporting Legacy mode + + +#ifndef UART_LEGACY_SUPPORT +#define UART_LEGACY_SUPPORT 1 +#endif + +// UART0_ENABLED - Enable UART0 instance +//========================================================== +#ifndef UART0_ENABLED +#define UART0_ENABLED 1 +#endif +// UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA + + +#ifndef UART0_CONFIG_USE_EASY_DMA +#define UART0_CONFIG_USE_EASY_DMA 1 +#endif + +// + +// + +// USBD_ENABLED - nrf_drv_usbd - Software Component +//========================================================== +#ifndef USBD_ENABLED +#define USBD_ENABLED 0 +#endif +// USBD_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef USBD_CONFIG_IRQ_PRIORITY +#define USBD_CONFIG_IRQ_PRIORITY 6 +#endif + +// USBD_CONFIG_DMASCHEDULER_MODE - USBD SMA scheduler working scheme + +// <0=> Prioritized access +// <1=> Round Robin + +#ifndef USBD_CONFIG_DMASCHEDULER_MODE +#define USBD_CONFIG_DMASCHEDULER_MODE 0 +#endif + +// USBD_CONFIG_DMASCHEDULER_ISO_BOOST - Give priority to isochronous transfers + + +// This option gives priority to isochronous transfers. +// Enabling it assures that isochronous transfers are always processed, +// even if multiple other transfers are pending. +// Isochronous endpoints are prioritized before the usbd_dma_scheduler_algorithm +// function is called, so the option is independent of the algorithm chosen. + +#ifndef USBD_CONFIG_DMASCHEDULER_ISO_BOOST +#define USBD_CONFIG_DMASCHEDULER_ISO_BOOST 1 +#endif + +// USBD_CONFIG_ISO_IN_ZLP - Respond to an IN token on ISO IN endpoint with ZLP when no data is ready + + +// If set, ISO IN endpoint will respond to an IN token with ZLP when no data is ready to be sent. +// Else, there will be no response. + +#ifndef USBD_CONFIG_ISO_IN_ZLP +#define USBD_CONFIG_ISO_IN_ZLP 0 +#endif + +// + +// WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer +//========================================================== +#ifndef WDT_ENABLED +#define WDT_ENABLED 0 +#endif +// WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode + +// <1=> Run in SLEEP, Pause in HALT +// <8=> Pause in SLEEP, Run in HALT +// <9=> Run in SLEEP and HALT +// <0=> Pause in SLEEP and HALT + +#ifndef WDT_CONFIG_BEHAVIOUR +#define WDT_CONFIG_BEHAVIOUR 1 +#endif + +// WDT_CONFIG_RELOAD_VALUE - Reload value <15-4294967295> + + +#ifndef WDT_CONFIG_RELOAD_VALUE +#define WDT_CONFIG_RELOAD_VALUE 2000 +#endif + +// WDT_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef WDT_CONFIG_IRQ_PRIORITY +#define WDT_CONFIG_IRQ_PRIORITY 6 +#endif + +// + +// nrfx_qspi - QSPI peripheral driver + +//========================================================== +// +//========================================================== + +// nrfx_usbd - USBD peripheral driver + +//========================================================== +// +//========================================================== + +// +//========================================================== + +// nRF_Drivers_External + +//========================================================== +// NRF_TWI_SENSOR_ENABLED - nrf_twi_sensor - nRF TWI Sensor module + + +#ifndef NRF_TWI_SENSOR_ENABLED +#define NRF_TWI_SENSOR_ENABLED 0 +#endif + +// +//========================================================== + +// nRF_Libraries + +//========================================================== +// APP_GPIOTE_ENABLED - app_gpiote - GPIOTE events dispatcher + + +#ifndef APP_GPIOTE_ENABLED +#define APP_GPIOTE_ENABLED 0 +#endif + +// APP_PWM_ENABLED - app_pwm - PWM functionality + + +#ifndef APP_PWM_ENABLED +#define APP_PWM_ENABLED 0 +#endif + +// APP_SCHEDULER_ENABLED - app_scheduler - Events scheduler +//========================================================== +#ifndef APP_SCHEDULER_ENABLED +#define APP_SCHEDULER_ENABLED 1 +#endif +// APP_SCHEDULER_WITH_PAUSE - Enabling pause feature + + +#ifndef APP_SCHEDULER_WITH_PAUSE +#define APP_SCHEDULER_WITH_PAUSE 0 +#endif + +// APP_SCHEDULER_WITH_PROFILER - Enabling scheduler profiling + + +#ifndef APP_SCHEDULER_WITH_PROFILER +#define APP_SCHEDULER_WITH_PROFILER 0 +#endif + +// + +// APP_SDCARD_ENABLED - app_sdcard - SD/MMC card support using SPI +//========================================================== +#ifndef APP_SDCARD_ENABLED +#define APP_SDCARD_ENABLED 0 +#endif +// APP_SDCARD_SPI_INSTANCE - SPI instance used + +// <0=> 0 +// <1=> 1 +// <2=> 2 + +#ifndef APP_SDCARD_SPI_INSTANCE +#define APP_SDCARD_SPI_INSTANCE 0 +#endif + +// APP_SDCARD_FREQ_INIT - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_INIT +#define APP_SDCARD_FREQ_INIT 67108864 +#endif + +// APP_SDCARD_FREQ_DATA - SPI frequency + +// <33554432=> 125 kHz +// <67108864=> 250 kHz +// <134217728=> 500 kHz +// <268435456=> 1 MHz +// <536870912=> 2 MHz +// <1073741824=> 4 MHz +// <2147483648=> 8 MHz + +#ifndef APP_SDCARD_FREQ_DATA +#define APP_SDCARD_FREQ_DATA 1073741824 +#endif + +// + +// APP_TIMER_ENABLED - app_timer - Application timer functionality +//========================================================== +#ifndef APP_TIMER_ENABLED +#define APP_TIMER_ENABLED 1 +#endif +// APP_TIMER_CONFIG_RTC_FREQUENCY - Configure RTC prescaler. + +// <0=> 32768 Hz +// <1=> 16384 Hz +// <3=> 8192 Hz +// <7=> 4096 Hz +// <15=> 2048 Hz +// <31=> 1024 Hz + +#ifndef APP_TIMER_CONFIG_RTC_FREQUENCY +#define APP_TIMER_CONFIG_RTC_FREQUENCY 0 +#endif + +// APP_TIMER_CONFIG_IRQ_PRIORITY - Interrupt priority + + +// Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice +// <0=> 0 (highest) +// <1=> 1 +// <2=> 2 +// <3=> 3 +// <4=> 4 +// <5=> 5 +// <6=> 6 +// <7=> 7 + +#ifndef APP_TIMER_CONFIG_IRQ_PRIORITY +#define APP_TIMER_CONFIG_IRQ_PRIORITY 6 +#endif + +// APP_TIMER_CONFIG_OP_QUEUE_SIZE - Capacity of timer requests queue. +// Size of the queue depends on how many timers are used +// in the system, how often timers are started and overall +// system latency. If queue size is too small app_timer calls +// will fail. + +#ifndef APP_TIMER_CONFIG_OP_QUEUE_SIZE +#define APP_TIMER_CONFIG_OP_QUEUE_SIZE 10 +#endif + +// APP_TIMER_CONFIG_USE_SCHEDULER - Enable scheduling app_timer events to app_scheduler + + +#ifndef APP_TIMER_CONFIG_USE_SCHEDULER +#define APP_TIMER_CONFIG_USE_SCHEDULER 0 +#endif + +// APP_TIMER_KEEPS_RTC_ACTIVE - Enable RTC always on + + +// If option is enabled RTC is kept running even if there is no active timers. +// This option can be used when app_timer is used for timestamping. + +#ifndef APP_TIMER_KEEPS_RTC_ACTIVE +#define APP_TIMER_KEEPS_RTC_ACTIVE 0 +#endif + +// APP_TIMER_SAFE_WINDOW_MS - Maximum possible latency (in milliseconds) of handling app_timer event. +// Maximum possible timeout that can be set is reduced by safe window. +// Example: RTC frequency 16384 Hz, maximum possible timeout 1024 seconds - APP_TIMER_SAFE_WINDOW_MS. +// Since RTC is not stopped when processor is halted in debugging session, this value +// must cover it if debugging is needed. It is possible to halt processor for APP_TIMER_SAFE_WINDOW_MS +// without corrupting app_timer behavior. + +#ifndef APP_TIMER_SAFE_WINDOW_MS +#define APP_TIMER_SAFE_WINDOW_MS 300000 +#endif + +// App Timer Legacy configuration - Legacy configuration. + +//========================================================== +// APP_TIMER_WITH_PROFILER - Enable app_timer profiling + + +#ifndef APP_TIMER_WITH_PROFILER +#define APP_TIMER_WITH_PROFILER 0 +#endif + +// APP_TIMER_CONFIG_SWI_NUMBER - Configure SWI instance used. + + +#ifndef APP_TIMER_CONFIG_SWI_NUMBER +#define APP_TIMER_CONFIG_SWI_NUMBER 0 +#endif + +// +//========================================================== + +// + +// APP_USBD_AUDIO_ENABLED - app_usbd_audio - USB AUDIO class + + +#ifndef APP_USBD_AUDIO_ENABLED +#define APP_USBD_AUDIO_ENABLED 0 +#endif + +// APP_USBD_ENABLED - app_usbd - USB Device library +//========================================================== +#ifndef APP_USBD_ENABLED +#define APP_USBD_ENABLED 0 +#endif +// APP_USBD_VID - Vendor ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Vendor ID ordered from USB IF: http://www.usb.org/developers/vendor/ + +#ifndef APP_USBD_VID +#define APP_USBD_VID 0 +#endif + +// APP_USBD_PID - Product ID. <0x0000-0xFFFF> + + +// Note: This value is not editable in Configuration Wizard. +// Selected Product ID + +#ifndef APP_USBD_PID +#define APP_USBD_PID 0 +#endif + +// APP_USBD_DEVICE_VER_MAJOR - Device version, major part. <0-99> + + +// Device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_MAJOR +#define APP_USBD_DEVICE_VER_MAJOR 1 +#endif + +// APP_USBD_DEVICE_VER_MINOR - Device version, minor part. <0-99> + + +// Device version, will be converted automatically to BCD notation. Use just decimal values. + +#ifndef APP_USBD_DEVICE_VER_MINOR +#define APP_USBD_DEVICE_VER_MINOR 0 +#endif + +// APP_USBD_CONFIG_SELF_POWERED - Self-powered device, as opposed to bus-powered. + + +#ifndef APP_USBD_CONFIG_SELF_POWERED +#define APP_USBD_CONFIG_SELF_POWERED 1 +#endif + +// APP_USBD_CONFIG_MAX_POWER - MaxPower field in configuration descriptor in milliamps. <0-500> + + +#ifndef APP_USBD_CONFIG_MAX_POWER +#define APP_USBD_CONFIG_MAX_POWER 100 +#endif + +// APP_USBD_CONFIG_POWER_EVENTS_PROCESS - Process power events. + + +// Enable processing power events in USB event handler. + +#ifndef APP_USBD_CONFIG_POWER_EVENTS_PROCESS +#define APP_USBD_CONFIG_POWER_EVENTS_PROCESS 1 +#endif + +// APP_USBD_CONFIG_EVENT_QUEUE_ENABLE - Enable event queue. + +// This is the default configuration when all the events are placed into internal queue. +// Disable it when an external queue is used like app_scheduler or if you wish to process all events inside interrupts. +// Processing all events from the interrupt level adds requirement not to call any functions that modifies the USBD library state from the context higher than USB interrupt context. +// Functions that modify USBD state are functions for sleep, wakeup, start, stop, enable, and disable. +//========================================================== +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_ENABLE +#define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 1 +#endif +// APP_USBD_CONFIG_EVENT_QUEUE_SIZE - The size of the event queue. <16-64> + + +// The size of the queue for the events that would be processed in the main loop. + +#ifndef APP_USBD_CONFIG_EVENT_QUEUE_SIZE +#define APP_USBD_CONFIG_EVENT_QUEUE_SIZE 32 +#endif + +// APP_USBD_CONFIG_SOF_HANDLING_MODE - Change SOF events handling mode. + + +// Normal queue - SOF events are pushed normally into the event queue. +// Compress queue - SOF events are counted and binded with other events or executed when the queue is empty. +// This prevents the queue from filling up with SOF events. +// Interrupt - SOF events are processed in interrupt. +// <0=> Normal queue +// <1=> Compress queue +// <2=> Interrupt + +#ifndef APP_USBD_CONFIG_SOF_HANDLING_MODE +#define APP_USBD_CONFIG_SOF_HANDLING_MODE 1 +#endif + +// + +// APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE - Provide a function that generates timestamps for logs based on the current SOF. + + +// The function app_usbd_sof_timestamp_get is implemented if the logger is enabled. +// Use it when initializing the logger. +// SOF processing is always enabled when this configuration parameter is active. +// Note: This option is configured outside of APP_USBD_CONFIG_LOG_ENABLED. +// This means that it works even if the logging in this very module is disabled. + +#ifndef APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE +#define APP_USBD_CONFIG_SOF_TIMESTAMP_PROVIDE 0 +#endif + +// APP_USBD_CONFIG_DESC_STRING_SIZE - Maximum size of the NULL-terminated string of the string descriptor. <31-254> + + +// 31 characters can be stored in the internal USB buffer used for transfers. +// Any value higher than 31 creates an additional buffer just for descriptor strings. + +#ifndef APP_USBD_CONFIG_DESC_STRING_SIZE +#define APP_USBD_CONFIG_DESC_STRING_SIZE 31 +#endif + +// APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED - Enable UTF8 conversion. + + +// Enable UTF8-encoded characters. In normal processing, only ASCII characters are available. + +#ifndef APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED +#define APP_USBD_CONFIG_DESC_STRING_UTF_ENABLED 0 +#endif + +// APP_USBD_STRINGS_LANGIDS - Supported languages identifiers. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of supported languages. +#ifndef APP_USBD_STRINGS_LANGIDS +#define APP_USBD_STRINGS_LANGIDS APP_USBD_LANG_AND_SUBLANG(APP_USBD_LANG_ENGLISH, APP_USBD_SUBLANG_ENGLISH_US) +#endif + +// APP_USBD_STRING_ID_MANUFACTURER - Define manufacturer string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_MANUFACTURER +#define APP_USBD_STRING_ID_MANUFACTURER 1 +#endif +// APP_USBD_STRINGS_MANUFACTURER_EXTERN - Define whether @ref APP_USBD_STRINGS_MANUFACTURER is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_MANUFACTURER_EXTERN +#define APP_USBD_STRINGS_MANUFACTURER_EXTERN 0 +#endif + +// APP_USBD_STRINGS_MANUFACTURER - String descriptor for the manufacturer name. + +// Note: This value is not editable in Configuration Wizard. +// Comma-separated list of manufacturer names for each defined language. +// Use @ref APP_USBD_STRING_DESC macro to create string descriptor from a NULL-terminated string. +// Use @ref APP_USBD_STRING_RAW8_DESC macro to create string descriptor from comma-separated uint8_t values. +// Use @ref APP_USBD_STRING_RAW16_DESC macro to create string descriptor from comma-separated uint16_t values. +// Alternatively, configure the macro to point to any internal variable pointer that already contains the descriptor. +// Setting string to NULL disables that string. +// The order of manufacturer names must be the same like in @ref APP_USBD_STRINGS_LANGIDS. +#ifndef APP_USBD_STRINGS_MANUFACTURER +#define APP_USBD_STRINGS_MANUFACTURER APP_USBD_STRING_DESC("Nordic Semiconductor") +#endif + +// + +// APP_USBD_STRING_ID_PRODUCT - Define product string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_PRODUCT +#define APP_USBD_STRING_ID_PRODUCT 2 +#endif +// APP_USBD_STRINGS_PRODUCT_EXTERN - Define whether @ref APP_USBD_STRINGS_PRODUCT is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRINGS_PRODUCT_EXTERN +#define APP_USBD_STRINGS_PRODUCT_EXTERN 0 +#endif + +// APP_USBD_STRINGS_PRODUCT - String descriptor for the product name. + +// Note: This value is not editable in Configuration Wizard. +// List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_PRODUCT +#define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52 USB Product") +#endif + +// + +// APP_USBD_STRING_ID_SERIAL - Define serial number string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_SERIAL +#define APP_USBD_STRING_ID_SERIAL 3 +#endif +// APP_USBD_STRING_SERIAL_EXTERN - Define whether @ref APP_USBD_STRING_SERIAL is created by macro or declared as a global variable. + + +#ifndef APP_USBD_STRING_SERIAL_EXTERN +#define APP_USBD_STRING_SERIAL_EXTERN 0 +#endif + +// APP_USBD_STRING_SERIAL - String descriptor for the serial number. + +// Note: This value is not editable in Configuration Wizard. +// Serial number that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRING_SERIAL +#define APP_USBD_STRING_SERIAL APP_USBD_STRING_DESC("000000000000") +#endif + +// + +// APP_USBD_STRING_ID_CONFIGURATION - Define configuration string ID. + +// Setting ID to 0 disables the string. +//========================================================== +#ifndef APP_USBD_STRING_ID_CONFIGURATION +#define APP_USBD_STRING_ID_CONFIGURATION 4 +#endif +// APP_USBD_STRING_CONFIGURATION_EXTERN - Define whether @ref APP_USBD_STRINGS_CONFIGURATION is created by macro or declared as global variable. + + +#ifndef APP_USBD_STRING_CONFIGURATION_EXTERN +#define APP_USBD_STRING_CONFIGURATION_EXTERN 0 +#endif + +// APP_USBD_STRINGS_CONFIGURATION - String descriptor for the device configuration. + +// Note: This value is not editable in Configuration Wizard. +// Configuration string that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER. +#ifndef APP_USBD_STRINGS_CONFIGURATION +#define APP_USBD_STRINGS_CONFIGURATION APP_USBD_STRING_DESC("Default configuration") +#endif + +// + +// APP_USBD_STRINGS_USER - Default values for user strings. + +// Note: This value is not editable in Configuration Wizard. +// This value stores all application specific user strings with the default initialization. +// The setup is done by X-macros. +// Expected macro parameters: +// @code +// X(mnemonic, [=str_idx], ...) +// @endcode +// - @c mnemonic: Mnemonic of the string descriptor that would be added to +// @ref app_usbd_string_desc_idx_t enumerator. +// - @c str_idx : String index value, can be set or left empty. +// For example, WinUSB driver requires descriptor to be present on 0xEE index. +// Then use X(USBD_STRING_WINUSB, =0xEE, (APP_USBD_STRING_DESC(...))) +// - @c ... : List of string descriptors for each defined language. +#ifndef APP_USBD_STRINGS_USER +#define APP_USBD_STRINGS_USER X(APP_USER_1, , APP_USBD_STRING_DESC("User 1")) +#endif + +// + +// APP_USBD_HID_ENABLED - app_usbd_hid - USB HID class +//========================================================== +#ifndef APP_USBD_HID_ENABLED +#define APP_USBD_HID_ENABLED 0 +#endif +// APP_USBD_HID_DEFAULT_IDLE_RATE - Default idle rate for HID class. <0-255> + + +// 0 means indefinite duration, any other value is multiplied by 4 milliseconds. Refer to Chapter 7.2.4 of HID 1.11 Specification. + +#ifndef APP_USBD_HID_DEFAULT_IDLE_RATE +#define APP_USBD_HID_DEFAULT_IDLE_RATE 0 +#endif + +// APP_USBD_HID_REPORT_IDLE_TABLE_SIZE - Size of idle rate table. <1-255> + + +// Must be higher than the highest report ID used. + +#ifndef APP_USBD_HID_REPORT_IDLE_TABLE_SIZE +#define APP_USBD_HID_REPORT_IDLE_TABLE_SIZE 4 +#endif + +// + +// APP_USBD_HID_GENERIC_ENABLED - app_usbd_hid_generic - USB HID generic + + +#ifndef APP_USBD_HID_GENERIC_ENABLED +#define APP_USBD_HID_GENERIC_ENABLED 0 +#endif + +// APP_USBD_HID_KBD_ENABLED - app_usbd_hid_kbd - USB HID keyboard + + +#ifndef APP_USBD_HID_KBD_ENABLED +#define APP_USBD_HID_KBD_ENABLED 0 +#endif + +// APP_USBD_HID_MOUSE_ENABLED - app_usbd_hid_mouse - USB HID mouse + + +#ifndef APP_USBD_HID_MOUSE_ENABLED +#define APP_USBD_HID_MOUSE_ENABLED 0 +#endif + +// APP_USBD_MSC_ENABLED - app_usbd_msc - USB MSC class + + +#ifndef APP_USBD_MSC_ENABLED +#define APP_USBD_MSC_ENABLED 0 +#endif + +// CRC16_ENABLED - crc16 - CRC16 calculation routines + + +#ifndef CRC16_ENABLED +#define CRC16_ENABLED 0 +#endif + +// CRC32_ENABLED - crc32 - CRC32 calculation routines + + +#ifndef CRC32_ENABLED +#define CRC32_ENABLED 0 +#endif + +// ECC_ENABLED - ecc - Elliptic Curve Cryptography Library + + +#ifndef ECC_ENABLED +#define ECC_ENABLED 0 +#endif + +// FDS_ENABLED - fds - Flash data storage module +//========================================================== +#ifndef FDS_ENABLED +#define FDS_ENABLED 0 +#endif +// Pages - Virtual page settings + +// Configure the number of virtual pages to use and their size. +//========================================================== +// FDS_VIRTUAL_PAGES - Number of virtual flash pages to use. +// One of the virtual pages is reserved by the system for garbage collection. +// Therefore, the minimum is two virtual pages: one page to store data and one page to be used by the system for garbage collection. +// The total amount of flash memory that is used by FDS amounts to @ref FDS_VIRTUAL_PAGES * @ref FDS_VIRTUAL_PAGE_SIZE * 4 bytes. + +#ifndef FDS_VIRTUAL_PAGES +#define FDS_VIRTUAL_PAGES 3 +#endif + +// FDS_VIRTUAL_PAGE_SIZE - The size of a virtual flash page. + + +// Expressed in number of 4-byte words. +// By default, a virtual page is the same size as a physical page. +// The size of a virtual page must be a multiple of the size of a physical page. +// <1024=> 1024 +// <2048=> 2048 + +#ifndef FDS_VIRTUAL_PAGE_SIZE +#define FDS_VIRTUAL_PAGE_SIZE 1024 +#endif + +// FDS_VIRTUAL_PAGES_RESERVED - The number of virtual flash pages that are used by other modules. +// FDS module stores its data in the last pages of the flash memory. +// By setting this value, you can move flash end address used by the FDS. +// As a result the reserved space can be used by other modules. + +#ifndef FDS_VIRTUAL_PAGES_RESERVED +#define FDS_VIRTUAL_PAGES_RESERVED 0 +#endif + +// +//========================================================== + +// Backend - Backend configuration + +// Configure which nrf_fstorage backend is used by FDS to write to flash. +//========================================================== +// FDS_BACKEND - FDS flash backend. + + +// NRF_FSTORAGE_SD uses the nrf_fstorage_sd backend implementation using the SoftDevice API. Use this if you have a SoftDevice present. +// NRF_FSTORAGE_NVMC uses the nrf_fstorage_nvmc implementation. Use this setting if you don't use the SoftDevice. +// <1=> NRF_FSTORAGE_NVMC +// <2=> NRF_FSTORAGE_SD + +#ifndef FDS_BACKEND +#define FDS_BACKEND 2 +#endif + +// +//========================================================== + +// Queue - Queue settings + +//========================================================== +// FDS_OP_QUEUE_SIZE - Size of the internal queue. +// Increase this value if you frequently get synchronous FDS_ERR_NO_SPACE_IN_QUEUES errors. + +#ifndef FDS_OP_QUEUE_SIZE +#define FDS_OP_QUEUE_SIZE 4 +#endif + +// +//========================================================== + +// CRC - CRC functionality + +//========================================================== +// FDS_CRC_CHECK_ON_READ - Enable CRC checks. + +// Save a record's CRC when it is written to flash and check it when the record is opened. +// Records with an incorrect CRC can still be 'seen' by the user using FDS functions, but they cannot be opened. +// Additionally, they will not be garbage collected until they are deleted. +//========================================================== +#ifndef FDS_CRC_CHECK_ON_READ +#define FDS_CRC_CHECK_ON_READ 0 +#endif +// FDS_CRC_CHECK_ON_WRITE - Perform a CRC check on newly written records. + + +// Perform a CRC check on newly written records. +// This setting can be used to make sure that the record data was not altered while being written to flash. +// <1=> Enabled +// <0=> Disabled + +#ifndef FDS_CRC_CHECK_ON_WRITE +#define FDS_CRC_CHECK_ON_WRITE 0 +#endif + +// + +// +//========================================================== + +// Users - Number of users + +//========================================================== +// FDS_MAX_USERS - Maximum number of callbacks that can be registered. +#ifndef FDS_MAX_USERS +#define FDS_MAX_USERS 4 +#endif + +// +//========================================================== + +// + +// HARDFAULT_HANDLER_ENABLED - hardfault_default - HardFault default handler for debugging and release + + +#ifndef HARDFAULT_HANDLER_ENABLED +#define HARDFAULT_HANDLER_ENABLED 0 +#endif + +// HCI_MEM_POOL_ENABLED - hci_mem_pool - memory pool implementation used by HCI +//========================================================== +#ifndef HCI_MEM_POOL_ENABLED +#define HCI_MEM_POOL_ENABLED 0 +#endif +// HCI_TX_BUF_SIZE - TX buffer size in bytes. +#ifndef HCI_TX_BUF_SIZE +#define HCI_TX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_SIZE - RX buffer size in bytes. +#ifndef HCI_RX_BUF_SIZE +#define HCI_RX_BUF_SIZE 600 +#endif + +// HCI_RX_BUF_QUEUE_SIZE - RX buffer queue size. +#ifndef HCI_RX_BUF_QUEUE_SIZE +#define HCI_RX_BUF_QUEUE_SIZE 4 +#endif + +// + +// HCI_SLIP_ENABLED - hci_slip - SLIP protocol implementation used by HCI +//========================================================== +#ifndef HCI_SLIP_ENABLED +#define HCI_SLIP_ENABLED 0 +#endif +// HCI_UART_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3862528=> 14400 baud +// <5152768=> 19200 baud +// <7716864=> 28800 baud +// <10289152=> 38400 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef HCI_UART_BAUDRATE +#define HCI_UART_BAUDRATE 30801920 +#endif + +// HCI_UART_FLOW_CONTROL - Hardware Flow Control + +// <0=> Disabled +// <1=> Enabled + +#ifndef HCI_UART_FLOW_CONTROL +#define HCI_UART_FLOW_CONTROL 0 +#endif + +// HCI_UART_RX_PIN - UART RX pin +#ifndef HCI_UART_RX_PIN +#define HCI_UART_RX_PIN 8 +#endif + +// HCI_UART_TX_PIN - UART TX pin +#ifndef HCI_UART_TX_PIN +#define HCI_UART_TX_PIN 6 +#endif + +// HCI_UART_RTS_PIN - UART RTS pin +#ifndef HCI_UART_RTS_PIN +#define HCI_UART_RTS_PIN 5 +#endif + +// HCI_UART_CTS_PIN - UART CTS pin +#ifndef HCI_UART_CTS_PIN +#define HCI_UART_CTS_PIN 7 +#endif + +// + +// HCI_TRANSPORT_ENABLED - hci_transport - HCI transport +//========================================================== +#ifndef HCI_TRANSPORT_ENABLED +#define HCI_TRANSPORT_ENABLED 0 +#endif +// HCI_MAX_PACKET_SIZE_IN_BITS - Maximum size of a single application packet in bits. +#ifndef HCI_MAX_PACKET_SIZE_IN_BITS +#define HCI_MAX_PACKET_SIZE_IN_BITS 8000 +#endif + +// + +// LED_SOFTBLINK_ENABLED - led_softblink - led_softblink module + + +#ifndef LED_SOFTBLINK_ENABLED +#define LED_SOFTBLINK_ENABLED 0 +#endif + +// LOW_POWER_PWM_ENABLED - low_power_pwm - low_power_pwm module + + +#ifndef LOW_POWER_PWM_ENABLED +#define LOW_POWER_PWM_ENABLED 0 +#endif + +// MEM_MANAGER_ENABLED - mem_manager - Dynamic memory allocator +//========================================================== +#ifndef MEM_MANAGER_ENABLED +#define MEM_MANAGER_ENABLED 0 +#endif +// MEMORY_MANAGER_SMALL_BLOCK_COUNT - Size of each memory blocks identified as 'small' block. <0-255> + + +#ifndef MEMORY_MANAGER_SMALL_BLOCK_COUNT +#define MEMORY_MANAGER_SMALL_BLOCK_COUNT 1 +#endif + +// MEMORY_MANAGER_SMALL_BLOCK_SIZE - Size of each memory blocks identified as 'small' block. +// Size of each memory blocks identified as 'small' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_SMALL_BLOCK_SIZE +#define MEMORY_MANAGER_SMALL_BLOCK_SIZE 32 +#endif + +// MEMORY_MANAGER_MEDIUM_BLOCK_COUNT - Size of each memory blocks identified as 'medium' block. <0-255> + + +#ifndef MEMORY_MANAGER_MEDIUM_BLOCK_COUNT +#define MEMORY_MANAGER_MEDIUM_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_MEDIUM_BLOCK_SIZE - Size of each memory blocks identified as 'medium' block. +// Size of each memory blocks identified as 'medium' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_MEDIUM_BLOCK_SIZE +#define MEMORY_MANAGER_MEDIUM_BLOCK_SIZE 256 +#endif + +// MEMORY_MANAGER_LARGE_BLOCK_COUNT - Size of each memory blocks identified as 'large' block. <0-255> + + +#ifndef MEMORY_MANAGER_LARGE_BLOCK_COUNT +#define MEMORY_MANAGER_LARGE_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_LARGE_BLOCK_SIZE - Size of each memory blocks identified as 'large' block. +// Size of each memory blocks identified as 'large' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_LARGE_BLOCK_SIZE +#define MEMORY_MANAGER_LARGE_BLOCK_SIZE 256 +#endif + +// MEMORY_MANAGER_XLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra large' block. <0-255> + + +#ifndef MEMORY_MANAGER_XLARGE_BLOCK_COUNT +#define MEMORY_MANAGER_XLARGE_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_XLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra large' block. +// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_XLARGE_BLOCK_SIZE +#define MEMORY_MANAGER_XLARGE_BLOCK_SIZE 1320 +#endif + +// MEMORY_MANAGER_XXLARGE_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra large' block. <0-255> + + +#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_COUNT +#define MEMORY_MANAGER_XXLARGE_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_XXLARGE_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra large' block. +// Size of each memory blocks identified as 'extra extra large' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_XXLARGE_BLOCK_SIZE +#define MEMORY_MANAGER_XXLARGE_BLOCK_SIZE 3444 +#endif + +// MEMORY_MANAGER_XSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra small' block. <0-255> + + +#ifndef MEMORY_MANAGER_XSMALL_BLOCK_COUNT +#define MEMORY_MANAGER_XSMALL_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_XSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra small' block. +// Size of each memory blocks identified as 'extra large' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_XSMALL_BLOCK_SIZE +#define MEMORY_MANAGER_XSMALL_BLOCK_SIZE 64 +#endif + +// MEMORY_MANAGER_XXSMALL_BLOCK_COUNT - Size of each memory blocks identified as 'extra extra small' block. <0-255> + + +#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_COUNT +#define MEMORY_MANAGER_XXSMALL_BLOCK_COUNT 0 +#endif + +// MEMORY_MANAGER_XXSMALL_BLOCK_SIZE - Size of each memory blocks identified as 'extra extra small' block. +// Size of each memory blocks identified as 'extra extra small' block. Memory block are recommended to be word-sized. + +#ifndef MEMORY_MANAGER_XXSMALL_BLOCK_SIZE +#define MEMORY_MANAGER_XXSMALL_BLOCK_SIZE 32 +#endif + +// MEM_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef MEM_MANAGER_CONFIG_LOG_ENABLED +#define MEM_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// MEM_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MEM_MANAGER_CONFIG_LOG_LEVEL +#define MEM_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// MEM_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef MEM_MANAGER_CONFIG_INFO_COLOR +#define MEM_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// MEM_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef MEM_MANAGER_CONFIG_DEBUG_COLOR +#define MEM_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// MEM_MANAGER_DISABLE_API_PARAM_CHECK - Disable API parameter checks in the module. + + +#ifndef MEM_MANAGER_DISABLE_API_PARAM_CHECK +#define MEM_MANAGER_DISABLE_API_PARAM_CHECK 0 +#endif + +// + +// NRF_BALLOC_ENABLED - nrf_balloc - Block allocator module +//========================================================== +#ifndef NRF_BALLOC_ENABLED +#define NRF_BALLOC_ENABLED 1 +#endif +// NRF_BALLOC_CONFIG_DEBUG_ENABLED - Enables debug mode in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_DEBUG_ENABLED +#define NRF_BALLOC_CONFIG_DEBUG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS - Number of words used as head guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS +#define NRF_BALLOC_CONFIG_HEAD_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS - Number of words used as tail guard. <0-255> + + +#ifndef NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS +#define NRF_BALLOC_CONFIG_TAIL_GUARD_WORDS 1 +#endif + +// NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED - Enables basic checks in this module. + + +#ifndef NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED +#define NRF_BALLOC_CONFIG_BASIC_CHECKS_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED - Enables double memory free check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DOUBLE_FREE_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED - Enables free memory corruption check in this module. + + +#ifndef NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED +#define NRF_BALLOC_CONFIG_DATA_TRASHING_CHECK_ENABLED 0 +#endif + +// NRF_BALLOC_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_BALLOC_CLI_CMDS +#define NRF_BALLOC_CLI_CMDS 0 +#endif + +// + +// + +// NRF_CSENSE_ENABLED - nrf_csense - Capacitive sensor module +//========================================================== +#ifndef NRF_CSENSE_ENABLED +#define NRF_CSENSE_ENABLED 0 +#endif +// NRF_CSENSE_PAD_HYSTERESIS - Minimum value of change required to determine that a pad was touched. +#ifndef NRF_CSENSE_PAD_HYSTERESIS +#define NRF_CSENSE_PAD_HYSTERESIS 15 +#endif + +// NRF_CSENSE_PAD_DEVIATION - Minimum value measured on a pad required to take it into account while calculating the step. +#ifndef NRF_CSENSE_PAD_DEVIATION +#define NRF_CSENSE_PAD_DEVIATION 70 +#endif + +// NRF_CSENSE_MIN_PAD_VALUE - Minimum normalized value on a pad required to take its value into account. +#ifndef NRF_CSENSE_MIN_PAD_VALUE +#define NRF_CSENSE_MIN_PAD_VALUE 20 +#endif + +// NRF_CSENSE_MAX_PADS_NUMBER - Maximum number of pads used for one instance. +#ifndef NRF_CSENSE_MAX_PADS_NUMBER +#define NRF_CSENSE_MAX_PADS_NUMBER 20 +#endif + +// NRF_CSENSE_MAX_VALUE - Maximum normalized value obtained from measurement. +#ifndef NRF_CSENSE_MAX_VALUE +#define NRF_CSENSE_MAX_VALUE 1000 +#endif + +// NRF_CSENSE_OUTPUT_PIN - Output pin used by the low-level module. +// This is used when capacitive sensor does not use COMP. + +#ifndef NRF_CSENSE_OUTPUT_PIN +#define NRF_CSENSE_OUTPUT_PIN 26 +#endif + +// + +// NRF_DRV_CSENSE_ENABLED - nrf_drv_csense - Capacitive sensor low-level module +//========================================================== +#ifndef NRF_DRV_CSENSE_ENABLED +#define NRF_DRV_CSENSE_ENABLED 0 +#endif +// USE_COMP - Use the comparator to implement the capacitive sensor driver. + +// Due to Anomaly 84, COMP I_SOURCE is not functional. It has too high a varation. +//========================================================== +#ifndef USE_COMP +#define USE_COMP 0 +#endif +// TIMER0_FOR_CSENSE - First TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER0_FOR_CSENSE +#define TIMER0_FOR_CSENSE 1 +#endif + +// TIMER1_FOR_CSENSE - Second TIMER instance used by the driver (not used on nRF51). +#ifndef TIMER1_FOR_CSENSE +#define TIMER1_FOR_CSENSE 2 +#endif + +// MEASUREMENT_PERIOD - Single measurement period. +// Time of a single measurement can be calculated as +// T = (1/2)*MEASUREMENT_PERIOD*(1/f_OSC) where f_OSC = I_SOURCE / (2C*(VUP-VDOWN) ). +// I_SOURCE, VUP, and VDOWN are values used to initialize COMP and C is the capacitance of the used pad. + +#ifndef MEASUREMENT_PERIOD +#define MEASUREMENT_PERIOD 20 +#endif + +// + +// + +// NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library +//========================================================== +#ifndef NRF_FSTORAGE_ENABLED +#define NRF_FSTORAGE_ENABLED 1 +#endif +// nrf_fstorage - Common settings + +// Common settings to all fstorage implementations +//========================================================== +// NRF_FSTORAGE_PARAM_CHECK_DISABLED - Disable user input validation + + +// If selected, use ASSERT to validate user input. +// This effectively removes user input validation in production code. +// Recommended setting: OFF, only enable this setting if size is a major concern. + +#ifndef NRF_FSTORAGE_PARAM_CHECK_DISABLED +#define NRF_FSTORAGE_PARAM_CHECK_DISABLED 0 +#endif + +// +//========================================================== + +// nrf_fstorage_sd - Implementation using the SoftDevice + +// Configuration options for the fstorage implementation using the SoftDevice +//========================================================== +// NRF_FSTORAGE_SD_QUEUE_SIZE - Size of the internal queue of operations +// Increase this value if API calls frequently return the error @ref NRF_ERROR_NO_MEM. + +#ifndef NRF_FSTORAGE_SD_QUEUE_SIZE +#define NRF_FSTORAGE_SD_QUEUE_SIZE 4 +#endif + +// NRF_FSTORAGE_SD_MAX_RETRIES - Maximum number of attempts at executing an operation when the SoftDevice is busy +// Increase this value if events frequently return the @ref NRF_ERROR_TIMEOUT error. +// The SoftDevice might fail to schedule flash access due to high BLE activity. + +#ifndef NRF_FSTORAGE_SD_MAX_RETRIES +#define NRF_FSTORAGE_SD_MAX_RETRIES 8 +#endif + +// NRF_FSTORAGE_SD_MAX_WRITE_SIZE - Maximum number of bytes to be written to flash in a single operation +// This value must be a multiple of four. +// Lowering this value can increase the chances of the SoftDevice being able to execute flash operations in between radio activity. +// This value is bound by the maximum number of bytes that can be written to flash in a single call to @ref sd_flash_write. +// That is 1024 bytes for nRF51 ICs and 4096 bytes for nRF52 ICs. + +#ifndef NRF_FSTORAGE_SD_MAX_WRITE_SIZE +#define NRF_FSTORAGE_SD_MAX_WRITE_SIZE 4096 +#endif + +// +//========================================================== + +// + +// NRF_GFX_ENABLED - nrf_gfx - GFX module + + +#ifndef NRF_GFX_ENABLED +#define NRF_GFX_ENABLED 0 +#endif + +// NRF_MEMOBJ_ENABLED - nrf_memobj - Linked memory allocator module + + +#ifndef NRF_MEMOBJ_ENABLED +#define NRF_MEMOBJ_ENABLED 1 +#endif + +// NRF_PWR_MGMT_ENABLED - nrf_pwr_mgmt - Power management module +//========================================================== +#ifndef NRF_PWR_MGMT_ENABLED +#define NRF_PWR_MGMT_ENABLED 1 +#endif +// NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED - Enables pin debug in the module. + +// Selected pin will be set when CPU is in sleep mode. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED +#define NRF_PWR_MGMT_CONFIG_DEBUG_PIN_ENABLED 0 +#endif +// NRF_PWR_MGMT_SLEEP_DEBUG_PIN - Pin number + +// <0=> 0 (P0.0) +// <1=> 1 (P0.1) +// <2=> 2 (P0.2) +// <3=> 3 (P0.3) +// <4=> 4 (P0.4) +// <5=> 5 (P0.5) +// <6=> 6 (P0.6) +// <7=> 7 (P0.7) +// <8=> 8 (P0.8) +// <9=> 9 (P0.9) +// <10=> 10 (P0.10) +// <11=> 11 (P0.11) +// <12=> 12 (P0.12) +// <13=> 13 (P0.13) +// <14=> 14 (P0.14) +// <15=> 15 (P0.15) +// <16=> 16 (P0.16) +// <17=> 17 (P0.17) +// <18=> 18 (P0.18) +// <19=> 19 (P0.19) +// <20=> 20 (P0.20) +// <21=> 21 (P0.21) +// <22=> 22 (P0.22) +// <23=> 23 (P0.23) +// <24=> 24 (P0.24) +// <25=> 25 (P0.25) +// <26=> 26 (P0.26) +// <27=> 27 (P0.27) +// <28=> 28 (P0.28) +// <29=> 29 (P0.29) +// <30=> 30 (P0.30) +// <31=> 31 (P0.31) +// <4294967295=> Not connected + +#ifndef NRF_PWR_MGMT_SLEEP_DEBUG_PIN +#define NRF_PWR_MGMT_SLEEP_DEBUG_PIN 31 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED - Enables CPU usage monitor. + + +// Module will trace percentage of CPU usage in one second intervals. + +#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED +#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 0 +#endif + +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED - Enable standby timeout. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S - Standby timeout (in seconds). +// Shutdown procedure will begin no earlier than after this number of seconds. + +#ifndef NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S +#define NRF_PWR_MGMT_CONFIG_STANDBY_TIMEOUT_S 3 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED - Enables FPU event cleaning. + + +#ifndef NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED +#define NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 1 +#endif + +// NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY - Blocked shutdown procedure will be retried every second. + + +#ifndef NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY +#define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 0 +#endif + +// NRF_PWR_MGMT_CONFIG_USE_SCHEDULER - Module will use @ref app_scheduler. + + +#ifndef NRF_PWR_MGMT_CONFIG_USE_SCHEDULER +#define NRF_PWR_MGMT_CONFIG_USE_SCHEDULER 0 +#endif + +// NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT - The number of priorities for module handlers. +// The number of stages of the shutdown process. + +#ifndef NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT +#define NRF_PWR_MGMT_CONFIG_HANDLER_PRIORITY_COUNT 3 +#endif + +// + +// NRF_QUEUE_ENABLED - nrf_queue - Queue module +//========================================================== +#ifndef NRF_QUEUE_ENABLED +#define NRF_QUEUE_ENABLED 0 +#endif +// NRF_QUEUE_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef NRF_QUEUE_CLI_CMDS +#define NRF_QUEUE_CLI_CMDS 0 +#endif + +// + +// NRF_SECTION_ITER_ENABLED - nrf_section_iter - Section iterator + + +#ifndef NRF_SECTION_ITER_ENABLED +#define NRF_SECTION_ITER_ENABLED 1 +#endif + +// NRF_SORTLIST_ENABLED - nrf_sortlist - Sorted list + + +#ifndef NRF_SORTLIST_ENABLED +#define NRF_SORTLIST_ENABLED 0 +#endif + +// NRF_SPI_MNGR_ENABLED - nrf_spi_mngr - SPI transaction manager + + +#ifndef NRF_SPI_MNGR_ENABLED +#define NRF_SPI_MNGR_ENABLED 0 +#endif + +// NRF_STRERROR_ENABLED - nrf_strerror - Library for converting error code to string. + + +#ifndef NRF_STRERROR_ENABLED +#define NRF_STRERROR_ENABLED 1 +#endif + +// NRF_TWI_MNGR_ENABLED - nrf_twi_mngr - TWI transaction manager + + +#ifndef NRF_TWI_MNGR_ENABLED +#define NRF_TWI_MNGR_ENABLED 0 +#endif + +// SLIP_ENABLED - slip - SLIP encoding and decoding + + +#ifndef SLIP_ENABLED +#define SLIP_ENABLED 0 +#endif + +// TASK_MANAGER_ENABLED - task_manager - Task manager. +//========================================================== +#ifndef TASK_MANAGER_ENABLED +#define TASK_MANAGER_ENABLED 0 +#endif +// TASK_MANAGER_CLI_CMDS - Enable CLI commands specific to the module + + +#ifndef TASK_MANAGER_CLI_CMDS +#define TASK_MANAGER_CLI_CMDS 0 +#endif + +// TASK_MANAGER_CONFIG_MAX_TASKS - Maximum number of tasks which can be created +#ifndef TASK_MANAGER_CONFIG_MAX_TASKS +#define TASK_MANAGER_CONFIG_MAX_TASKS 2 +#endif + +// TASK_MANAGER_CONFIG_STACK_SIZE - Stack size for every task (power of 2) +#ifndef TASK_MANAGER_CONFIG_STACK_SIZE +#define TASK_MANAGER_CONFIG_STACK_SIZE 1024 +#endif + +// TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED - Enable stack profiling. + + +#ifndef TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED +#define TASK_MANAGER_CONFIG_STACK_PROFILER_ENABLED 1 +#endif + +// TASK_MANAGER_CONFIG_STACK_GUARD - Configures stack guard. + +// <0=> Disabled +// <4=> 32 bytes +// <5=> 64 bytes +// <6=> 128 bytes +// <7=> 256 bytes +// <8=> 512 bytes + +#ifndef TASK_MANAGER_CONFIG_STACK_GUARD +#define TASK_MANAGER_CONFIG_STACK_GUARD 7 +#endif + +// + +// app_button - buttons handling module + +//========================================================== +// BUTTON_ENABLED - Enables Button module + + +#ifndef BUTTON_ENABLED +#define BUTTON_ENABLED 1 +#endif + +// BUTTON_HIGH_ACCURACY_ENABLED - Enables GPIOTE high accuracy for buttons + + +#ifndef BUTTON_HIGH_ACCURACY_ENABLED +#define BUTTON_HIGH_ACCURACY_ENABLED 0 +#endif + +// +//========================================================== + +// app_usbd_cdc_acm - USB CDC ACM class + +//========================================================== +// APP_USBD_CDC_ACM_ENABLED - Enabling USBD CDC ACM Class library + + +#ifndef APP_USBD_CDC_ACM_ENABLED +#define APP_USBD_CDC_ACM_ENABLED 0 +#endif + +// APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE - Send ZLP on write with same size as endpoint + + +// If enabled, CDC ACM class will automatically send a zero length packet after transfer which has the same size as endpoint. +// This may limit throughput if a lot of binary data is sent, but in terminal mode operation it makes sure that the data is always displayed right after it is sent. + +#ifndef APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE +#define APP_USBD_CDC_ACM_ZLP_ON_EPSIZE_WRITE 1 +#endif + +// +//========================================================== + +// nrf_cli - Command line interface + +//========================================================== +// NRF_CLI_ENABLED - Enable/disable the CLI module. + + +#ifndef NRF_CLI_ENABLED +#define NRF_CLI_ENABLED 0 +#endif + +// NRF_CLI_ARGC_MAX - Maximum number of parameters passed to the command handler. +#ifndef NRF_CLI_ARGC_MAX +#define NRF_CLI_ARGC_MAX 12 +#endif + +// NRF_CLI_BUILD_IN_CMDS_ENABLED - CLI built-in commands. + + +#ifndef NRF_CLI_BUILD_IN_CMDS_ENABLED +#define NRF_CLI_BUILD_IN_CMDS_ENABLED 1 +#endif + +// NRF_CLI_CMD_BUFF_SIZE - Maximum buffer size for a single command. +#ifndef NRF_CLI_CMD_BUFF_SIZE +#define NRF_CLI_CMD_BUFF_SIZE 128 +#endif + +// NRF_CLI_ECHO_STATUS - CLI echo status. If set, echo is ON. + + +#ifndef NRF_CLI_ECHO_STATUS +#define NRF_CLI_ECHO_STATUS 1 +#endif + +// NRF_CLI_WILDCARD_ENABLED - Enable wildcard functionality for CLI commands. + + +#ifndef NRF_CLI_WILDCARD_ENABLED +#define NRF_CLI_WILDCARD_ENABLED 0 +#endif + +// NRF_CLI_METAKEYS_ENABLED - Enable additional control keys for CLI commands like ctrl+a, ctrl+e, ctrl+w, ctrl+u + + +#ifndef NRF_CLI_METAKEYS_ENABLED +#define NRF_CLI_METAKEYS_ENABLED 0 +#endif + +// NRF_CLI_PRINTF_BUFF_SIZE - Maximum print buffer size. +#ifndef NRF_CLI_PRINTF_BUFF_SIZE +#define NRF_CLI_PRINTF_BUFF_SIZE 23 +#endif + +// NRF_CLI_HISTORY_ENABLED - Enable CLI history mode. +//========================================================== +#ifndef NRF_CLI_HISTORY_ENABLED +#define NRF_CLI_HISTORY_ENABLED 1 +#endif +// NRF_CLI_HISTORY_ELEMENT_SIZE - Size of one memory object reserved for CLI history. +#ifndef NRF_CLI_HISTORY_ELEMENT_SIZE +#define NRF_CLI_HISTORY_ELEMENT_SIZE 32 +#endif + +// NRF_CLI_HISTORY_ELEMENT_COUNT - Number of history memory objects. +#ifndef NRF_CLI_HISTORY_ELEMENT_COUNT +#define NRF_CLI_HISTORY_ELEMENT_COUNT 8 +#endif + +// + +// NRF_CLI_VT100_COLORS_ENABLED - CLI VT100 colors. + + +#ifndef NRF_CLI_VT100_COLORS_ENABLED +#define NRF_CLI_VT100_COLORS_ENABLED 1 +#endif + +// NRF_CLI_STATISTICS_ENABLED - Enable CLI statistics. + + +#ifndef NRF_CLI_STATISTICS_ENABLED +#define NRF_CLI_STATISTICS_ENABLED 1 +#endif + +// NRF_CLI_LOG_BACKEND - Enable logger backend interface. + + +#ifndef NRF_CLI_LOG_BACKEND +#define NRF_CLI_LOG_BACKEND 1 +#endif + +// NRF_CLI_USES_TASK_MANAGER_ENABLED - Enable CLI to use task_manager + + +#ifndef NRF_CLI_USES_TASK_MANAGER_ENABLED +#define NRF_CLI_USES_TASK_MANAGER_ENABLED 0 +#endif + +// +//========================================================== + +// nrf_fprintf - fprintf function. + +//========================================================== +// NRF_FPRINTF_ENABLED - Enable/disable fprintf module. + + +#ifndef NRF_FPRINTF_ENABLED +#define NRF_FPRINTF_ENABLED 1 +#endif + +// NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED - For each printed LF, function will add CR. + + +#ifndef NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED +#define NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 1 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_Log + +//========================================================== +// NRF_LOG_BACKEND_RTT_ENABLED - nrf_log_backend_rtt - Log RTT backend +//========================================================== +#ifndef NRF_LOG_BACKEND_RTT_ENABLED +#define NRF_LOG_BACKEND_RTT_ENABLED 0 +#endif +// NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS - Period before retrying writing to RTT +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS +#define NRF_LOG_BACKEND_RTT_TX_RETRY_DELAY_MS 1 +#endif + +// NRF_LOG_BACKEND_RTT_TX_RETRY_CNT - Writing to RTT retries. +// If RTT fails to accept any new data after retries +// module assumes that host is not active and on next +// request it will perform only one write attempt. +// On successful writing, module assumes that host is active +// and scheme with retry is applied again. + +#ifndef NRF_LOG_BACKEND_RTT_TX_RETRY_CNT +#define NRF_LOG_BACKEND_RTT_TX_RETRY_CNT 3 +#endif + +// + +// NRF_LOG_BACKEND_UART_ENABLED - nrf_log_backend_uart - Log UART backend +//========================================================== +#ifndef NRF_LOG_BACKEND_UART_ENABLED +#define NRF_LOG_BACKEND_UART_ENABLED 1 +#endif +// NRF_LOG_BACKEND_UART_TX_PIN - UART TX pin +#ifndef NRF_LOG_BACKEND_UART_TX_PIN +#define NRF_LOG_BACKEND_UART_TX_PIN 6 +#endif + +// NRF_LOG_BACKEND_UART_BAUDRATE - Default Baudrate + +// <323584=> 1200 baud +// <643072=> 2400 baud +// <1290240=> 4800 baud +// <2576384=> 9600 baud +// <3862528=> 14400 baud +// <5152768=> 19200 baud +// <7716864=> 28800 baud +// <10289152=> 38400 baud +// <15400960=> 57600 baud +// <20615168=> 76800 baud +// <30801920=> 115200 baud +// <61865984=> 230400 baud +// <67108864=> 250000 baud +// <121634816=> 460800 baud +// <251658240=> 921600 baud +// <268435456=> 1000000 baud + +#ifndef NRF_LOG_BACKEND_UART_BAUDRATE +#define NRF_LOG_BACKEND_UART_BAUDRATE 30801920 +#endif + +// NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. +// Size of the buffer is a trade-off between RAM usage and processing. +// if buffer is smaller then strings will often be fragmented. +// It is recommended to use size which will fit typical log and only the +// longer one will be fragmented. + +#ifndef NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE +#define NRF_LOG_BACKEND_UART_TEMP_BUFFER_SIZE 64 +#endif + +// + +// NRF_LOG_ENABLED - nrf_log - Logger +//========================================================== +#ifndef NRF_LOG_ENABLED +#define NRF_LOG_ENABLED 1 +#endif +// Log message pool - Configuration of log message pool + +//========================================================== +// NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. +// If a small value is set, then performance of logs processing +// is degraded because data is fragmented. Bigger value impacts +// RAM memory utilization. The size is set to fit a message with +// a timestamp and up to 2 arguments in a single memory object. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE +#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20 +#endif + +// NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects +// If a small value is set, then it may lead to a deadlock +// in certain cases if backend has high latency and holds +// multiple messages for long time. Bigger value impacts +// RAM memory usage. + +#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT +#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8 +#endif + +// +//========================================================== + +// NRF_LOG_ALLOW_OVERFLOW - Configures behavior when circular buffer is full. + + +// If set then oldest logs are overwritten. Otherwise a +// marker is injected informing about overflow. + +#ifndef NRF_LOG_ALLOW_OVERFLOW +#define NRF_LOG_ALLOW_OVERFLOW 1 +#endif + +// NRF_LOG_BUFSIZE - Size of the buffer for storing logs (in bytes). + + +// Must be power of 2 and multiple of 4. +// If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum. +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 +// <2048=> 2048 +// <4096=> 4096 +// <8192=> 8192 +// <16384=> 16384 + +#ifndef NRF_LOG_BUFSIZE +#define NRF_LOG_BUFSIZE 1024 +#endif + +// NRF_LOG_CLI_CMDS - Enable CLI commands for the module. + + +#ifndef NRF_LOG_CLI_CMDS +#define NRF_LOG_CLI_CMDS 0 +#endif + +// NRF_LOG_DEFAULT_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_LOG_DEFAULT_LEVEL +#define NRF_LOG_DEFAULT_LEVEL 4 +#endif + +// NRF_LOG_DEFERRED - Enable deffered logger. + + +// Log data is buffered and can be processed in idle. + +#ifndef NRF_LOG_DEFERRED +#define NRF_LOG_DEFERRED 1 +#endif + +// NRF_LOG_FILTERS_ENABLED - Enable dynamic filtering of logs. + + +#ifndef NRF_LOG_FILTERS_ENABLED +#define NRF_LOG_FILTERS_ENABLED 0 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_STR_PUSH_BUFFER_SIZE - Size of the buffer dedicated for strings stored using @ref NRF_LOG_PUSH. + +// <16=> 16 +// <32=> 32 +// <64=> 64 +// <128=> 128 +// <256=> 256 +// <512=> 512 +// <1024=> 1024 + +#ifndef NRF_LOG_STR_PUSH_BUFFER_SIZE +#define NRF_LOG_STR_PUSH_BUFFER_SIZE 128 +#endif + +// NRF_LOG_USES_COLORS - If enabled then ANSI escape code for colors is prefixed to every string +//========================================================== +#ifndef NRF_LOG_USES_COLORS +#define NRF_LOG_USES_COLORS 0 +#endif +// NRF_LOG_COLOR_DEFAULT - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_LOG_COLOR_DEFAULT +#define NRF_LOG_COLOR_DEFAULT 0 +#endif + +// NRF_LOG_ERROR_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_LOG_ERROR_COLOR +#define NRF_LOG_ERROR_COLOR 2 +#endif + +// NRF_LOG_WARNING_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_LOG_WARNING_COLOR +#define NRF_LOG_WARNING_COLOR 4 +#endif + +// + +// NRF_LOG_USES_TIMESTAMP - Enable timestamping + +// Function for getting the timestamp is provided by the user +//========================================================== +#ifndef NRF_LOG_USES_TIMESTAMP +#define NRF_LOG_USES_TIMESTAMP 0 +#endif +// NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY - Default frequency of the timestamp (in Hz) or 0 to use app_timer frequency. +#ifndef NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY +#define NRF_LOG_TIMESTAMP_DEFAULT_FREQUENCY 0 +#endif + +// + +// nrf_log module configuration + +//========================================================== +// nrf_log in nRF_Core + +//========================================================== +// NRF_MPU_LIB_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MPU_LIB_CONFIG_LOG_ENABLED +#define NRF_MPU_LIB_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MPU_LIB_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MPU_LIB_CONFIG_LOG_LEVEL +#define NRF_MPU_LIB_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MPU_LIB_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_MPU_LIB_CONFIG_INFO_COLOR +#define NRF_MPU_LIB_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MPU_LIB_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_MPU_LIB_CONFIG_DEBUG_COLOR +#define NRF_MPU_LIB_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_STACK_GUARD_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_STACK_GUARD_CONFIG_LOG_ENABLED +#define NRF_STACK_GUARD_CONFIG_LOG_ENABLED 0 +#endif +// NRF_STACK_GUARD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_STACK_GUARD_CONFIG_LOG_LEVEL +#define NRF_STACK_GUARD_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_STACK_GUARD_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_STACK_GUARD_CONFIG_INFO_COLOR +#define NRF_STACK_GUARD_CONFIG_INFO_COLOR 0 +#endif + +// NRF_STACK_GUARD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_STACK_GUARD_CONFIG_DEBUG_COLOR +#define NRF_STACK_GUARD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TASK_MANAGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TASK_MANAGER_CONFIG_LOG_ENABLED +#define TASK_MANAGER_CONFIG_LOG_ENABLED 0 +#endif +// TASK_MANAGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TASK_MANAGER_CONFIG_LOG_LEVEL +#define TASK_MANAGER_CONFIG_LOG_LEVEL 3 +#endif + +// TASK_MANAGER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TASK_MANAGER_CONFIG_INFO_COLOR +#define TASK_MANAGER_CONFIG_INFO_COLOR 0 +#endif + +// TASK_MANAGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TASK_MANAGER_CONFIG_DEBUG_COLOR +#define TASK_MANAGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Drivers + +//========================================================== +// CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef CLOCK_CONFIG_LOG_ENABLED +#define CLOCK_CONFIG_LOG_ENABLED 0 +#endif +// CLOCK_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef CLOCK_CONFIG_LOG_LEVEL +#define CLOCK_CONFIG_LOG_LEVEL 3 +#endif + +// CLOCK_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef CLOCK_CONFIG_INFO_COLOR +#define CLOCK_CONFIG_INFO_COLOR 0 +#endif + +// CLOCK_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef CLOCK_CONFIG_DEBUG_COLOR +#define CLOCK_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// COMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef COMP_CONFIG_LOG_ENABLED +#define COMP_CONFIG_LOG_ENABLED 0 +#endif +// COMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef COMP_CONFIG_LOG_LEVEL +#define COMP_CONFIG_LOG_LEVEL 3 +#endif + +// COMP_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef COMP_CONFIG_INFO_COLOR +#define COMP_CONFIG_INFO_COLOR 0 +#endif + +// COMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef COMP_CONFIG_DEBUG_COLOR +#define COMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef GPIOTE_CONFIG_LOG_ENABLED +#define GPIOTE_CONFIG_LOG_ENABLED 0 +#endif +// GPIOTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef GPIOTE_CONFIG_LOG_LEVEL +#define GPIOTE_CONFIG_LOG_LEVEL 3 +#endif + +// GPIOTE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef GPIOTE_CONFIG_INFO_COLOR +#define GPIOTE_CONFIG_INFO_COLOR 0 +#endif + +// GPIOTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef GPIOTE_CONFIG_DEBUG_COLOR +#define GPIOTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// LPCOMP_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef LPCOMP_CONFIG_LOG_ENABLED +#define LPCOMP_CONFIG_LOG_ENABLED 0 +#endif +// LPCOMP_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef LPCOMP_CONFIG_LOG_LEVEL +#define LPCOMP_CONFIG_LOG_LEVEL 3 +#endif + +// LPCOMP_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef LPCOMP_CONFIG_INFO_COLOR +#define LPCOMP_CONFIG_INFO_COLOR 0 +#endif + +// LPCOMP_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef LPCOMP_CONFIG_DEBUG_COLOR +#define LPCOMP_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// MAX3421E_HOST_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef MAX3421E_HOST_CONFIG_LOG_ENABLED +#define MAX3421E_HOST_CONFIG_LOG_ENABLED 0 +#endif +// MAX3421E_HOST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef MAX3421E_HOST_CONFIG_LOG_LEVEL +#define MAX3421E_HOST_CONFIG_LOG_LEVEL 3 +#endif + +// MAX3421E_HOST_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef MAX3421E_HOST_CONFIG_INFO_COLOR +#define MAX3421E_HOST_CONFIG_INFO_COLOR 0 +#endif + +// MAX3421E_HOST_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef MAX3421E_HOST_CONFIG_DEBUG_COLOR +#define MAX3421E_HOST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRFX_USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef NRFX_USBD_CONFIG_LOG_ENABLED +#define NRFX_USBD_CONFIG_LOG_ENABLED 0 +#endif +// NRFX_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRFX_USBD_CONFIG_LOG_LEVEL +#define NRFX_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// NRFX_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_USBD_CONFIG_INFO_COLOR +#define NRFX_USBD_CONFIG_INFO_COLOR 0 +#endif + +// NRFX_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRFX_USBD_CONFIG_DEBUG_COLOR +#define NRFX_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PDM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PDM_CONFIG_LOG_ENABLED +#define PDM_CONFIG_LOG_ENABLED 0 +#endif +// PDM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PDM_CONFIG_LOG_LEVEL +#define PDM_CONFIG_LOG_LEVEL 3 +#endif + +// PDM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PDM_CONFIG_INFO_COLOR +#define PDM_CONFIG_INFO_COLOR 0 +#endif + +// PDM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PDM_CONFIG_DEBUG_COLOR +#define PDM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PPI_CONFIG_LOG_ENABLED +#define PPI_CONFIG_LOG_ENABLED 0 +#endif +// PPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PPI_CONFIG_LOG_LEVEL +#define PPI_CONFIG_LOG_LEVEL 3 +#endif + +// PPI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PPI_CONFIG_INFO_COLOR +#define PPI_CONFIG_INFO_COLOR 0 +#endif + +// PPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PPI_CONFIG_DEBUG_COLOR +#define PPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PWM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef PWM_CONFIG_LOG_ENABLED +#define PWM_CONFIG_LOG_ENABLED 0 +#endif +// PWM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PWM_CONFIG_LOG_LEVEL +#define PWM_CONFIG_LOG_LEVEL 3 +#endif + +// PWM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PWM_CONFIG_INFO_COLOR +#define PWM_CONFIG_INFO_COLOR 0 +#endif + +// PWM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PWM_CONFIG_DEBUG_COLOR +#define PWM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// QDEC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef QDEC_CONFIG_LOG_ENABLED +#define QDEC_CONFIG_LOG_ENABLED 0 +#endif +// QDEC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef QDEC_CONFIG_LOG_LEVEL +#define QDEC_CONFIG_LOG_LEVEL 3 +#endif + +// QDEC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef QDEC_CONFIG_INFO_COLOR +#define QDEC_CONFIG_INFO_COLOR 0 +#endif + +// QDEC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef QDEC_CONFIG_DEBUG_COLOR +#define QDEC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// RNG_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RNG_CONFIG_LOG_ENABLED +#define RNG_CONFIG_LOG_ENABLED 0 +#endif +// RNG_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef RNG_CONFIG_LOG_LEVEL +#define RNG_CONFIG_LOG_LEVEL 3 +#endif + +// RNG_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef RNG_CONFIG_INFO_COLOR +#define RNG_CONFIG_INFO_COLOR 0 +#endif + +// RNG_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef RNG_CONFIG_DEBUG_COLOR +#define RNG_CONFIG_DEBUG_COLOR 0 +#endif + +// RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED - Enables logging of random numbers. + + +#ifndef RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED +#define RNG_CONFIG_RANDOM_NUMBER_LOG_ENABLED 0 +#endif + +// + +// RTC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef RTC_CONFIG_LOG_ENABLED +#define RTC_CONFIG_LOG_ENABLED 0 +#endif +// RTC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef RTC_CONFIG_LOG_LEVEL +#define RTC_CONFIG_LOG_LEVEL 3 +#endif + +// RTC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef RTC_CONFIG_INFO_COLOR +#define RTC_CONFIG_INFO_COLOR 0 +#endif + +// RTC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef RTC_CONFIG_DEBUG_COLOR +#define RTC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// SAADC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SAADC_CONFIG_LOG_ENABLED +#define SAADC_CONFIG_LOG_ENABLED 0 +#endif +// SAADC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SAADC_CONFIG_LOG_LEVEL +#define SAADC_CONFIG_LOG_LEVEL 3 +#endif + +// SAADC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SAADC_CONFIG_INFO_COLOR +#define SAADC_CONFIG_INFO_COLOR 0 +#endif + +// SAADC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SAADC_CONFIG_DEBUG_COLOR +#define SAADC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// SPIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPIS_CONFIG_LOG_ENABLED +#define SPIS_CONFIG_LOG_ENABLED 0 +#endif +// SPIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SPIS_CONFIG_LOG_LEVEL +#define SPIS_CONFIG_LOG_LEVEL 3 +#endif + +// SPIS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SPIS_CONFIG_INFO_COLOR +#define SPIS_CONFIG_INFO_COLOR 0 +#endif + +// SPIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SPIS_CONFIG_DEBUG_COLOR +#define SPIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// SPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SPI_CONFIG_LOG_ENABLED +#define SPI_CONFIG_LOG_ENABLED 0 +#endif +// SPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SPI_CONFIG_LOG_LEVEL +#define SPI_CONFIG_LOG_LEVEL 3 +#endif + +// SPI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SPI_CONFIG_INFO_COLOR +#define SPI_CONFIG_INFO_COLOR 0 +#endif + +// SPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SPI_CONFIG_DEBUG_COLOR +#define SPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TIMER_CONFIG_LOG_ENABLED +#define TIMER_CONFIG_LOG_ENABLED 0 +#endif +// TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TIMER_CONFIG_LOG_LEVEL +#define TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TIMER_CONFIG_INFO_COLOR +#define TIMER_CONFIG_INFO_COLOR 0 +#endif + +// TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TIMER_CONFIG_DEBUG_COLOR +#define TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TWIS_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWIS_CONFIG_LOG_ENABLED +#define TWIS_CONFIG_LOG_ENABLED 0 +#endif +// TWIS_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TWIS_CONFIG_LOG_LEVEL +#define TWIS_CONFIG_LOG_LEVEL 3 +#endif + +// TWIS_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TWIS_CONFIG_INFO_COLOR +#define TWIS_CONFIG_INFO_COLOR 0 +#endif + +// TWIS_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TWIS_CONFIG_DEBUG_COLOR +#define TWIS_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// TWI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef TWI_CONFIG_LOG_ENABLED +#define TWI_CONFIG_LOG_ENABLED 0 +#endif +// TWI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef TWI_CONFIG_LOG_LEVEL +#define TWI_CONFIG_LOG_LEVEL 3 +#endif + +// TWI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TWI_CONFIG_INFO_COLOR +#define TWI_CONFIG_INFO_COLOR 0 +#endif + +// TWI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef TWI_CONFIG_DEBUG_COLOR +#define TWI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef UART_CONFIG_LOG_ENABLED +#define UART_CONFIG_LOG_ENABLED 0 +#endif +// UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef UART_CONFIG_LOG_LEVEL +#define UART_CONFIG_LOG_LEVEL 3 +#endif + +// UART_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef UART_CONFIG_INFO_COLOR +#define UART_CONFIG_INFO_COLOR 0 +#endif + +// UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef UART_CONFIG_DEBUG_COLOR +#define UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// USBD_CONFIG_LOG_ENABLED - Enable logging in the module +//========================================================== +#ifndef USBD_CONFIG_LOG_ENABLED +#define USBD_CONFIG_LOG_ENABLED 0 +#endif +// USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef USBD_CONFIG_LOG_LEVEL +#define USBD_CONFIG_LOG_LEVEL 3 +#endif + +// USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef USBD_CONFIG_INFO_COLOR +#define USBD_CONFIG_INFO_COLOR 0 +#endif + +// USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef USBD_CONFIG_DEBUG_COLOR +#define USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// WDT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef WDT_CONFIG_LOG_ENABLED +#define WDT_CONFIG_LOG_ENABLED 0 +#endif +// WDT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef WDT_CONFIG_LOG_LEVEL +#define WDT_CONFIG_LOG_LEVEL 3 +#endif + +// WDT_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef WDT_CONFIG_INFO_COLOR +#define WDT_CONFIG_INFO_COLOR 0 +#endif + +// WDT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef WDT_CONFIG_DEBUG_COLOR +#define WDT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Libraries + +//========================================================== +// APP_TIMER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_TIMER_CONFIG_LOG_ENABLED +#define APP_TIMER_CONFIG_LOG_ENABLED 0 +#endif +// APP_TIMER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_LOG_LEVEL +#define APP_TIMER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_TIMER_CONFIG_INITIAL_LOG_LEVEL +#define APP_TIMER_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// APP_TIMER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_TIMER_CONFIG_INFO_COLOR +#define APP_TIMER_CONFIG_INFO_COLOR 0 +#endif + +// APP_TIMER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_TIMER_CONFIG_DEBUG_COLOR +#define APP_TIMER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED +#define APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL +#define APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_CDC_ACM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_CDC_ACM_CONFIG_INFO_COLOR +#define APP_USBD_CDC_ACM_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR +#define APP_USBD_CDC_ACM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_CONFIG_LOG_ENABLED - Enable logging in the module. +//========================================================== +#ifndef APP_USBD_CONFIG_LOG_ENABLED +#define APP_USBD_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_CONFIG_LOG_LEVEL +#define APP_USBD_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_CONFIG_INFO_COLOR +#define APP_USBD_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_CONFIG_DEBUG_COLOR +#define APP_USBD_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_DUMMY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_DUMMY_CONFIG_LOG_ENABLED +#define APP_USBD_DUMMY_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_DUMMY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_DUMMY_CONFIG_LOG_LEVEL +#define APP_USBD_DUMMY_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_DUMMY_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_DUMMY_CONFIG_INFO_COLOR +#define APP_USBD_DUMMY_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_DUMMY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_DUMMY_CONFIG_DEBUG_COLOR +#define APP_USBD_DUMMY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_MSC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_MSC_CONFIG_LOG_ENABLED +#define APP_USBD_MSC_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_MSC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_MSC_CONFIG_LOG_LEVEL +#define APP_USBD_MSC_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_MSC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_MSC_CONFIG_INFO_COLOR +#define APP_USBD_MSC_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_MSC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_MSC_CONFIG_DEBUG_COLOR +#define APP_USBD_MSC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_ENABLED 0 +#endif +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_LOG_LEVEL 3 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_INFO_COLOR 0 +#endif + +// APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR +#define APP_USBD_NRF_DFU_TRIGGER_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_ATFIFO_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_ATFIFO_CONFIG_LOG_ENABLED +#define NRF_ATFIFO_CONFIG_LOG_ENABLED 0 +#endif +// NRF_ATFIFO_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_ATFIFO_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_ATFIFO_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_ATFIFO_CONFIG_INFO_COLOR +#define NRF_ATFIFO_CONFIG_INFO_COLOR 0 +#endif + +// NRF_ATFIFO_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_ATFIFO_CONFIG_DEBUG_COLOR +#define NRF_ATFIFO_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BALLOC_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BALLOC_CONFIG_LOG_ENABLED +#define NRF_BALLOC_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BALLOC_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_LOG_LEVEL +#define NRF_BALLOC_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL - Initial severity level if dynamic filtering is enabled. + + +// If module generates a lot of logs, initial log level can +// be decreased to prevent flooding. Severity level can be +// increased on instance basis. +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL +#define NRF_BALLOC_CONFIG_INITIAL_LOG_LEVEL 3 +#endif + +// NRF_BALLOC_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BALLOC_CONFIG_INFO_COLOR +#define NRF_BALLOC_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BALLOC_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BALLOC_CONFIG_DEBUG_COLOR +#define NRF_BALLOC_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_EMPTY_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_EMPTY_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_QSPI_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_QSPI_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_ENABLED 0 +#endif +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_BLOCK_DEV_RAM_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_INFO_COLOR 0 +#endif + +// NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR +#define NRF_BLOCK_DEV_RAM_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_BLE_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_BLE_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_BLE_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_BLE_UART_CONFIG_INFO_COLOR +#define NRF_CLI_BLE_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_BLE_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_CLI_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_CLI_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_CLI_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_CLI_UART_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_CLI_UART_CONFIG_LOG_ENABLED +#define NRF_CLI_UART_CONFIG_LOG_ENABLED 0 +#endif +// NRF_CLI_UART_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_CLI_UART_CONFIG_LOG_LEVEL +#define NRF_CLI_UART_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_CLI_UART_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_UART_CONFIG_INFO_COLOR +#define NRF_CLI_UART_CONFIG_INFO_COLOR 0 +#endif + +// NRF_CLI_UART_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_CLI_UART_CONFIG_DEBUG_COLOR +#define NRF_CLI_UART_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_LIBUARTE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_LIBUARTE_CONFIG_LOG_ENABLED +#define NRF_LIBUARTE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_LIBUARTE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_LIBUARTE_CONFIG_LOG_LEVEL +#define NRF_LIBUARTE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_LIBUARTE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_LIBUARTE_CONFIG_INFO_COLOR +#define NRF_LIBUARTE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_LIBUARTE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_LIBUARTE_CONFIG_DEBUG_COLOR +#define NRF_LIBUARTE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_MEMOBJ_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_MEMOBJ_CONFIG_LOG_ENABLED +#define NRF_MEMOBJ_CONFIG_LOG_ENABLED 0 +#endif +// NRF_MEMOBJ_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_MEMOBJ_CONFIG_LOG_LEVEL +#define NRF_MEMOBJ_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_MEMOBJ_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_MEMOBJ_CONFIG_INFO_COLOR +#define NRF_MEMOBJ_CONFIG_INFO_COLOR 0 +#endif + +// NRF_MEMOBJ_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_MEMOBJ_CONFIG_DEBUG_COLOR +#define NRF_MEMOBJ_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED +#define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0 +#endif +// NRF_PWR_MGMT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL +#define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_PWR_MGMT_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_PWR_MGMT_CONFIG_INFO_COLOR +#define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0 +#endif + +// NRF_PWR_MGMT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_PWR_MGMT_CONFIG_DEBUG_COLOR +#define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_QUEUE_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_QUEUE_CONFIG_LOG_ENABLED +#define NRF_QUEUE_CONFIG_LOG_ENABLED 0 +#endif +// NRF_QUEUE_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_LEVEL +#define NRF_QUEUE_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL - Initial severity level if dynamic filtering is enabled + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL +#define NRF_QUEUE_CONFIG_LOG_INIT_FILTER_LEVEL 3 +#endif + +// NRF_QUEUE_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_QUEUE_CONFIG_INFO_COLOR +#define NRF_QUEUE_CONFIG_INFO_COLOR 0 +#endif + +// NRF_QUEUE_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_QUEUE_CONFIG_DEBUG_COLOR +#define NRF_QUEUE_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_ANT_LOG_ENABLED - Enable logging in SoftDevice handler (ANT) module. +//========================================================== +#ifndef NRF_SDH_ANT_LOG_ENABLED +#define NRF_SDH_ANT_LOG_ENABLED 0 +#endif +// NRF_SDH_ANT_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_ANT_LOG_LEVEL +#define NRF_SDH_ANT_LOG_LEVEL 3 +#endif + +// NRF_SDH_ANT_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_ANT_INFO_COLOR +#define NRF_SDH_ANT_INFO_COLOR 0 +#endif + +// NRF_SDH_ANT_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_ANT_DEBUG_COLOR +#define NRF_SDH_ANT_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_BLE_LOG_ENABLED - Enable logging in SoftDevice handler (BLE) module. +//========================================================== +#ifndef NRF_SDH_BLE_LOG_ENABLED +#define NRF_SDH_BLE_LOG_ENABLED 1 +#endif +// NRF_SDH_BLE_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_BLE_LOG_LEVEL +#define NRF_SDH_BLE_LOG_LEVEL 3 +#endif + +// NRF_SDH_BLE_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_BLE_INFO_COLOR +#define NRF_SDH_BLE_INFO_COLOR 0 +#endif + +// NRF_SDH_BLE_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_BLE_DEBUG_COLOR +#define NRF_SDH_BLE_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_LOG_ENABLED - Enable logging in SoftDevice handler module. +//========================================================== +#ifndef NRF_SDH_LOG_ENABLED +#define NRF_SDH_LOG_ENABLED 1 +#endif +// NRF_SDH_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_LOG_LEVEL +#define NRF_SDH_LOG_LEVEL 3 +#endif + +// NRF_SDH_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_INFO_COLOR +#define NRF_SDH_INFO_COLOR 0 +#endif + +// NRF_SDH_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_DEBUG_COLOR +#define NRF_SDH_DEBUG_COLOR 0 +#endif + +// + +// NRF_SDH_SOC_LOG_ENABLED - Enable logging in SoftDevice handler (SoC) module. +//========================================================== +#ifndef NRF_SDH_SOC_LOG_ENABLED +#define NRF_SDH_SOC_LOG_ENABLED 1 +#endif +// NRF_SDH_SOC_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SDH_SOC_LOG_LEVEL +#define NRF_SDH_SOC_LOG_LEVEL 3 +#endif + +// NRF_SDH_SOC_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_SOC_INFO_COLOR +#define NRF_SDH_SOC_INFO_COLOR 0 +#endif + +// NRF_SDH_SOC_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SDH_SOC_DEBUG_COLOR +#define NRF_SDH_SOC_DEBUG_COLOR 0 +#endif + +// + +// NRF_SORTLIST_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_SORTLIST_CONFIG_LOG_ENABLED +#define NRF_SORTLIST_CONFIG_LOG_ENABLED 0 +#endif +// NRF_SORTLIST_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_SORTLIST_CONFIG_LOG_LEVEL +#define NRF_SORTLIST_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_SORTLIST_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SORTLIST_CONFIG_INFO_COLOR +#define NRF_SORTLIST_CONFIG_INFO_COLOR 0 +#endif + +// NRF_SORTLIST_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_SORTLIST_CONFIG_DEBUG_COLOR +#define NRF_SORTLIST_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// NRF_TWI_SENSOR_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_ENABLED +#define NRF_TWI_SENSOR_CONFIG_LOG_ENABLED 0 +#endif +// NRF_TWI_SENSOR_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NRF_TWI_SENSOR_CONFIG_LOG_LEVEL +#define NRF_TWI_SENSOR_CONFIG_LOG_LEVEL 3 +#endif + +// NRF_TWI_SENSOR_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_TWI_SENSOR_CONFIG_INFO_COLOR +#define NRF_TWI_SENSOR_CONFIG_INFO_COLOR 0 +#endif + +// NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR +#define NRF_TWI_SENSOR_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// PM_LOG_ENABLED - Enable logging in Peer Manager and its submodules. +//========================================================== +#ifndef PM_LOG_ENABLED +#define PM_LOG_ENABLED 1 +#endif +// PM_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef PM_LOG_LEVEL +#define PM_LOG_LEVEL 3 +#endif + +// PM_LOG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PM_LOG_INFO_COLOR +#define PM_LOG_INFO_COLOR 0 +#endif + +// PM_LOG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef PM_LOG_DEBUG_COLOR +#define PM_LOG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// nrf_log in nRF_Serialization + +//========================================================== +// SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED +#define SER_HAL_TRANSPORT_CONFIG_LOG_ENABLED 0 +#endif +// SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL +#define SER_HAL_TRANSPORT_CONFIG_LOG_LEVEL 3 +#endif + +// SER_HAL_TRANSPORT_CONFIG_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SER_HAL_TRANSPORT_CONFIG_INFO_COLOR +#define SER_HAL_TRANSPORT_CONFIG_INFO_COLOR 0 +#endif + +// SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR +#define SER_HAL_TRANSPORT_CONFIG_DEBUG_COLOR 0 +#endif + +// + +// +//========================================================== + +// +//========================================================== + +// + +// NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED - nrf_log_str_formatter - Log string formatter + + +#ifndef NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED +#define NRF_LOG_STR_FORMATTER_TIMESTAMP_FORMAT_ENABLED 1 +#endif + +// +//========================================================== + +// nRF_NFC + +//========================================================== +// NFC_AC_REC_ENABLED - nfc_ac_rec - NFC NDEF Alternative Carrier record encoder + + +#ifndef NFC_AC_REC_ENABLED +#define NFC_AC_REC_ENABLED 0 +#endif + +// NFC_AC_REC_PARSER_ENABLED - nfc_ac_rec_parser - Alternative Carrier record parser + + +#ifndef NFC_AC_REC_PARSER_ENABLED +#define NFC_AC_REC_PARSER_ENABLED 0 +#endif + +// NFC_BLE_OOB_ADVDATA_ENABLED - nfc_ble_oob_advdata - AD data for OOB pairing encoder +//========================================================== +#ifndef NFC_BLE_OOB_ADVDATA_ENABLED +#define NFC_BLE_OOB_ADVDATA_ENABLED 0 +#endif +// ADVANCED_ADVDATA_SUPPORT - Non-mandatory AD types for BLE OOB pairing are encoded inside the NDEF message (e.g. service UUIDs) + +// <1=> Enabled +// <0=> Disabled + +#ifndef ADVANCED_ADVDATA_SUPPORT +#define ADVANCED_ADVDATA_SUPPORT 0 +#endif + +// + +// NFC_BLE_OOB_ADVDATA_PARSER_ENABLED - nfc_ble_oob_advdata_parser - BLE OOB pairing AD data parser + + +#ifndef NFC_BLE_OOB_ADVDATA_PARSER_ENABLED +#define NFC_BLE_OOB_ADVDATA_PARSER_ENABLED 0 +#endif + +// NFC_BLE_PAIR_LIB_ENABLED - nfc_ble_pair_lib - Library parameters +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_ENABLED +#define NFC_BLE_PAIR_LIB_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_BLE_PAIR_LIB_LOG_ENABLED +#define NFC_BLE_PAIR_LIB_LOG_ENABLED 0 +#endif +// NFC_BLE_PAIR_LIB_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_BLE_PAIR_LIB_LOG_LEVEL +#define NFC_BLE_PAIR_LIB_LOG_LEVEL 3 +#endif + +// NFC_BLE_PAIR_LIB_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_BLE_PAIR_LIB_INFO_COLOR +#define NFC_BLE_PAIR_LIB_INFO_COLOR 0 +#endif + +// NFC_BLE_PAIR_LIB_DEBUG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_BLE_PAIR_LIB_DEBUG_COLOR +#define NFC_BLE_PAIR_LIB_DEBUG_COLOR 0 +#endif + +// + +// NFC_BLE_PAIR_LIB_SECURITY_PARAMETERS - Common Peer Manager security parameters. + +//========================================================== +// BLE_NFC_SEC_PARAM_BOND - Enables device bonding. + +// If bonding is enabled at least one of the BLE_NFC_SEC_PARAM_KDIST options must be enabled. +//========================================================== +#ifndef BLE_NFC_SEC_PARAM_BOND +#define BLE_NFC_SEC_PARAM_BOND 1 +#endif +// BLE_NFC_SEC_PARAM_KDIST_OWN_ENC - Enables Long Term Key and Master Identification distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ENC +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_OWN_ID - Enables Identity Resolving Key and Identity Address Information distribution by device. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_OWN_ID +#define BLE_NFC_SEC_PARAM_KDIST_OWN_ID 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ENC - Enables Long Term Key and Master Identification distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ENC +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ENC 1 +#endif + +// BLE_NFC_SEC_PARAM_KDIST_PEER_ID - Enables Identity Resolving Key and Identity Address Information distribution by peer. + + +#ifndef BLE_NFC_SEC_PARAM_KDIST_PEER_ID +#define BLE_NFC_SEC_PARAM_KDIST_PEER_ID 1 +#endif + +// + +// BLE_NFC_SEC_PARAM_MIN_KEY_SIZE - Minimal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MIN_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MIN_KEY_SIZE 7 +#endif + +// BLE_NFC_SEC_PARAM_MAX_KEY_SIZE - Maximal size of a security key. + +// <7=> 7 +// <8=> 8 +// <9=> 9 +// <10=> 10 +// <11=> 11 +// <12=> 12 +// <13=> 13 +// <14=> 14 +// <15=> 15 +// <16=> 16 + +#ifndef BLE_NFC_SEC_PARAM_MAX_KEY_SIZE +#define BLE_NFC_SEC_PARAM_MAX_KEY_SIZE 16 +#endif + +// +//========================================================== + +// + +// NFC_BLE_PAIR_MSG_ENABLED - nfc_ble_pair_msg - NDEF message for OOB pairing encoder + + +#ifndef NFC_BLE_PAIR_MSG_ENABLED +#define NFC_BLE_PAIR_MSG_ENABLED 0 +#endif + +// NFC_CH_COMMON_ENABLED - nfc_ble_pair_common - OOB pairing common data + + +#ifndef NFC_CH_COMMON_ENABLED +#define NFC_CH_COMMON_ENABLED 0 +#endif + +// NFC_EP_OOB_REC_ENABLED - nfc_ep_oob_rec - EP record for BLE pairing encoder + + +#ifndef NFC_EP_OOB_REC_ENABLED +#define NFC_EP_OOB_REC_ENABLED 0 +#endif + +// NFC_HS_REC_ENABLED - nfc_hs_rec - Handover Select NDEF record encoder + + +#ifndef NFC_HS_REC_ENABLED +#define NFC_HS_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_ENABLED - nfc_le_oob_rec - LE record for BLE pairing encoder + + +#ifndef NFC_LE_OOB_REC_ENABLED +#define NFC_LE_OOB_REC_ENABLED 0 +#endif + +// NFC_LE_OOB_REC_PARSER_ENABLED - nfc_le_oob_rec_parser - LE record parser + + +#ifndef NFC_LE_OOB_REC_PARSER_ENABLED +#define NFC_LE_OOB_REC_PARSER_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_MSG_ENABLED - nfc_launchapp_msg - Encoding data for NDEF Application Launching message for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_MSG_ENABLED +#define NFC_NDEF_LAUNCHAPP_MSG_ENABLED 0 +#endif + +// NFC_NDEF_LAUNCHAPP_REC_ENABLED - nfc_launchapp_rec - Encoding data for NDEF Application Launching record for NFC Tag + + +#ifndef NFC_NDEF_LAUNCHAPP_REC_ENABLED +#define NFC_NDEF_LAUNCHAPP_REC_ENABLED 0 +#endif + +// NFC_NDEF_MSG_ENABLED - nfc_ndef_msg - NFC NDEF Message generator module +//========================================================== +#ifndef NFC_NDEF_MSG_ENABLED +#define NFC_NDEF_MSG_ENABLED 0 +#endif +// NFC_NDEF_MSG_TAG_TYPE - NFC Tag Type + +// <2=> Type 2 Tag +// <4=> Type 4 Tag + +#ifndef NFC_NDEF_MSG_TAG_TYPE +#define NFC_NDEF_MSG_TAG_TYPE 2 +#endif + +// + +// NFC_NDEF_MSG_PARSER_ENABLED - nfc_ndef_msg_parser - NFC NDEF message parser module +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_ENABLED +#define NFC_NDEF_MSG_PARSER_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_MSG_PARSER_LOG_ENABLED +#define NFC_NDEF_MSG_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_MSG_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_MSG_PARSER_LOG_LEVEL +#define NFC_NDEF_MSG_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_MSG_PARSER_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_NDEF_MSG_PARSER_INFO_COLOR +#define NFC_NDEF_MSG_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_NDEF_RECORD_ENABLED - nfc_ndef_record - NFC NDEF Record generator module + + +#ifndef NFC_NDEF_RECORD_ENABLED +#define NFC_NDEF_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_RECORD_PARSER_ENABLED - nfc_ndef_record_parser - NFC NDEF Record parser module +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_ENABLED +#define NFC_NDEF_RECORD_PARSER_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_NDEF_RECORD_PARSER_LOG_ENABLED +#define NFC_NDEF_RECORD_PARSER_LOG_ENABLED 0 +#endif +// NFC_NDEF_RECORD_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_NDEF_RECORD_PARSER_LOG_LEVEL +#define NFC_NDEF_RECORD_PARSER_LOG_LEVEL 3 +#endif + +// NFC_NDEF_RECORD_PARSER_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_NDEF_RECORD_PARSER_INFO_COLOR +#define NFC_NDEF_RECORD_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_NDEF_TEXT_RECORD_ENABLED - nfc_text_rec - Encoding data for a text record for NFC Tag + + +#ifndef NFC_NDEF_TEXT_RECORD_ENABLED +#define NFC_NDEF_TEXT_RECORD_ENABLED 0 +#endif + +// NFC_NDEF_URI_MSG_ENABLED - nfc_uri_msg - Encoding data for NDEF message with URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_MSG_ENABLED +#define NFC_NDEF_URI_MSG_ENABLED 0 +#endif + +// NFC_NDEF_URI_REC_ENABLED - nfc_uri_rec - Encoding data for a URI record for NFC Tag + + +#ifndef NFC_NDEF_URI_REC_ENABLED +#define NFC_NDEF_URI_REC_ENABLED 0 +#endif + +// NFC_T2T_PARSER_ENABLED - nfc_type_2_tag_parser - Parser for decoding Type 2 Tag data +//========================================================== +#ifndef NFC_T2T_PARSER_ENABLED +#define NFC_T2T_PARSER_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T2T_PARSER_LOG_ENABLED +#define NFC_T2T_PARSER_LOG_ENABLED 0 +#endif +// NFC_T2T_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T2T_PARSER_LOG_LEVEL +#define NFC_T2T_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T2T_PARSER_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T2T_PARSER_INFO_COLOR +#define NFC_T2T_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_APDU_ENABLED - nfc_t4t_apdu - APDU encoder/decoder for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_APDU_ENABLED +#define NFC_T4T_APDU_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_APDU_LOG_ENABLED +#define NFC_T4T_APDU_LOG_ENABLED 0 +#endif +// NFC_T4T_APDU_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_APDU_LOG_LEVEL +#define NFC_T4T_APDU_LOG_LEVEL 3 +#endif + +// NFC_T4T_APDU_LOG_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_APDU_LOG_COLOR +#define NFC_T4T_APDU_LOG_COLOR 0 +#endif + +// + +// + +// NFC_T4T_CC_FILE_PARSER_ENABLED - nfc_t4t_cc_file - Capability Container file for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_ENABLED +#define NFC_T4T_CC_FILE_PARSER_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_ENABLED +#define NFC_T4T_CC_FILE_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_CC_FILE_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_CC_FILE_PARSER_LOG_LEVEL +#define NFC_T4T_CC_FILE_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T4T_CC_FILE_PARSER_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_CC_FILE_PARSER_INFO_COLOR +#define NFC_T4T_CC_FILE_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED - nfc_t4t_hl_detection_procedures - NDEF Detection Procedure for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_ENABLED 0 +#endif +// NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL +#define NFC_T4T_HL_DETECTION_PROCEDURES_LOG_LEVEL 3 +#endif + +// NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR +#define NFC_T4T_HL_DETECTION_PROCEDURES_INFO_COLOR 0 +#endif + +// + +// APDU_BUFF_SIZE - Size (in bytes) of the buffer for APDU storage +#ifndef APDU_BUFF_SIZE +#define APDU_BUFF_SIZE 250 +#endif + +// CC_STORAGE_BUFF_SIZE - Size (in bytes) of the buffer for CC file storage +#ifndef CC_STORAGE_BUFF_SIZE +#define CC_STORAGE_BUFF_SIZE 64 +#endif + +// + +// NFC_T4T_TLV_BLOCK_PARSER_ENABLED - nfc_t4t_tlv_block - TLV block for Type 4 Tag +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED - Enables logging in the module. +//========================================================== +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_ENABLED 0 +#endif +// NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL - Default Severity level + +// <0=> Off +// <1=> Error +// <2=> Warning +// <3=> Info +// <4=> Debug + +#ifndef NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL +#define NFC_T4T_TLV_BLOCK_PARSER_LOG_LEVEL 3 +#endif + +// NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR - ANSI escape code prefix. + +// <0=> Default +// <1=> Black +// <2=> Red +// <3=> Green +// <4=> Yellow +// <5=> Blue +// <6=> Magenta +// <7=> Cyan +// <8=> White + +#ifndef NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR +#define NFC_T4T_TLV_BLOCK_PARSER_INFO_COLOR 0 +#endif + +// + +// + +// +//========================================================== + +// nRF_Segger_RTT + +//========================================================== +// segger_rtt - SEGGER RTT + +//========================================================== +// SEGGER_RTT_CONFIG_BUFFER_SIZE_UP - Size of upstream buffer. +// Note that either @ref NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE +// or this value is actually used. It depends on which one is bigger. + +#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_UP +#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512 +#endif + +// SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Maximum number of upstream buffers. +#ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS +#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2 +#endif + +// SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of downstream buffer. +#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN +#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16 +#endif + +// SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Maximum number of downstream buffers. +#ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS +#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2 +#endif + +// SEGGER_RTT_CONFIG_DEFAULT_MODE - RTT behavior if the buffer is full. + + +// The following modes are supported: +// - SKIP - Do not block, output nothing. +// - TRIM - Do not block, output as much as fits. +// - BLOCK - Wait until there is space in the buffer. +// <0=> SKIP +// <1=> TRIM +// <2=> BLOCK_IF_FIFO_FULL + +#ifndef SEGGER_RTT_CONFIG_DEFAULT_MODE +#define SEGGER_RTT_CONFIG_DEFAULT_MODE 0 +#endif + +// +//========================================================== + +// +//========================================================== + +// nRF_SoftDevice + +//========================================================== +// NRF_SDH_BLE_ENABLED - nrf_sdh_ble - SoftDevice BLE event handler +//========================================================== +#ifndef NRF_SDH_BLE_ENABLED +#define NRF_SDH_BLE_ENABLED 1 +#endif +// BLE Stack configuration - Stack configuration parameters + +// The SoftDevice handler will configure the stack with these parameters when calling @ref nrf_sdh_ble_default_cfg_set. +// Other libraries might depend on these values; keep them up-to-date even if you are not explicitely calling @ref nrf_sdh_ble_default_cfg_set. +//========================================================== +// NRF_SDH_BLE_GAP_DATA_LENGTH <27-251> + + +// Requested BLE GAP data length to be negotiated. + +#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH +#define NRF_SDH_BLE_GAP_DATA_LENGTH 27 +#endif + +// NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. +#ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT +#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 1 +#endif + +// NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. +#ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT +#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0 +#endif + +// NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. +// Maximum number of total concurrent connections using the default configuration. + +#ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT +#define NRF_SDH_BLE_TOTAL_LINK_COUNT 1 +#endif + +// NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. +// The time set aside for this connection on every connection interval in 1.25 ms units. + +#ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH +#define NRF_SDH_BLE_GAP_EVENT_LENGTH 6 +#endif + +// NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. +#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE +#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247 +#endif + +// NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4. +#ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE +#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408 +#endif + +// NRF_SDH_BLE_VS_UUID_COUNT - The number of vendor-specific UUIDs. +#ifndef NRF_SDH_BLE_VS_UUID_COUNT +#define NRF_SDH_BLE_VS_UUID_COUNT 10 +#endif + +// NRF_SDH_BLE_SERVICE_CHANGED - Include the Service Changed characteristic in the Attribute Table. + + +#ifndef NRF_SDH_BLE_SERVICE_CHANGED +#define NRF_SDH_BLE_SERVICE_CHANGED 0 +#endif + +// +//========================================================== + +// BLE Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_BLE_OBSERVER_PRIO_LEVELS - Total number of priority levels for BLE observers. +// This setting configures the number of priority levels available for BLE event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_BLE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_BLE_OBSERVER_PRIO_LEVELS 4 +#endif + +// BLE Observers priorities - Invididual priorities + +//========================================================== +// BLE_ADV_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Advertising module. + +#ifndef BLE_ADV_BLE_OBSERVER_PRIO +#define BLE_ADV_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_ANCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Apple Notification Service Client. + +#ifndef BLE_ANCS_C_BLE_OBSERVER_PRIO +#define BLE_ANCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_ANS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Alert Notification Service Client. + +#ifndef BLE_ANS_C_BLE_OBSERVER_PRIO +#define BLE_ANS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service. + +#ifndef BLE_BAS_BLE_OBSERVER_PRIO +#define BLE_BAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Battery Service Client. + +#ifndef BLE_BAS_C_BLE_OBSERVER_PRIO +#define BLE_BAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_BPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Blood Pressure Service. + +#ifndef BLE_BPS_BLE_OBSERVER_PRIO +#define BLE_BPS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection parameters module. + +#ifndef BLE_CONN_PARAMS_BLE_OBSERVER_PRIO +#define BLE_CONN_PARAMS_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_CONN_STATE_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Connection State module. + +#ifndef BLE_CONN_STATE_BLE_OBSERVER_PRIO +#define BLE_CONN_STATE_BLE_OBSERVER_PRIO 0 +#endif + +// BLE_CSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Cycling Speed and Cadence Service. + +#ifndef BLE_CSCS_BLE_OBSERVER_PRIO +#define BLE_CSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_CTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Current Time Service Client. + +#ifndef BLE_CTS_C_BLE_OBSERVER_PRIO +#define BLE_CTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DB_DISC_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Database Discovery module. + +#ifndef BLE_DB_DISC_BLE_OBSERVER_PRIO +#define BLE_DB_DISC_BLE_OBSERVER_PRIO 1 +#endif + +// BLE_DFU_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_BLE_OBSERVER_PRIO +#define BLE_DFU_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_DIS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Device Information Client. + +#ifndef BLE_DIS_C_BLE_OBSERVER_PRIO +#define BLE_DIS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_GLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Glucose Service. + +#ifndef BLE_GLS_BLE_OBSERVER_PRIO +#define BLE_GLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HIDS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Human Interface Device Service. + +#ifndef BLE_HIDS_BLE_OBSERVER_PRIO +#define BLE_HIDS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service. + +#ifndef BLE_HRS_BLE_OBSERVER_PRIO +#define BLE_HRS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HRS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Heart Rate Service Client. + +#ifndef BLE_HRS_C_BLE_OBSERVER_PRIO +#define BLE_HRS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_HTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Health Thermometer Service. + +#ifndef BLE_HTS_BLE_OBSERVER_PRIO +#define BLE_HTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service. + +#ifndef BLE_IAS_BLE_OBSERVER_PRIO +#define BLE_IAS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_IAS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Immediate Alert Service Client. + +#ifndef BLE_IAS_C_BLE_OBSERVER_PRIO +#define BLE_IAS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service. + +#ifndef BLE_LBS_BLE_OBSERVER_PRIO +#define BLE_LBS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LBS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the LED Button Service Client. + +#ifndef BLE_LBS_C_BLE_OBSERVER_PRIO +#define BLE_LBS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LLS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Link Loss Service. + +#ifndef BLE_LLS_BLE_OBSERVER_PRIO +#define BLE_LLS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_LNS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Location Navigation Service. + +#ifndef BLE_LNS_BLE_OBSERVER_PRIO +#define BLE_LNS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Service. + +#ifndef BLE_NUS_BLE_OBSERVER_PRIO +#define BLE_NUS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_NUS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the UART Central Service. + +#ifndef BLE_NUS_C_BLE_OBSERVER_PRIO +#define BLE_NUS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service. + +#ifndef BLE_OTS_BLE_OBSERVER_PRIO +#define BLE_OTS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_OTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Object transfer service client. + +#ifndef BLE_OTS_C_BLE_OBSERVER_PRIO +#define BLE_OTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Service. + +#ifndef BLE_RSCS_BLE_OBSERVER_PRIO +#define BLE_RSCS_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_RSCS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Running Speed and Cadence Client. + +#ifndef BLE_RSCS_C_BLE_OBSERVER_PRIO +#define BLE_RSCS_C_BLE_OBSERVER_PRIO 2 +#endif + +// BLE_TPS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the TX Power Service. + +#ifndef BLE_TPS_BLE_OBSERVER_PRIO +#define BLE_TPS_BLE_OBSERVER_PRIO 2 +#endif + +// BSP_BTN_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Button Control module. + +#ifndef BSP_BTN_BLE_OBSERVER_PRIO +#define BSP_BTN_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the NFC pairing library. + +#ifndef NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO +#define NFC_BLE_PAIR_LIB_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_BMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Bond Management Service. + +#ifndef NRF_BLE_BMS_BLE_OBSERVER_PRIO +#define NRF_BLE_BMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_CGMS_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Contiuon Glucose Monitoring Service. + +#ifndef NRF_BLE_CGMS_BLE_OBSERVER_PRIO +#define NRF_BLE_CGMS_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_ES_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Eddystone module. + +#ifndef NRF_BLE_ES_BLE_OBSERVER_PRIO +#define NRF_BLE_ES_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT Service Client. + +#ifndef NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO +#define NRF_BLE_GATTS_C_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_GATT_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the GATT module. + +#ifndef NRF_BLE_GATT_BLE_OBSERVER_PRIO +#define NRF_BLE_GATT_BLE_OBSERVER_PRIO 1 +#endif + +// NRF_BLE_QWR_BLE_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the Queued writes module. + +#ifndef NRF_BLE_QWR_BLE_OBSERVER_PRIO +#define NRF_BLE_QWR_BLE_OBSERVER_PRIO 2 +#endif + +// NRF_BLE_SCAN_OBSERVER_PRIO +// Priority for dispatching the BLE events to the Scanning Module. + +#ifndef NRF_BLE_SCAN_OBSERVER_PRIO +#define NRF_BLE_SCAN_OBSERVER_PRIO 1 +#endif + +// PM_BLE_OBSERVER_PRIO - Priority with which BLE events are dispatched to the Peer Manager module. +#ifndef PM_BLE_OBSERVER_PRIO +#define PM_BLE_OBSERVER_PRIO 1 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_ENABLED - nrf_sdh - SoftDevice handler +//========================================================== +#ifndef NRF_SDH_ENABLED +#define NRF_SDH_ENABLED 1 +#endif +// Dispatch model + +// This setting configures how Stack events are dispatched to the application. +//========================================================== +// NRF_SDH_DISPATCH_MODEL + + +// NRF_SDH_DISPATCH_MODEL_INTERRUPT: SoftDevice events are passed to the application from the interrupt context. +// NRF_SDH_DISPATCH_MODEL_APPSH: SoftDevice events are scheduled using @ref app_scheduler. +// NRF_SDH_DISPATCH_MODEL_POLLING: SoftDevice events are to be fetched manually. +// <0=> NRF_SDH_DISPATCH_MODEL_INTERRUPT +// <1=> NRF_SDH_DISPATCH_MODEL_APPSH +// <2=> NRF_SDH_DISPATCH_MODEL_POLLING + +#ifndef NRF_SDH_DISPATCH_MODEL +#define NRF_SDH_DISPATCH_MODEL 0 +#endif + +// +//========================================================== + +// Clock - SoftDevice clock configuration + +//========================================================== +// NRF_SDH_CLOCK_LF_SRC - SoftDevice clock source. + +// <0=> NRF_CLOCK_LF_SRC_RC +// <1=> NRF_CLOCK_LF_SRC_XTAL +// <2=> NRF_CLOCK_LF_SRC_SYNTH + +#ifndef NRF_SDH_CLOCK_LF_SRC +#define NRF_SDH_CLOCK_LF_SRC 1 +#endif + +// NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. +#ifndef NRF_SDH_CLOCK_LF_RC_CTIV +#define NRF_SDH_CLOCK_LF_RC_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. +// How often (in number of calibration intervals) the RC oscillator shall be calibrated +// if the temperature has not changed. + +#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV +#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0 +#endif + +// NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing. + +// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM +// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM +// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM +// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM +// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM +// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM +// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM +// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM +// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM +// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM +// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM +// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM + +#ifndef NRF_SDH_CLOCK_LF_ACCURACY +#define NRF_SDH_CLOCK_LF_ACCURACY 7 +#endif + +// +//========================================================== + +// SDH Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_REQ_OBSERVER_PRIO_LEVELS - Total number of priority levels for request observers. +// This setting configures the number of priority levels available for the SoftDevice request event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_REQ_OBSERVER_PRIO_LEVELS +#define NRF_SDH_REQ_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STATE_OBSERVER_PRIO_LEVELS - Total number of priority levels for state observers. +// This setting configures the number of priority levels available for the SoftDevice state event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STATE_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STATE_OBSERVER_PRIO_LEVELS 2 +#endif + +// NRF_SDH_STACK_OBSERVER_PRIO_LEVELS - Total number of priority levels for stack event observers. +// This setting configures the number of priority levels available for the SoftDevice stack event handlers (ANT, BLE, SoC). +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_STACK_OBSERVER_PRIO_LEVELS +#define NRF_SDH_STACK_OBSERVER_PRIO_LEVELS 2 +#endif + + +// State Observers priorities - Invididual priorities + +//========================================================== +// CLOCK_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_STATE_OBSERVER_PRIO +#define CLOCK_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_STATE_OBSERVER_PRIO +#define POWER_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// RNG_CONFIG_STATE_OBSERVER_PRIO +// Priority with which state events are dispatched to this module. + +#ifndef RNG_CONFIG_STATE_OBSERVER_PRIO +#define RNG_CONFIG_STATE_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// Stack Event Observers priorities - Invididual priorities + +//========================================================== +// NRF_SDH_ANT_STACK_OBSERVER_PRIO +// This setting configures the priority with which ANT events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have ANT events dispatched before or after other stack events, such as BLE or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_ANT_STACK_OBSERVER_PRIO +#define NRF_SDH_ANT_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_BLE_STACK_OBSERVER_PRIO +// This setting configures the priority with which BLE events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have BLE events dispatched before or after other stack events, such as ANT or SoC. +// Zero is the highest priority. + +#ifndef NRF_SDH_BLE_STACK_OBSERVER_PRIO +#define NRF_SDH_BLE_STACK_OBSERVER_PRIO 0 +#endif + +// NRF_SDH_SOC_STACK_OBSERVER_PRIO +// This setting configures the priority with which SoC events are processed with respect to other events coming from the stack. +// Modify this setting if you need to have SoC events dispatched before or after other stack events, such as ANT or BLE. +// Zero is the highest priority. + +#ifndef NRF_SDH_SOC_STACK_OBSERVER_PRIO +#define NRF_SDH_SOC_STACK_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// NRF_SDH_SOC_ENABLED - nrf_sdh_soc - SoftDevice SoC event handler +//========================================================== +#ifndef NRF_SDH_SOC_ENABLED +#define NRF_SDH_SOC_ENABLED 1 +#endif +// SoC Observers - Observers and priority levels + +//========================================================== +// NRF_SDH_SOC_OBSERVER_PRIO_LEVELS - Total number of priority levels for SoC observers. +// This setting configures the number of priority levels available for the SoC event handlers. +// The priority level of a handler determines the order in which it receives events, with respect to other handlers. + +#ifndef NRF_SDH_SOC_OBSERVER_PRIO_LEVELS +#define NRF_SDH_SOC_OBSERVER_PRIO_LEVELS 2 +#endif + +// SoC Observers priorities - Invididual priorities + +//========================================================== +// BLE_ADV_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Advertising module. + +#ifndef BLE_ADV_SOC_OBSERVER_PRIO +#define BLE_ADV_SOC_OBSERVER_PRIO 1 +#endif + +// BLE_DFU_SOC_OBSERVER_PRIO +// Priority with which BLE events are dispatched to the DFU Service. + +#ifndef BLE_DFU_SOC_OBSERVER_PRIO +#define BLE_DFU_SOC_OBSERVER_PRIO 1 +#endif + +// CLOCK_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Clock driver. + +#ifndef CLOCK_CONFIG_SOC_OBSERVER_PRIO +#define CLOCK_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// POWER_CONFIG_SOC_OBSERVER_PRIO +// Priority with which SoC events are dispatched to the Power driver. + +#ifndef POWER_CONFIG_SOC_OBSERVER_PRIO +#define POWER_CONFIG_SOC_OBSERVER_PRIO 0 +#endif + +// +//========================================================== + +// +//========================================================== + + +// + +// +//========================================================== + +// <<< end of configuration section >>> +#endif //SDK_CONFIG_H + + diff --git a/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/readme.md b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/readme.md new file mode 100644 index 00000000..7ffc7068 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/samples/nrf52832/readme.md @@ -0,0 +1,7 @@ +# 说明 + +1. 本工程基于 nRF52832 平台开发,使用的 SDK 版本为 `nRF5_SDK_15.3.0_59ac345`,如需其他版本 SDK,请前往 [NORDIC 官网](https://www.nordicsemi.com/Software-and-tools/Software/nRF5-SDK/Download) 下载 +2. 蓝牙协议栈为 s132 版本,在 NORDIC SDK 中的路径为 `\components\softdevice\s132\hex\s132_nrf52_6.1.1_softdevice.hex`,请根据实际需要自行烧录协议栈 +3. Keil工程的DeviceFamilyPack为 `NordicSemiconductor.nRF_DeviceFamilyPack.8.24.1.pack`,如需其他 pack 请前往 [NORDIC 官网](http://developer.nordicsemi.com/nRF51_SDK/pieces/nRF_DeviceFamilyPack/) 下载 +4. 例程keil工程文件路径 `\qcloud_iot_explorer_ble\samples\nrf52832\pca10040\s132\arm5_no_packs` +5. 使用 code_extract.py 脚本抽取代码得到 `qcloud-iot-ble-nrf52832` 目录,请将该目录放置 NORDIC SDK 的 `\examples\ble_peripheral` 目录下,打开keil工程编译即可 diff --git a/components/connectivity/qcloud_iot_explorer_ble/scripts/code_extract/code_extract.py b/components/connectivity/qcloud_iot_explorer_ble/scripts/code_extract/code_extract.py new file mode 100644 index 00000000..5027bbf3 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/scripts/code_extract/code_extract.py @@ -0,0 +1,74 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +import sys +import os +import shutil + +demo_dir_prefix = 'qcloud-iot-ble-' +script_path = os.path.split(os.path.realpath(__file__))[0] +sdk_path = os.path.join(script_path, '..', '..') + + +def extract_nrf2832(dest_dir): + print('extract code for nrf52832 start, dest dir %s' % dest_dir) + if os.path.exists(dest_dir): + shutil.rmtree(dest_dir) + shutil.copytree(os.path.join(sdk_path, 'samples', 'nrf52832'), dest_dir) + + new_sdk_path = os.path.join(dest_dir, 'qcloud_iot_explorer_ble') + shutil.copytree(os.path.join(sdk_path, 'inc'), os.path.join(new_sdk_path, 'inc')) + shutil.copytree(os.path.join(sdk_path, 'src'), os.path.join(new_sdk_path, 'src')) + print('extract code success') + pass + + +def extract_esp32(dest_dir): + print('extract code for esp32, dest dir %s' % dest_dir) + if os.path.exists(dest_dir): + shutil.rmtree(dest_dir) + shutil.copytree(os.path.join(sdk_path, 'samples', 'esp32'), dest_dir) + + new_sdk_path = os.path.join(dest_dir, 'components', 'qcloud_llsync') + shutil.copytree(os.path.join(sdk_path, 'inc'), os.path.join(new_sdk_path, 'inc')) + shutil.copytree(os.path.join(sdk_path, 'src'), os.path.join(new_sdk_path, 'src')) + + print('extract code success') + pass + + +def extract_lifesense(dest_dir): + print('extract code for lifesense, dest dir %s' % dest_dir) + if os.path.exists(dest_dir): + shutil.rmtree(dest_dir) + shutil.copytree(os.path.join(sdk_path, 'samples', 'lifesense'), dest_dir) + + new_sdk_path = os.path.join(dest_dir, 'qcloud_iot_explorer_ble') + shutil.copytree(os.path.join(sdk_path, 'inc'), os.path.join(new_sdk_path, 'inc')) + shutil.copytree(os.path.join(sdk_path, 'src'), os.path.join(new_sdk_path, 'src')) + + print('extract code success') + pass + + +if __name__ == '__main__': + if len(sys.argv) < 2: + print('\nUsage: python3 %s [dest dir]' % sys.argv[0]) + print('\nDefinitions:') + print('\t%s' % 'Device type. The following are allowed: nrf52832, esp32, lefesense') + print('[dest dir]\t%s %s\n' % ('Where the code stored. Default path: ', script_path)) + else: + if len(sys.argv) == 2: + dest_dir = os.path.join(script_path, demo_dir_prefix + sys.argv[1]) + else: + dest_dir = os.path.join(sys.argv[2], demo_dir_prefix + sys.argv[1]) + + if 'nrf52832' == sys.argv[1]: + extract_nrf2832(dest_dir) + elif 'esp32' == sys.argv[1]: + extract_esp32(dest_dir) + elif 'lifesense' == sys.argv[1]: + extract_lifesense(dest_dir) + else: + print('Unknow platform %s, extract failed' % sys.argv[1]) + pass diff --git a/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/config/dt.conf b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/config/dt.conf new file mode 100644 index 00000000..4acdac73 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/config/dt.conf @@ -0,0 +1,109 @@ +# 文件统一定义 +[FILE] +COPYRIGHT = /* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +NAME_PREFIX = ble_qiot_template +MACRO_PREFIX = BLE_QIOT_ +ENUM_PREFIX = BLE_QIOT_ + +# json文本内健定义 +[JSON] +VERSION = version +PROPERTY = properties +MODE = mode +EVENT = events +TYPE = type +PARAMS = params +ACTION = actions +INPUT = input +OUTPUT = output +ID = id +DEFINE = define +MAPPING = mapping +UNIT = unit +BOOL = bool +ENUM = enum +STRING = string +FLOAT = float +INT = int +TIME = timestamp + +# 数据类型定义 +# 左侧数值表示实际数值,默认从0开始枚举 +# BUTT表示最大值 +[DATA_TYPE] +0 = BOOL +1 = INT +2 = STRING +3 = FLOAT +4 = ENUM +5 = TIME +6 = BUTT + +# 消息类型定义 +# 左侧数值表示实际数值,默认从0开始枚举 +# BUTT表示最大值 +[MSG_TYPE] +0 = PROPERTY +1 = EVENT +2 = ACTION +3 = BUTT + +# Property 读写属性定义 +# 左侧数值表示实际数值,默认从0开始枚举 +# BUTT表示最大值 +[PROPERTY_AUTH] +0 = RW +1 = READ +2 = BUTT + +# 数据功能,请求 or 回复 +# 左侧数值表示实际数值,默认从0开始枚举 +# BUTT表示最大值 +[EFFECT] +0= REQUEST +1 = REPLY +2 = BUTT + +# Reply消息结果定义 +# 左侧数值表示实际数值,默认从0开始枚举 +# BUTT表示最大值 +[REPLY] +0 = SUCCESS +1 = FAIL +2 = DATA_ERR +3 = BUTT + +# 服务端向设备端下发消息类型定义 +# 左侧数值表示实际数值,默认从0开始枚举 +# BUTT表示最大值 +[DATA_DOWN] +0 = REPORT_REPLY +1 = CONTROL +2 = GET_STATUS_REPLY +3 = ACTION +4 = EVENT_REPLY + +# 设备端向服务端上报消息类型定义 +# 左侧数值表示实际数值,默认从0开始枚举 +# BUTT表示最大值 +[EVENT_UP] +0 = PROPERTY_REPORT +1 = CONTROL_REPLY +2 = GET_STATUS +3 = EVENT_POST +4 = ACTION_REPLY +5 = BIND_SIGN_RET +6 = CONN_SIGN_RET +7 = UNBIND_SIGN_RET +8 = REPORT_MTU +9 = BUTT diff --git a/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/readme.md b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/readme.md new file mode 100644 index 00000000..3054b5a2 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/readme.md @@ -0,0 +1,60 @@ +## 介绍 +使用`python`脚本将后台生成的`json`格式的数据模版文件转为`c`代码文件。 +极大的减少了用户的开发工作,同时保证了终端设备,网关设备上数据定义的一致性。 +请使用`python3`解释器运行。 + +## 目录结构 +```c +interpret_json_dt +├─config # 配置文件目录 +│ └─dt.conf # INI配置文件 +├─src # 脚本文件目录 +│ ├─dt_fixed_content # 固定代码文件目录 +│ │ └─dt_ble_action # ble action部分固定代码 +│ │ └─dt_ble_event # ble event部分固定代码 +│ │ └─dt_ble_property # ble proerty部分固定代码 +│ │ └─dt_ble_prototype # ble 函数原型 +│ │ └─dt_gateway_action # gateway action部分固定代码 +│ │ └─dt_gateway_event # gateway event部分固定代码 +│ │ └─dt_gateway_property # gateway property部分固定代码 +│ │ └─dt_gateway_prototype # gateway 函数原型 +│ ├─interpret_dt_ble.py # 转换json脚本生成ble sdk代码 +│ ├─interpret_dt_gateway.py # 转换json脚本生成网关代码 +│ ├─example.json # 示例文件 +``` + +## 代码生成原理 +采取`动态生成 + 固定写入`的方式来生成代码。 +* 动态生成:通过脚本解析`json`文件,将数据模版转换为对应的代码 +* 固定写入:数据模版的操作函数是固定不变的,从静态文件读取写入,达到简化脚本的目的 + +### 头文件生成 +1. 按照`LLSync协议`定义写入公共定义,包括数据类型定义,消息类型定义等 +2. 解析`json`文件,将字符串`id`转换为枚举类型`id` +3. 将每个`id`对应的值根据其类型进行转换 + * 对于枚举类型,将其枚举值转换为枚举类型 + * 对于整数类型或浮点数类型,将其最大值,最小值,起始值,步进转换为宏定义 + * 对于字符串类型,将其最大长度,最小长度转换为宏定义 +4. 写入不同数据类型的结构体定义 +5. 写入不同数据类型的函数声明,函数声明从`dt_gateway_prototype`中读 + +### BLE C文件生成 +1. 解析`json`文件,根据`id`生成其操作函数,**操作函数需要用户按照需求实现** +2. 解析`json`文件,生成数据模版的结构数组 +3. 读取静态文件,写入固定操作函数 + +### 网关C文件生成 +1. 解析`json`文件,生成数据模版的结构数组 +2. 读取静态文件,写入固定操作函数 + +## 使用方法 +### BLE SDK +1. 从物联网平台下载数据模版`json`文件 +2. 执行`python3 interpret_dt_ble.py `来生成对应的数据模版文件 +3. 按照数据特性实现`ble_qiot_template.c`中的操作函数 +4. 将生成文件拷贝到`data_template`目录编译即可 + +### 网关 +1. 从物联网平台下载数据模版`json`文件 +2. 执行`python3 interpret_dt_gateway.py `来生成对应的数据模版文件 +3. 将生成文件拷贝SDK编译即可。 \ No newline at end of file diff --git a/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_action b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_action new file mode 100644 index 00000000..45e75dbf --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_action @@ -0,0 +1,96 @@ +uint8_t ble_action_get_intput_type_by_id(uint8_t action_id, uint8_t input_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (input_id >= sg_ble_event_array[action_id].array_size) { + ble_qiot_log_e("invalid input id %d", input_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_action_array[action_id].input_type_array[input_id]; +} + +uint8_t ble_action_get_output_type_by_id(uint8_t action_id, uint8_t output_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (output_id >= sg_ble_event_array[action_id].array_size) { + ble_qiot_log_e("invalid output id %d", output_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_action_array[action_id].output_type_array[output_id]; +} + +int ble_action_get_input_id_size(uint8_t action_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + return sg_ble_action_array[action_id].input_id_size; +} + +int ble_action_get_output_id_size(uint8_t action_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + return sg_ble_action_array[action_id].output_id_size; +} + +int ble_action_user_handle_input_param(uint8_t action_id, e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + if (NULL != sg_ble_action_array[action_id].input_cb) { + if (0 != sg_ble_action_array[action_id].input_cb(input_param_array, input_array_size, output_id_array)) { + ble_qiot_log_e("input handle error"); + return -1; + } + } + + return 0; +} + +int ble_action_user_handle_output_param(uint8_t action_id, uint8_t output_id, char *buf, uint16_t buf_len) +{ + int ret_len = 0; + + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + if (NULL == sg_ble_action_array[action_id].output_cb){ + ble_qiot_log_e("invalid callback, action id %d", action_id); + return 0; + } + + if (!ble_check_space_enough_by_type(sg_ble_action_array[action_id].output_type_array[output_id], buf_len)) { + ble_qiot_log_e("not enough space get data, action id %d, output id %d", action_id, output_id); + return -1; + } + + ret_len = sg_ble_action_array[action_id].output_cb(output_id, buf, buf_len); + if (ret_len < 0) { + ble_qiot_log_e("get action data failed, action id %d, output id %d", action_id, output_id); + return -1; + }else { + if (ble_check_ret_value_by_type(sg_ble_action_array[action_id].output_type_array[output_id], buf_len, ret_len)){ + return ret_len; + }else{ + ble_qiot_log_e("action data length invalid, action id %d, output id %d", action_id, output_id); + return -1; + } + } +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_event b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_event new file mode 100644 index 00000000..7fbe525c --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_event @@ -0,0 +1,65 @@ +int ble_event_get_id_array_size(uint8_t event_id) +{ + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return -1; + } + + return sg_ble_event_array[event_id].array_size; +} + +uint8_t ble_event_get_param_id_type(uint8_t event_id, uint8_t param_id) +{ + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (param_id >= sg_ble_event_array[event_id].array_size) { + ble_qiot_log_e("invalid param id %d", param_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_event_array[event_id].event_array[param_id].type; +} + +int ble_event_get_data_by_id(uint8_t event_id, uint8_t param_id, char *out_buf, uint16_t buf_len) +{ + int ret_len = 0; + + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return -1; + } + if (param_id >= sg_ble_event_array[event_id].array_size) { + ble_qiot_log_e("invalid param id %d", param_id); + return -1; + } + if (NULL == sg_ble_event_array[event_id].event_array[param_id].get_cb) { + ble_qiot_log_e("invalid callback, event id %d, param id %d", event_id, param_id); + return 0; + } + + if (!ble_check_space_enough_by_type(sg_ble_event_array[event_id].event_array[param_id].type, buf_len)) { + ble_qiot_log_e("not enough space get data, event id %d, param id %d", event_id, param_id); + return -1; + } + ret_len = sg_ble_event_array[event_id].event_array[param_id].get_cb(out_buf, buf_len); + if (ret_len < 0) { + ble_qiot_log_e("get event data failed, event id %d, param id %d", event_id, param_id); + return -1; + }else { + if (ble_check_ret_value_by_type(sg_ble_event_array[event_id].event_array[param_id].type, buf_len, ret_len)){ + return ret_len; + }else{ + ble_qiot_log_e("evnet data length invalid, event id %d, param id %d", event_id, param_id); + return -1; + } + } +} + +int ble_user_event_reply_handle(uint8_t event_id, uint8_t result) +{ + ble_qiot_log_d("event id %d, reply result %d", event_id, result); + + return BLE_QIOT_RS_OK; +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_property b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_property new file mode 100644 index 00000000..3783784f --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_property @@ -0,0 +1,105 @@ +static bool ble_check_space_enough_by_type(uint8_t type, uint16_t left_size) +{ + switch(type) + { + case BLE_QIOT_DATA_TYPE_BOOL: + return left_size >= sizeof(uint8_t); + case BLE_QIOT_DATA_TYPE_INT: + case BLE_QIOT_DATA_TYPE_FLOAT: + case BLE_QIOT_DATA_TYPE_TIME: + return left_size >= sizeof(uint32_t); + case BLE_QIOT_DATA_TYPE_ENUM: + return left_size >= sizeof(uint16_t); + default: + // string length is unknow, default true + return true; + } +} + +static uint16_t ble_check_ret_value_by_type(uint8_t type, uint16_t buf_len, uint16_t ret_val) +{ + switch(type) + { + case BLE_QIOT_DATA_TYPE_BOOL: + return ret_val <= sizeof(uint8_t); + case BLE_QIOT_DATA_TYPE_INT: + case BLE_QIOT_DATA_TYPE_FLOAT: + case BLE_QIOT_DATA_TYPE_TIME: + return ret_val <= sizeof(uint32_t); + case BLE_QIOT_DATA_TYPE_ENUM: + return ret_val <= sizeof(uint16_t); + default: + // string length is unknow, default true + return ret_val <= buf_len; + } +} + +uint8_t ble_get_property_type_by_id(uint8_t id) +{ + if (id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + return sg_ble_property_array[id].type; +} + +int ble_user_property_set_data(const e_ble_tlv *tlv) +{ + POINTER_SANITY_CHECK(tlv, BLE_QIOT_RS_ERR_PARA); + if (tlv->id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", tlv->id); + return BLE_QIOT_RS_ERR; + } + + if (NULL != sg_ble_property_array[tlv->id].set_cb) { + if (0 != sg_ble_property_array[tlv->id].set_cb(tlv->val, tlv->len)) { + ble_qiot_log_e("set property id %d failed", tlv->id); + return BLE_QIOT_RS_ERR; + }else { + return BLE_QIOT_RS_OK; + } + } + ble_qiot_log_e("invalid set callback, id %d", tlv->id); + + return BLE_QIOT_RS_ERR; +} + +int ble_user_property_get_data_by_id(uint8_t id, char *buf, uint16_t buf_len) +{ + int ret_len = 0; + + POINTER_SANITY_CHECK(buf, BLE_QIOT_RS_ERR_PARA); + if (id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", id); + return -1; + } + + if (NULL != sg_ble_property_array[id].get_cb) { + if (!ble_check_space_enough_by_type(sg_ble_property_array[id].type, buf_len)) { + ble_qiot_log_e("not enough space get property id %d data", id); + return -1; + } + ret_len = sg_ble_property_array[id].get_cb(buf, buf_len); + if (ret_len < 0) { + ble_qiot_log_e("get property id %d data failed", id); + return -1; + }else { + if (ble_check_ret_value_by_type(sg_ble_property_array[id].type, buf_len, ret_len)){ + return ret_len; + }else{ + ble_qiot_log_e("property id %d length invalid", id); + return -1; + } + } + } + ble_qiot_log_e("invalid callback, property id %d", id); + + return 0; +} + +int ble_user_property_report_reply_handle(uint8_t result) +{ + ble_qiot_log_d("report reply result %d", result); + + return BLE_QIOT_RS_OK; +} diff --git a/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_prototype b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_prototype new file mode 100644 index 00000000..8fd8a2bb --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/dt_fixed_content/dt_ble_prototype @@ -0,0 +1,25 @@ +// property module +#ifdef BLE_QIOT_INCLUDE_PROPERTY +uint8_t ble_get_property_type_by_id(uint8_t id); +int ble_user_property_set_data(const e_ble_tlv *tlv); +int ble_user_property_get_data_by_id(uint8_t id, char *buf, uint16_t buf_len); +int ble_user_property_report_reply_handle(uint8_t result); +#endif + +// event module +#ifdef BLE_QIOT_INCLUDE_EVENT +int ble_event_get_id_array_size(uint8_t event_id); +uint8_t ble_event_get_param_id_type(uint8_t event_id, uint8_t param_id); +int ble_event_get_data_by_id(uint8_t event_id, uint8_t param_id, char *out_buf, uint16_t buf_len); +int ble_user_event_reply_handle(uint8_t event_id, uint8_t result); +#endif + +// action module +#ifdef BLE_QIOT_INCLUDE_ACTION +uint8_t ble_action_get_intput_type_by_id(uint8_t action_id, uint8_t input_id); +uint8_t ble_action_get_output_type_by_id(uint8_t action_id, uint8_t output_id); +int ble_action_get_input_id_size(uint8_t action_id); +int ble_action_get_output_id_size(uint8_t action_id); +int ble_action_user_handle_input_param(uint8_t action_id, e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array); +int ble_action_user_handle_output_param(uint8_t action_id, uint8_t output_id, char *buf, uint16_t buf_len); +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/interpret_dt_ble.py b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/interpret_dt_ble.py new file mode 100644 index 00000000..d6db8319 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/scripts/interpret_json_dt/src/interpret_dt_ble.py @@ -0,0 +1,607 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- +import sys +import json +import os +import configparser + +script_path = os.path.split(os.path.realpath(__file__))[0] +dt_config = configparser.ConfigParser() + + +def _dt_get_config_from_file(): + config_file = open(os.path.join(script_path, '..', 'config', 'dt.conf'), 'r', encoding='UTF-8') + config_content = config_file.read() + config_file.close() + dt_config.read_string(config_content) + pass + + +def _dt_get_json_from_file(filenmae): + _dt_get_config_from_file() + json_file = open(filenmae, 'r', encoding='UTF-8') + file_content = json_file.read() + json_file.close() + return json.loads(file_content) + + +def _dt_write_newline_to_file(write_fd, write_buf): + write_fd.writelines(write_buf + '\n') + pass + + +def _dt_write_macro_to_file(write_fd, macro, macro_val): + write_fd.writelines('#define\t%-40s\t%-32s\n' % (dt_config['FILE']['MACRO_PREFIX'] + + macro.upper(), macro_val.upper())) + pass + + +def _dt_write_enum_to_file(write_fd, enum_comments, enum_prefix, enum_suffix_list, enum_value_list=None): + init_flag = True + write_fd.writelines('\n' + enum_comments + '\n') + write_fd.writelines('enum {\n') + + if enum_value_list == None: + for enum_suffix in enum_suffix_list: + if init_flag: + write_fd.writelines('\t' + dt_config['FILE']['ENUM_PREFIX'] + + (enum_prefix + '_' + enum_suffix).upper() + ' = 0,\n') + init_flag = False + else: + write_fd.writelines('\t' + dt_config['FILE']['ENUM_PREFIX'] + + (enum_prefix + '_' + enum_suffix).upper() + ',\n') + else: + for idx, enum_suffix in enumerate(enum_suffix_list): + write_fd.writelines('\t' + dt_config['FILE']['ENUM_PREFIX'] + + (enum_prefix + '_' + enum_suffix).upper() + ' = %s,\n' % enum_value_list[idx]) + + write_fd.writelines('};\n') + pass + + +def _dt_get_enum_list_from_conf(conf_data): + return [v for k, v in conf_data.items()] + + +def _dt_get_enum_list_from_ids(property_json): + id_list = [value.get('id') for value in property_json] + id_list.append('BUTT') + return id_list + + +def _dt_get_enum_list_from_mapping(mapping): + new_list = sorted(mapping.keys()) + enum_prefix = [mapping[key] for key in new_list] + enum_prefix.append('BUTT') + enum_val = [key for key in new_list] + enum_val.append(str(int(new_list[-1]) + 1)) + + return [enum_prefix, enum_val] + + +def _dt_not_exist(dt_data): + if not dt_data: + return True + else: + return False + + +def _dt_write_public_header(write_fd): + _dt_write_enum_to_file(write_fd, '// data type in template, corresponding to type in json file', + dt_config['DATA_TYPE'].name, + _dt_get_enum_list_from_conf(dt_config['DATA_TYPE'])) + _dt_write_enum_to_file(write_fd, '// message type, reference data template ', dt_config['MSG_TYPE'].name, + _dt_get_enum_list_from_conf(dt_config['MSG_TYPE'])) + _dt_write_enum_to_file(write_fd, '// define property authority, not used', dt_config['PROPERTY_AUTH'].name, + _dt_get_enum_list_from_conf(dt_config['PROPERTY_AUTH'])) + _dt_write_enum_to_file(write_fd, '// define reply result', dt_config['REPLY'].name, + _dt_get_enum_list_from_conf(dt_config['REPLY'])) + _dt_write_enum_to_file(write_fd, '// define message flow direction', dt_config['EFFECT'].name, + _dt_get_enum_list_from_conf(dt_config['EFFECT'])) + _dt_write_enum_to_file(write_fd, '// define message type that from server to device', dt_config['DATA_DOWN'].name, + _dt_get_enum_list_from_conf(dt_config['DATA_DOWN'])) + _dt_write_enum_to_file(write_fd, '// define message type that from device to server', dt_config['EVENT_UP'].name, + _dt_get_enum_list_from_conf(dt_config['EVENT_UP'])) + + _dt_write_newline_to_file(write_fd, + '\n// msg header define, bit 7-6 is msg type, bit 5 means request or reply, bit 4 - 0 is id') + _dt_write_macro_to_file(write_fd, 'PARSE_MSG_HEAD_TYPE(_c)', '(((_c) & 0xFF) >> 6)') + _dt_write_macro_to_file(write_fd, 'PARSE_MSG_HEAD_EFFECT(_c)', + '((((_c) & 0xFF) & 0x20) ? BLE_QIOT_EFFECT_REPLY : BLE_QIOT_EFFECT_REQUEST)') + _dt_write_macro_to_file(write_fd, 'PARSE_MSG_HEAD_ID(_c)', '((_c) & 0x1F)') + _dt_write_macro_to_file(write_fd, 'PACKAGE_MSG_HEAD(_type, _reply, _id)', + '(((_type) << 6) | (((_reply) == BLE_QIOT_EFFECT_REPLY) << 5) | ((_id) & 0x1F))') + + _dt_write_newline_to_file(write_fd, + '\n// tlv header define, bit 7 - 5 is type, bit 4 - 0 depends on type of data template') + _dt_write_macro_to_file(write_fd, 'PARSE_TLV_HEAD_TYPE(_c)', '(((_c) & 0xFF) >> 5)') + _dt_write_macro_to_file(write_fd, 'PARSE_TLV_HEAD_ID(_c)', '((_c) & 0x1F)') + _dt_write_macro_to_file(write_fd, 'PACKAGE_TLV_HEAD(_type, _id)', '(((_type) << 5) | ((_id) & 0x1F))\n') + + _dt_write_newline_to_file(write_fd, '\n// define tlv struct') + _dt_write_newline_to_file(write_fd, 'typedef struct{' + '\n\tuint8_t type;' + '\n\tuint8_t id;' + '\n\tuint16_t len;' + '\n\tchar *val;' + '\n}e_ble_tlv;') + pass + + +def _dt_trans_property_json_to_h_file(write_fd, _proterty_data): + if _dt_not_exist(_proterty_data): + return + + _dt_write_macro_to_file(write_fd, 'INCLUDE_PROPERTY', '') + # all property id define, the tail of macro name corresponding to property id in json file + _dt_write_enum_to_file(write_fd, '// define property id', 'PROPERTY_ID', _dt_get_enum_list_from_ids(_proterty_data)) + + # define property id values, including size, length, limit ... + for property_id in _proterty_data: + if property_id[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['ENUM']: + enum_prefix, enum_val = _dt_get_enum_list_from_mapping( + property_id[dt_config['JSON']['DEFINE']][dt_config['JSON']['MAPPING']]) + _dt_write_enum_to_file(write_fd, '// define property %s enum' % property_id[dt_config['JSON']['ID']], + 'PROPERTY_' + property_id[dt_config['JSON']['ID']], enum_prefix, enum_val) + elif property_id[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['INT'] or \ + property_id[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['FLOAT']: + _dt_write_newline_to_file(write_fd, '\n// define %s attributes' % property_id[dt_config['JSON']['ID']]) + for k, v in property_id[dt_config['JSON']['DEFINE']].items(): + if v != '' and k != dt_config['JSON']['TYPE'] and k != dt_config['JSON']['UNIT']: + _dt_write_macro_to_file(write_fd, 'PROPERTY_' + property_id[dt_config['JSON']['ID']] + '_' + k, + '(' + v + ')') + elif property_id[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['STRING']: + _dt_write_newline_to_file(write_fd, '\n// define %s length limit' % property_id[dt_config['JSON']['ID']]) + for k, v in property_id[dt_config['JSON']['DEFINE']].items(): + if v != '' and k != dt_config['JSON']['TYPE']: + _dt_write_macro_to_file(write_fd, + 'PROPERTY_' + property_id[dt_config['JSON']['ID']] + '_LEN_' + k, + '(' + v + ')') + else: + pass + # define prototype of callback function + _dt_write_newline_to_file(write_fd, '\n// define property set handle return 0 if success, other is error\n' + '// sdk call the function that inform the server data to the device') + _dt_write_newline_to_file(write_fd, 'typedef int (*property_set_cb)(const char *data, uint16_t len);') + _dt_write_newline_to_file(write_fd, + '\n// define property get handle. return the data length obtained, -1 is error, 0 is no data\n' + '// sdk call the function fetch user data and send to the server, the data should wrapped by user ' + 'adn skd just transmit') + _dt_write_newline_to_file(write_fd, 'typedef int (*property_get_cb)(char *buf, uint16_t buf_len);') + _dt_write_newline_to_file(write_fd, + '\n// each property have a struct ble_property_t, make up a array named sg_ble_property_array') + _dt_write_newline_to_file(write_fd, 'typedef struct{' + '\n\tproperty_set_cb set_cb;\t//set callback' + '\n\tproperty_get_cb get_cb;\t//get callback' + '\n\tuint8_t authority;\t//property authority' + '\n\tuint8_t type;\t//data type' + '\n}ble_property_t;') + pass + + +def _dt_trans_event_json_to_h_file(write_fd, _event_data): + if _dt_not_exist(_event_data): + return + + _dt_write_macro_to_file(write_fd, 'INCLUDE_EVENT', '') + # define event id + _dt_write_enum_to_file(write_fd, '// define event id', 'EVENT_ID', _dt_get_enum_list_from_ids(_event_data)) + + for event in _event_data: + # define param id of event + _dt_write_enum_to_file(write_fd, '// define param id for event %s' % event.get(dt_config['JSON']['ID']), + 'EVENT_' + event.get(dt_config['JSON']['ID']) + '_PARAM_ID', + _dt_get_enum_list_from_ids(event.get(dt_config['JSON']['PARAMS']))) + # define param value of event + for param in event.get('params'): + if param[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['ENUM']: + enum_prefix, enum_val = _dt_get_enum_list_from_mapping(param[dt_config['JSON']['DEFINE']]['mapping']) + _dt_write_enum_to_file(write_fd, '// define enum for param %s' % param[dt_config['JSON']['ID']], + 'EVEMT_' + event.get(dt_config['JSON']['ID']) + '_' + param[ + dt_config['JSON']['ID']], + enum_prefix, enum_val) + elif param[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['INT'] or \ + param[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['FLOAT']: + _dt_write_newline_to_file(write_fd, '\n// define param %s attributes' % param[dt_config['JSON']['ID']]) + for k, v in param[dt_config['JSON']['DEFINE']].items(): + if v != '' and k != dt_config['JSON']['TYPE'] and k != dt_config['JSON']['UNIT']: + _dt_write_macro_to_file(write_fd, + 'EVENT_' + event.get(dt_config['JSON']['ID']) + '_' + param[ + dt_config['JSON']['ID']] + '_' + k, + '(' + v + ')') + elif param[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['STRING']: + _dt_write_newline_to_file(write_fd, '\n// define range for param %s' % param[dt_config['JSON']['ID']]) + for k, v in param[dt_config['JSON']['DEFINE']].items(): + if v != '' and k != dt_config['JSON']['TYPE']: + _dt_write_macro_to_file(write_fd, + 'EVENT_' + event.get(dt_config['JSON']['ID']) + '_' + param[ + dt_config['JSON']['ID']] + '_LEN_' + k, + '(' + v + ')') + + _dt_write_newline_to_file(write_fd, + '\n// define event get handle. return the data length obtained, -1 is error, 0 is no data\n' + '// sdk call the function fetch user data and send to the server, the data should wrapped by user ' + 'adn skd just transmit') + _dt_write_newline_to_file(write_fd, 'typedef int (*event_get_cb)(char *buf, uint16_t buf_len);') + _dt_write_newline_to_file(write_fd, '\n// each param have a struct ble_event_param, make up a array for the event') + _dt_write_newline_to_file(write_fd, 'typedef struct{' + '\n\tevent_get_cb get_cb;\t//get param data callback' + '\n\tuint8_t type;\t//param type' + '\n}ble_event_param;') + _dt_write_newline_to_file(write_fd, '\n// a array named sg_ble_event_array is composed by all the event array') + _dt_write_newline_to_file(write_fd, 'typedef struct{' + '\n\tble_event_param *event_array;\t//array of params data' + '\n\tuint8_t array_size;\t//array size' + '\n}ble_event_t;') + pass + + +def _dt_trans_action_json_to_h_file(write_fd, _action_data): + if _dt_not_exist(_action_data): + return + + _dt_write_macro_to_file(write_fd, 'INCLUDE_ACTION', '') + # define action id + _dt_write_enum_to_file(write_fd, '// define action id', 'ACTION_ID', _dt_get_enum_list_from_ids(_action_data)) + max_input_id, max_output_id = 0, 0 + for action in _action_data: + # define action input id + _dt_write_enum_to_file(write_fd, '// define input id for action %s' % action.get(dt_config['JSON']['ID']), + 'ACTION_' + action.get(dt_config['JSON']['ID']) + '_INPUT_ID', + _dt_get_enum_list_from_ids(action.get(dt_config['JSON']['INPUT']))) + _dt_write_enum_to_file(write_fd, '// define output id for action %s' % action.get(dt_config['JSON']['ID']), + 'ACTION_' + action.get(dt_config['JSON']['ID']) + '_OUTPUT_ID', + _dt_get_enum_list_from_ids(action.get(dt_config['JSON']['OUTPUT']))) + max_input_id = max(len(_dt_get_enum_list_from_ids(action.get(dt_config['JSON']['INPUT']))), max_input_id) + max_output_id = max(len(_dt_get_enum_list_from_ids(action.get(dt_config['JSON']['OUTPUT']))), max_output_id) + # define input id values + for input_id in action.get('input'): + if input_id[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['ENUM']: + enum_prefix, enum_val = _dt_get_enum_list_from_mapping( + input_id[dt_config['JSON']['DEFINE']][dt_config['JSON']['MAPPING']]) + _dt_write_enum_to_file(write_fd, '// define enum for input id %s' % input_id[dt_config['JSON']['ID']], + 'ACTION_INPUT_' + action.get(dt_config['JSON']['ID']) + '_' + input_id[ + dt_config['JSON']['ID']], + enum_prefix, enum_val) + elif input_id[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['INT'] or \ + input_id[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['FLOAT']: + for k, v in input_id[dt_config['JSON']['DEFINE']].items(): + if v != '' and k != dt_config['JSON']['TYPE'] and k != dt_config['JSON']['UNIT']: + _dt_write_macro_to_file(write_fd, + 'ACTION_INPUT_' + action.get(dt_config['JSON']['ID']) + '_' + input_id[ + dt_config['JSON']['ID']] + '_' + k, + '(' + v + ')') + elif input_id[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['STRING']: + _dt_write_newline_to_file(write_fd, + '\n// define input id %s attributes' % input_id[dt_config['JSON']['ID']]) + for k, v in input_id[dt_config['JSON']['DEFINE']].items(): + if v != '' and k != dt_config['JSON']['TYPE']: + _dt_write_macro_to_file(write_fd, + 'ACTION_OUTPUT_' + action.get(dt_config['JSON']['ID']) + '_' + input_id[ + dt_config['JSON']['ID']] + '_LEN_' + k, + '(' + v + ')') + else: + pass + for output in action.get('output'): + if output[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['ENUM']: + enum_prefix, enum_val = _dt_get_enum_list_from_mapping( + output[dt_config['JSON']['DEFINE']][dt_config['JSON']['MAPPING']]) + _dt_write_enum_to_file(write_fd, '// define enum for output id %s' % output[dt_config['JSON']['ID']], + 'ACTION_OUTPUT_' + action.get(dt_config['JSON']['ID']) + '_' + output[ + dt_config['JSON']['ID']], + enum_prefix, enum_val) + elif output[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['INT'] or \ + output[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['FLOAT']: + _dt_write_newline_to_file(write_fd, + '\n// define output id %s attributes' % output[dt_config['JSON']['ID']]) + for k, v in output[dt_config['JSON']['DEFINE']].items(): + if v != '' and k != dt_config['JSON']['TYPE'] and k != dt_config['JSON']['UNIT']: + _dt_write_macro_to_file(write_fd, + 'ACTION_OUTPUT_' + action.get(dt_config['JSON']['ID']) + '_' + output[ + dt_config['JSON']['ID']] + '_' + k, + '(' + v + ')') + elif output[dt_config['JSON']['DEFINE']][dt_config['JSON']['TYPE']] == dt_config['JSON']['STRING']: + _dt_write_newline_to_file(write_fd, + '\n// define output id %s attributes' % output[dt_config['JSON']['ID']]) + for k, v in output[dt_config['JSON']['DEFINE']].items(): + if v != '' and k != dt_config['JSON']['TYPE']: + _dt_write_macro_to_file(write_fd, + 'ACTION_OUTPUT_' + action.get(dt_config['JSON']['ID']) + '_' + output[ + dt_config['JSON']['ID']] + '_LEN_' + k, + '(' + v + ')') + _dt_write_newline_to_file(write_fd, '\n// define max input id and output id in all of input id and output id above') + _dt_write_macro_to_file(write_fd, 'ACTION_INPUT_ID_BUTT', str(max_input_id - 1)) + _dt_write_macro_to_file(write_fd, 'ACTION_OUTPUT_ID_BUTT', str(max_output_id - 1)) + _dt_write_newline_to_file(write_fd, '\n// define action input handle, return 0 is success, other is error.\n' + '// input_param_array carry the data from server, include input id, data length ,data val\n' + '// input_array_size means how many input id\n' + '// output_id_array filling with output id numbers that need obtained, sdk will traverse it and call the action_output_handle to obtained data') + _dt_write_newline_to_file(write_fd, + 'typedef int (*action_input_handle)(e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array);') + _dt_write_newline_to_file(write_fd, + '\n// define action output handle, return length of the data, 0 is no data, -1 is error\n' + '// output_id means which id data should be obtained') + _dt_write_newline_to_file(write_fd, + 'typedef int (*action_output_handle)(uint8_t output_id, char *buf, uint16_t buf_len);') + _dt_write_newline_to_file(write_fd, + '\n// each action have a struct ble_action_t, make up a array named sg_ble_action_array') + _dt_write_newline_to_file(write_fd, 'typedef struct{' + '\n\taction_input_handle input_cb;\t//handle input data' + '\n\taction_output_handle output_cb;\t// get output data in the callback' + '\n\tuint8_t *input_type_array;\t//type array for input id' + '\n\tuint8_t *output_type_array;\t//type array for output id' + '\n\tuint8_t input_id_size;\t//numbers of input id' + '\n\tuint8_t output_id_size;\t//numbers of output id' + '\n}ble_action_t;') + pass + + +def _dt_write_function_prototype(write_fd): + file_fd = open(os.path.join(script_path, 'dt_fixed_content', 'dt_ble_prototype'), 'r', encoding='UTF-8') + file_content = file_fd.read() + file_fd.close() + _dt_write_newline_to_file(write_fd, file_content) + pass + + +def _dt_generate_header_file(_json_data): + h_file = open(dt_config['FILE']['NAME_PREFIX'] + '.h', 'w', encoding='UTF-8') + + _dt_write_newline_to_file(h_file, dt_config['FILE']['COPYRIGHT']) + _dt_write_newline_to_file(h_file, '#ifndef ' + dt_config['FILE']['NAME_PREFIX'].upper() + '_H_') + _dt_write_newline_to_file(h_file, '#define ' + dt_config['FILE']['NAME_PREFIX'].upper() + '_H_') + _dt_write_newline_to_file(h_file, '#ifdef __cplusplus\n' + 'extern "C"{\n#endif\n') + + _dt_write_newline_to_file(h_file, '#include \n') + + _dt_write_public_header(h_file) + _dt_trans_property_json_to_h_file(h_file, _json_data.get(dt_config['JSON']['PROPERTY'])) + _dt_trans_event_json_to_h_file(h_file, _json_data.get(dt_config['JSON']['EVENT'])) + _dt_trans_action_json_to_h_file(h_file, _json_data.get(dt_config['JSON']['ACTION'])) + _dt_write_function_prototype(h_file) + + _dt_write_newline_to_file(h_file, '\n' + '#ifdef __cplusplus' + '\n' + '}' + '\n' + '#endif') + _dt_write_newline_to_file(h_file, '#endif ' + '//' + (dt_config['FILE']['NAME_PREFIX']).upper() + '_H_') + + h_file.close() + pass + + +def _dt_get_property_function_name(property_id): + return 'ble_property_' + property_id.lower() + '_get' + + +def _dt_set_property_function_name(property_id): + return 'ble_property_' + property_id.lower() + '_set' + + +def _dt_get_property_mode(mode): + if mode == 'rw': + return 'BLE_QIOT_PROPERTY_AUTH_RW' + elif mode == 'r': + return 'BLE_QIOT_PROPERTY_AUTH_READ' + else: + print("invalid property mode") + pass + + +def _dt_get_type_by_str(type_str): + if type_str == dt_config['JSON']['BOOL']: + return 'BLE_QIOT_DATA_TYPE_BOOL' + elif type_str == dt_config['JSON']['INT']: + return 'BLE_QIOT_DATA_TYPE_INT' + elif type_str == dt_config['JSON']['STRING']: + return 'BLE_QIOT_DATA_TYPE_STRING' + elif type_str == dt_config['JSON']['FLOAT']: + return 'BLE_QIOT_DATA_TYPE_FLOAT' + elif type_str == dt_config['JSON']['ENUM']: + return 'BLE_QIOT_DATA_TYPE_ENUM' + elif type_str == dt_config['JSON']['TIME']: + return 'BLE_QIOT_DATA_TYPE_TIME' + else: + print('invalid type string') + pass + + +def _dt_get_ret_val_by_type(data_type): + if data_type == dt_config['JSON']['STRING']: + return 'buf_len' + elif data_type == dt_config['JSON']['INT']: + return 'sizeof(uint32_t)' + elif data_type == dt_config['JSON']['ENUM']: + return 'sizeof(uint16_t)' + elif data_type == dt_config['JSON']['BOOL']: + return 'sizeof(uint8_t)' + elif data_type == dt_config['JSON']['FLOAT']: + return 'sizeof(float)' + elif data_type == dt_config['JSON']['TIME']: + return 'sizeof(uint32_t)' + else: + print('invalid data type') + + +def _dt_get_function_param_by_type(data_type): + return '(char *data, uint16_t buf_len)' + + +def _dt_trans_property_json_to_c_file(write_fd, _proterty_data): + if _dt_not_exist(_proterty_data): + return + + # define property set/get function + for property_id in _proterty_data: + _dt_write_newline_to_file(write_fd, + 'static int ' + _dt_set_property_function_name( + property_id.get(dt_config['JSON']['ID'])) + + '(const char *data, uint16_t len)\n{\n\treturn 0;\n}\n') + _dt_write_newline_to_file(write_fd, + 'static int ' + _dt_get_property_function_name( + property_id.get(dt_config['JSON']['ID'])) + + '%s\n{\n\treturn %s;\n}\n' % + (_dt_get_function_param_by_type( + property_id.get(dt_config['JSON']['DEFINE']).get(dt_config['JSON']['TYPE'])), + _dt_get_ret_val_by_type( + property_id.get(dt_config['JSON']['DEFINE']).get(dt_config['JSON']['TYPE'])))) + + # define property array + _dt_write_newline_to_file(write_fd, 'static ble_property_t sg_ble_property_array[BLE_QIOT_PROPERTY_ID_BUTT] = {') + for property_id in _proterty_data: + _dt_write_newline_to_file(write_fd, '\t{%-30s %-30s %-20s %-20s},' % + (_dt_set_property_function_name(property_id.get(dt_config['JSON']['ID'])) + ',', + _dt_get_property_function_name(property_id.get(dt_config['JSON']['ID'])) + ',', + _dt_get_property_mode(property_id.get(dt_config['JSON']['MODE'])) + ',', + _dt_get_type_by_str( + property_id.get(dt_config['JSON']['DEFINE']).get(dt_config['JSON']['TYPE'])) + )) + _dt_write_newline_to_file(write_fd, '};\n') + + dt_property_file = open(os.path.join(script_path, 'dt_fixed_content', 'dt_ble_property'), 'r', encoding='UTF-8') + dt_property_content = dt_property_file.read() + dt_property_file.close() + # write operation to file + _dt_write_newline_to_file(write_fd, dt_property_content) + pass + + +def _dt_trans_event_json_to_c_file(write_fd, _evnet_data): + if _dt_not_exist(_evnet_data): + return + + for event in _evnet_data: + # define event get function + for param in event.get('params'): + _dt_write_newline_to_file(write_fd, + 'static int ' + 'ble_event_get_' + event.get(dt_config['JSON']['ID']).lower() + + '_' + param.get(dt_config['JSON']['ID']).lower() + '%s\n{\n\treturn %s;\n}\n' % + (_dt_get_function_param_by_type( + param.get(dt_config['JSON']['DEFINE']).get(dt_config['JSON']['TYPE'])), + _dt_get_ret_val_by_type( + param.get(dt_config['JSON']['DEFINE']).get(dt_config['JSON']['TYPE'])))) + # define param array + _dt_write_newline_to_file(write_fd, 'static ble_event_param sg_ble_event_%s_array[%s] = {' % + (event.get(dt_config['JSON']['ID']).lower(), + dt_config['FILE']['ENUM_PREFIX'] + 'EVENT_' + + event.get(dt_config['JSON']['ID']).upper() + '_PARAM_ID_BUTT')) + for param in event.get('params'): + _dt_write_newline_to_file(write_fd, '\t{%-32s %-20s},' % ( + 'ble_event_get_' + event.get(dt_config['JSON']['ID']).lower() + '_' + param.get( + dt_config['JSON']['ID']).lower() + ', ', + _dt_get_type_by_str(param.get(dt_config['JSON']['DEFINE']).get(dt_config['JSON']['TYPE'])))) + _dt_write_newline_to_file(write_fd, '};\n') + + # define event array + _dt_write_newline_to_file(write_fd, 'static ble_event_t sg_ble_event_array[BLE_QIOT_EVENT_ID_BUTT] = {') + for event in _evnet_data: + _dt_write_newline_to_file(write_fd, '\t{%-32s %-32s},' % ( + 'sg_ble_event_' + event.get(dt_config['JSON']['ID']).lower() + '_array,', + 'sizeof(sg_ble_event_' + event.get(dt_config['JSON']['ID']).lower() + '_array) / sizeof(ble_event_param)')) + _dt_write_newline_to_file(write_fd, '};\n') + + dt_event_file = open(os.path.join(script_path, 'dt_fixed_content', 'dt_ble_event'), 'r', encoding='UTF-8') + dt_event_content = dt_event_file.read() + dt_event_file.close() + # write operation to file + _dt_write_newline_to_file(write_fd, dt_event_content) + pass + + +def _dt_trans_action_json_to_c_file(write_fd, _action_data): + if _dt_not_exist(_action_data): + return + + for idx, action in enumerate(_action_data): + # define action input and output callback + _dt_write_newline_to_file(write_fd, + 'static int ' + 'ble_action_handle_' + action.get( + dt_config['JSON']['ID']).lower() + '_input_cb' + + '(e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array)\n' + '{\n\treturn 0;\n}\n') + _dt_write_newline_to_file(write_fd, + 'static int ' + 'ble_action_handle_' + action.get( + dt_config['JSON']['ID']).lower() + '_output_cb' + + '(uint8_t output_id, char *buf, uint16_t buf_len)\n' + '{\n\treturn buf_len;\n}\n') + # define type array of input id + _dt_write_newline_to_file(write_fd, + 'static uint8_t ' + 'sg_ble_action_%s_input_type_array[%s] = {' % + (action.get(dt_config['JSON']['ID']).lower(), + dt_config['FILE']['ENUM_PREFIX'] + 'ACTION_' + + action.get(dt_config['JSON']['ID']).upper() + '_INPUT_ID_BUTT')) + for input_id in action.get('input'): + _dt_write_newline_to_file(write_fd, + '\t' + _dt_get_type_by_str(input_id.get(dt_config['JSON']['DEFINE']).get( + dt_config['JSON']['TYPE'])) + ',') + _dt_write_newline_to_file(write_fd, '};\n') + + # define type array of output id + _dt_write_newline_to_file(write_fd, + 'static uint8_t ' + 'sg_ble_action_%s_output_type_array[%s] = {' % ( + action.get(dt_config['JSON']['ID']).lower(), + dt_config['FILE']['ENUM_PREFIX'] + 'ACTION_' + action.get( + dt_config['JSON']['ID']).upper() + '_OUTPUT_ID_BUTT')) + for input_id in action.get('output'): + _dt_write_newline_to_file(write_fd, + '\t' + _dt_get_type_by_str(input_id.get(dt_config['JSON']['DEFINE']).get( + dt_config['JSON']['TYPE'])) + ',') + _dt_write_newline_to_file(write_fd, '};\n') + + # define action array + _dt_write_newline_to_file(write_fd, 'static ble_action_t ' + 'sg_ble_action_array[BLE_QIOT_ACTION_ID_BUTT] = {') + for action in _action_data: + _dt_write_newline_to_file(write_fd, + '\t{ble_action_handle_%s_input_cb, ble_action_handle_%s_output_cb, \n' + '\t\tsg_ble_action_%s_input_type_array, sg_ble_action_%s_output_type_array, \n' + '\t\tsizeof(sg_ble_action_%s_input_type_array) / sizeof(uint8_t), \n' + '\t\tsizeof(sg_ble_action_%s_output_type_array) / sizeof(uint8_t)},' % + (action.get(dt_config['JSON']['ID']).lower(), + action.get(dt_config['JSON']['ID']).lower(), + action.get(dt_config['JSON']['ID']).lower(), + action.get(dt_config['JSON']['ID']).lower(), + action.get(dt_config['JSON']['ID']).lower(), + action.get(dt_config['JSON']['ID']).lower())) + _dt_write_newline_to_file(write_fd, '};\n') + + dt_action_file = open(os.path.join(script_path, 'dt_fixed_content', 'dt_ble_action'), 'r', encoding='UTF-8') + dt_action_content = dt_action_file.read() + dt_action_file.close() + # write operation to file + _dt_write_newline_to_file(write_fd, dt_action_content) + pass + + +def _dt_generate_c_file(_json_data): + c_file = open(dt_config['FILE']['NAME_PREFIX'] + '.c', 'w', encoding='UTF-8') + + _dt_write_newline_to_file(c_file, dt_config['FILE']['COPYRIGHT']) + _dt_write_newline_to_file(c_file, '#ifdef __cplusplus\nextern "C" {\n#endif\n') + + _dt_write_newline_to_file(c_file, '#include "ble_qiot_template.h"\n') + _dt_write_newline_to_file(c_file, '#include ') + _dt_write_newline_to_file(c_file, '#include ') + _dt_write_newline_to_file(c_file, '#include \n') + _dt_write_newline_to_file(c_file, '#include "ble_qiot_export.h"') + _dt_write_newline_to_file(c_file, '#include "ble_qiot_common.h"') + _dt_write_newline_to_file(c_file, '#include "ble_qiot_param_check.h"\n') + + _dt_trans_property_json_to_c_file(c_file, _json_data.get(dt_config['JSON']['PROPERTY'])) + _dt_trans_event_json_to_c_file(c_file, _json_data.get(dt_config['JSON']['EVENT'])) + _dt_trans_action_json_to_c_file(c_file, _json_data.get(dt_config['JSON']['ACTION'])) + _dt_write_newline_to_file(c_file, '\n#ifdef __cplusplus\n}\n#endif') + pass + + +if __name__ == "__main__": + if len(sys.argv) != 2: + print('Usage: python3 %s ' % sys.argv[0]) + else: + print("reading json file start") + json_data = _dt_get_json_from_file(sys.argv[1]) + print("reading json file end") + + print("generate header file start") + _dt_generate_header_file(json_data) + print("generate header file end") + print("generate source file start") + _dt_generate_c_file(json_data) + print("generate source file end") + pass diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_llsync_data.c b/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_llsync_data.c new file mode 100644 index 00000000..46de90ff --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_llsync_data.c @@ -0,0 +1,349 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_llsync_data.h" + +#include +#include +#include + +#include "ble_qiot_export.h" +#include "ble_qiot_import.h" +#include "ble_qiot_common.h" +#include "ble_qiot_llsync_event.h" +#include "ble_qiot_utils_base64.h" +#include "ble_qiot_log.h" +#include "ble_qiot_param_check.h" +#include "ble_qiot_service.h" +#include "ble_qiot_template.h" + +#define BLE_LLDATA_MAX_INPUT_ID 8 +#define BLE_LLDATA_MAX_OUTPUT_ID 8 + +static int ble_lldata_parse_tlv(const char *buf, int buf_len, e_ble_tlv *tlv) +{ + int ret_len = 0; + uint16_t string_len = 0; + + tlv->type = BLE_QIOT_PARSE_TLV_HEAD_TYPE(buf[0]); + if (tlv->type >= BLE_QIOT_DATA_TYPE_BUTT) { + ble_qiot_log_e("invalid tlv type %d", tlv->type); + return -1; + } + tlv->id = BLE_QIOT_PARSE_TLV_HEAD_ID(buf[0]); + ret_len++; + + switch (tlv->type) { + case BLE_QIOT_DATA_TYPE_BOOL: + tlv->len = 1; + tlv->val = (char *)buf + ret_len; + ret_len += 1; + break; + case BLE_QIOT_DATA_TYPE_ENUM: + tlv->len = 2; + tlv->val = (char *)buf + ret_len; + ret_len += 2; + break; + case BLE_QIOT_DATA_TYPE_INT: + case BLE_QIOT_DATA_TYPE_FLOAT: + case BLE_QIOT_DATA_TYPE_TIME: + tlv->len = 4; + tlv->val = (char *)buf + ret_len; + ret_len += 4; + break; + case BLE_QIOT_DATA_TYPE_STRING: + if (buf_len < 3) { + ble_qiot_log_e("buf length invalid"); + return -1; + } + memcpy(&string_len, &buf[ret_len], sizeof(int16_t)); + tlv->len = NTOHS(string_len); + ret_len += 2; + tlv->val = (char *)buf + ret_len; + ret_len += tlv->len; + break; + default: + break; + } + ble_qiot_log_d("type %d, id %d, len %d", tlv->type, tlv->id, tlv->len); + + return ret_len; +} + +static ble_qiot_ret_status_t ble_lldata_property_data_handle(bool is_request, const char *in_buf, int buf_len) +{ +#ifdef BLE_QIOT_INCLUDE_PROPERTY + uint16_t parse_len = 0; + uint16_t ret_len = 0; + e_ble_tlv tlv; + int handle_ret = BLE_QIOT_REPLY_SUCCESS; + ble_qiot_ret_status_t inform_ret = BLE_QIOT_RS_OK; + + while (parse_len < buf_len) { + memset(&tlv, 0, sizeof(e_ble_tlv)); + ret_len = ble_lldata_parse_tlv(in_buf + parse_len, buf_len - parse_len, &tlv); + parse_len += ret_len; + if (parse_len > buf_len) { + ble_qiot_log_e("parse tlv failed"); + handle_ret = BLE_QIOT_REPLY_DATA_ERR; + break; + } + + if (BLE_QIOT_RS_OK != ble_user_property_set_data(&tlv)) { + ble_qiot_log_e("user handle property error, id %d, type %d, len %d", tlv.id, tlv.type, tlv.len); + handle_ret = BLE_QIOT_REPLY_FAIL; + break; + } + } + + if (is_request) { + inform_ret = + ble_event_notify(BLE_QIOT_EVENT_UP_CONTROL_REPLY, NULL, 0, (const char *)&handle_ret, sizeof(uint8_t)); + return (BLE_QIOT_REPLY_SUCCESS == handle_ret) ? inform_ret : BLE_QIOT_RS_ERR; + } else { + return (BLE_QIOT_REPLY_SUCCESS == handle_ret) ? BLE_QIOT_RS_OK : BLE_QIOT_RS_ERR; + } +#else + ble_qiot_log_e("llsync property not support"); + return BLE_QIOT_RS_OK; +#endif +} + +#ifdef BLE_QIOT_INCLUDE_PROPERTY +ble_qiot_ret_status_t ble_user_property_get_report_data(void) +{ + uint8_t property_id = 0; + uint8_t property_type = 0; + int property_len = 0; + uint8_t data_buf[BLE_QIOT_EVENT_MAX_SIZE] = {0}; + uint16_t data_len = 0; + uint16_t string_len = 0; + + ble_qiot_log_d("property report"); + for (property_id = 0; property_id < BLE_QIOT_PROPERTY_ID_BUTT; property_id++) { + property_type = ble_get_property_type_by_id(property_id); + if (property_type == BLE_QIOT_DATA_TYPE_BUTT) { + ble_qiot_log_e("property id %d type %d invalid", property_id, property_type); + return BLE_QIOT_RS_ERR; + } + data_buf[data_len++] = BLE_QIOT_PACKAGE_TLV_HEAD(property_type, property_id); + if (BLE_QIOT_DATA_TYPE_STRING == property_type) { + // reserved 2 bytes for string length + property_len = ble_user_property_get_data_by_id(property_id, (char *)data_buf + data_len + 2, + sizeof(data_buf) - data_len - 2); + } else { + property_len = + ble_user_property_get_data_by_id(property_id, (char *)data_buf + data_len, sizeof(data_buf) - data_len); + } + if (property_len < 0) { + ble_qiot_log_e("too long data, property id %d, data length %d", property_id, data_len); + return BLE_QIOT_RS_ERR; + } else if (property_len == 0) { + // no data to post + data_len--; + data_buf[data_len] = '0'; + ble_qiot_log_d("property id %d no data to post", property_id); + } else { + if (BLE_QIOT_DATA_TYPE_STRING == property_type) { + string_len = HTONS(property_len); + memcpy(data_buf + data_len, &string_len, sizeof(uint16_t)); + data_len += sizeof(uint16_t); + } + data_len += property_len; + } + } + // ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "user data", data_buf, data_len); + + return ble_event_notify(BLE_QIOT_EVENT_UP_PROPERTY_REPORT, NULL, 0, (const char *)data_buf, data_len); +} +#endif + +// default method is control +ble_qiot_ret_status_t ble_lldata_property_request_handle(const char *in_buf, int buf_len) +{ + return ble_lldata_property_data_handle(true, in_buf, buf_len); +} + +static ble_qiot_ret_status_t ble_lldata_property_report_reply(const char *in_buf, int buf_len) +{ +#ifdef BLE_QIOT_INCLUDE_PROPERTY + int ret_code = 0; + + ret_code = ble_user_property_report_reply_handle(in_buf[0]); + if (ret_code) { + ble_qiot_log_e("ble_user_property_report_reply_handle error, ret %d", ret_code); + return BLE_QIOT_RS_ERR; + } + + return BLE_QIOT_RS_OK; +#else + ble_qiot_log_e("llsync property not support"); + return BLE_QIOT_RS_OK; +#endif +} + +static ble_qiot_ret_status_t ble_lldata_property_get_status_reply(const char *in_buf, int buf_len) +{ +#ifdef BLE_QIOT_INCLUDE_PROPERTY + uint8_t result = 0; + uint16_t reply_len = 0; + + result = in_buf[0]; + memcpy(&reply_len, &in_buf[1], sizeof(uint16_t)); + reply_len = NTOHS(reply_len); + ble_qiot_log_d("get status result %d, data len %d", result, reply_len); + if (BLE_QIOT_REPLY_SUCCESS == result) { + return ble_lldata_property_data_handle(false, in_buf + 3, reply_len); + } else { + ble_qiot_log_e("get status failed, result %d", result); + return BLE_QIOT_RS_ERR; + } +#else + ble_qiot_log_e("llsync property not support"); + return BLE_QIOT_RS_OK; +#endif +} + +// handle reply from remote +ble_qiot_ret_status_t ble_lldata_property_reply_handle(uint8_t type, const char *in_buf, int buf_len) +{ + switch (type) { + case BLE_QIOT_DATA_DOWN_REPORT_REPLY: + return ble_lldata_property_report_reply(in_buf, buf_len); + case BLE_QIOT_DATA_DOWN_GET_STATUS_REPLY: + return ble_lldata_property_get_status_reply(in_buf, buf_len); + default: + ble_qiot_log_e("invalid property reply type"); + break; + } + + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_lldata_event_handle(uint8_t id, const char *in_buf, int len) +{ +#ifdef BLE_QIOT_INCLUDE_EVENT + int ret_code = 0; + + ret_code = ble_user_event_reply_handle(id, in_buf[0]); + if (ret_code) { + ble_qiot_log_e("ble_user_event_reply_handle error, ret %d", ret_code); + return BLE_QIOT_RS_ERR; + } +#else + ble_qiot_log_e("llsync event not support"); +#endif + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_lldata_action_handle(uint8_t action_id, const char *in_buf, int len) +{ +#ifdef BLE_QIOT_INCLUDE_ACTION + POINTER_SANITY_CHECK(in_buf, BLE_QIOT_RS_ERR_PARA); + + uint16_t parse_len = 0; + uint8_t tlv_index = 0; + int ret_len = 0; + e_ble_tlv tlv[BLE_QIOT_ACTION_INPUT_ID_BUTT] = {0}; + int handle_ret = BLE_QIOT_REPLY_SUCCESS; + uint8_t output_flag_array[BLE_QIOT_ACTION_OUTPUT_ID_BUTT] = {0}; + uint8_t output_id = 0; + uint8_t output_type = 0; + uint8_t data_buf[BLE_QIOT_EVENT_MAX_SIZE] = {0}; + uint16_t data_len = 0; + int output_param_len = 0; + uint16_t string_len = 0; + uint8_t header_buf[2] = {0}; + + ble_qiot_log_d("action %d", action_id); + while (parse_len < len) { + if (tlv_index >= BLE_QIOT_ACTION_INPUT_ID_BUTT) { + ble_qiot_log_e("invalid tlv index %d", tlv_index); + handle_ret = BLE_QIOT_REPLY_DATA_ERR; + goto end; + } + ret_len = ble_lldata_parse_tlv(in_buf + parse_len, len - parse_len, &tlv[tlv_index]); + if (-1 == ret_len) { + handle_ret = BLE_QIOT_REPLY_DATA_ERR; + goto end; + } + parse_len += ret_len; + tlv_index++; + if (parse_len > len) { + ble_qiot_log_e("parse tlv failed"); + handle_ret = BLE_QIOT_REPLY_DATA_ERR; + goto end; + } + } + if (0 != ble_action_user_handle_input_param(action_id, tlv, tlv_index, output_flag_array)) { + ble_qiot_log_e("handle input failed, id %d", action_id); + handle_ret = BLE_QIOT_REPLY_FAIL; + goto end; + } + + for (output_id = 0; output_id < BLE_QIOT_ACTION_OUTPUT_ID_BUTT; output_id++) { + if (output_flag_array[output_id]) { + output_type = ble_action_get_output_type_by_id(action_id, output_id); + if (output_type == BLE_QIOT_DATA_TYPE_BUTT) { + ble_qiot_log_e("invalid type, action id %d, output id %d", action_id, output_id); + handle_ret = BLE_QIOT_REPLY_FAIL; + goto end; + } + data_buf[data_len++] = BLE_QIOT_PACKAGE_TLV_HEAD(output_type, output_id); + if (BLE_QIOT_DATA_TYPE_STRING == output_type) { + output_param_len = ble_action_user_handle_output_param( + action_id, output_id, (char *)data_buf + data_len + 2, sizeof(data_buf) - data_len - 2); + } else { + output_param_len = ble_action_user_handle_output_param( + action_id, output_id, (char *)data_buf + data_len, sizeof(data_buf) - data_len); + } + if (output_param_len < 0) { + ble_qiot_log_e("too long data, action id %d, data length %d", action_id, data_len); + handle_ret = BLE_QIOT_REPLY_FAIL; + goto end; + } else if (output_param_len == 0) { + // no data to post + data_len--; + data_buf[data_len] = '0'; + ble_qiot_log_d("output id %d no data to post", output_id); + } else { + if (BLE_QIOT_DATA_TYPE_STRING == output_type) { + string_len = HTONS(output_param_len); + memcpy(data_buf + data_len, &string_len, sizeof(uint16_t)); + data_len += sizeof(uint16_t); + } + data_len += output_param_len; + } + } + } + // ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "user data", data_buf, data_len); + + header_buf[0] = BLE_QIOT_REPLY_SUCCESS; + header_buf[1] = action_id; + return ble_event_notify(BLE_QIOT_EVENT_UP_ACTION_REPLY, header_buf, sizeof(header_buf), (const char *)data_buf, + data_len); + +end: + ble_event_notify(BLE_QIOT_EVENT_UP_ACTION_REPLY, NULL, 0, (const char *)&handle_ret, sizeof(uint8_t)); + return BLE_QIOT_RS_ERR; +#else + ble_qiot_log_e("llsync action not support"); + return BLE_QIOT_RS_ERR; +#endif +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_llsync_device.c b/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_llsync_device.c new file mode 100644 index 00000000..1c52b084 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_llsync_device.c @@ -0,0 +1,357 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_llsync_device.h" + +#include +#include +#include + +#include "ble_qiot_common.h" +#include "ble_qiot_config.h" +#include "ble_qiot_export.h" +#include "ble_qiot_hmac.h" +#include "ble_qiot_import.h" +#include "ble_qiot_log.h" +#include "ble_qiot_param_check.h" +#include "ble_qiot_utils_base64.h" +#include "ble_qiot_md5.h" + +#define BLE_GET_EXPIRATION_TIME(_cur_time) ((_cur_time) + BLE_EXPIRATION_TIME) + +static ble_core_data sg_core_data; // ble data storage in flash +static ble_device_info sg_device_info; // device info storage in flash +static e_llsync_bind_state sg_llsync_bind_state; // llsync bind state in used +static e_llsync_connection_state sg_llsync_connection_state; // llsync connection state in used +static e_ble_connection_state sg_ble_connection_state; // ble connection state in used + +static int memchk(const uint8_t *buf, int len) +{ + int i = 0; + + for (i = 0; i < len; i++) { + if (buf[i] != 0xFF) { + return 1; + } + } + + return 0; +} + +ble_qiot_ret_status_t ble_init_flash_data(void) +{ + if (sizeof(sg_core_data) != + ble_read_flash(BLE_QIOT_RECORD_FLASH_ADDR, (char *)&sg_core_data, sizeof(sg_core_data))) { + ble_qiot_log_e("read flash error"); + return BLE_QIOT_RS_ERR_FLASH; + } + if (0 == memchk((const uint8_t *)&sg_core_data, sizeof(sg_core_data))) { + memset(&sg_core_data, 0, sizeof(sg_core_data)); + } + + if (0 != ble_get_mac(sg_device_info.mac)) { + ble_qiot_log_e("get mac error"); + return BLE_QIOT_RS_ERR_FLASH; + } + if (0 != ble_get_product_id(sg_device_info.product_id)) { + ble_qiot_log_e("get product id error"); + return BLE_QIOT_RS_ERR_FLASH; + } + if (0 != ble_get_psk(sg_device_info.psk)) { + ble_qiot_log_e("get secret key error"); + return BLE_QIOT_RS_ERR_FLASH; + } + if (0 == ble_get_device_name(sg_device_info.device_name)) { + ble_qiot_log_e("get device name error"); + return BLE_QIOT_RS_ERR_FLASH; + } + llsync_bind_state_set((e_llsync_bind_state)sg_core_data.bind_state); + + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "core_data", (char *)&sg_core_data, sizeof(sg_core_data)); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "device_info", (char *)&sg_device_info, sizeof(sg_device_info)); + + return BLE_QIOT_RS_OK; +} + +static ble_qiot_ret_status_t ble_write_core_data(ble_core_data *core_data) +{ + memcpy(&sg_core_data, core_data, sizeof(ble_core_data)); + if (sizeof(ble_core_data) != + ble_write_flash(BLE_QIOT_RECORD_FLASH_ADDR, (char *)&sg_core_data, sizeof(ble_core_data))) { + ble_qiot_log_e("write core failed"); + return BLE_QIOT_RS_ERR_FLASH; + } + + return BLE_QIOT_RS_OK; +} + +void llsync_bind_state_set(e_llsync_bind_state new_state) +{ + ble_qiot_log_d("bind state: %d ---> %d", sg_llsync_bind_state, new_state); + sg_llsync_bind_state = new_state; +} + +e_llsync_bind_state llsync_bind_state_get(void) +{ + return sg_llsync_bind_state; +} + +void llsync_connection_state_set(e_llsync_connection_state new_state) +{ + ble_qiot_log_d("connection state: %d ---> %d", sg_llsync_connection_state, new_state); + sg_llsync_connection_state = new_state; +} + +e_llsync_connection_state llsync_connection_state_get(void) +{ + return sg_llsync_connection_state; +} + +void ble_connection_state_set(e_ble_connection_state new_state) +{ + sg_ble_connection_state = new_state; +} + +e_ble_connection_state ble_connection_state_get(void) +{ + return sg_ble_connection_state; +} + +bool ble_is_connected(void) +{ + return sg_ble_connection_state == E_BLE_CONNECTED; +} + +bool llsync_is_connected(void) +{ + return sg_llsync_connection_state == E_LLSYNC_CONNECTED; +} + +// [1byte bind state] + [6 bytes mac] + [8bytes identify string]/[10 bytes product id] +int ble_get_my_broadcast_data(char *out_buf, int buf_len) +{ + POINTER_SANITY_CHECK(out_buf, BLE_QIOT_RS_ERR_PARA); + BUFF_LEN_SANITY_CHECK(buf_len, BLE_BIND_IDENTIFY_STR_LEN + BLE_QIOT_MAC_LEN + 1, BLE_QIOT_RS_ERR_PARA); + + int ret_len = 0; + + out_buf[ret_len] = sg_llsync_bind_state & LLSYNC_BIND_STATE_MASK; + out_buf[ret_len] |= BLE_QIOT_LLSYNC_PROTOCOL_VERSION << 4; + ret_len++; + + if (E_LLSYNC_BIND_SUCC == (sg_llsync_bind_state & LLSYNC_BIND_STATE_MASK)) { + uint8_t md5_in_buf[128] = {0}; + uint8_t md5_in_len = 0; + uint8_t md5_out_buf[MD5_DIGEST_SIZE] = {0}; + + // 1 bytes state + 8 bytes device identify_str + 8 bytes identify_str + memcpy((char *)md5_in_buf, sg_device_info.product_id, sizeof(sg_device_info.product_id)); + md5_in_len += sizeof(sg_device_info.product_id); + memcpy((char *)md5_in_buf + md5_in_len, sg_device_info.device_name, strlen(sg_device_info.device_name)); + md5_in_len += strlen(sg_device_info.device_name); + utils_md5(md5_in_buf, md5_in_len, md5_out_buf); + for (int i = 0; i < MD5_DIGEST_SIZE / 2; i++) { + out_buf[i + ret_len] = md5_out_buf[i] ^ md5_out_buf[i + MD5_DIGEST_SIZE / 2]; + } + ret_len += MD5_DIGEST_SIZE / 2; + memcpy(out_buf + ret_len, sg_core_data.identify_str, sizeof(sg_core_data.identify_str)); + ret_len += sizeof(sg_core_data.identify_str); + } else { + // 1 bytes state + 6 bytes mac + 10 bytes product id + memcpy(out_buf + ret_len, sg_device_info.mac, BLE_QIOT_MAC_LEN); + ret_len += BLE_QIOT_MAC_LEN; + memcpy(out_buf + ret_len, sg_device_info.product_id, sizeof(sg_device_info.product_id)); + ret_len += sizeof(sg_device_info.product_id); + } + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "broadcast", out_buf, ret_len); + + return ret_len; +} + +int ble_bind_get_authcode(const char *bind_data, uint16_t data_len, char *out_buf, uint16_t buf_len) +{ + POINTER_SANITY_CHECK(bind_data, BLE_QIOT_RS_ERR_PARA); + BUFF_LEN_SANITY_CHECK(data_len, (int32_t)sizeof(ble_bind_data), BLE_QIOT_RS_ERR_PARA); + POINTER_SANITY_CHECK(out_buf, BLE_QIOT_RS_ERR_PARA); + BUFF_LEN_SANITY_CHECK(buf_len, SHA1_DIGEST_SIZE + BLE_QIOT_DEVICE_NAME_LEN, BLE_QIOT_RS_ERR_PARA); + + char out_sign[SHA1_DIGEST_SIZE] = {0}; + char sign_info[80] = {0}; + int sign_info_len = 0; + int time_expiration = 0; + int nonce = 0; + int ret_len = 0; + uint8_t secret[BLE_QIOT_PSK_LEN / 4 * 3] = {0}; + int secret_len = 0; + + // if the pointer "char *bind_data" is not aligned with 4 byte, in some cpu convert it to + // pointer "ble_bind_data *" work correctly, but some cpu will get wrong value, or cause + // other "Unexpected Error". Here copy it to a local variable make sure aligned with 4 byte. + ble_bind_data bind_data_aligned; + memcpy(&bind_data_aligned, bind_data, sizeof(ble_bind_data)); + + nonce = NTOHL(bind_data_aligned.nonce); + time_expiration = BLE_GET_EXPIRATION_TIME(NTOHL(bind_data_aligned.timestamp)); + + // [10 bytes product_id] + [x bytes device name] + ';' + [4 bytes nonce] + ';' + [4 bytes timestamp] + memcpy(sign_info, sg_device_info.product_id, sizeof(sg_device_info.product_id)); + sign_info_len += sizeof(sg_device_info.product_id); + memcpy(sign_info + sign_info_len, sg_device_info.device_name, strlen(sg_device_info.device_name)); + sign_info_len += strlen(sg_device_info.device_name); + snprintf(sign_info + sign_info_len, sizeof(sign_info) - sign_info_len, ";%u", nonce); + sign_info_len += strlen(sign_info + sign_info_len); + snprintf(sign_info + sign_info_len, sizeof(sign_info) - sign_info_len, ";%u", time_expiration); + sign_info_len += strlen(sign_info + sign_info_len); + + qcloud_iot_utils_base64decode(secret, sizeof(secret), (size_t *)&secret_len, + (const unsigned char *)sg_device_info.psk, sizeof(sg_device_info.psk)); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "bind sign in", sign_info, sign_info_len); + utils_hmac_sha1((const char *)sign_info, sign_info_len, out_sign, (const char *)secret, secret_len); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "bind sign out", out_sign, sizeof(out_sign)); + + // return [SHA1_DIGEST_SIZE bytes sign] + [x bytes device_name] + memset(out_buf, 0, buf_len); + memcpy(out_buf, out_sign, SHA1_DIGEST_SIZE); + ret_len += SHA1_DIGEST_SIZE; + + memcpy(out_buf + ret_len, sg_device_info.device_name, strlen(sg_device_info.device_name)); + ret_len += strlen(sg_device_info.device_name); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "bind auth code", out_buf, ret_len); + + return ret_len; +} + +ble_qiot_ret_status_t ble_bind_write_result(const char *result, uint16_t len) +{ + POINTER_SANITY_CHECK(result, BLE_QIOT_RS_ERR_PARA); + BUFF_LEN_SANITY_CHECK(len, (int32_t)sizeof(ble_core_data), BLE_QIOT_RS_ERR_PARA); + + ble_core_data *bind_result = (ble_core_data *)result; + + llsync_bind_state_set((e_llsync_bind_state)bind_result->bind_state); + return ble_write_core_data(bind_result); +} + +ble_qiot_ret_status_t ble_unbind_write_result(void) +{ + ble_core_data bind_result; + + llsync_connection_state_set(E_LLSYNC_DISCONNECTED); + llsync_bind_state_set(E_LLSYNC_BIND_IDLE); + memset(&bind_result, 0, sizeof(bind_result)); + return ble_write_core_data(&bind_result); +} + +int ble_conn_get_authcode(const char *conn_data, uint16_t data_len, char *out_buf, uint16_t buf_len) +{ + POINTER_SANITY_CHECK(conn_data, BLE_QIOT_RS_ERR_PARA); + BUFF_LEN_SANITY_CHECK(data_len, (int32_t)sizeof(ble_conn_data), BLE_QIOT_RS_ERR_PARA); + POINTER_SANITY_CHECK(out_buf, BLE_QIOT_RS_ERR_PARA); + BUFF_LEN_SANITY_CHECK(buf_len, SHA1_DIGEST_SIZE + BLE_QIOT_DEVICE_NAME_LEN, BLE_QIOT_RS_ERR_PARA); + + char sign_info[64] = {0}; + char out_sign[SHA1_DIGEST_SIZE] = {0}; + int sign_info_len = 0; + int timestamp = 0; + int ret_len = 0; + + // if the pointer "char *bind_data" is not aligned with 4 byte, in some cpu convert it to + // pointer "ble_bind_data *" work correctly, but some cpu will get wrong value, or cause + // other "Unexpected Error". Here copy it to a local variable make sure aligned with 4 byte. + ble_conn_data conn_data_aligned; + memcpy(&conn_data_aligned, conn_data, sizeof(ble_conn_data)); + + // valid sign + timestamp = NTOHL(conn_data_aligned.timestamp); + snprintf(sign_info + sign_info_len, sizeof(sign_info) - sign_info_len, "%d", timestamp); + sign_info_len += strlen(sign_info + sign_info_len); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "valid sign in", sign_info, sign_info_len); + utils_hmac_sha1(sign_info, sign_info_len, out_sign, sg_core_data.local_psk, sizeof(sg_core_data.local_psk)); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "valid sign out", out_sign, SHA1_DIGEST_SIZE); + if (0 != memcmp(&conn_data_aligned.sign_info, out_sign, SHA1_DIGEST_SIZE)) { + ble_qiot_log_e("invalid connect sign"); + return BLE_QIOT_RS_VALID_SIGN_ERR; + } + + // calc sign + memset(sign_info, 0, sizeof(sign_info)); + sign_info_len = 0; + + // expiration time + product id + device name + timestamp = BLE_GET_EXPIRATION_TIME(NTOHL(conn_data_aligned.timestamp)); + snprintf(sign_info + sign_info_len, sizeof(sign_info) - sign_info_len, "%d", timestamp); + sign_info_len += strlen(sign_info + sign_info_len); + memcpy(sign_info + sign_info_len, sg_device_info.product_id, sizeof(sg_device_info.product_id)); + sign_info_len += sizeof(sg_device_info.product_id); + memcpy(sign_info + sign_info_len, sg_device_info.device_name, strlen(sg_device_info.device_name)); + sign_info_len += strlen(sg_device_info.device_name); + + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "conn sign in", sign_info, sign_info_len); + utils_hmac_sha1(sign_info, sign_info_len, out_sign, sg_core_data.local_psk, sizeof(sg_core_data.local_psk)); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "conn sign out", out_sign, sizeof(out_sign)); + + // return authcode + memset(out_buf, 0, buf_len); + memcpy(out_buf, out_sign, SHA1_DIGEST_SIZE); + ret_len += SHA1_DIGEST_SIZE; + memcpy(out_buf + ret_len, sg_device_info.device_name, strlen(sg_device_info.device_name)); + ret_len += strlen(sg_device_info.device_name); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "conn auth code", out_buf, ret_len); + + return ret_len; +} + +int ble_unbind_get_authcode(const char *unbind_data, uint16_t data_len, char *out_buf, uint16_t buf_len) +{ + POINTER_SANITY_CHECK(unbind_data, BLE_QIOT_RS_ERR_PARA); + BUFF_LEN_SANITY_CHECK(data_len, (int32_t)sizeof(ble_unbind_data), BLE_QIOT_RS_ERR_PARA); + POINTER_SANITY_CHECK(out_buf, BLE_QIOT_RS_ERR_PARA); + BUFF_LEN_SANITY_CHECK(buf_len, SHA1_DIGEST_SIZE, BLE_QIOT_RS_ERR_PARA); + + char sign_info[32] = {0}; + char out_sign[SHA1_DIGEST_SIZE] = {0}; + int sign_info_len = 0; + int ret_len = 0; + + // valid sign + memcpy(sign_info, BLE_UNBIND_REQUEST_STR, BLE_UNBIND_REQUEST_STR_LEN); + sign_info_len += BLE_UNBIND_REQUEST_STR_LEN; + utils_hmac_sha1(sign_info, sign_info_len, out_sign, sg_core_data.local_psk, sizeof(sg_core_data.local_psk)); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "valid sign out", out_sign, SHA1_DIGEST_SIZE); + + if (0 != memcmp(((ble_unbind_data *)unbind_data)->sign_info, out_sign, SHA1_DIGEST_SIZE)) { + ble_qiot_log_e("invalid unbind sign"); + return BLE_QIOT_RS_VALID_SIGN_ERR; + } + + // calc sign + memset(sign_info, 0, sizeof(sign_info)); + sign_info_len = 0; + + memcpy(sign_info, BLE_UNBIND_RESPONSE, strlen(BLE_UNBIND_RESPONSE)); + sign_info_len += BLE_UNBIND_RESPONSE_STR_LEN; + utils_hmac_sha1(sign_info, sign_info_len, out_sign, sg_core_data.local_psk, sizeof(sg_core_data.local_psk)); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "unbind auth code", out_sign, SHA1_DIGEST_SIZE); + + memset(out_buf, 0, buf_len); + memcpy(out_buf, out_sign, sizeof(out_sign)); + ret_len += sizeof(out_sign); + + return ret_len; +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_llsync_event.c b/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_llsync_event.c new file mode 100644 index 00000000..12c52436 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_llsync_event.c @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_llsync_event.h" + +#include +#include + +#include "ble_qiot_import.h" +#include "ble_qiot_common.h" +#include "ble_qiot_param_check.h" +#include "ble_qiot_service.h" +#include "ble_qiot_template.h" +#include "ble_qiot_llsync_device.h" + +ble_qiot_ret_status_t ble_event_get_status(void) +{ +#ifdef BLE_QIOT_INCLUDE_PROPERTY + return ble_event_notify(BLE_QIOT_EVENT_UP_GET_STATUS, NULL, 0, NULL, 0); +#else + ble_qiot_log_e("llsync property not support"); + return BLE_QIOT_RS_OK; +#endif +} + +ble_qiot_ret_status_t ble_event_report_property(void) +{ +#ifdef BLE_QIOT_INCLUDE_PROPERTY + return ble_user_property_get_report_data(); +#else + ble_qiot_log_e("llsync property not support"); + return BLE_QIOT_RS_OK; +#endif +} + +ble_qiot_ret_status_t ble_event_report_device_info(void) +{ + char device_info[3] = {0}; + uint16_t mtu_size = 0; + + mtu_size = ble_get_user_data_mtu_size(); + mtu_size = HTONS(mtu_size); + device_info[0] = BLE_QIOT_LLSYNC_PROTOCOL_VERSION; + memcpy(&device_info[1], &mtu_size, sizeof(mtu_size)); + + return ble_event_notify(BLE_QIOT_EVENT_UP_REPORT_MTU, NULL, 0, (const char *)device_info, sizeof(device_info)); +} + +ble_qiot_ret_status_t ble_event_notify(uint8_t type, uint8_t *header, uint8_t header_len, const char *buf, + uint16_t buf_len) +{ + char * p = NULL; + uint16_t left_len = 0; + uint16_t send_len = 0; + uint16_t mtu_size = 0; + uint8_t slice_state = BLE_QIOT_EVENT_NO_SLICE; + uint8_t send_buf[BLE_QIOT_EVENT_BUF_SIZE] = {0}; + uint16_t send_buf_index = 0; + uint16_t tmp_len = 0; + + if (!llsync_is_connected() && type != BLE_QIOT_EVENT_UP_BIND_SIGN_RET && type != BLE_QIOT_EVENT_UP_CONN_SIGN_RET && + type != BLE_QIOT_EVENT_UP_UNBIND_SIGN_RET) { + ble_qiot_log_e("upload msg negate, device not connected"); + return BLE_QIOT_RS_ERR; + } + + // reserve event header length, 3 bytes fixed length + n bytes header + mtu_size = ble_get_user_data_mtu_size(); + mtu_size = mtu_size > sizeof(send_buf) ? sizeof(send_buf) : mtu_size; + mtu_size -= (BLE_QIOT_EVENT_FIXED_HEADER_LEN + header_len); + ble_qiot_log_d("mtu size %d", mtu_size); + + p = (char *)buf; + left_len = buf_len; + do { + memset(send_buf, 0, sizeof(send_buf)); + send_buf_index = 0; + send_len = left_len > mtu_size ? mtu_size : left_len; + + send_buf[send_buf_index++] = type; + if (NULL != buf) { + tmp_len = HTONS(send_len + header_len); + memcpy(send_buf + send_buf_index, &tmp_len, sizeof(uint16_t)); + send_buf_index += sizeof(uint16_t); + if (NULL != header) { + memcpy(send_buf + send_buf_index, header, header_len); + send_buf_index += header_len; + } + memcpy(send_buf + send_buf_index, p, send_len); + send_buf_index += send_len; + + p += send_len; + left_len -= send_len; + // add event id + send_len += (BLE_QIOT_EVENT_FIXED_HEADER_LEN + header_len); + + if (0 == left_len) { + if (BLE_QIOT_EVENT_NO_SLICE == slice_state) { + slice_state = BLE_QIOT_EVENT_NO_SLICE; + } else { + slice_state = BLE_QIOT_EVENT_SLICE_FOOT; + } + } else { + if (BLE_QIOT_EVENT_NO_SLICE == slice_state) { + slice_state = BLE_QIOT_EVENT_SLICE_HEAD; + } else { + slice_state = BLE_QIOT_EVENT_SLICE_BODY; + } + } + // the high 2 bits means slice state, and the left 14 bits is data length + send_buf[1] |= slice_state << 6; + } else { + send_len = send_buf_index; + } + + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "post data", (char *)send_buf, send_len); + if (0 != ble_send_notify(send_buf, send_len)) { + ble_qiot_log_e("event post failed, type %d", type); + return BLE_QIOT_RS_ERR; + } + } while (left_len != 0); + + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_event_post(uint8_t event_id) +{ +#ifdef BLE_QIOT_INCLUDE_EVENT + uint8_t param_id = 0; + uint8_t param_id_size = 0; + uint8_t param_type = 0; + int param_len = 0; + uint8_t data_buf[BLE_QIOT_EVENT_MAX_SIZE] = {0}; + uint16_t data_len = 0; + uint16_t string_len = 0; + uint8_t header_buf[1] = {0}; + + ble_qiot_log_d("post event %d", event_id); + param_id_size = ble_event_get_id_array_size(event_id); + // get all the data + for (param_id = 0; param_id < param_id_size; param_id++) { + param_type = ble_event_get_param_id_type(event_id, param_id); + if (param_type == BLE_QIOT_DATA_TYPE_BUTT) { + ble_qiot_log_e("invalid type, event id %d, param id %d", event_id, param_id); + return BLE_QIOT_RS_ERR; + } + + data_buf[data_len++] = BLE_QIOT_PACKAGE_TLV_HEAD(param_type, param_id); + if (BLE_QIOT_DATA_TYPE_STRING == param_type) { + // reserved 2 bytes for string length, other type have fixed length + param_len = ble_event_get_data_by_id(event_id, param_id, (char *)data_buf + data_len + 2, + sizeof(data_buf) - data_len - 2); + } else { + param_len = + ble_event_get_data_by_id(event_id, param_id, (char *)data_buf + data_len, sizeof(data_buf) - data_len); + } + if (param_len < 0) { + ble_qiot_log_e("too long data, event id %d, data length %d", event_id, data_len); + return BLE_QIOT_RS_ERR; + } else if (param_len == 0) { + // no data to post + data_len--; + data_buf[data_len] = '0'; + ble_qiot_log_d("param id %d no data to post", param_id); + } else { + if (BLE_QIOT_DATA_TYPE_STRING == param_type) { + string_len = HTONS(param_len); + memcpy(data_buf + data_len, &string_len, sizeof(uint16_t)); + data_len += sizeof(uint16_t); + } + data_len += param_len; + } + } + header_buf[0] = event_id; + + return ble_event_notify(BLE_QIOT_EVENT_UP_EVENT_POST, header_buf, sizeof(header_buf), (const char *)data_buf, + data_len); +#else + ble_qiot_log_e("llsync event not support"); + return BLE_QIOT_RS_ERR; +#endif +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_service.c b/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_service.c new file mode 100644 index 00000000..015f2220 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/core/ble_qiot_service.c @@ -0,0 +1,508 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_service.h" + +#include + +#include "ble_qiot_export.h" +#include "ble_qiot_import.h" +#include "ble_qiot_llsync_data.h" +#include "ble_qiot_llsync_device.h" +#include "ble_qiot_llsync_event.h" +#include "ble_qiot_log.h" +#include "ble_qiot_param_check.h" +#include "ble_qiot_service.h" +#include "ble_qiot_template.h" + +// llsync support data fragment, so we need to package all the data before parsing if the data is slice +static ble_event_slice_t sg_ble_slice_data; + +#if (1 == BLE_QIOT_BUTTON_BROADCAST) +static ble_timer_t sg_bind_timer = NULL; +#endif + +static qiot_service_init_s service_info = { + .service_uuid16 = IOT_BLE_UUID_SERVICE, + .service_uuid128 = IOT_BLE_UUID_BASE, + .device_info = + { + .uuid16 = IOT_BLE_UUID_DEVICE_INFO, + .gatt_char_props = GATT_CHAR_WRITE, + .on_write = ble_device_info_write_cb, + }, + .data = + { + .uuid16 = IOT_BLE_UUID_DATA, + .gatt_char_props = GATT_CHAR_WRITE, + .on_write = ble_lldata_write_cb, + }, + .event = + { + .uuid16 = IOT_BLE_UUID_EVENT, + .gatt_char_props = GATT_CHAR_NOTIFY, + .on_write = NULL, + }, +}; + +const qiot_service_init_s *ble_get_qiot_services(void) +{ + return &service_info; +} + +#if (1 == BLE_QIOT_BUTTON_BROADCAST) +static void ble_bind_timer_callback(void *param) +{ + ble_qiot_log_i("timer timeout"); + if (E_LLSYNC_BIND_WAIT == llsync_bind_state_get()) { + ble_advertising_stop(); + llsync_bind_state_set(E_LLSYNC_BIND_IDLE); + ble_qiot_log_i("stop advertising"); + } +} +#endif + +ble_qiot_ret_status_t ble_qiot_advertising_start(void) +{ + adv_info_s my_adv_info; + uint16_t uuids[1]; + uint8_t adv_data[32] = {0}; + uint8_t adv_data_len = 0; + + uuids[0] = IOT_BLE_UUID_SERVICE; + my_adv_info.uuid_info.uuid_num = 1; + my_adv_info.uuid_info.uuids = uuids; + + if (E_LLSYNC_BIND_IDLE == llsync_bind_state_get()) { +#if (1 == BLE_QIOT_BUTTON_BROADCAST) + if (NULL == sg_bind_timer) { + sg_bind_timer = ble_timer_create(BLE_TIMER_ONE_SHOT_TYPE, ble_bind_timer_callback); + if (NULL == sg_bind_timer) { + ble_qiot_log_i("create bind timer failed"); + return BLE_QIOT_RS_ERR; + } + } +#endif + + ble_advertising_stop(); + + llsync_bind_state_set(E_LLSYNC_BIND_WAIT); + adv_data_len = ble_get_my_broadcast_data((char *)adv_data, sizeof(adv_data)); + my_adv_info.manufacturer_info.company_identifier = TENCENT_COMPANY_IDENTIFIER; + my_adv_info.manufacturer_info.adv_data = adv_data; + my_adv_info.manufacturer_info.adv_data_len = adv_data_len; + ble_advertising_start(&my_adv_info); + ble_qiot_log_i("start wait advertising"); + +#if (1 == BLE_QIOT_BUTTON_BROADCAST) + ble_timer_start(sg_bind_timer, BLE_QIOT_BIND_TIMEOUT); +#endif + } else if (E_LLSYNC_BIND_WAIT == llsync_bind_state_get()) { + ble_advertising_stop(); + llsync_bind_state_set(E_LLSYNC_BIND_WAIT); + adv_data_len = ble_get_my_broadcast_data((char *)adv_data, sizeof(adv_data)); + my_adv_info.manufacturer_info.company_identifier = TENCENT_COMPANY_IDENTIFIER; + my_adv_info.manufacturer_info.adv_data = adv_data; + my_adv_info.manufacturer_info.adv_data_len = adv_data_len; + ble_advertising_start(&my_adv_info); + ble_qiot_log_i("restart wait advertising"); + +#if (1 == BLE_QIOT_BUTTON_BROADCAST) + ble_timer_stop(sg_bind_timer); + ble_timer_start(sg_bind_timer, BLE_QIOT_BIND_TIMEOUT); +#endif + } else if (E_LLSYNC_BIND_SUCC == llsync_bind_state_get()) { + ble_advertising_stop(); + adv_data_len = ble_get_my_broadcast_data((char *)adv_data, sizeof(adv_data)); + my_adv_info.manufacturer_info.company_identifier = TENCENT_COMPANY_IDENTIFIER; + my_adv_info.manufacturer_info.adv_data = adv_data; + my_adv_info.manufacturer_info.adv_data_len = adv_data_len; + ble_advertising_start(&my_adv_info); + ble_qiot_log_i("start bind advertising"); + } else { + // do nothing + } + + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_qiot_advertising_stop(void) +{ + return 0 == ble_advertising_stop() ? BLE_QIOT_RS_OK : BLE_QIOT_RS_ERR; +} + +ble_qiot_ret_status_t ble_qiot_explorer_init(void) +{ + ble_qiot_ret_status_t ret_code = BLE_QIOT_RS_OK; + const qiot_service_init_s *service_info = NULL; + + ble_qiot_set_log_level(BLE_QIOT_LOG_LEVEL_INFO); + + service_info = ble_get_qiot_services(); + ble_services_add(service_info); + + ret_code = ble_init_flash_data(); + if (ret_code != BLE_QIOT_RS_OK) { + ble_qiot_log_e("flash init failed, ret code %d", ret_code); + } + + return ret_code; +} + +void ble_device_info_write_cb(const uint8_t *buf, uint16_t len) +{ + ble_device_info_msg_handle((const char *)buf, len); +} + +void ble_lldata_write_cb(const uint8_t *buf, uint16_t len) +{ + ble_lldata_msg_handle((const char *)buf, len); +} + +// when gap get ble connect event, use this function +void ble_gap_connect_cb(void) +{ + ble_connection_state_set(E_BLE_CONNECTED); +} + +// when gap get ble disconnect event, use this function +void ble_gap_disconnect_cb(void) +{ + llsync_connection_state_set(E_LLSYNC_DISCONNECTED); + ble_connection_state_set(E_BLE_DISCONNECTED); +} + +static uint8_t ble_msg_type_header_len(uint8_t type) +{ + if (type == BLE_QIOT_GET_STATUS_REPLY_DATA_TYPE) { + return BLE_QIOT_GET_STATUS_REPLY_HEADER_LEN; + } else { + return BLE_QIOT_DATA_FIXED_HEADER_LEN; + } +} + +int ble_device_info_msg_handle(const char *in_buf, int in_len) +{ + POINTER_SANITY_CHECK(in_buf, BLE_QIOT_RS_ERR_PARA); + uint8_t ch; + char out_buf[80] = {0}; + uint8_t slice_flag = 0; + uint8_t header_len = 0; + uint8_t slice_type = 0; + uint16_t tmp_len = 0; + char * p_data = NULL; + int p_data_len = 0; + int ret_len = 0; + int ret = BLE_QIOT_RS_OK; + + + p_data = (char *)in_buf; + p_data_len = in_len; + + // E_DEV_MSG_SYNC_TIME, E_DEV_MSG_CONN_VALID, E_DEV_MSG_BIND_SUCC, E_DEV_MSG_UNBIND this 4 type + // of message has more than one bytes data, it may cut to several slices, here need to merge them + // together, other type message only has 1 byte data, not need merge. + if(in_len > 3) { + slice_type = in_buf[0]; + slice_flag = in_buf[1]; + if (BLE_QIOT_IS_SLICE_PACKAGE(slice_flag)) { + if (BLE_QIOT_IS_SLICE_HEADER(slice_flag)) { + if (sg_ble_slice_data.have_data) { + ble_qiot_log_e("new data coming when package msg, clear the buffer"); + memset(&sg_ble_slice_data, 0, sizeof(sg_ble_slice_data)); + } + sg_ble_slice_data.have_data = true; + sg_ble_slice_data.type = slice_type; + header_len = ble_msg_type_header_len(slice_type); + // reserved data length space + sg_ble_slice_data.buf_len += header_len; + + sg_ble_slice_data.buf[0] = in_buf[0]; + if (BLE_QIOT_GET_STATUS_REPLY_DATA_TYPE == slice_type) { + sg_ble_slice_data.buf[1] = in_buf[1]; + } + memcpy(sg_ble_slice_data.buf + sg_ble_slice_data.buf_len, in_buf + header_len, in_len - header_len); + sg_ble_slice_data.buf_len += (in_len - header_len); + return BLE_QIOT_RS_OK; + } else if (BLE_QIOT_IS_SLICE_BODY(slice_flag)) { + if (!sg_ble_slice_data.have_data) { + ble_qiot_log_e("slice no header package"); + return BLE_QIOT_RS_ERR; + } + if (slice_type != sg_ble_slice_data.type) { + ble_qiot_log_e("invalid msg type %d, except msg type %d", slice_type, sg_ble_slice_data.type); + return BLE_QIOT_RS_ERR; + } + if (sg_ble_slice_data.buf_len + (in_len - header_len) > sizeof(sg_ble_slice_data.buf)) { + ble_qiot_log_e("slice data is too long, max length %d", sizeof(sg_ble_slice_data.buf)); + return BLE_QIOT_RS_ERR; + } + header_len = ble_msg_type_header_len(slice_type); + memcpy(sg_ble_slice_data.buf + sg_ble_slice_data.buf_len, in_buf + header_len, in_len - header_len); + sg_ble_slice_data.buf_len += (in_len - header_len); + return BLE_QIOT_RS_OK; + } else { + if (!sg_ble_slice_data.have_data) { + ble_qiot_log_e("slice no header package"); + return BLE_QIOT_RS_ERR; + } + if (slice_type != sg_ble_slice_data.type) { + ble_qiot_log_e("invalid msg type %d, except msg type %d", slice_type, sg_ble_slice_data.type); + return BLE_QIOT_RS_ERR; + } + if (sg_ble_slice_data.buf_len + (in_len - header_len) > sizeof(sg_ble_slice_data.buf)) { + ble_qiot_log_e("slice data is too long, max length %d", sizeof(sg_ble_slice_data.buf)); + return BLE_QIOT_RS_ERR; + } + header_len = ble_msg_type_header_len(slice_type); + memcpy(sg_ble_slice_data.buf + sg_ble_slice_data.buf_len, in_buf + header_len, in_len - header_len); + sg_ble_slice_data.buf_len += (in_len - header_len); + // write data length + tmp_len = HTONS(sg_ble_slice_data.buf_len - header_len); + if (BLE_QIOT_GET_STATUS_REPLY_DATA_TYPE == slice_type) { + memcpy(&sg_ble_slice_data.buf[2], &tmp_len, sizeof(tmp_len)); + } else { + memcpy(&sg_ble_slice_data.buf[1], &tmp_len, sizeof(tmp_len)); + } + p_data = sg_ble_slice_data.buf; + p_data_len = sg_ble_slice_data.buf_len; + // ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "tlv", p_data, p_data_len); + } + } else { + ble_qiot_log_d("data not slice"); + } + } + + // ch = in_buf[0]; + ch = p_data[0]; + switch (ch) { + case E_DEV_MSG_SYNC_TIME: + ret_len = ble_bind_get_authcode(p_data + 3, p_data_len - 3, out_buf, sizeof(out_buf)); + if (ret_len <= 0) { + ble_qiot_log_e("get bind authcode failed"); + ret = BLE_QIOT_RS_ERR; + break; + } + ret = ble_event_notify((uint8_t)BLE_QIOT_EVENT_UP_BIND_SIGN_RET, NULL, 0, out_buf, ret_len); + break; + case E_DEV_MSG_CONN_VALID: + ret_len = ble_conn_get_authcode(p_data + 3, p_data_len - 3, out_buf, sizeof(out_buf)); + if (ret_len <= 0) { + ble_qiot_log_e("get connect authcode failed"); + ret = BLE_QIOT_RS_ERR; + break; + } + ret = ble_event_notify((uint8_t)BLE_QIOT_EVENT_UP_CONN_SIGN_RET, NULL, 0, out_buf, ret_len); + break; + case E_DEV_MSG_BIND_SUCC: + if (BLE_QIOT_RS_OK != ble_bind_write_result(p_data + 3, p_data_len - 3)) { + ble_qiot_log_e("write bind result failed"); + ret = BLE_QIOT_RS_ERR; + break; + } + break; + case E_DEV_MSG_BIND_FAIL: + ble_qiot_log_i("get msg bind fail"); + break; + case E_DEV_MSG_UNBIND: + ret_len = ble_unbind_get_authcode(p_data + 3, p_data_len - 3, out_buf, sizeof(out_buf)); + if (ret_len <= 0) { + ble_qiot_log_e("get unbind authcode failed"); + ret = BLE_QIOT_RS_ERR; + break; + } + ret = ble_event_notify((uint8_t)BLE_QIOT_EVENT_UP_UNBIND_SIGN_RET, NULL, 0, out_buf, ret_len); + break; + case E_DEV_MSG_CONN_SUCC: + ble_qiot_log_i("get msg connect success"); + llsync_connection_state_set(E_LLSYNC_CONNECTED); + ret = ble_event_report_device_info(); + break; + case E_DEV_MSG_CONN_FAIL: + ble_qiot_log_i("get msg connect fail"); + break; + case E_DEV_MSG_UNBIND_SUCC: + ble_qiot_log_i("get msg unbind success"); + if (BLE_QIOT_RS_OK != ble_unbind_write_result()) { + ble_qiot_log_e("write unbind result failed"); + ret = BLE_QIOT_RS_ERR; + break; + } + break; + case E_DEV_MSG_UNBIND_FAIL: + ble_qiot_log_i("get msg unbind fail"); + break; + default: + break; + } + memset(&sg_ble_slice_data, 0, sizeof(sg_ble_slice_data)); + + return ret; +} + +// lldata message from remote +int ble_lldata_msg_handle(const char *in_buf, int in_len) +{ + POINTER_SANITY_CHECK(in_buf, BLE_QIOT_RS_ERR_PARA); + + uint8_t data_type = 0; + uint8_t data_effect = 0; + uint8_t id = 0; + uint8_t slice_flag = 0; + uint8_t header_len = 0; + uint8_t slice_type = 0; + uint16_t tmp_len = 0; + char * p_data = NULL; + int p_data_len = 0; + int ret = 0; + + if (!llsync_is_connected()) { + ble_qiot_log_e("operation negate, device not connected"); + return BLE_QIOT_RS_ERR; + } + + p_data = (char *)in_buf; + p_data_len = in_len; + + data_type = BLE_QIOT_PARSE_MSG_HEAD_TYPE(in_buf[0]); + if (data_type >= BLE_QIOT_DATA_TYPE_BUTT) { + ble_qiot_log_e("invalid data type %d", data_type); + return BLE_QIOT_RS_ERR; + } + data_effect = BLE_QIOT_PARSE_MSG_HEAD_EFFECT(in_buf[0]); + if (data_effect >= BLE_QIOT_EFFECT_BUTT) { + ble_qiot_log_e("invalid data effect %d", data_effect); + return BLE_QIOT_RS_ERR; + } + id = BLE_QIOT_PARSE_MSG_HEAD_ID(in_buf[0]); + ble_qiot_log_d("data type %d, effect %d, id %d", data_type, data_effect, id); + + // if data is action_reply, control or get_status_reply, the data maybe need package + if ((data_type == BLE_QIOT_MSG_TYPE_ACTION) || (in_buf[0] == BLE_QIOT_CONTROL_DATA_TYPE) || + (in_buf[0] == BLE_QIOT_GET_STATUS_REPLY_DATA_TYPE)) { + if (in_buf[0] == BLE_QIOT_GET_STATUS_REPLY_DATA_TYPE) { + slice_flag = in_buf[2]; + slice_type = in_buf[0]; + } else { + slice_flag = in_buf[1]; + slice_type = data_type; + } + if (BLE_QIOT_IS_SLICE_PACKAGE(slice_flag)) { + if (BLE_QIOT_IS_SLICE_HEADER(slice_flag)) { + if (sg_ble_slice_data.have_data) { + ble_qiot_log_e("new data coming when package msg, clear the buffer"); + memset(&sg_ble_slice_data, 0, sizeof(sg_ble_slice_data)); + } + sg_ble_slice_data.have_data = true; + sg_ble_slice_data.type = slice_type; + header_len = ble_msg_type_header_len(slice_type); + // reserved data length space + sg_ble_slice_data.buf_len += header_len; + + sg_ble_slice_data.buf[0] = in_buf[0]; + if (BLE_QIOT_GET_STATUS_REPLY_DATA_TYPE == slice_type) { + sg_ble_slice_data.buf[1] = in_buf[1]; + } + memcpy(sg_ble_slice_data.buf + sg_ble_slice_data.buf_len, in_buf + header_len, in_len - header_len); + sg_ble_slice_data.buf_len += (in_len - header_len); + return BLE_QIOT_RS_OK; + } else if (BLE_QIOT_IS_SLICE_BODY(slice_flag)) { + if (!sg_ble_slice_data.have_data) { + ble_qiot_log_e("slice no header package"); + return BLE_QIOT_RS_ERR; + } + if (slice_type != sg_ble_slice_data.type) { + ble_qiot_log_e("invalid msg type %d, except msg type %d", slice_type, sg_ble_slice_data.type); + return BLE_QIOT_RS_ERR; + } + if (sg_ble_slice_data.buf_len + (in_len - header_len) > sizeof(sg_ble_slice_data.buf)) { + ble_qiot_log_e("slice data is too long, max length %d", sizeof(sg_ble_slice_data.buf)); + return BLE_QIOT_RS_ERR; + } + header_len = ble_msg_type_header_len(slice_type); + memcpy(sg_ble_slice_data.buf + sg_ble_slice_data.buf_len, in_buf + header_len, in_len - header_len); + sg_ble_slice_data.buf_len += (in_len - header_len); + return BLE_QIOT_RS_OK; + } else { + if (!sg_ble_slice_data.have_data) { + ble_qiot_log_e("slice no header package"); + return BLE_QIOT_RS_ERR; + } + if (slice_type != sg_ble_slice_data.type) { + ble_qiot_log_e("invalid msg type %d, except msg type %d", slice_type, sg_ble_slice_data.type); + return BLE_QIOT_RS_ERR; + } + if (sg_ble_slice_data.buf_len + (in_len - header_len) > sizeof(sg_ble_slice_data.buf)) { + ble_qiot_log_e("slice data is too long, max length %d", sizeof(sg_ble_slice_data.buf)); + return BLE_QIOT_RS_ERR; + } + header_len = ble_msg_type_header_len(slice_type); + memcpy(sg_ble_slice_data.buf + sg_ble_slice_data.buf_len, in_buf + header_len, in_len - header_len); + sg_ble_slice_data.buf_len += (in_len - header_len); + // write data length + tmp_len = HTONS(sg_ble_slice_data.buf_len - header_len); + if (BLE_QIOT_GET_STATUS_REPLY_DATA_TYPE == slice_type) { + memcpy(&sg_ble_slice_data.buf[2], &tmp_len, sizeof(tmp_len)); + } else { + memcpy(&sg_ble_slice_data.buf[1], &tmp_len, sizeof(tmp_len)); + } + p_data = sg_ble_slice_data.buf; + p_data_len = sg_ble_slice_data.buf_len; + // ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_INFO, "tlv", p_data, p_data_len); + } + } else { + ble_qiot_log_d("data not slice"); + } + } + + switch (data_type) { + case BLE_QIOT_MSG_TYPE_PROPERTY: + if (BLE_QIOT_EFFECT_REQUEST == data_effect) { + // default E_BLE_DATA_DOWN_TYPE_CONTROL + ret = ble_lldata_property_request_handle(p_data + 3, p_data_len - 3); + } else if (BLE_QIOT_EFFECT_REPLY == data_effect) { + // id means BLE_QIOT_DATA_DOWN_GET_STATUS_REPLY or BLE_QIOT_DATA_DOWN_REPORT_REPLY + ret = ble_lldata_property_reply_handle(id, p_data + 1, p_data_len - 1); + } else { + ret = BLE_QIOT_RS_ERR; + } + break; + case BLE_QIOT_MSG_TYPE_EVENT: + if (BLE_QIOT_EFFECT_REPLY == data_effect) { + ret = ble_lldata_event_handle(id, p_data + 1, p_data_len - 1); + } else { + ble_qiot_log_e("invalid event data effect"); + ret = BLE_QIOT_RS_ERR; + } + break; + case BLE_QIOT_MSG_TYPE_ACTION: + if (BLE_QIOT_EFFECT_REQUEST == data_effect) { + ret = ble_lldata_action_handle(id, p_data + 3, p_data_len - 3); + } else { + ble_qiot_log_e("invalid action data effect"); + ret = BLE_QIOT_RS_ERR; + } + break; + default: + break; + } + memset(&sg_ble_slice_data, 0, sizeof(sg_ble_slice_data)); + + return ret; +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_common.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_common.h new file mode 100644 index 00000000..b7528786 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_common.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef QCLOUD_BLE_QIOT_COMMON_H +#define QCLOUD_BLE_QIOT_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_QIOT_PRODUCT_ID_LEN (10) // fixed length of product id +#define BLE_QIOT_DEVICE_NAME_LEN (48) // max length of device name +#define BLE_QIOT_PSK_LEN (24) // fixed length of secret key +#define BLE_QIOT_MAC_LEN (6) // fixed length of mac + +#define SWAP_32(x) \ + ((((x)&0xFF000000) >> 24) | (((x)&0x00FF0000) >> 8) | (((x)&0x0000FF00) << 8) | (((x)&0x000000FF) << 24)) +#define SWAP_16(x) ((((x)&0xFF00) >> 8) | (((x)&0x00FF) << 8)) +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define HTONL(x) SWAP_32(x) +#define HTONS(x) SWAP_16(x) +#define NTOHL(x) SWAP_32(x) +#define NTOHS(x) SWAP_16(x) +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define HTONL(x) (x) +#define HTONS(x) (x) +#define NTOHL(x) (x) +#define NTOHS(x) (x) +#else +#error "undefined byte order" +#endif + +#ifdef __cplusplus +} +#endif + +#endif // QCLOUD_BLE_QIOT_COMMON_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_hmac.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_hmac.h new file mode 100644 index 00000000..383e8d95 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_hmac.h @@ -0,0 +1,32 @@ +/* + * Tencent is pleased to support the open source community by making IoT Hub available. + * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. + + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_QIOT_HMAC_H +#define QCLOUD_BLE_QIOT_HMAC_H + +#if defined(__cplusplus) +extern "C" { +#endif + +#include + +#define SHA1_DIGEST_SIZE 20 + +void utils_hmac_sha1(const char *msg, int msg_len, char *digest, const char *key, int key_len); + +#if defined(__cplusplus) +} +#endif +#endif // QCLOUD_BLE_QIOT_HMAC_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_llsync_data.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_llsync_data.h new file mode 100644 index 00000000..af6d9838 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_llsync_data.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef QCLOUD_BLE_QIOT_LLSYNC_DATA_H +#define QCLOUD_BLE_QIOT_LLSYNC_DATA_H +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define BLE_QIOT_CONTROL_DATA_TYPE (0x00) +#define BLE_QIOT_GET_STATUS_REPLY_DATA_TYPE (0x22) + +#define BLE_QIOT_GET_STATUS_REPLY_HEADER_LEN (4) +#define BLE_QIOT_DATA_FIXED_HEADER_LEN (3) + +// handle property request +ble_qiot_ret_status_t ble_lldata_property_request_handle(const char *in_buf, int buf_len); +// handle property reply +ble_qiot_ret_status_t ble_lldata_property_reply_handle(uint8_t type, const char *in_buf, int buf_len); + +// handle event data +ble_qiot_ret_status_t ble_lldata_event_handle(uint8_t id, const char *in_buf, int len); + +// handle action data +ble_qiot_ret_status_t ble_lldata_action_handle(uint8_t id, const char *in_buf, int len); + +ble_qiot_ret_status_t ble_user_property_get_report_data(void); +#ifdef __cplusplus +} +#endif +#endif // QCLOUD_BLE_QIOT_LLSYNC_DATA_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_llsync_device.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_llsync_device.h new file mode 100644 index 00000000..dc1596b4 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_llsync_device.h @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef QCLOUD_BLE_QIOT_LLSYNC_DEVICE_H +#define QCLOUD_BLE_QIOT_LLSYNC_DEVICE_H +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "ble_qiot_common.h" +#include "ble_qiot_export.h" +#include "ble_qiot_hmac.h" +#include "ble_qiot_llsync_event.h" + +#define LLSYNC_BIND_STATE_MASK 0x03 +#define LLSYNC_PROTOCOL_VERSION_MASK 0xF0 + +#define BLE_QIOT_LLSYNC_PROTOCOL_VERSION (1) // llsync protocol version, equal or less than 15 + +#define BLE_LOCAL_PSK_LEN 4 +#define BLE_BIND_IDENTIFY_STR_LEN 8 +#define BLE_EXPIRATION_TIME 60 // timestamp expiration value +#define BLE_UNBIND_REQUEST_STR "UnbindRequest" +#define BLE_UNBIND_REQUEST_STR_LEN (sizeof("UnbindRequest") - 1) +#define BLE_UNBIND_RESPONSE "UnbindResponse" +#define BLE_UNBIND_RESPONSE_STR_LEN (sizeof("UnbindResponse") - 1) + +typedef enum { + E_DEV_MSG_SYNC_TIME = 0, // sync info before bind + E_DEV_MSG_CONN_VALID, // connect request + E_DEV_MSG_BIND_SUCC, // inform bind success + E_DEV_MSG_BIND_FAIL, // inform bind failed + E_DEV_MSG_UNBIND, // unbind request + E_DEV_MSG_CONN_SUCC, // inform connect result + E_DEV_MSG_CONN_FAIL, + E_DEV_MSG_UNBIND_SUCC, // inform unbind result + E_DEV_MSG_UNBIND_FAIL, + E_DEV_MSG_MSG_BUTT, +} e_dev_info_msg_type; + +typedef enum { + E_LLSYNC_BIND_IDLE = 0, // no bind + E_LLSYNC_BIND_WAIT, // wait bind, return idle state if no bind in the period + E_LLSYNC_BIND_SUCC, // bound +} e_llsync_bind_state; + +typedef enum { + E_LLSYNC_DISCONNECTED = 0, + E_LLSYNC_CONNECTED, +} e_llsync_connection_state; + +typedef enum { + E_BLE_DISCONNECTED = 0, + E_BLE_CONNECTED, +} e_ble_connection_state; + +typedef struct ble_device_info_t_ { + char product_id[BLE_QIOT_PRODUCT_ID_LEN]; + char device_name[BLE_QIOT_DEVICE_NAME_LEN + 1]; + char psk[BLE_QIOT_PSK_LEN]; + char mac[BLE_QIOT_MAC_LEN]; +} ble_device_info; + +typedef struct ble_core_data_ { + uint8_t bind_state; + char local_psk[BLE_LOCAL_PSK_LEN]; + char identify_str[BLE_BIND_IDENTIFY_STR_LEN]; +} ble_core_data; + +// write to uuid FEE1 before bind +typedef struct ble_bind_data_t_ { + int nonce; + int timestamp; +} ble_bind_data; + +// connect data struct +typedef struct ble_conn_data_t_ { + int timestamp; + char sign_info[SHA1_DIGEST_SIZE]; +} ble_conn_data; + +// unbind data struct +typedef struct ble_unbind_data_t_ { + char sign_info[SHA1_DIGEST_SIZE]; +} ble_unbind_data; + +typedef struct { + bool have_data; // start received package + uint8_t type; // event type + uint16_t buf_len; // the length of data + char buf[BLE_QIOT_EVENT_MAX_SIZE]; +} ble_event_slice_t; + +// read sdk data from flash +ble_qiot_ret_status_t ble_init_flash_data(void); + +// set llsync bind state +void llsync_bind_state_set(e_llsync_bind_state new_state); + +// get llsync bind state +e_llsync_bind_state llsync_bind_state_get(void); + +// set llsync connection state +void llsync_connection_state_set(e_llsync_connection_state new_state); + +// get llsync connection state +e_llsync_connection_state llsync_connection_state_get(void); + +// set ble connection state +void ble_connection_state_set(e_ble_connection_state new_state); + +// get ble connection state +e_ble_connection_state ble_connection_state_get(void); + +// get llsync connection state +bool llsync_is_connected(void); + +// get ble connection state +bool ble_is_connected(void); + +// get broadcast data +int ble_get_my_broadcast_data(char *out_buf, int buf_len); + +// get bind authcode, return authcode length; +// out_buf length must greater than SHA1_DIGEST_SIZE + BLE_QIOT_DEVICE_NAME_LEN +int ble_bind_get_authcode(const char *bind_data, uint16_t data_len, char *out_buf, uint16_t buf_len); + +// write bind result to flash, return 0 is success +ble_qiot_ret_status_t ble_bind_write_result(const char *result, uint16_t len); + +// write unbind result to flash, return 0 is success +ble_qiot_ret_status_t ble_unbind_write_result(void); + +// get connect authcode, return authcode length; +// out_buf length must greater than SHA1_DIGEST_SIZE + BLE_QIOT_DEVICE_NAME_LEN +int ble_conn_get_authcode(const char *conn_data, uint16_t data_len, char *out_buf, uint16_t buf_len); + +// get connect authcode, return authcode length; +// out_buf length must greater than SHA1_DIGEST_SIZE + BLE_UNBIND_RESPONSE_STR_LEN +int ble_unbind_get_authcode(const char *unbind_data, uint16_t data_len, char *out_buf, uint16_t buf_len); +#ifdef __cplusplus +} +#endif +#endif // QCLOUD_BLE_QIOT_LLSYNC_DEVICE_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_llsync_event.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_llsync_event.h new file mode 100644 index 00000000..3e333645 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_llsync_event.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef QCLOUD_BLE_QIOT_LLSYNC_EVENT_H +#define QCLOUD_BLE_QIOT_LLSYNC_EVENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "ble_qiot_config.h" +#include "ble_qiot_export.h" + +enum { + BLE_QIOT_EVENT_NO_SLICE = 0, + BLE_QIOT_EVENT_SLICE_HEAD = 1, + BLE_QIOT_EVENT_SLICE_BODY = 2, + BLE_QIOT_EVENT_SLICE_FOOT = 3, +}; + +#define BLE_QIOT_EVENT_FIXED_HEADER_LEN (3) + +// the bit 15 - 14 is slice flag, bit 13 - 0 is tlv length +#define BLE_QIOT_IS_SLICE_PACKAGE(_C) ((_C)&0XC0) +#define BLE_QIOT_IS_SLICE_HEADER(_C) (((_C)&0XC0) == 0X40) +#define BLE_QIOT_IS_SLICE_BODY(_C) (((_C)&0XC0) == 0X80) +#define BLE_QIOT_IS_SLICE_TAIL(_C) (((_C)&0XC0) == 0XC0) + +ble_qiot_ret_status_t ble_event_notify(uint8_t type, uint8_t *header, uint8_t header_len, const char *buf, + uint16_t buf_len); + +#ifdef __cplusplus +} +#endif + +#endif // QCLOUD_BLE_QIOT_LLSYNC_EVENT_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_log.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_log.h new file mode 100644 index 00000000..840213fc --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_log.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef QCLOUD_BLE_QIOT_LOG_H +#define QCLOUD_BLE_QIOT_LOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_config.h" + +typedef enum { + BLE_QIOT_LOG_LEVEL_NONE = 0, + BLE_QIOT_LOG_LEVEL_ERR, + BLE_QIOT_LOG_LEVEL_WARN, + BLE_QIOT_LOG_LEVEL_INFO, + BLE_QIOT_LOG_LEVEL_DEBUG, + BLE_QIOT_LOG_LEVEL_ALL, +} e_ble_qiot_log_level; + +// log new line feed type +#define LINE_NONE +#define LINE_LF "\n" +#define LINE_CR "\r" +#define LINE_CRLF "\r\n" + +// log new line feed type config +#define LOG_LINE_FEED_TYPE LINE_CRLF + +extern e_ble_qiot_log_level g_log_level; + +#ifndef ble_qiot_log_d +#define ble_qiot_log_d(fmt, args...) \ +do { \ + if (g_log_level < BLE_QIOT_LOG_LEVEL_DEBUG) break; \ + BLE_QIOT_LOG_PRINT("qiot debug: " fmt LOG_LINE_FEED_TYPE, ##args); \ +} while (0) +#endif + +#ifndef ble_qiot_log_i +#define ble_qiot_log_i(fmt, args...) \ +do { \ + if (g_log_level < BLE_QIOT_LOG_LEVEL_INFO) break; \ + BLE_QIOT_LOG_PRINT("qiot info: " fmt LOG_LINE_FEED_TYPE, ##args); \ +} while (0) +#endif + +#ifndef ble_qiot_log_w +#define ble_qiot_log_w(fmt, args...) \ +do { \ + if (g_log_level < BLE_QIOT_LOG_LEVEL_WARN) break; \ + BLE_QIOT_LOG_PRINT("qiot warn(%s|%d): " fmt LOG_LINE_FEED_TYPE, __FILE__, __LINE__, ##args); \ +} while (0) +#endif + +#ifndef ble_qiot_log_e +#define ble_qiot_log_e(fmt, args...) \ +do { \ + if (g_log_level < BLE_QIOT_LOG_LEVEL_ERR) break; \ + BLE_QIOT_LOG_PRINT("qiot err(%s|%d): " fmt LOG_LINE_FEED_TYPE, __FILE__, __LINE__, ##args); \ +} while (0) +#endif + +#ifndef ble_qiot_log +#define ble_qiot_log(level, fmt, args...) \ +do { \ + if (g_log_level < level) break; \ + BLE_QIOT_LOG_PRINT("qiot log(%s|%d): " fmt LOG_LINE_FEED_TYPE, __FILE__, __LINE__, ##args); \ +} while (0) +#endif + +// this function only use for ble_qiot_log_hex +#ifndef ble_qiot_log_raw +#define ble_qiot_log_raw(fmt, args...) \ +do { \ + BLE_QIOT_LOG_PRINT(fmt, ##args); \ +} while (0) +#endif + +void ble_qiot_set_log_level(e_ble_qiot_log_level level); + +#if (0 == BLE_QIOT_USER_DEFINE_HEDUMP) +void ble_qiot_log_hex(e_ble_qiot_log_level level, const char *hex_name, const char *data, uint32_t data_len); +#endif // BLE_QIOT_USER_DEFINE_HEDUMP + +#ifdef __cplusplus +} +#endif +#endif // QCLOUD_BLE_QIOT_LOG_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_md5.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_md5.h new file mode 100644 index 00000000..2d670e0f --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_md5.h @@ -0,0 +1,94 @@ +/* + * Tencent is pleased to support the open source community by making IoT Hub available. + * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. + + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_QIOT_MD5_H +#define QCLOUD_BLE_QIOT_MD5_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MD5_DIGEST_SIZE 16 + +typedef struct { + unsigned int total[2]; /*!< number of bytes processed */ + unsigned int state[4]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} iot_md5_context; + +/** + * @brief init MD5 context + * + * @param ctx MD5 context + */ +void utils_md5_init(iot_md5_context *ctx); + +/** + * @brief free MD5 context + * + * @param ctx MD5 context + */ +void utils_md5_free(iot_md5_context *ctx); + +/** + * @brief clone MD5 context + * + * @param dst destination MD5 context + * @param src source MD5 context + */ +void utils_md5_clone(iot_md5_context *dst, const iot_md5_context *src); + +/** + * @brief start MD5 calculation + * + * @param ctx MD5 context + */ +void utils_md5_starts(iot_md5_context *ctx); + +/** + * @brief MD5 update + * + * @param ctx MD5 context + * @param input input data + * @param ilen data length + */ +void utils_md5_update(iot_md5_context *ctx, const unsigned char *input, unsigned int ilen); + +/** + * @brief finish MD5 calculation + * + * @param ctx MD5 context + * @param output MD5 result + */ +void utils_md5_finish(iot_md5_context *ctx, unsigned char output[16]); + +/* MD5 internal process */ +void utils_md5_process(iot_md5_context *ctx, const unsigned char data[64]); + +/** + * @brief Output = MD5( input buffer ) + * + * @param input data input + * @param ilen data lenght + * @param output MD5 result + */ +void utils_md5(const unsigned char *input, unsigned int ilen, unsigned char output[16]); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_param_check.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_param_check.h new file mode 100644 index 00000000..ba51bcd2 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_param_check.h @@ -0,0 +1,93 @@ +/* + * Tencent is pleased to support the open source community by making IoT Hub available. + * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. + + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_IOT_PARAM_CHECK_H_ +#define QCLOUD_BLE_IOT_PARAM_CHECK_H_ + +#if defined(__cplusplus) +extern "C" { +#endif + +#include "ble_qiot_log.h" + +#define NUMBERIC_SANITY_CHECK(num, err) \ + do { \ + if (0 == (num)) { \ + ble_qiot_log_e("Invalid argument, numeric 0"); \ + return (err); \ + } \ + } while (0) + +#define NUMBERIC_SANITY_CHECK_RTN(num) \ + do { \ + if (0 == (num)) { \ + ble_qiot_log_e("Invalid argument, numeric 0"); \ + return; \ + } \ + } while (0) + +#define BUFF_LEN_SANITY_CHECK(num, min, err) \ + do { \ + if ((min) > (num)) { \ + ble_qiot_log_e("Invalid argument, %d <= %d", min, num); \ + return (err); \ + } \ + } while (0) + +#define POINTER_SANITY_CHECK(ptr, err) \ + do { \ + if (NULL == (ptr)) { \ + ble_qiot_log_e("Invalid argument, %s = %p", #ptr, ptr); \ + return (err); \ + } \ + } while (0) + +#define POINTER_SANITY_CHECK_RTN(ptr) \ + do { \ + if (NULL == (ptr)) { \ + ble_qiot_log_e("Invalid argument, %s = %p", #ptr, ptr); \ + return; \ + } \ + } while (0) + +#define STRING_PTR_SANITY_CHECK(ptr, err) \ + do { \ + if (NULL == (ptr)) { \ + ble_qiot_log_e("Invalid argument, %s = %p", #ptr, (ptr)); \ + return (err); \ + } \ + if (0 == strlen((ptr))) { \ + ble_qiot_log_e("Invalid argument, %s = '%s'", #ptr, (ptr)); \ + return (err); \ + } \ + } while (0) + +#define STRING_PTR_SANITY_CHECK_RTN(ptr) \ + do { \ + if (NULL == (ptr)) { \ + ble_qiot_log_e("Invalid argument, %s = %p", #ptr, (ptr)); \ + return; \ + } \ + if (0 == strlen((ptr))) { \ + ble_qiot_log_e("Invalid argument, %s = '%s'", #ptr, (ptr)); \ + return; \ + } \ + } while (0) + +#if defined(__cplusplus) +} +#endif + +#endif /* QCLOUD_BLE_IOT_PARAM_CHECK_H_ */ diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_service.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_service.h new file mode 100644 index 00000000..942c70aa --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_service.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef QCLOUD_BLE_IOT_SERVICE_H_ +#define QCLOUD_BLE_IOT_SERVICE_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "ble_qiot_export.h" +#include "ble_qiot_llsync_data.h" +#include "ble_qiot_template.h" + +// handle llsync device info +// return 0 is success, other is error +int ble_device_info_msg_handle(const char *in_buf, int in_len); + +// lldata message from remote +// return 0 is success, other is error +int ble_lldata_msg_handle(const char *in_buf, int in_len); + +#ifdef __cplusplus +} +#endif +#endif // QCLOUD_BLE_IOT_SERVICE_H_ diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_sha1.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_sha1.h new file mode 100644 index 00000000..89fca2ab --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_sha1.h @@ -0,0 +1,93 @@ +/* + * Tencent is pleased to support the open source community by making IoT Hub available. + * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. + + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_LLSYNC_BLE_QIOT_SHA1_H +#define QCLOUD_BLE_LLSYNC_BLE_QIOT_SHA1_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * \brief SHA-1 context structure + */ +typedef struct { + uint32_t total[2]; /*!< number of bytes processed */ + uint32_t state[5]; /*!< intermediate digest state */ + unsigned char buffer[64]; /*!< data block being processed */ +} iot_sha1_context; + +/** + * \brief Initialize SHA-1 context + * + * \param ctx SHA-1 context to be initialized + */ +void utils_sha1_init(iot_sha1_context *ctx); + +/** + * \brief Clear SHA-1 context + * + * \param ctx SHA-1 context to be cleared + */ +void utils_sha1_free(iot_sha1_context *ctx); + +/** + * \brief Clone (the state of) a SHA-1 context + * + * \param dst The destination context + * \param src The context to be cloned + */ +void utils_sha1_clone(iot_sha1_context *dst, const iot_sha1_context *src); + +/** + * \brief SHA-1 context setup + * + * \param ctx context to be initialized + */ +void utils_sha1_starts(iot_sha1_context *ctx); + +/** + * \brief SHA-1 process buffer + * + * \param ctx SHA-1 context + * \param input buffer holding the data + * \param ilen length of the input data + */ +void utils_sha1_update(iot_sha1_context *ctx, const unsigned char *input, size_t ilen); + +/** + * \brief SHA-1 final digest + * + * \param ctx SHA-1 context + * \param output SHA-1 checksum result + */ +void utils_sha1_finish(iot_sha1_context *ctx, unsigned char output[20]); + +/* Internal use */ +void utils_sha1_process(iot_sha1_context *ctx, const unsigned char data[64]); + +/** + * \brief Output = SHA-1( input buffer ) + * + * \param input buffer holding the data + * \param ilen length of the input data + * \param output SHA-1 checksum result + */ +void utils_sha1(const unsigned char *input, size_t ilen, unsigned char output[20]); + +#endif // QCLOUD_BLE_LLSYNC_BLE_QIOT_SHA1_H diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_utils_base64.h b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_utils_base64.h new file mode 100644 index 00000000..4b93fc2e --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/internal_inc/ble_qiot_utils_base64.h @@ -0,0 +1,36 @@ +/* + * Tencent is pleased to support the open source community by making IoT Hub available. + * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. + + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_IOT_UTILS_BASE64_H_ +#define QCLOUD_BLE_IOT_UTILS_BASE64_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "ble_qiot_export.h" + +ble_qiot_ret_status_t qcloud_iot_utils_base64encode(unsigned char *dst, size_t dlen, size_t *olen, + const unsigned char *src, size_t slen); + +ble_qiot_ret_status_t qcloud_iot_utils_base64decode(unsigned char *dst, size_t dlen, size_t *olen, + const unsigned char *src, size_t slen); + +#ifdef __cplusplus +} +#endif +#endif /* QCLOUD_BLE_IOT_UTILS_BASE64_H_ */ diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_base64.c b/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_base64.c new file mode 100644 index 00000000..8598ebc2 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_base64.c @@ -0,0 +1,180 @@ +/* + * Tencent is pleased to support the open source community by making IoT Hub available. + * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. + + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_utils_base64.h" +#include "ble_qiot_export.h" +#include +#include + +static const unsigned char base64_enc_map[64] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', + 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', + 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'}; + +static const unsigned char base64_dec_map[128] = { + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 62, + 127, 127, 127, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 127, 127, 127, 64, 127, 127, 127, 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 127, 127, 127, 127, 127, 127, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 127, 127, 127, 127, 127}; + +#define BASE64_SIZE_T_MAX ((size_t)-1) /* SIZE_T_MAX is not standard */ + +ble_qiot_ret_status_t qcloud_iot_utils_base64encode(unsigned char *dst, size_t dlen, size_t *olen, + const unsigned char *src, size_t slen) +{ + size_t i, n; + unsigned char *p; + + if (slen == 0) { + *olen = 0; + return (BLE_QIOT_RS_OK); + } + + n = slen / 3 + (slen % 3 != 0); + + if (n > (BASE64_SIZE_T_MAX - 1) / 4) { + *olen = BASE64_SIZE_T_MAX; + return (BLE_QIOT_RS_ERR); + } + + n *= 4; + + if ((dlen < n + 1) || (NULL == dst)) { + *olen = n + 1; + return (BLE_QIOT_RS_ERR); + } + + n = (slen / 3) * 3; + + int C1, C2, C3; + for (i = 0, p = dst; i < n; i += 3) { + C1 = *src++; + C2 = *src++; + C3 = *src++; + + *p++ = base64_enc_map[(C1 >> 2) & 0x3F]; + *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F]; + *p++ = base64_enc_map[(((C2 & 15) << 2) + (C3 >> 6)) & 0x3F]; + *p++ = base64_enc_map[C3 & 0x3F]; + } + + if (i < slen) { + C1 = *src++; + C2 = ((i + 1) < slen) ? *src++ : 0; + + *p++ = base64_enc_map[(C1 >> 2) & 0x3F]; + *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F]; + + if ((i + 1) < slen) + *p++ = base64_enc_map[((C2 & 15) << 2) & 0x3F]; + else + *p++ = '='; + + *p++ = '='; + } + + *olen = p - dst; + *p = 0; + + return (BLE_QIOT_RS_OK); +} + +ble_qiot_ret_status_t qcloud_iot_utils_base64decode(unsigned char *dst, size_t dlen, size_t *olen, + const unsigned char *src, size_t slen) +{ + size_t i, n; + uint32_t j, x; + unsigned char *p; + + /* First pass: check for validity and get output length */ + for (i = n = j = 0; i < slen; i++) { + /* Skip spaces before checking for EOL */ + x = 0; + while (i < slen && src[i] == ' ') { + ++i; + ++x; + } + + /* Spaces at end of buffer are OK */ + if (i == slen) + break; + + if ((slen - i) >= 2 && src[i] == '\r' && src[i + 1] == '\n') + continue; + + if (src[i] == '\n') + continue; + + /* Space inside a line is an error */ + if (x != 0) + return (BLE_QIOT_RS_ERR); + + if (src[i] == '=' && ++j > 2) + return (BLE_QIOT_RS_ERR); + + if (src[i] > 127 || base64_dec_map[src[i]] == 127) + return (BLE_QIOT_RS_ERR); + + if (base64_dec_map[src[i]] < 64 && j != 0) + return (BLE_QIOT_RS_ERR); + + n++; + } + + if (n == 0) { + *olen = 0; + return (BLE_QIOT_RS_OK); + } + + n = ((n * 6) + 7) >> 3; + n -= j; + + if (dst == NULL || dlen < n) { + *olen = n; + return (BLE_QIOT_RS_ERR); + } + + for (j = 3, n = x = 0, p = dst; i > 0; i--, src++) { + if (*src == '\r' || *src == '\n' || *src == ' ') + continue; + + j -= (base64_dec_map[*src] == 64); + x = (x << 6) | (base64_dec_map[*src] & 0x3F); + + if (++n == 4) { + n = 0; + if (j > 0) + *p++ = (unsigned char)(x >> 16); + if (j > 1) + *p++ = (unsigned char)(x >> 8); + if (j > 2) + *p++ = (unsigned char)(x); + } + } + + *olen = p - dst; + + return (BLE_QIOT_RS_OK); +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_hmac.c b/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_hmac.c new file mode 100644 index 00000000..562dc11a --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_hmac.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "ble_qiot_log.h" +#include "ble_qiot_sha1.h" +#include "ble_qiot_hmac.h" + +#define KEY_IOPAD_SIZE 64 + +int8_t utils_hb2hex(uint8_t hb) +{ + hb = hb & 0xF; + return (int8_t)(hb < 10 ? '0' + hb : hb - 10 + 'a'); +} + +void utils_hmac_sha1(const char *msg, int msg_len, char *digest, const char *key, int key_len) +{ + if ((NULL == msg) || (NULL == digest) || (NULL == key)) { + ble_qiot_log_e("parameter is Null,failed!"); + return; + } + + if (key_len > KEY_IOPAD_SIZE) { + ble_qiot_log_e("key_len > size(%d) of array", KEY_IOPAD_SIZE); + return; + } + + iot_sha1_context context; + unsigned char k_ipad[KEY_IOPAD_SIZE]; /* inner padding - key XORd with ipad */ + unsigned char k_opad[KEY_IOPAD_SIZE]; /* outer padding - key XORd with opad */ + unsigned char out[SHA1_DIGEST_SIZE]; + int i; + + /* start out by storing key in pads */ + memset(k_ipad, 0, sizeof(k_ipad)); + memset(k_opad, 0, sizeof(k_opad)); + memcpy(k_ipad, key, key_len); + memcpy(k_opad, key, key_len); + + /* XOR key with ipad and opad values */ + for (i = 0; i < KEY_IOPAD_SIZE; i++) { + k_ipad[i] ^= 0x36; + k_opad[i] ^= 0x5c; + } + + /* perform inner SHA */ + utils_sha1_init(&context); /* init context for 1st pass */ + utils_sha1_starts(&context); /* setup context for 1st pass */ + utils_sha1_update(&context, k_ipad, KEY_IOPAD_SIZE); /* start with inner pad */ + utils_sha1_update(&context, (unsigned char *)msg, msg_len); /* then text of datagram */ + utils_sha1_finish(&context, out); /* finish up 1st pass */ + + /* perform outer SHA */ + utils_sha1_init(&context); /* init context for 2nd pass */ + utils_sha1_starts(&context); /* setup context for 2nd pass */ + utils_sha1_update(&context, k_opad, KEY_IOPAD_SIZE); /* start with outer pad */ + utils_sha1_update(&context, out, SHA1_DIGEST_SIZE); /* then results of 1st hash */ + utils_sha1_finish(&context, out); /* finish up 2nd pass */ + + memcpy(digest, out, SHA1_DIGEST_SIZE); + /* for (i = 0; i < SHA1_DIGEST_SIZE; ++i) { + digest[i * 2] = utils_hb2hex(out[i] >> 4); + digest[i * 2 + 1] = utils_hb2hex(out[i]); + }*/ +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_log.c b/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_log.c new file mode 100644 index 00000000..66ac6c7b --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_log.c @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_log.h" + +#include +#include +#include + +#define HEX_DUMP_BYTE_PER_LINE 16 + +e_ble_qiot_log_level g_log_level = BLE_QIOT_LOG_LEVEL_INFO; + +void ble_qiot_set_log_level(e_ble_qiot_log_level level) +{ + g_log_level = level; + return; +} + +#if (0 == BLE_QIOT_USER_DEFINE_HEDUMP) +void ble_qiot_log_hex(e_ble_qiot_log_level level, const char *hex_name, const char *data, uint32_t data_len) +{ + char buf[HEX_DUMP_BYTE_PER_LINE * 5] = {0}; + int line_count = 0, line = 0, byte = 0, rest = 0, start_byte = 0; + + if (g_log_level < level) return; + + line_count = data_len / HEX_DUMP_BYTE_PER_LINE; + if (data_len % HEX_DUMP_BYTE_PER_LINE) { + line_count += 1; + } + + ble_qiot_log_raw("\r\nble qiot dump: %s, length: %d\r\n", hex_name, data_len); + ble_qiot_log_raw(" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\r\n"); + ble_qiot_log_raw("===============================================\r\n"); + for (line = 0; line < line_count; line++) { + start_byte = line * HEX_DUMP_BYTE_PER_LINE; + if (data_len - start_byte < HEX_DUMP_BYTE_PER_LINE) { + rest = data_len % HEX_DUMP_BYTE_PER_LINE; + } else { + rest = HEX_DUMP_BYTE_PER_LINE; + } + + for (byte = 0; byte < HEX_DUMP_BYTE_PER_LINE; byte++) { + if (byte < rest) { + sprintf(&buf[byte * 3], "%02X ", data[start_byte + byte]); + } else { + sprintf(&buf[byte * 3], " "); + } + } + + sprintf(&buf[HEX_DUMP_BYTE_PER_LINE * 3], "| "); + for (byte = 0; byte < rest; byte++) { + if (data[start_byte + byte] >= ' ' && data[start_byte + byte] <= '~') { + buf[HEX_DUMP_BYTE_PER_LINE * 3 + 2 + byte] = data[start_byte + byte]; + } else { + buf[HEX_DUMP_BYTE_PER_LINE * 3 + 2 + byte] = '.'; + } + } + sprintf(&buf[HEX_DUMP_BYTE_PER_LINE * 3 + 2 + rest], "\r\n"); + + ble_qiot_log_raw("%s", buf); // do not use printf(buf), that cause '%' transfer next character + } + ble_qiot_log_raw("\r\n"); +} +#endif // BLE_QIOT_USER_DEFINE_HEDUMP + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_md5.c b/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_md5.c new file mode 100644 index 00000000..3e562584 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_md5.c @@ -0,0 +1,299 @@ +/* + * Tencent is pleased to support the open source community by making IoT Hub available. + * Copyright (C) 2018-2020 THL A29 Limited, a Tencent company. All rights reserved. + + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_md5.h" + +#include +#include +#include + +/* Implementation that should never be optimized out by the compiler */ +static void _utils_md5_zeroize(void *v, size_t n) +{ + volatile unsigned char *p = v; + while (n--) *p++ = 0; +} + +/* + * 32-bit integer manipulation macros (little endian) + */ +#ifndef IOT_MD5_GET_UINT32_LE +#define IOT_MD5_GET_UINT32_LE(n, b, i) \ + { \ + (n) = ((uint32_t)(b)[(i)]) | ((uint32_t)(b)[(i) + 1] << 8) | ((uint32_t)(b)[(i) + 2] << 16) | \ + ((uint32_t)(b)[(i) + 3] << 24); \ + } +#endif + +#ifndef IOT_MD5_PUT_UINT32_LE +#define IOT_MD5_PUT_UINT32_LE(n, b, i) \ + { \ + (b)[(i)] = (unsigned char)(((n)) & 0xFF); \ + (b)[(i) + 1] = (unsigned char)(((n) >> 8) & 0xFF); \ + (b)[(i) + 2] = (unsigned char)(((n) >> 16) & 0xFF); \ + (b)[(i) + 3] = (unsigned char)(((n) >> 24) & 0xFF); \ + } +#endif + +void utils_md5_init(iot_md5_context *ctx) +{ + memset(ctx, 0, sizeof(iot_md5_context)); +} + +void utils_md5_free(iot_md5_context *ctx) +{ + if (ctx == NULL) { + return; + } + + _utils_md5_zeroize(ctx, sizeof(iot_md5_context)); +} + +void utils_md5_clone(iot_md5_context *dst, const iot_md5_context *src) +{ + *dst = *src; +} + +/* + * MD5 context setup + */ +void utils_md5_starts(iot_md5_context *ctx) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; +} + +void utils_md5_process(iot_md5_context *ctx, const unsigned char data[64]) +{ + uint32_t X[16], A, B, C, D; + + IOT_MD5_GET_UINT32_LE(X[0], data, 0); + IOT_MD5_GET_UINT32_LE(X[1], data, 4); + IOT_MD5_GET_UINT32_LE(X[2], data, 8); + IOT_MD5_GET_UINT32_LE(X[3], data, 12); + IOT_MD5_GET_UINT32_LE(X[4], data, 16); + IOT_MD5_GET_UINT32_LE(X[5], data, 20); + IOT_MD5_GET_UINT32_LE(X[6], data, 24); + IOT_MD5_GET_UINT32_LE(X[7], data, 28); + IOT_MD5_GET_UINT32_LE(X[8], data, 32); + IOT_MD5_GET_UINT32_LE(X[9], data, 36); + IOT_MD5_GET_UINT32_LE(X[10], data, 40); + IOT_MD5_GET_UINT32_LE(X[11], data, 44); + IOT_MD5_GET_UINT32_LE(X[12], data, 48); + IOT_MD5_GET_UINT32_LE(X[13], data, 52); + IOT_MD5_GET_UINT32_LE(X[14], data, 56); + IOT_MD5_GET_UINT32_LE(X[15], data, 60); + +#define S(x, n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) + +#define P(a, b, c, d, k, s, t) \ + { \ + a += F(b, c, d) + X[k] + t; \ + a = S(a, s) + b; \ + } + + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + +#define F(x, y, z) (z ^ (x & (y ^ z))) + + P(A, B, C, D, 0, 7, 0xD76AA478); + P(D, A, B, C, 1, 12, 0xE8C7B756); + P(C, D, A, B, 2, 17, 0x242070DB); + P(B, C, D, A, 3, 22, 0xC1BDCEEE); + P(A, B, C, D, 4, 7, 0xF57C0FAF); + P(D, A, B, C, 5, 12, 0x4787C62A); + P(C, D, A, B, 6, 17, 0xA8304613); + P(B, C, D, A, 7, 22, 0xFD469501); + P(A, B, C, D, 8, 7, 0x698098D8); + P(D, A, B, C, 9, 12, 0x8B44F7AF); + P(C, D, A, B, 10, 17, 0xFFFF5BB1); + P(B, C, D, A, 11, 22, 0x895CD7BE); + P(A, B, C, D, 12, 7, 0x6B901122); + P(D, A, B, C, 13, 12, 0xFD987193); + P(C, D, A, B, 14, 17, 0xA679438E); + P(B, C, D, A, 15, 22, 0x49B40821); + +#undef F + +#define F(x, y, z) (y ^ (z & (x ^ y))) + + P(A, B, C, D, 1, 5, 0xF61E2562); + P(D, A, B, C, 6, 9, 0xC040B340); + P(C, D, A, B, 11, 14, 0x265E5A51); + P(B, C, D, A, 0, 20, 0xE9B6C7AA); + P(A, B, C, D, 5, 5, 0xD62F105D); + P(D, A, B, C, 10, 9, 0x02441453); + P(C, D, A, B, 15, 14, 0xD8A1E681); + P(B, C, D, A, 4, 20, 0xE7D3FBC8); + P(A, B, C, D, 9, 5, 0x21E1CDE6); + P(D, A, B, C, 14, 9, 0xC33707D6); + P(C, D, A, B, 3, 14, 0xF4D50D87); + P(B, C, D, A, 8, 20, 0x455A14ED); + P(A, B, C, D, 13, 5, 0xA9E3E905); + P(D, A, B, C, 2, 9, 0xFCEFA3F8); + P(C, D, A, B, 7, 14, 0x676F02D9); + P(B, C, D, A, 12, 20, 0x8D2A4C8A); + +#undef F + +#define F(x, y, z) (x ^ y ^ z) + + P(A, B, C, D, 5, 4, 0xFFFA3942); + P(D, A, B, C, 8, 11, 0x8771F681); + P(C, D, A, B, 11, 16, 0x6D9D6122); + P(B, C, D, A, 14, 23, 0xFDE5380C); + P(A, B, C, D, 1, 4, 0xA4BEEA44); + P(D, A, B, C, 4, 11, 0x4BDECFA9); + P(C, D, A, B, 7, 16, 0xF6BB4B60); + P(B, C, D, A, 10, 23, 0xBEBFBC70); + P(A, B, C, D, 13, 4, 0x289B7EC6); + P(D, A, B, C, 0, 11, 0xEAA127FA); + P(C, D, A, B, 3, 16, 0xD4EF3085); + P(B, C, D, A, 6, 23, 0x04881D05); + P(A, B, C, D, 9, 4, 0xD9D4D039); + P(D, A, B, C, 12, 11, 0xE6DB99E5); + P(C, D, A, B, 15, 16, 0x1FA27CF8); + P(B, C, D, A, 2, 23, 0xC4AC5665); + +#undef F + +#define F(x, y, z) (y ^ (x | ~z)) + + P(A, B, C, D, 0, 6, 0xF4292244); + P(D, A, B, C, 7, 10, 0x432AFF97); + P(C, D, A, B, 14, 15, 0xAB9423A7); + P(B, C, D, A, 5, 21, 0xFC93A039); + P(A, B, C, D, 12, 6, 0x655B59C3); + P(D, A, B, C, 3, 10, 0x8F0CCC92); + P(C, D, A, B, 10, 15, 0xFFEFF47D); + P(B, C, D, A, 1, 21, 0x85845DD1); + P(A, B, C, D, 8, 6, 0x6FA87E4F); + P(D, A, B, C, 15, 10, 0xFE2CE6E0); + P(C, D, A, B, 6, 15, 0xA3014314); + P(B, C, D, A, 13, 21, 0x4E0811A1); + P(A, B, C, D, 4, 6, 0xF7537E82); + P(D, A, B, C, 11, 10, 0xBD3AF235); + P(C, D, A, B, 2, 15, 0x2AD7D2BB); + P(B, C, D, A, 9, 21, 0xEB86D391); + +#undef F + + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; +} + +/* + * MD5 process buffer + */ +void utils_md5_update(iot_md5_context *ctx, const unsigned char *input, unsigned int ilen) +{ + uint32_t fill; + uint32_t left; + + if (ilen == 0) { + return; + } + + left = ctx->total[0] & 0x3F; + fill = 64 - left; + + ctx->total[0] += (uint32_t)ilen; + ctx->total[0] &= 0xFFFFFFFF; + + if (ctx->total[0] < (uint32_t)ilen) { + ctx->total[1]++; + } + + if (left && ilen >= fill) { + memcpy((void *)(ctx->buffer + left), input, fill); + utils_md5_process(ctx, ctx->buffer); + input += fill; + ilen -= fill; + left = 0; + } + + while (ilen >= 64) { + utils_md5_process(ctx, input); + input += 64; + ilen -= 64; + } + + if (ilen > 0) { + memcpy((void *)(ctx->buffer + left), input, ilen); + } +} + +static const unsigned char iot_md5_padding[64] = {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +/* + * MD5 final digest + */ +void utils_md5_finish(iot_md5_context *ctx, unsigned char output[16]) +{ + uint32_t last, padn; + uint32_t high, low; + unsigned char msglen[8]; + + high = (ctx->total[0] >> 29) | (ctx->total[1] << 3); + low = (ctx->total[0] << 3); + + IOT_MD5_PUT_UINT32_LE(low, msglen, 0); + IOT_MD5_PUT_UINT32_LE(high, msglen, 4); + + last = ctx->total[0] & 0x3F; + padn = (last < 56) ? (56 - last) : (120 - last); + + utils_md5_update(ctx, iot_md5_padding, padn); + utils_md5_update(ctx, msglen, 8); + + IOT_MD5_PUT_UINT32_LE(ctx->state[0], output, 0); + IOT_MD5_PUT_UINT32_LE(ctx->state[1], output, 4); + IOT_MD5_PUT_UINT32_LE(ctx->state[2], output, 8); + IOT_MD5_PUT_UINT32_LE(ctx->state[3], output, 12); +} + +/* + * output = MD5( input buffer ) + */ +void utils_md5(const unsigned char *input, unsigned int ilen, unsigned char output[16]) +{ + iot_md5_context ctx; + + utils_md5_init(&ctx); + utils_md5_starts(&ctx); + utils_md5_update(&ctx, input, ilen); + utils_md5_finish(&ctx, output); + utils_md5_free(&ctx); +} + +#ifdef __cplusplus +} +#endif diff --git a/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_sha1.c b/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_sha1.c new file mode 100644 index 00000000..3291d0e2 --- /dev/null +++ b/components/connectivity/qcloud_iot_explorer_ble/src/utils/ble_qiot_utils_sha1.c @@ -0,0 +1,327 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_sha1.h" + +#include +#include + +/* Implementation that should never be optimized out by the compiler */ +static void utils_sha1_zeroize(void *v, size_t n) +{ + volatile unsigned char *p = v; + while (n--) { + *p++ = 0; + } +} + +/* + * 32-bit integer manipulation macros (big endian) + */ +#ifndef IOT_SHA1_GET_UINT32_BE +#define IOT_SHA1_GET_UINT32_BE(n, b, i) \ + { \ + (n) = ((uint32_t)(b)[(i)] << 24) | ((uint32_t)(b)[(i) + 1] << 16) | ((uint32_t)(b)[(i) + 2] << 8) | \ + ((uint32_t)(b)[(i) + 3]); \ + } +#endif + +#ifndef IOT_SHA1_PUT_UINT32_BE +#define IOT_SHA1_PUT_UINT32_BE(n, b, i) \ + { \ + (b)[(i)] = (unsigned char)((n) >> 24); \ + (b)[(i) + 1] = (unsigned char)((n) >> 16); \ + (b)[(i) + 2] = (unsigned char)((n) >> 8); \ + (b)[(i) + 3] = (unsigned char)((n)); \ + } +#endif + +void utils_sha1_init(iot_sha1_context *ctx) +{ + memset(ctx, 0, sizeof(iot_sha1_context)); +} + +void utils_sha1_free(iot_sha1_context *ctx) +{ + if (ctx == NULL) { + return; + } + + utils_sha1_zeroize(ctx, sizeof(iot_sha1_context)); +} + +void utils_sha1_clone(iot_sha1_context *dst, const iot_sha1_context *src) +{ + *dst = *src; +} + +/* + * SHA-1 context setup + */ +void utils_sha1_starts(iot_sha1_context *ctx) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; + ctx->state[4] = 0xC3D2E1F0; +} + +void utils_sha1_process(iot_sha1_context *ctx, const unsigned char data[64]) +{ + uint32_t temp, W[16], A, B, C, D, E; + + IOT_SHA1_GET_UINT32_BE(W[0], data, 0); + IOT_SHA1_GET_UINT32_BE(W[1], data, 4); + IOT_SHA1_GET_UINT32_BE(W[2], data, 8); + IOT_SHA1_GET_UINT32_BE(W[3], data, 12); + IOT_SHA1_GET_UINT32_BE(W[4], data, 16); + IOT_SHA1_GET_UINT32_BE(W[5], data, 20); + IOT_SHA1_GET_UINT32_BE(W[6], data, 24); + IOT_SHA1_GET_UINT32_BE(W[7], data, 28); + IOT_SHA1_GET_UINT32_BE(W[8], data, 32); + IOT_SHA1_GET_UINT32_BE(W[9], data, 36); + IOT_SHA1_GET_UINT32_BE(W[10], data, 40); + IOT_SHA1_GET_UINT32_BE(W[11], data, 44); + IOT_SHA1_GET_UINT32_BE(W[12], data, 48); + IOT_SHA1_GET_UINT32_BE(W[13], data, 52); + IOT_SHA1_GET_UINT32_BE(W[14], data, 56); + IOT_SHA1_GET_UINT32_BE(W[15], data, 60); + +#define S(x, n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) + +#define R(t) \ + (temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ W[(t - 14) & 0x0F] ^ W[t & 0x0F], (W[t & 0x0F] = S(temp, 1))) + +#define P(a, b, c, d, e, x) \ + { \ + e += S(a, 5) + F(b, c, d) + K + x; \ + b = S(b, 30); \ + } + + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + E = ctx->state[4]; + +#define F(x, y, z) (z ^ (x & (y ^ z))) +#define K 0x5A827999 + + P(A, B, C, D, E, W[0]); + P(E, A, B, C, D, W[1]); + P(D, E, A, B, C, W[2]); + P(C, D, E, A, B, W[3]); + P(B, C, D, E, A, W[4]); + P(A, B, C, D, E, W[5]); + P(E, A, B, C, D, W[6]); + P(D, E, A, B, C, W[7]); + P(C, D, E, A, B, W[8]); + P(B, C, D, E, A, W[9]); + P(A, B, C, D, E, W[10]); + P(E, A, B, C, D, W[11]); + P(D, E, A, B, C, W[12]); + P(C, D, E, A, B, W[13]); + P(B, C, D, E, A, W[14]); + P(A, B, C, D, E, W[15]); + P(E, A, B, C, D, R(16)); + P(D, E, A, B, C, R(17)); + P(C, D, E, A, B, R(18)); + P(B, C, D, E, A, R(19)); + +#undef K +#undef F + +#define F(x, y, z) (x ^ y ^ z) +#define K 0x6ED9EBA1 + + P(A, B, C, D, E, R(20)); + P(E, A, B, C, D, R(21)); + P(D, E, A, B, C, R(22)); + P(C, D, E, A, B, R(23)); + P(B, C, D, E, A, R(24)); + P(A, B, C, D, E, R(25)); + P(E, A, B, C, D, R(26)); + P(D, E, A, B, C, R(27)); + P(C, D, E, A, B, R(28)); + P(B, C, D, E, A, R(29)); + P(A, B, C, D, E, R(30)); + P(E, A, B, C, D, R(31)); + P(D, E, A, B, C, R(32)); + P(C, D, E, A, B, R(33)); + P(B, C, D, E, A, R(34)); + P(A, B, C, D, E, R(35)); + P(E, A, B, C, D, R(36)); + P(D, E, A, B, C, R(37)); + P(C, D, E, A, B, R(38)); + P(B, C, D, E, A, R(39)); + +#undef K +#undef F + +#define F(x, y, z) ((x & y) | (z & (x | y))) +#define K 0x8F1BBCDC + + P(A, B, C, D, E, R(40)); + P(E, A, B, C, D, R(41)); + P(D, E, A, B, C, R(42)); + P(C, D, E, A, B, R(43)); + P(B, C, D, E, A, R(44)); + P(A, B, C, D, E, R(45)); + P(E, A, B, C, D, R(46)); + P(D, E, A, B, C, R(47)); + P(C, D, E, A, B, R(48)); + P(B, C, D, E, A, R(49)); + P(A, B, C, D, E, R(50)); + P(E, A, B, C, D, R(51)); + P(D, E, A, B, C, R(52)); + P(C, D, E, A, B, R(53)); + P(B, C, D, E, A, R(54)); + P(A, B, C, D, E, R(55)); + P(E, A, B, C, D, R(56)); + P(D, E, A, B, C, R(57)); + P(C, D, E, A, B, R(58)); + P(B, C, D, E, A, R(59)); + +#undef K +#undef F + +#define F(x, y, z) (x ^ y ^ z) +#define K 0xCA62C1D6 + + P(A, B, C, D, E, R(60)); + P(E, A, B, C, D, R(61)); + P(D, E, A, B, C, R(62)); + P(C, D, E, A, B, R(63)); + P(B, C, D, E, A, R(64)); + P(A, B, C, D, E, R(65)); + P(E, A, B, C, D, R(66)); + P(D, E, A, B, C, R(67)); + P(C, D, E, A, B, R(68)); + P(B, C, D, E, A, R(69)); + P(A, B, C, D, E, R(70)); + P(E, A, B, C, D, R(71)); + P(D, E, A, B, C, R(72)); + P(C, D, E, A, B, R(73)); + P(B, C, D, E, A, R(74)); + P(A, B, C, D, E, R(75)); + P(E, A, B, C, D, R(76)); + P(D, E, A, B, C, R(77)); + P(C, D, E, A, B, R(78)); + P(B, C, D, E, A, R(79)); + +#undef K +#undef F + + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; + ctx->state[4] += E; +} + +/* + * SHA-1 process buffer + */ +void utils_sha1_update(iot_sha1_context *ctx, const unsigned char *input, size_t ilen) +{ + size_t fill; + uint32_t left; + + if (ilen == 0) { + return; + } + + left = ctx->total[0] & 0x3F; + fill = 64 - left; + + ctx->total[0] += (uint32_t)ilen; + ctx->total[0] &= 0xFFFFFFFF; + + if (ctx->total[0] < (uint32_t)ilen) { + ctx->total[1]++; + } + + if (left && ilen >= fill) { + memcpy((void *)(ctx->buffer + left), input, fill); + utils_sha1_process(ctx, ctx->buffer); + input += fill; + ilen -= fill; + left = 0; + } + + while (ilen >= 64) { + utils_sha1_process(ctx, input); + input += 64; + ilen -= 64; + } + + if (ilen > 0) { + memcpy((void *)(ctx->buffer + left), input, ilen); + } +} + +static const unsigned char iot_sha1_padding[64] = {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +/* + * SHA-1 final digest + */ +void utils_sha1_finish(iot_sha1_context *ctx, unsigned char output[20]) +{ + uint32_t last, padn; + uint32_t high, low; + unsigned char msglen[8]; + + high = (ctx->total[0] >> 29) | (ctx->total[1] << 3); + low = (ctx->total[0] << 3); + + IOT_SHA1_PUT_UINT32_BE(high, msglen, 0); + IOT_SHA1_PUT_UINT32_BE(low, msglen, 4); + + last = ctx->total[0] & 0x3F; + padn = (last < 56) ? (56 - last) : (120 - last); + + utils_sha1_update(ctx, iot_sha1_padding, padn); + utils_sha1_update(ctx, msglen, 8); + + IOT_SHA1_PUT_UINT32_BE(ctx->state[0], output, 0); + IOT_SHA1_PUT_UINT32_BE(ctx->state[1], output, 4); + IOT_SHA1_PUT_UINT32_BE(ctx->state[2], output, 8); + IOT_SHA1_PUT_UINT32_BE(ctx->state[3], output, 12); + IOT_SHA1_PUT_UINT32_BE(ctx->state[4], output, 16); +} + +/* + * output = SHA-1( input buffer ) + */ +void utils_sha1(const unsigned char *input, size_t ilen, unsigned char output[20]) +{ + iot_sha1_context ctx; + + utils_sha1_init(&ctx); + utils_sha1_starts(&ctx); + utils_sha1_update(&ctx, input, ilen); + utils_sha1_finish(&ctx, output); + utils_sha1_free(&ctx); +} + +#ifdef __cplusplus +} +#endif diff --git a/doc/28.BLE_Device_Quick_Start.md b/doc/28.BLE_Device_Quick_Start.md new file mode 100644 index 00000000..9b22cac9 --- /dev/null +++ b/doc/28.BLE_Device_Quick_Start.md @@ -0,0 +1,132 @@ +# 1 操作场景 + +使用BLE蓝牙模拟一款智能灯,配合“腾讯连连”小程序实现设备接入,物联网开发平台可以远程控制灯的亮度、颜色、开关,并实时获取智能灯上报到开发平台的数据。 + +本文档主要指导您如何使用NRF52832模组在物联网开发平台创建智能灯产品并通过手机接入。 + + +# 2 前提条件 + +为了通过下面的步骤快速理解该业务流程,需要做好以下准备工作: +- 申请物联网开发平台服务。 +- 准备一块NRF52832开发板。 +- 下载最新版本代码。 +- 安装python、JLink驱动程序。 + + +# 3 操作步骤 + +## 3.1 控制台操作 + +### 3.1.1 新建项目 +1. 登录 [物联网开发平台控制台](https://console.cloud.tencent.com/iotexplorer),选择【新建项目】。 +2. 在新建项目页面,填写项目基本信息,完成后点击保存。 + - 项目名称:输入“智能灯演示”或其他名称。 + - 项目描述:按照实际需求填写项目描述。 + ![](image/BLE/new_project.png) + + +### 3.1.2 新建产品 +1. 进入该项目的产品列表页面,单击【新建产品】。 +2. 在新建产品页面,填写产品基本信息,完成后点击保存。 + - 产品名称:输入“蓝牙智能灯”或其他产品名称。 + - 产品类型:选择“智慧生活—电工照明—灯”。 + - 设备类型:选择“设备”。 + - 认证方式:选择“密钥认证”。 + - 通信方式:选择“BLE”。 + - 其他选项保持默认。 + ![](image/BLE/new_product.png) + + +### 3.1.3 创建数据模板 +1. 打开刚刚创建的【蓝牙智能灯】产品。 +![](image/BLE/ble_product.png) + +2. 选择【数据模板】,点击【导入JSON】。 +![](image/BLE/data_template.png) + +1. 打开代码中的`examples\nimble_llsync\date_templatenrf52832.json`,如果出现乱码请将您的编辑器修改为utf8编码,将文件中的代码粘贴进来,点击【导入】。 +![](image/BLE/import_json.png) + + +### 3.1.4 交互开发配置 +配置产品在小程序端的控制面板、配网引导、快捷入口,若不配置则使用系统默认配置。 +![](image/BLE/llsync_gui.png) + + +### 3.1.5 新建设备 +在设备调试页面中,单击【新建设备】,输入设备名“ble_device_01”或其他设备名称,点击【保存】。 +![](image/BLE/new_device.png) + + + +## 3.2 设备端操作 + +### 3.2.1 硬件简介与连接 +开发板实物如下: +![](image/BLE/nrf52832_board.jpg) + +指示灯作用如下 +- LED1: 开关 +- LED2: action +- LED3: replay +- LED4: 未使用 + +1. 使用USB线连接开发板左上角串口。 +2. 使用JLink连接开发板右下角下载线接口。 +3. 打开左上角电源开关。 +4. 打开设备管理器,确保串口和JLink能够正常识别,若不能识别请重新安装驱动。 + ![](image/BLE/jlink_driver.png) + +### 3.2.2 准备软件环境 +1. 新买到的nrf52832开发板可能已经烧写了 NORDIC 官方蓝牙协议栈,需要进行擦除,否则会导致下载失败、程序异常或其他问题 +2. 启动 JFlash.exe,选择 File -> New project + ![](image/BLE/jflash1.png) +3. 点击省略号添加设备 + ![](image/BLE/jflash2.png) +4. 在“Device”中输入nrf52832,选择具体芯片型号,例程中使用的为nRF52832_xxAA + ![](image/BLE/jflash3.png) +5. 选择 Target -> Manual Programming -> Erase Chip 擦除芯片 + ![](image/BLE/jflash4.png) +6. 擦除完成后即可继续进行之后的开发 + +### 3.2.3 代码修改与烧录 +1. 打开工程`board\Nordic_NRF52832\KEIL\llsync\TencentOS_tiny.uvprojx`。 +2. 打开文件`ble_qiot_import.c`,找到以下三个宏并修改为你自己的设备信息。 + ![](image/BLE/edit_device_info.png) +3. 在【设备调试】页面中选择【设备信息】子页面,将【设备名称】、【设备密钥】、【产品ID】分别填入`DEVICE_NAME`,`SECRET_KEY`,`PRODUCT_ID`。 + ![](image/BLE/device_info.png) +4. 编译下载并运行。 + +## 3.3 腾讯连连小程序调试 +1. 微信主页面下拉并搜索【腾讯连连】小程序。 + ![](image/BLE/llsync1.jpg) +2. 点击下方的【加号】添加设备。 + ![](image/BLE/llsync2.jpg) + ![](image/BLE/llsync3.jpg) +3. 待扫描到蓝牙设备后点击右侧的【连接】。 + ![](image/BLE/llsync4.jpg) +4. 在【我的设备】中打开刚刚添加的蓝牙设备。 + ![](image/BLE/llsync5.jpg) +5. 点击右侧的【立即连接】连接设备,如连接失败。 + ![](image/BLE/llsync6.jpg) +6. 连接成功后点击【电灯开关】,可以看到开发版上【LED1】随之变化。 + ![](image/BLE/llsync7.jpg) +7. 点击【亮度】或【颜色】按钮进行设置 +8. 查看串口打印,可以看到亮度、颜色设置成功 + ![](image/BLE/com_debug.png) + +# 4 Q&A +Q: 实际产品中如何处理设备信息? +A: 例程中 `DEVICE_NAME`, `SECRET_KEY`, `PRODUCT_ID` 直接写在代码中,产品中应保存在Flash中,同时修改`ble_qiot_import.c`中`ble_get_product_id()`,`ble_get_device_name()`,`ble_get_psk()`三个函数。 + +Q: LLSync SDK 需要多大的 Flash 来保存配置信息? +A: 目前只需要不到32字节。 + +Q: 如果开发其他 BLE 芯片,有什么注意事项? +A: `components\connectivity\qcloud_iot_explorer_ble\inc\ble_qiot_import.h` 为用户需要移植适配的接口,与蓝牙协议栈相关的接口在`ble_qiot_import.c`中已经完成了适配,用户仅需根据实际产品要开发`ble_write_flash()`,`ble_read_flash()`等接口。 + +# 5 参考资料 +[LLSync SDK](https://github.com/tencentyun/qcloud-iot-explorer-BLE-sdk-embedded) 内相关文档 +[LLSync SDK 接入指引](https://cloud.tencent.com/document/product/1081/48398) +[LLSync SDK 使用参考](https://cloud.tencent.com/document/product/1081/48399) diff --git a/doc/image/BLE/ble_product.png b/doc/image/BLE/ble_product.png new file mode 100644 index 00000000..39f47c60 Binary files /dev/null and b/doc/image/BLE/ble_product.png differ diff --git a/doc/image/BLE/com_debug.png b/doc/image/BLE/com_debug.png new file mode 100644 index 00000000..fb80809e Binary files /dev/null and b/doc/image/BLE/com_debug.png differ diff --git a/doc/image/BLE/data_template.png b/doc/image/BLE/data_template.png new file mode 100644 index 00000000..8f6f70fa Binary files /dev/null and b/doc/image/BLE/data_template.png differ diff --git a/doc/image/BLE/device_info.png b/doc/image/BLE/device_info.png new file mode 100644 index 00000000..1c4dabee Binary files /dev/null and b/doc/image/BLE/device_info.png differ diff --git a/doc/image/BLE/edit_device_info.png b/doc/image/BLE/edit_device_info.png new file mode 100644 index 00000000..0cf7a7e3 Binary files /dev/null and b/doc/image/BLE/edit_device_info.png differ diff --git a/doc/image/BLE/import_json.png b/doc/image/BLE/import_json.png new file mode 100644 index 00000000..a7fbae77 Binary files /dev/null and b/doc/image/BLE/import_json.png differ diff --git a/doc/image/BLE/jflash1.png b/doc/image/BLE/jflash1.png new file mode 100644 index 00000000..a1e54eca Binary files /dev/null and b/doc/image/BLE/jflash1.png differ diff --git a/doc/image/BLE/jflash2.png b/doc/image/BLE/jflash2.png new file mode 100644 index 00000000..10459e74 Binary files /dev/null and b/doc/image/BLE/jflash2.png differ diff --git a/doc/image/BLE/jflash3.png b/doc/image/BLE/jflash3.png new file mode 100644 index 00000000..a05f654e Binary files /dev/null and b/doc/image/BLE/jflash3.png differ diff --git a/doc/image/BLE/jflash4.png b/doc/image/BLE/jflash4.png new file mode 100644 index 00000000..a1f1722d Binary files /dev/null and b/doc/image/BLE/jflash4.png differ diff --git a/doc/image/BLE/jlink_driver.png b/doc/image/BLE/jlink_driver.png new file mode 100644 index 00000000..c6fb3950 Binary files /dev/null and b/doc/image/BLE/jlink_driver.png differ diff --git a/doc/image/BLE/llsync1.jpg b/doc/image/BLE/llsync1.jpg new file mode 100644 index 00000000..c541ad66 Binary files /dev/null and b/doc/image/BLE/llsync1.jpg differ diff --git a/doc/image/BLE/llsync2.jpg b/doc/image/BLE/llsync2.jpg new file mode 100644 index 00000000..d5e1315f Binary files /dev/null and b/doc/image/BLE/llsync2.jpg differ diff --git a/doc/image/BLE/llsync3.jpg b/doc/image/BLE/llsync3.jpg new file mode 100644 index 00000000..e6d553a6 Binary files /dev/null and b/doc/image/BLE/llsync3.jpg differ diff --git a/doc/image/BLE/llsync4.jpg b/doc/image/BLE/llsync4.jpg new file mode 100644 index 00000000..25907ccd Binary files /dev/null and b/doc/image/BLE/llsync4.jpg differ diff --git a/doc/image/BLE/llsync5.jpg b/doc/image/BLE/llsync5.jpg new file mode 100644 index 00000000..ee123b61 Binary files /dev/null and b/doc/image/BLE/llsync5.jpg differ diff --git a/doc/image/BLE/llsync6.jpg b/doc/image/BLE/llsync6.jpg new file mode 100644 index 00000000..335215b2 Binary files /dev/null and b/doc/image/BLE/llsync6.jpg differ diff --git a/doc/image/BLE/llsync7.jpg b/doc/image/BLE/llsync7.jpg new file mode 100644 index 00000000..39423364 Binary files /dev/null and b/doc/image/BLE/llsync7.jpg differ diff --git a/doc/image/BLE/llsync_gui.png b/doc/image/BLE/llsync_gui.png new file mode 100644 index 00000000..42f68389 Binary files /dev/null and b/doc/image/BLE/llsync_gui.png differ diff --git a/doc/image/BLE/new_device.png b/doc/image/BLE/new_device.png new file mode 100644 index 00000000..d2f61f3b Binary files /dev/null and b/doc/image/BLE/new_device.png differ diff --git a/doc/image/BLE/new_product.png b/doc/image/BLE/new_product.png new file mode 100644 index 00000000..fd02ca47 Binary files /dev/null and b/doc/image/BLE/new_product.png differ diff --git a/doc/image/BLE/new_project.png b/doc/image/BLE/new_project.png new file mode 100644 index 00000000..e7af8574 Binary files /dev/null and b/doc/image/BLE/new_project.png differ diff --git a/doc/image/BLE/nrf52832_board.jpg b/doc/image/BLE/nrf52832_board.jpg new file mode 100644 index 00000000..20d2d21f Binary files /dev/null and b/doc/image/BLE/nrf52832_board.jpg differ diff --git a/examples/nimble_llsync/ble_qiot_config.h b/examples/nimble_llsync/ble_qiot_config.h new file mode 100644 index 00000000..5df5ad17 --- /dev/null +++ b/examples/nimble_llsync/ble_qiot_config.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef QCLOUD_BLE_QIOT_CONFIG_H +#define QCLOUD_BLE_QIOT_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define BLE_QIOT_SDK_VERSION "1.2.0" // sdk version +#define BLE_QIOT_SDK_DEBUG 0 // sdk debug switch + +// the device broadcast is controlled by the user, but we provide a mechanism to help the device save more power. +// if you want broadcast is triggered by something like press a button instead of all the time, and the broadcast +// stopped automatically in a few minutes if the device is not bind, define BLE_QIOT_BUTTON_BROADCAST is 1 and +// BLE_QIOT_BIND_TIMEOUT is the period that broadcast stopped. +// if the device in the bound state, broadcast dose not stop automatically. +#define BLE_QIOT_BUTTON_BROADCAST 0 +#if (1 == BLE_QIOT_BUTTON_BROADCAST) +#define BLE_QIOT_BIND_TIMEOUT (2 * 60 * 1000) // unit: ms +#endif + +// some data like integer need to be transmitted in a certain byte order, defined it according to your device +#define __ORDER_LITTLE_ENDIAN__ 1234 +#define __ORDER_BIG_ENDIAN__ 4321 +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ + +// in some BLE stack ble_qiot_log_hex() maybe not work, user can use there own hexdump function +#define BLE_QIOT_USER_DEFINE_HEDUMP 0 + +#if (1 == BLE_QIOT_USER_DEFINE_HEDUMP) +// add your code here like this +// #define ble_qiot_log_hex(level, hex_name, data, data_len) \ +// do { \ +// MY_RAW_LOG("\r\nble qiot dump: %s, length: %d\r\n", hex_name, data_len); \ +// MY_RAW_HEXDUMP_(data, data_len); \ +// } while(0) + +// or use your own hexdump function with same definition +// void ble_qiot_log_hex(e_ble_qiot_log_level level, const char *hex_name, const char *data, uint32_t data_len); +#endif // BLE_QIOT_USER_DEFINE_HEDUMP + +// Macro for logging a formatted string, the function must printf raw string without any color, prefix, newline or +// timestamp +#define BLE_QIOT_LOG_PRINT(...) printf(__VA_ARGS__) + +// nrf52832xxAA Flash size is 512KB, nrf52832xxAB Flash size is 512KB, be carefol of the address! +#define BLE_QIOT_RECORD_FLASH_ADDR 0x7e000 // qiot data storage address +#define BLE_QIOT_RECORD_FLASH_PAGESIZE 4096 // flash page size, see chip datasheet +#define BLE_QIOT_RECORD_FLASH_PAGENUM 2 // how many pages qiot use + +// the following definition will affect the stack that LLSync used, the minimum value tested is +// 2048 (BLE_QIOT_EVENT_MAX_SIZE is 128, BLE_QIOT_EVENT_BUF_SIZE is 23) the max length that llsync event data, depends +// on the length of user data reported to Tencent Lianlian at a time +#define BLE_QIOT_EVENT_MAX_SIZE (128) +// the minimum between BLE_QIOT_EVENT_MAX_SIZE and mtu +#define BLE_QIOT_EVENT_BUF_SIZE (23) + +#define BLE_QIOT_INCLUDE_PROPERTY + +#ifdef __cplusplus +} +#endif + +#endif // QCLOUD_BLE_QIOT_CONFIG_H diff --git a/examples/nimble_llsync/ble_qiot_import.c b/examples/nimble_llsync/ble_qiot_import.c new file mode 100644 index 00000000..0dba5eb5 --- /dev/null +++ b/examples/nimble_llsync/ble_qiot_import.c @@ -0,0 +1,428 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// #include "nrf52832_xxaa_service.h" + +#include +#include +#include + +#include "ble_qiot_import.h" + +// #include "host/ble_hs.h" +// #include "host/ble_uuid.h" +#include "host/ble_gap.h" +#include "host/ble_gatt.h" + +#include "flash_storage.h" +#include "ble_qiot_log.h" + + +// divece configs +// this only for reference, please create your own device and replace it! +// https://cloud.tencent.com/product/iotexplorer +// #define PRODUCT_ID "PRODUCT_ID" // 10 Bytes +// #define DEVICE_NAME "YOUR_DEVICE_NAME" // equal or lesser than 48 Bytes +// #define SECRET_KEY "YOUR_PRODUCT_SECRET_KEY_" // 24 Bytes + +#define PRODUCT_ID "RF1EOUKV5C" +#define DEVICE_NAME "ble_device_02" +#define SECRET_KEY "3zDmA91czLhz9+XsuPeSzw==" + +#define ADV_DEVICE_NAME "tos_llsync" + + +#define IOT_BLE_UUID_BASE96 0xe2, 0xa4, 0x1b, 0x54, 0x93, 0xe4, 0x6a, 0xb5, \ + 0x20, 0x4e, 0xd0, 0x65 + +#define UINT16_TO_BYTES(n) ((uint8_t) (n)), ((uint8_t)((n) >> 8)) +#define UINT32_TO_BYTES(n) ((uint8_t) (n)), ((uint8_t)((n) >> 8)), ((uint8_t)((n) >> 16)), ((uint8_t)((n) >> 24)) + +#define UINT16_TO_UUID32(n) ((uint8_t) (n)), ((uint8_t)((n) >> 8)), ((uint8_t)((n) >> 16)), ((uint8_t)((n) >> 24)) +#define IOT_BLE_UUID128_BUILD(uuid) IOT_BLE_UUID_BASE96, UINT16_TO_UUID32(uuid) + +#define IOT_BLE_UUID128_SERVICE IOT_BLE_UUID128_BUILD(IOT_BLE_UUID_SERVICE) +#define IOT_BLE_UUID128_DEVICE_INFO IOT_BLE_UUID128_BUILD(IOT_BLE_UUID_DEVICE_INFO) +#define IOT_BLE_UUID128_DATA IOT_BLE_UUID128_BUILD(IOT_BLE_UUID_DATA) +#define IOT_BLE_UUID128_EVENT IOT_BLE_UUID128_BUILD(IOT_BLE_UUID_EVENT) + +static ble_uuid128_t ble_uuid128_t_service = BLE_UUID128_INIT(IOT_BLE_UUID128_SERVICE); +static ble_uuid128_t ble_uuid128_t_device_info = BLE_UUID128_INIT(IOT_BLE_UUID128_DEVICE_INFO); +static ble_uuid128_t ble_uuid128_t_data = BLE_UUID128_INIT(IOT_BLE_UUID128_DATA); +static ble_uuid128_t ble_uuid128_t_event = BLE_UUID128_INIT(IOT_BLE_UUID128_EVENT); + +static uint16_t qiot_gap_connect_handle; + +static uint16_t qiot_device_info_handle; +static uint16_t qiot_data_handle; +static uint16_t qiot_event_handle; + +static int ble_svc_qiot_access(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg); + +// LLsync BLE services and characteristics +static const struct ble_gatt_svc_def ble_svc_qiot_defs[] = { + { + .type = BLE_GATT_SVC_TYPE_PRIMARY, + .uuid = &ble_uuid128_t_service.u, + // .uuid = BLE_UUID16_DECLARE(IOT_BLE_UUID_SERVICE), + .characteristics = (struct ble_gatt_chr_def[]) { + { + .uuid = &ble_uuid128_t_device_info.u, + // .uuid = BLE_UUID16_DECLARE(IOT_BLE_UUID_DEVICE_INFO), + .access_cb = ble_svc_qiot_access, + // .val_handle = &qiot_device_info_handle, + // .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_WRITE_NO_RSP, + .flags = BLE_GATT_CHR_F_WRITE_NO_RSP, + // .flags = 0xFFF, + }, + { + .uuid = &ble_uuid128_t_data.u, + // .uuid = BLE_UUID16_DECLARE(IOT_BLE_UUID_DATA), + .access_cb = ble_svc_qiot_access, + // .flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_WRITE_NO_RSP, + .flags = BLE_GATT_CHR_F_WRITE_NO_RSP, + }, + { + .uuid = &ble_uuid128_t_event.u, + // .uuid = BLE_UUID16_DECLARE(IOT_BLE_UUID_EVENT), + .access_cb = ble_svc_qiot_access, + .val_handle = &qiot_event_handle, + .flags = BLE_GATT_CHR_F_NOTIFY, + }, + + // end of characteristics + {.uuid = 0}, + }, + }, + + // end of services + {.type = 0}, +}; + +static int ble_svc_qiot_access(uint16_t conn_handle, uint16_t attr_handle, + struct ble_gatt_access_ctxt *ctxt, void *arg) +{ + const ble_uuid_t *uuid; + // int rand_num; + int rc, ret; + uint16_t len = 0; + uint8_t buf[256] = {0}; + + uuid = ctxt->chr->uuid; + + if(ble_uuid_cmp(uuid, &ble_uuid128_t_device_info.u) == 0) + { + switch (ctxt->op) + { + case BLE_GATT_ACCESS_OP_WRITE_CHR: + rc = ble_hs_mbuf_to_flat(ctxt->om, buf, sizeof(buf), &len); + if (rc != 0) + { + ble_qiot_log_e("ble att err, ret: %d", ret); + return BLE_ATT_ERR_UNLIKELY; + } + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_DEBUG, "device info raw", (char *)buf, len); + ble_device_info_write_cb(buf, len); + default: + return BLE_ATT_ERR_UNLIKELY; + } + } + else if(ble_uuid_cmp(uuid, &ble_uuid128_t_data.u) == 0) + { + switch (ctxt->op) + { + case BLE_GATT_ACCESS_OP_WRITE_CHR: + rc = ble_hs_mbuf_to_flat(ctxt->om, buf, sizeof(buf), &len); + if (rc != 0) + { + ble_qiot_log_e("ble att err, ret: %d", ret); + return BLE_ATT_ERR_UNLIKELY; + } + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_DEBUG, "lldata raw", (char *)buf, len); + ble_lldata_write_cb(buf, len); + default: + return BLE_ATT_ERR_UNLIKELY; + } + } + else if(ble_uuid_cmp(uuid, &ble_uuid128_t_event.u) == 0) + { + // this characteristic not have read or write attribute + } + else + { + ble_qiot_log_e("unknown service or characteristic"); + } + + return 0; +} + +// add services and characteristic +void ble_services_add(const qiot_service_init_s *p_service) +{ + int ret = 0; + + ret = ble_gatts_count_cfg(ble_svc_qiot_defs); + if(ret != 0) + { + ble_qiot_log_e("ble_gatts_count_cfg() err, ret: %d", ret); + } + + ret = ble_gatts_add_svcs(ble_svc_qiot_defs); + if(ret != 0) + { + ble_qiot_log_e("ble_gatts_add_svcs() err, ret: %d", ret); + } + + return; +} + +int ble_get_product_id(char *product_id) +{ + memcpy(product_id, PRODUCT_ID, strlen(PRODUCT_ID)); + return 0; +} + +int ble_get_device_name(char *device_name) +{ + memcpy(device_name, DEVICE_NAME, strlen(DEVICE_NAME)); + return strlen(DEVICE_NAME); +} + +int ble_get_psk(char *psk) +{ + memcpy(psk, SECRET_KEY, strlen(SECRET_KEY)); + return 0; +} + +int ble_get_mac(char *mac) +{ + memcpy(mac, MYNEWT_VAL_BLE_PUBLIC_DEV_ADDR, sizeof(MYNEWT_VAL_BLE_PUBLIC_DEV_ADDR)); + ble_qiot_log_hex(BLE_QIOT_LOG_LEVEL_DEBUG, "mac_addr", mac, 6); + + return 0; +} + +int ble_write_flash(uint32_t flash_addr, const char *write_buf, uint16_t write_len) +{ + return fstorage_write(flash_addr, write_len, write_buf); +} + +int ble_read_flash(uint32_t flash_addr, char *read_buf, uint16_t read_len) +{ + return fstorage_read(flash_addr, read_len, read_buf); +} + +int ble_qiot_gap_event_fn(struct ble_gap_event *event, void *arg) +{ + ble_qiot_log_d("get event, type: %d", event->type); + + switch (event->type) { + case BLE_GAP_EVENT_CONNECT: + /* A new connection was established or a connection attempt failed */ + MODLOG_DFLT(INFO, "connection %s; status=%d\n", + event->connect.status == 0 ? "established" : "failed", + event->connect.status); + + if (event->connect.status != 0) { + /* Connection failed; resume advertising */ + ble_qiot_advertising_start(); + qiot_gap_connect_handle = 0; + } + else + { + qiot_gap_connect_handle = event->connect.conn_handle; + } + + break; + + case BLE_GAP_EVENT_DISCONNECT: + MODLOG_DFLT(INFO, "disconnect; reason=%d\n", event->disconnect.reason); + + /* Connection terminated; resume advertising */ + ble_qiot_advertising_start(); + qiot_gap_connect_handle = 0; + break; + + case BLE_GAP_EVENT_ADV_COMPLETE: + MODLOG_DFLT(INFO, "adv complete\n"); + ble_qiot_advertising_start(); + break; + + // case BLE_GAP_EVENT_SUBSCRIBE: + // MODLOG_DFLT(INFO, "subscribe event; cur_notify=%d\n value handle; " + // "val_handle=%d\n", + // event->subscribe.cur_notify, hrs_hrm_handle); + // if (event->subscribe.attr_handle == hrs_hrm_handle) { + // notify_state = event->subscribe.cur_notify; + // notify_conn_handle = event->subscribe.conn_handle; + // blehr_tx_hrate_reset(); + // } else if (event->subscribe.attr_handle != hrs_hrm_handle) { + // notify_state = event->subscribe.cur_notify; + // notify_conn_handle = 0; + // blehr_tx_hrate_stop(); + // } + // break; + + case BLE_GAP_EVENT_MTU: + MODLOG_DFLT(INFO, "mtu update event; conn_handle=%d mtu=%d\n", + event->mtu.conn_handle, + event->mtu.value); + break; + + } + + return 0; +} + + +#define ADV_MAX_UUID16_NUM 15 +static uint8_t ble_addr_type; + +ble_qiot_ret_status_t ble_advertising_start(adv_info_s *adv) +{ + int ret = 0, i = 0; + struct ble_gap_adv_params adv_params; + struct ble_hs_adv_fields fields; + struct ble_hs_adv_fields rsp_fields; + uint8_t adv_manufacture_data[32] = {0}; + ble_uuid16_t adv_uuids16_list[ADV_MAX_UUID16_NUM]; + + memset(&fields, 0, sizeof(fields)); + memset(&rsp_fields, 0, sizeof(rsp_fields)); + + // set advertising data + /* Advertise two flags: + * o Discoverability in forthcoming advertisement (general) + * o BLE-only (BR/EDR unsupported). + */ + fields.flags = BLE_HS_ADV_F_DISC_GEN | + BLE_HS_ADV_F_BREDR_UNSUP; + + // fields.uuids16 = (ble_uuid16_t)adv->uuid_info.uuids;?? + if (adv->uuid_info.uuid_num > ADV_MAX_UUID16_NUM) + { + printf("err: too many uuids16 in adv data! (uuids num %d)\r\n", adv->uuid_info.uuid_num); + return BLE_QIOT_RS_ERR; + } + + for (i=0; iuuid_info.uuid_num; i++) + { + adv_uuids16_list[i].u.type = BLE_UUID_TYPE_16; + adv_uuids16_list[i].value = adv->uuid_info.uuids[i]; + } + fields.uuids16 = adv_uuids16_list; + fields.num_uuids16 = adv->uuid_info.uuid_num; + fields.uuids16_is_complete = 1; + + memcpy(&adv_manufacture_data[0], (uint8_t *)&adv->manufacturer_info.company_identifier, 2); + memcpy(&adv_manufacture_data[2], adv->manufacturer_info.adv_data, adv->manufacturer_info.adv_data_len); + fields.mfg_data = adv_manufacture_data; + fields.mfg_data_len = adv->manufacturer_info.adv_data_len + 2; + + ret = ble_gap_adv_set_fields(&fields); + if (ret != 0) + { + ble_qiot_log_e("ble_gap_adv_set_fields() err, ret: %d", ret); + return BLE_QIOT_RS_ERR; + } + + // set advertising respond data + rsp_fields.name = ADV_DEVICE_NAME; + rsp_fields.name_len = strlen(ADV_DEVICE_NAME); + rsp_fields.name_is_complete = 1; + ret = ble_gap_adv_rsp_set_fields(&rsp_fields); + if(ret != 0) + { + ble_qiot_log_e("ble_gap_adv_rsp_set_fields() err, ret: %d", ret); + return BLE_QIOT_RS_ERR; + } + + ret = ble_hs_id_infer_auto(0, &ble_addr_type); + if (ret != 0) + { + ble_qiot_log_e("ble_hs_id_infer_auto() err, ret: %d", ret); + return BLE_QIOT_RS_ERR; + } + + memset(&adv_params, 0, sizeof adv_params); + adv_params.conn_mode = BLE_GAP_CONN_MODE_UND; + adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN; + ret = ble_gap_adv_start(ble_addr_type, NULL, BLE_HS_FOREVER, + &adv_params, ble_qiot_gap_event_fn, NULL); + if (ret != 0) + { + ble_qiot_log_e("ble_gap_adv_start() err, ret: %d", ret); + return BLE_QIOT_RS_ERR; + } + + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_advertising_stop(void) +{ + int ret = 0; + + ble_gap_adv_stop(); + if(ret != 0) + { + ble_qiot_log_e("ble_gap_adv_stop() err, ret: %d", ret); + return BLE_QIOT_RS_ERR; + } + + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_send_notify(uint8_t *buf, uint8_t len) +{ + struct os_mbuf *om; + int rc = 0; + + om = ble_hs_mbuf_from_flat(buf, len); + + rc = ble_gattc_notify_custom(qiot_gap_connect_handle, qiot_event_handle, om); + if(rc) + { + ble_qiot_log_e("send notify err, return %d", rc); + return BLE_QIOT_RS_ERR; + } + + return BLE_QIOT_RS_OK; +} + +ble_timer_t ble_timer_create(uint8_t type, ble_timer_cb timeout_handle) +{ + return (ble_timer_t)NULL; +} + +ble_qiot_ret_status_t ble_timer_start(ble_timer_t timer_id, uint32_t period) +{ + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_timer_stop(ble_timer_t timer_id) +{ + return BLE_QIOT_RS_OK; +} + +ble_qiot_ret_status_t ble_timer_delete(ble_timer_t timer_id) +{ + return BLE_QIOT_RS_OK; +} + +// should return ATT_MTU - 3 +uint16_t ble_get_user_data_mtu_size(void) +{ + // this is an example, the default mtu is 23, user should get real mtu and return it + int mtu = 23; + + return mtu - 3; +} diff --git a/examples/nimble_llsync/date_template/ble_qiot_template.c b/examples/nimble_llsync/date_template/ble_qiot_template.c new file mode 100644 index 00000000..6a009eda --- /dev/null +++ b/examples/nimble_llsync/date_template/ble_qiot_template.c @@ -0,0 +1,541 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "ble_qiot_template.h" + +#include +#include +#include + +#include "ble_qiot_export.h" +#include "ble_qiot_common.h" +#include "ble_qiot_param_check.h" + + +extern void property_power_switch(const char *data, uint16_t len); +extern void action_led_blink(int ms); +extern void report_reply_blink(void); + + +static uint8_t sg_test_power_switch = false; + +static int ble_property_power_switch_set(const char *data, uint16_t len) +{ + ble_qiot_log_d("set property power_switch %d", *(uint8_t *)data); + property_power_switch(data, len); + sg_test_power_switch = data[0]; + + return 0; +} + +static int ble_property_power_switch_get(char *data, uint16_t buf_len) +{ + ble_qiot_log_d("get property power_switch %d", sg_test_power_switch); + data[0] = sg_test_power_switch; + + return sizeof(uint8_t); +} + +static uint16_t sg_test_color = 0; + +static int ble_property_color_set(const char *data, uint16_t len) +{ + uint16_t color_value = 0; + + memcpy(&color_value, data, sizeof(uint16_t)); + color_value = NTOHS(color_value); + ble_qiot_log_d("set property color %d", color_value); + sg_test_color = color_value; + + return 0; +} + +static int ble_property_color_get(char *data, uint16_t buf_len) +{ + uint16_t color_value = 0; + + ble_qiot_log_d("get property color %d", color_value); + color_value = HTONS(sg_test_color); + memcpy(data, &color_value, sizeof(uint16_t)); + + return sizeof(uint16_t); +} + +static int sg_test_brightness = 0; + +static int ble_property_brightness_set(const char *data, uint16_t len) +{ + int brightness_value = 0; + + memcpy(&brightness_value, data, sizeof(int)); + brightness_value = NTOHL(brightness_value); + + if ((brightness_value < BLE_QIOT_PROPERTY_BRIGHTNESS_MIN) || + (brightness_value > BLE_QIOT_PROPERTY_BRIGHTNESS_MAX)) { + ble_qiot_log_e("invalid brightness value %d", brightness_value); + return -1; + } + + ble_qiot_log_d("set property brightness %d", brightness_value); + sg_test_brightness = brightness_value; + + return 0; +} + +static int ble_property_brightness_get(char *data, uint16_t buf_len) +{ + int brightness_value = 0; + + ble_qiot_log_d("get property brightness %d", sg_test_brightness); + brightness_value = HTONL(sg_test_brightness); + memcpy(data, &brightness_value, sizeof(int)); + + return sizeof(uint32_t); +} + +static char sg_test_name[100 + 1] = "default name"; + +static int ble_property_name_set(const char *data, uint16_t len) +{ + ble_qiot_log_d("set property name %.*s", len, data); + if (len > sizeof(sg_test_name) - 1) { + ble_qiot_log_d("too long name"); + return -1; + } + memset(sg_test_name, 0, sizeof(sg_test_name)); + memcpy(sg_test_name, data, len); + + return 0; +} + +static int ble_property_name_get(char *data, uint16_t buf_len) +{ + int i = 0; + + ble_qiot_log_d("get property name %s", sg_test_name); + if (0 == strncmp("default name", sg_test_name, sizeof("default name") - 1)) { + for (i = 0; i < 26 * 3; i++) { + data[i] = 'a' + (i % 26); + } + return i; + } else { + memcpy(data, sg_test_name, strlen(sg_test_name)); + return strlen(sg_test_name); + } +} + +static ble_property_t sg_ble_property_array[BLE_QIOT_PROPERTY_ID_BUTT] = { + {ble_property_power_switch_set, ble_property_power_switch_get, BLE_QIOT_PROPERTY_AUTH_RW, BLE_QIOT_DATA_TYPE_BOOL}, + {ble_property_color_set, ble_property_color_get, BLE_QIOT_PROPERTY_AUTH_RW, BLE_QIOT_DATA_TYPE_ENUM}, + {ble_property_brightness_set, ble_property_brightness_get, BLE_QIOT_PROPERTY_AUTH_RW, BLE_QIOT_DATA_TYPE_INT}, + {ble_property_name_set, ble_property_name_get, BLE_QIOT_PROPERTY_AUTH_RW, BLE_QIOT_DATA_TYPE_STRING}, +}; + +static bool ble_check_space_enough_by_type(uint8_t type, uint16_t left_size) +{ + switch (type) { + case BLE_QIOT_DATA_TYPE_BOOL: + return left_size >= sizeof(uint8_t); + case BLE_QIOT_DATA_TYPE_INT: + case BLE_QIOT_DATA_TYPE_FLOAT: + case BLE_QIOT_DATA_TYPE_TIME: + return left_size >= sizeof(uint32_t); + case BLE_QIOT_DATA_TYPE_ENUM: + return left_size >= sizeof(uint16_t); + default: + // string length is unknow, default true + return true; + } +} + +static uint16_t ble_check_ret_value_by_type(uint8_t type, uint16_t buf_len, uint16_t ret_val) +{ + switch (type) { + case BLE_QIOT_DATA_TYPE_BOOL: + return ret_val <= sizeof(uint8_t); + case BLE_QIOT_DATA_TYPE_INT: + case BLE_QIOT_DATA_TYPE_FLOAT: + case BLE_QIOT_DATA_TYPE_TIME: + return ret_val <= sizeof(uint32_t); + case BLE_QIOT_DATA_TYPE_ENUM: + return ret_val <= sizeof(uint16_t); + default: + // string length is unknow, default true + return ret_val <= buf_len; + } +} + +uint8_t ble_get_property_type_by_id(uint8_t id) +{ + if (id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + return sg_ble_property_array[id].type; +} + +int ble_user_property_set_data(const e_ble_tlv *tlv) +{ + POINTER_SANITY_CHECK(tlv, BLE_QIOT_RS_ERR_PARA); + if (tlv->id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", tlv->id); + return BLE_QIOT_RS_ERR; + } + + if (NULL != sg_ble_property_array[tlv->id].set_cb) { + if (0 != sg_ble_property_array[tlv->id].set_cb(tlv->val, tlv->len)) { + ble_qiot_log_e("set property id %d failed", tlv->id); + return BLE_QIOT_RS_ERR; + } else { + return BLE_QIOT_RS_OK; + } + } + ble_qiot_log_e("invalid set callback, id %d", tlv->id); + + return BLE_QIOT_RS_ERR; +} + +int ble_user_property_get_data_by_id(uint8_t id, char *buf, uint16_t buf_len) +{ + int ret_len = 0; + + POINTER_SANITY_CHECK(buf, BLE_QIOT_RS_ERR_PARA); + if (id >= BLE_QIOT_PROPERTY_ID_BUTT) { + ble_qiot_log_e("invalid property id %d", id); + return -1; + } + + if (NULL != sg_ble_property_array[id].get_cb) { + if (!ble_check_space_enough_by_type(sg_ble_property_array[id].type, buf_len)) { + ble_qiot_log_e("not enough space get property id %d data", id); + return -1; + } + ret_len = sg_ble_property_array[id].get_cb(buf, buf_len); + if (ret_len < 0) { + ble_qiot_log_e("get property id %d data failed", id); + return -1; + } else { + if (ble_check_ret_value_by_type(sg_ble_property_array[id].type, buf_len, ret_len)) { + return ret_len; + } else { + ble_qiot_log_e("property id %d length invalid, type %d", id, sg_ble_property_array[id].type); + return -1; + } + } + } + ble_qiot_log_e("invalid callback, property id %d", id); + + return 0; +} + +int ble_user_property_report_reply_handle(uint8_t result) +{ + ble_qiot_log_d("report reply result %d", result); + if (0 == result) { + report_reply_blink(); + } + + return BLE_QIOT_RS_OK; +} + +static int ble_event_get_status_report_status(char *buf, uint16_t buf_len) +{ + buf[0] = 1; + + return 1; +} + +static int ble_event_get_status_report_message(char *buf, uint16_t buf_len) +{ + int i = 0; + + for (i = 0; i < 26 * 3; i++) { + buf[i] = 'a' + (i % 26); + } + + return i; +} + +static ble_event_param sg_ble_event_status_report_array[BLE_QIOT_EVENT_STATUS_REPORT_PARAM_ID_BUTT] = { + {ble_event_get_status_report_status, BLE_QIOT_DATA_TYPE_BOOL}, + {ble_event_get_status_report_message, BLE_QIOT_DATA_TYPE_STRING}, +}; + +static int ble_event_get_low_voltage_voltage(char *data, uint16_t buf_len) +{ + float tmp = 1.0; + + memcpy(data, &tmp, sizeof(float)); + + return sizeof(float); +} + +static ble_event_param sg_ble_event_low_voltage_array[BLE_QIOT_EVENT_LOW_VOLTAGE_PARAM_ID_BUTT] = { + {ble_event_get_low_voltage_voltage, BLE_QIOT_DATA_TYPE_FLOAT}, +}; + +static int ble_event_get_hardware_fault_name(char *data, uint16_t buf_len) +{ + memcpy(data, "hardware_fault", sizeof("hardware_fault") - 1); + + return sizeof("hardware_fault") - 1; +} + +static int ble_event_get_hardware_fault_error_code(char *data, uint16_t buf_len) +{ + int error_code = HTONL(1024); + + memcpy(data, &error_code, sizeof(int)); + + return sizeof(int); +} + +static ble_event_param sg_ble_event_hardware_fault_array[BLE_QIOT_EVENT_HARDWARE_FAULT_PARAM_ID_BUTT] = { + {ble_event_get_hardware_fault_name, BLE_QIOT_DATA_TYPE_STRING}, + {ble_event_get_hardware_fault_error_code, BLE_QIOT_DATA_TYPE_INT}, +}; + +static ble_event_t sg_ble_event_array[BLE_QIOT_EVENT_ID_BUTT] = { + {sg_ble_event_status_report_array, sizeof(sg_ble_event_status_report_array) / sizeof(ble_event_param)}, + {sg_ble_event_low_voltage_array, sizeof(sg_ble_event_low_voltage_array) / sizeof(ble_event_param)}, + {sg_ble_event_hardware_fault_array, sizeof(sg_ble_event_hardware_fault_array) / sizeof(ble_event_param)}, +}; + +int ble_event_get_id_array_size(uint8_t event_id) +{ + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return -1; + } + + return sg_ble_event_array[event_id].array_size; +} + +uint8_t ble_event_get_param_id_type(uint8_t event_id, uint8_t param_id) +{ + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (param_id >= sg_ble_event_array[event_id].array_size) { + ble_qiot_log_e("invalid param id %d", param_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_event_array[event_id].event_array[param_id].type; +} + +int ble_event_get_data_by_id(uint8_t event_id, uint8_t param_id, char *out_buf, uint16_t buf_len) +{ + int ret_len = 0; + + if (event_id >= BLE_QIOT_EVENT_ID_BUTT) { + ble_qiot_log_e("invalid event id %d", event_id); + return -1; + } + if (param_id >= sg_ble_event_array[event_id].array_size) { + ble_qiot_log_e("invalid param id %d", param_id); + return -1; + } + if (NULL == sg_ble_event_array[event_id].event_array[param_id].get_cb) { + ble_qiot_log_e("invalid callback, event id %d, param id %d", event_id, param_id); + return 0; + } + + if (!ble_check_space_enough_by_type(sg_ble_event_array[event_id].event_array[param_id].type, buf_len)) { + ble_qiot_log_e("not enough space get data, event id %d, param id %d", event_id, param_id); + return -1; + } + ret_len = sg_ble_event_array[event_id].event_array[param_id].get_cb(out_buf, buf_len); + if (ret_len < 0) { + ble_qiot_log_e("get event data failed, event id %d, param id %d", event_id, param_id); + return -1; + } else { + if (ble_check_ret_value_by_type(sg_ble_event_array[event_id].event_array[param_id].type, buf_len, ret_len)) { + return ret_len; + } else { + ble_qiot_log_e("evnet data length invalid, event id %d, param id %d, type %d", event_id, param_id, + sg_ble_event_array[event_id].event_array[param_id].type); + return -1; + } + } +} + +int ble_user_event_reply_handle(uint8_t event_id, uint8_t result) +{ + ble_qiot_log_d("event id %d, reply result %d", event_id, result); + + return BLE_QIOT_RS_OK; +} + +static int ble_action_handle_loop_input_cb(e_ble_tlv *input_param_array, uint8_t input_array_size, + uint8_t *output_id_array) +{ + int result = 0; + + if (NULL == input_param_array || NULL == output_id_array) { + ble_qiot_log_e("invalid param"); + return -1; + } + + report_reply_blink(); + for (int i = 0; i < input_array_size; i++) { + ble_qiot_log_d("id %d", input_param_array[i].id); + } + + memcpy(&result, input_param_array[0].val, sizeof(int)); + result = NTOHL(result); + ble_qiot_log_d("id %d, val %d", input_param_array[0].id, result); + action_led_blink(result); + + output_id_array[BLE_QIOT_ACTION_LOOP_OUTPUT_ID_RESULT] = true; + + return 0; +} + +static int ble_action_handle_loop_output_cb(uint8_t output_id, char *buf, uint16_t buf_len) +{ + int data_len = 0; + int i = 0; + + switch (output_id) { + case BLE_QIOT_ACTION_LOOP_OUTPUT_ID_RESULT: + for (i = 0; i < 26 * 3; i++) { + buf[i] = 'a' + (i % 26); + } + data_len = i; + break; + default: + break; + } + return data_len; +} + +static uint8_t sg_ble_action_loop_input_type_array[BLE_QIOT_ACTION_LOOP_INPUT_ID_BUTT] = { + BLE_QIOT_DATA_TYPE_INT, +}; + +static uint8_t sg_ble_action_loop_output_type_array[BLE_QIOT_ACTION_LOOP_OUTPUT_ID_BUTT] = { + BLE_QIOT_DATA_TYPE_STRING, +}; + +static ble_action_t sg_ble_action_array[BLE_QIOT_ACTION_ID_BUTT] = { + {ble_action_handle_loop_input_cb, ble_action_handle_loop_output_cb, sg_ble_action_loop_input_type_array, + sg_ble_action_loop_output_type_array, sizeof(sg_ble_action_loop_input_type_array) / sizeof(uint8_t), + sizeof(sg_ble_action_loop_output_type_array) / sizeof(uint8_t)}, +}; + +uint8_t ble_action_get_intput_type_by_id(uint8_t action_id, uint8_t input_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (input_id >= sg_ble_event_array[action_id].array_size) { + ble_qiot_log_e("invalid input id %d", input_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_action_array[action_id].input_type_array[input_id]; +} + +uint8_t ble_action_get_output_type_by_id(uint8_t action_id, uint8_t output_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + if (output_id >= sg_ble_event_array[action_id].array_size) { + ble_qiot_log_e("invalid output id %d", output_id); + return BLE_QIOT_DATA_TYPE_BUTT; + } + + return sg_ble_action_array[action_id].output_type_array[output_id]; +} + +int ble_action_get_input_id_size(uint8_t action_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + return sg_ble_action_array[action_id].input_id_size; +} + +int ble_action_get_output_id_size(uint8_t action_id) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + return sg_ble_action_array[action_id].output_id_size; +} + +int ble_action_user_handle_input_param(uint8_t action_id, e_ble_tlv *input_param_array, uint8_t input_array_size, + uint8_t *output_id_array) +{ + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + + if (NULL != sg_ble_action_array[action_id].input_cb) { + if (0 != sg_ble_action_array[action_id].input_cb(input_param_array, input_array_size, output_id_array)) { + ble_qiot_log_e("input handle error"); + return -1; + } + } + + return 0; +} + +int ble_action_user_handle_output_param(uint8_t action_id, uint8_t output_id, char *buf, uint16_t buf_len) +{ + int ret_len = 0; + + if (action_id >= BLE_QIOT_ACTION_ID_BUTT) { + ble_qiot_log_e("invalid action id %d", action_id); + return -1; + } + if (NULL == sg_ble_action_array[action_id].output_cb) { + ble_qiot_log_e("invalid callback, action id %d", action_id); + return 0; + } + + if (!ble_check_space_enough_by_type(sg_ble_action_array[action_id].output_type_array[output_id], buf_len)) { + ble_qiot_log_e("not enough space get data, action id %d, output id %d", action_id, output_id); + return -1; + } + + ret_len = sg_ble_action_array[action_id].output_cb(output_id, buf, buf_len); + if (ret_len < 0) { + ble_qiot_log_e("get action data failed, action id %d, output id %d", action_id, output_id); + return -1; + } else { + if (ble_check_ret_value_by_type(sg_ble_action_array[action_id].output_type_array[output_id], buf_len, + ret_len)) { + return ret_len; + } else { + ble_qiot_log_e("action data length invalid, action id %d, output id %d", action_id, output_id); + return -1; + } + } +} + +#ifdef __cplusplus +} +#endif diff --git a/examples/nimble_llsync/date_template/ble_qiot_template.h b/examples/nimble_llsync/date_template/ble_qiot_template.h new file mode 100644 index 00000000..95117c2b --- /dev/null +++ b/examples/nimble_llsync/date_template/ble_qiot_template.h @@ -0,0 +1,285 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef BLE_QIOT_TEMPLATE_H_ +#define BLE_QIOT_TEMPLATE_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +// data type in template, corresponding to type in json file +enum { + BLE_QIOT_DATA_TYPE_BOOL = 0, + BLE_QIOT_DATA_TYPE_INT, + BLE_QIOT_DATA_TYPE_STRING, + BLE_QIOT_DATA_TYPE_FLOAT, + BLE_QIOT_DATA_TYPE_ENUM, + BLE_QIOT_DATA_TYPE_TIME, + BLE_QIOT_DATA_TYPE_BUTT, +}; + +// message type, reference data template +enum { + BLE_QIOT_MSG_TYPE_PROPERTY = 0, + BLE_QIOT_MSG_TYPE_EVENT, + BLE_QIOT_MSG_TYPE_ACTION, + BLE_QIOT_MSG_TYPE_BUTT, +}; + +// define property authority, not used +enum { + BLE_QIOT_PROPERTY_AUTH_RW = 0, + BLE_QIOT_PROPERTY_AUTH_READ, + BLE_QIOT_PROPERTY_AUTH_BUTT, +}; + +// define reply result +enum { + BLE_QIOT_REPLY_SUCCESS = 0, + BLE_QIOT_REPLY_FAIL, + BLE_QIOT_REPLY_DATA_ERR, + BLE_QIOT_REPLY_BUTT, +}; + +// define message flow direction +enum { + BLE_QIOT_EFFECT_REQUEST = 0, + BLE_QIOT_EFFECT_REPLY, + BLE_QIOT_EFFECT_BUTT, +}; + +// define message type that from server to device +enum { + BLE_QIOT_DATA_DOWN_REPORT_REPLY = 0, + BLE_QIOT_DATA_DOWN_CONTROL, + BLE_QIOT_DATA_DOWN_GET_STATUS_REPLY, + BLE_QIOT_DATA_DOWN_ACTION, + BLE_QIOT_DATA_DOWN_EVENT_REPLY, +}; + +// define message type that from device to server +enum { + BLE_QIOT_EVENT_UP_PROPERTY_REPORT = 0, + BLE_QIOT_EVENT_UP_CONTROL_REPLY, + BLE_QIOT_EVENT_UP_GET_STATUS, + BLE_QIOT_EVENT_UP_EVENT_POST, + BLE_QIOT_EVENT_UP_ACTION_REPLY, + BLE_QIOT_EVENT_UP_BIND_SIGN_RET, + BLE_QIOT_EVENT_UP_CONN_SIGN_RET, + BLE_QIOT_EVENT_UP_UNBIND_SIGN_RET, + BLE_QIOT_EVENT_UP_REPORT_MTU, + BLE_QIOT_EVENT_UP_BUTT, +}; + +// msg header define, bit 7-6 is msg type, bit 5 means request or reply, bit 4 - 0 is id +#define BLE_QIOT_PARSE_MSG_HEAD_TYPE(_C) (((_C)&0XFF) >> 6) +#define BLE_QIOT_PARSE_MSG_HEAD_EFFECT(_C) ((((_C)&0XFF) & 0X20) ? BLE_QIOT_EFFECT_REPLY : BLE_QIOT_EFFECT_REQUEST) +#define BLE_QIOT_PARSE_MSG_HEAD_ID(_C) ((_C)&0X1F) +#define BLE_QIOT_PACKAGE_MSG_HEAD(_TYPE, _REPLY, _ID) \ + (((_TYPE) << 6) | (((_REPLY) == BLE_QIOT_EFFECT_REPLY) << 5) | ((_ID)&0X1F)) + +// tlv header define, bit 7 - 5 is type, bit 4 - 0 depends on type of data template +#define BLE_QIOT_PARSE_TLV_HEAD_TYPE(_C) (((_C)&0XFF) >> 5) +#define BLE_QIOT_PARSE_TLV_HEAD_ID(_C) ((_C)&0X1F) +#define BLE_QIOT_PACKAGE_TLV_HEAD(_TYPE, _ID) (((_TYPE) << 5) | ((_ID)&0X1F)) + +// define property id +enum { + BLE_QIOT_PROPERTY_ID_POWER_SWITCH = 0, + BLE_QIOT_PROPERTY_ID_COLOR, + BLE_QIOT_PROPERTY_ID_BRIGHTNESS, + BLE_QIOT_PROPERTY_ID_NAME, + BLE_QIOT_PROPERTY_ID_BUTT, +}; + +// define property color enum +enum { + BLE_QIOT_PROPERTY_COLOR_RED = 0, + BLE_QIOT_PROPERTY_COLOR_GREEN = 1, + BLE_QIOT_PROPERTY_COLOR_BLUE = 2, + BLE_QIOT_PROPERTY_COLOR_BUTT = 3, +}; + +// define brightness attributes +#define BLE_QIOT_PROPERTY_BRIGHTNESS_STEP (1) +#define BLE_QIOT_PROPERTY_BRIGHTNESS_MIN (0) +#define BLE_QIOT_PROPERTY_BRIGHTNESS_MAX (100) +#define BLE_QIOT_PROPERTY_BRIGHTNESS_START (1) + +// define name length limit +#define BLE_QIOT_PROPERTY_NAME_LEN_MIN (0) +#define BLE_QIOT_PROPERTY_NAME_LEN_MAX (640) + +// define property set handle return 0 if success, other is error +// sdk call the function that inform the server data to the device +typedef int (*property_set_cb)(const char *data, uint16_t len); + +// define property get handle. return the data length obtained, -1 is error, 0 is no data +// sdk call the function fetch user data and send to the server, the data should wrapped by user adn skd just transmit +typedef int (*property_get_cb)(char *buf, uint16_t buf_len); + +// each property have a struct ble_property_t, make up a array named sg_ble_property_array +typedef struct { + property_set_cb set_cb; // set callback + property_get_cb get_cb; // get callback + uint8_t authority; // property authority + uint8_t type; // data type +} ble_property_t; + +// define event id +enum { + BLE_QIOT_EVENT_ID_STATUS_REPORT = 0, + BLE_QIOT_EVENT_ID_LOW_VOLTAGE, + BLE_QIOT_EVENT_ID_HARDWARE_FAULT, + BLE_QIOT_EVENT_ID_BUTT, +}; + +// define param id for event status_report +enum { + BLE_QIOT_EVENT_STATUS_REPORT_PARAM_ID_STATUS = 0, + BLE_QIOT_EVENT_STATUS_REPORT_PARAM_ID_MESSAGE, + BLE_QIOT_EVENT_STATUS_REPORT_PARAM_ID_BUTT, +}; + +// define range for param message +#define BLE_QIOT_EVENT_STATUS_REPORT_MESSAGE_LEN_MIN (0) +#define BLE_QIOT_EVENT_STATUS_REPORT_MESSAGE_LEN_MAX (64) + +// define param id for event low_voltage +enum { + BLE_QIOT_EVENT_LOW_VOLTAGE_PARAM_ID_VOLTAGE = 0, + BLE_QIOT_EVENT_LOW_VOLTAGE_PARAM_ID_BUTT, +}; + +// define param voltage attributes +#define BLE_QIOT_EVENT_LOW_VOLTAGE_VOLTAGE_STEP (1) +#define BLE_QIOT_EVENT_LOW_VOLTAGE_VOLTAGE_MIN (0.0) +#define BLE_QIOT_EVENT_LOW_VOLTAGE_VOLTAGE_MAX (24.0) +#define BLE_QIOT_EVENT_LOW_VOLTAGE_VOLTAGE_START (1) + +// define param id for event hardware_fault +enum { + BLE_QIOT_EVENT_HARDWARE_FAULT_PARAM_ID_NAME = 0, + BLE_QIOT_EVENT_HARDWARE_FAULT_PARAM_ID_ERROR_CODE, + BLE_QIOT_EVENT_HARDWARE_FAULT_PARAM_ID_BUTT, +}; + +// define range for param name +#define BLE_QIOT_EVENT_HARDWARE_FAULT_NAME_LEN_MIN (0) +#define BLE_QIOT_EVENT_HARDWARE_FAULT_NAME_LEN_MAX (64) + +// define param error_code attributes +#define BLE_QIOT_EVENT_HARDWARE_FAULT_ERROR_CODE_STEP (1) +#define BLE_QIOT_EVENT_HARDWARE_FAULT_ERROR_CODE_MIN (0) +#define BLE_QIOT_EVENT_HARDWARE_FAULT_ERROR_CODE_MAX (2000) +#define BLE_QIOT_EVENT_HARDWARE_FAULT_ERROR_CODE_START (1) + +// define event get handle. return the data length obtained, -1 is error, 0 is no data +// sdk call the function fetch user data and send to the server, the data should wrapped by user adn skd just transmit +typedef int (*event_get_cb)(char *buf, uint16_t buf_len); + +// each param have a struct ble_event_param, make up a array for the event +typedef struct { + event_get_cb get_cb; // get param data callback + uint8_t type; // param type +} ble_event_param; + +// a array named sg_ble_event_array is composed by all the event array +typedef struct { + ble_event_param *event_array; // array of params data + uint8_t array_size; // array size +} ble_event_t; + +// define action id +enum { + BLE_QIOT_ACTION_ID_LOOP = 0, + BLE_QIOT_ACTION_ID_BUTT, +}; + +// define input id for action loop +enum { + BLE_QIOT_ACTION_LOOP_INPUT_ID_INTERVAL = 0, + BLE_QIOT_ACTION_LOOP_INPUT_ID_BUTT, +}; + +// define output id for action loop +enum { + BLE_QIOT_ACTION_LOOP_OUTPUT_ID_RESULT = 0, + BLE_QIOT_ACTION_LOOP_OUTPUT_ID_BUTT, +}; +#define BLE_QIOT_ACTION_INPUT_LOOP_INTERVAL_MIN (0) +#define BLE_QIOT_ACTION_INPUT_LOOP_INTERVAL_MAX (100) +#define BLE_QIOT_ACTION_INPUT_LOOP_INTERVAL_START (0) +#define BLE_QIOT_ACTION_INPUT_LOOP_INTERVAL_STEP (1) + +// define output id result attributes +#define BLE_QIOT_ACTION_OUTPUT_LOOP_RESULT_LEN_MIN (0) +#define BLE_QIOT_ACTION_OUTPUT_LOOP_RESULT_LEN_MAX (320) + +// define max input id and output id in all of input id and output id above +#define BLE_QIOT_ACTION_INPUT_ID_BUTT 1 +#define BLE_QIOT_ACTION_OUTPUT_ID_BUTT 1 + +// define tlv struct +typedef struct { + uint8_t type; + uint8_t id; + uint16_t len; + char * val; +} e_ble_tlv; + +// define action input handle, return 0 is success, other is error. +// input_param_array carry the data from server, include input id, data length ,data val +// input_array_size means how many input id +// output_id_array filling with output id numbers that need obtained, sdk will traverse it and call the +// action_output_handle to obtained data +typedef int (*action_input_handle)(e_ble_tlv *input_param_array, uint8_t input_array_size, uint8_t *output_id_array); + +// define action output handle, return length of the data, 0 is no data, -1 is error +// output_id means which id data should be obtained +typedef int (*action_output_handle)(uint8_t output_id, char *buf, uint16_t buf_len); + +// each action have a struct ble_action_t, make up a array named sg_ble_action_array +typedef struct { + action_input_handle input_cb; // handle input data + action_output_handle output_cb; // get output data in the callback + uint8_t * input_type_array; // type array for input id + uint8_t * output_type_array; // type array for output id + uint8_t input_id_size; // numbers of input id + uint8_t output_id_size; // numbers of output id +} ble_action_t; +// property module +uint8_t ble_get_property_type_by_id(uint8_t id); +int ble_user_property_set_data(const e_ble_tlv *tlv); +int ble_user_property_get_data_by_id(uint8_t id, char *buf, uint16_t buf_len); +int ble_user_property_report_reply_handle(uint8_t result); + +// event module +int ble_event_get_id_array_size(uint8_t event_id); +uint8_t ble_event_get_param_id_type(uint8_t event_id, uint8_t param_id); +int ble_event_get_data_by_id(uint8_t event_id, uint8_t param_id, char *out_buf, uint16_t buf_len); +int ble_user_event_reply_handle(uint8_t event_id, uint8_t result); + +// action module +uint8_t ble_action_get_intput_type_by_id(uint8_t action_id, uint8_t input_id); +uint8_t ble_action_get_output_type_by_id(uint8_t action_id, uint8_t output_id); +int ble_action_get_input_id_size(uint8_t action_id); +int ble_action_get_output_id_size(uint8_t action_id); +int ble_action_user_handle_input_param(uint8_t action_id, e_ble_tlv *input_param_array, uint8_t input_array_size, + uint8_t *output_id_array); +int ble_action_user_handle_output_param(uint8_t action_id, uint8_t output_id, char *buf, uint16_t buf_len); + +#ifdef __cplusplus +} +#endif +#endif // BLE_QIOT_TEMPLATE_H_ diff --git a/examples/nimble_llsync/date_template/nrf52832.json b/examples/nimble_llsync/date_template/nrf52832.json new file mode 100644 index 00000000..e313f550 --- /dev/null +++ b/examples/nimble_llsync/date_template/nrf52832.json @@ -0,0 +1,183 @@ +{ + "version": "1.0", + "profile": { + "ProductId": "DHZX03IQAZ", + "CategoryId": "141" + }, + "properties": [ + { + "id": "power_switch", + "name": "电灯开关", + "desc": "控制电灯开灭", + "required": true, + "mode": "rw", + "define": { + "type": "bool", + "mapping": { + "0": "关", + "1": "开" + } + } + }, + { + "id": "color", + "name": "颜色", + "desc": "灯光颜色", + "mode": "rw", + "define": { + "type": "enum", + "mapping": { + "0": "Red", + "1": "Green", + "2": "Blue" + } + } + }, + { + "id": "brightness", + "name": "亮度", + "desc": "灯光亮度", + "mode": "rw", + "define": { + "type": "int", + "unit": "%", + "step": "1", + "min": "0", + "max": "100", + "start": "1" + } + }, + { + "id": "name", + "name": "灯位置名称", + "desc": "灯位置名称:书房、客厅等", + "mode": "rw", + "define": { + "type": "string", + "min": "0", + "max": "640" + }, + "required": false + } + ], + "events": [ + { + "id": "status_report", + "name": "DeviceStatus", + "desc": "Report the device status", + "type": "info", + "required": false, + "params": [ + { + "id": "status", + "name": "running_state", + "desc": "Report current device running state", + "define": { + "type": "bool", + "mapping": { + "0": "normal", + "1": "fault" + } + } + }, + { + "id": "message", + "name": "Message", + "desc": "Some extra message", + "define": { + "type": "string", + "min": "0", + "max": "64" + } + } + ] + }, + { + "id": "low_voltage", + "name": "LowVoltage", + "desc": "Alert for device voltage is low", + "type": "alert", + "required": false, + "params": [ + { + "id": "voltage", + "name": "Voltage", + "desc": "Current voltage", + "define": { + "type": "float", + "unit": "V", + "step": "1", + "min": "0.0", + "max": "24.0", + "start": "1" + } + } + ] + }, + { + "id": "hardware_fault", + "name": "Hardware_fault", + "desc": "Report hardware fault", + "type": "fault", + "required": false, + "params": [ + { + "id": "name", + "name": "Name", + "desc": "Name like: memory,tf card, censors ...", + "define": { + "type": "string", + "min": "0", + "max": "64" + } + }, + { + "id": "error_code", + "name": "Error_Code", + "desc": "Error code for fault", + "define": { + "type": "int", + "unit": "", + "step": "1", + "min": "0", + "max": "2000", + "start": "1" + } + } + ] + } + ], + "actions": [ + { + "id": "loop", + "name": "loop", + "desc": "", + "input": [ + { + "id": "interval", + "name": "interval", + "define": { + "type": "int", + "min": "0", + "max": "100", + "start": "0", + "step": "1", + "unit": "" + } + } + ], + "output": [ + { + "id": "result", + "name": "result", + "define": { + "type": "string", + "min": "0", + "max": "320" + } + } + ], + "required": false + } + ] +} diff --git a/examples/nimble_llsync/flash_storage.c b/examples/nimble_llsync/flash_storage.c new file mode 100644 index 00000000..1420ef1a --- /dev/null +++ b/examples/nimble_llsync/flash_storage.c @@ -0,0 +1,209 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "flash_storage.h" +#include "ble_qiot_config.h" +#include "nrf_fstorage.h" +#include "nrf_sdh.h" +#include "nrf_sdh_ble.h" +#include "nrf_fstorage_nvmc.h" +#include "nrf_log.h" +#include "nrf_log_ctrl.h" +#include "nrf_log_default_backends.h" +#include + + +#ifdef SOFTDEVICE_PRESENT +#include "nrf_fstorage_sd.h" +#else +#include "nrf_fstorage_nvmc.h" +#endif + +static void fstorage_evt_handler(nrf_fstorage_evt_t *p_evt); + +NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) = { + /* Set a handler for fstorage events. */ + .evt_handler = fstorage_evt_handler, + + /* These below are the boundaries of the flash space assigned to this instance of fstorage. + * You must set these manually, even at runtime, before nrf_fstorage_init() is called. + * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the + * last page of flash available to write data. */ + .start_addr = 0x7e000, + .end_addr = 0x7ffff, +}; + +static void *p_write_buf = NULL; + +void fstorage_init(void) +{ + nrf_fstorage_api_t *p_fs_api; + ret_code_t rc; + +#ifdef SOFTDEVICE_PRESENT + NRF_LOG_INFO("SoftDevice is present."); + NRF_LOG_INFO("Initializing nrf_fstorage_sd implementation..."); + /* Initialize an fstorage instance using the nrf_fstorage_sd backend. + * nrf_fstorage_sd uses the SoftDevice to write to flash. This implementation can safely be + * used whenever there is a SoftDevice, regardless of its status (enabled/disabled). */ + p_fs_api = &nrf_fstorage_sd; +#else + NRF_LOG_INFO("SoftDevice not present."); + NRF_LOG_INFO("Initializing nrf_fstorage_nvmc implementation..."); + /* Initialize an fstorage instance using the nrf_fstorage_nvmc backend. + * nrf_fstorage_nvmc uses the NVMC peripheral. This implementation can be used when the + * SoftDevice is disabled or not present. + * + * Using this implementation when the SoftDevice is enabled results in a hardfault. */ + p_fs_api = &nrf_fstorage_nvmc; +#endif + + p_write_buf = NULL; + rc = nrf_fstorage_init(&fstorage, p_fs_api, NULL); + APP_ERROR_CHECK(rc); +} + +/**@brief Helper function to obtain the last address on the last page of the on-chip flash that + * can be used to write user data. + * It is possible to set the start and end addresses of an fstorage instance at runtime. + * They can be set multiple times, should it be needed. The helper function below can + * be used to determine the last address on the last page of flash memory available to + * store data. + */ +/* +static uint32_t nrf5_flash_end_addr_get() +{ + uint32_t const bootloader_addr = NRF_UICR->NRFFW[0]; + uint32_t const page_sz = NRF_FICR->CODEPAGESIZE; + uint32_t const code_sz = NRF_FICR->CODESIZE; + + return (bootloader_addr != 0xFFFFFFFF ? + bootloader_addr : (code_sz * page_sz)); +} +*/ + +/**@brief Sleep until an event is received. */ +static void power_manage(void) +{ +#ifdef SOFTDEVICE_PRESENT + (void)sd_app_evt_wait(); +#else + __WFE(); +#endif +} + +int fstorage_read(uint32_t addr, uint32_t read_len, void *p_data) +{ + ret_code_t rc; + + /* Read data. */ + rc = nrf_fstorage_read(&fstorage, addr, p_data, read_len); + if (rc != NRF_SUCCESS) { + NRF_LOG_ERROR("nrf_fstorage_read() returned: %s\n", nrf_strerror_get(rc)); + return 0; + } + + return read_len; +} + +static uint32_t round_up_u32(uint32_t len) +{ + if (len % sizeof(uint32_t)) { + return (len + sizeof(uint32_t) - (len % sizeof(uint32_t))); + } + + return len; +} + +int fstorage_erase(uint32_t addr) +{ + ret_code_t rc; + + rc = nrf_fstorage_erase(&fstorage, addr, BLE_QIOT_RECORD_FLASH_PAGENUM, NULL); + if (rc != NRF_SUCCESS) { + NRF_LOG_ERROR("nrf_fstorage_erase() returned: %s\n", nrf_strerror_get(rc)); + return rc; + } + + return 0; +} + +int fstorage_write(uint32_t addr, uint32_t write_len, void const *p_data) +{ + /* The following code snippet make sure that the length of the data we are writing to flash + * is a multiple of the program unit of the flash peripheral (4 bytes). + */ + uint32_t len = round_up_u32(write_len); + ret_code_t rc; + + rc = nrf_fstorage_erase(&fstorage, addr, BLE_QIOT_RECORD_FLASH_PAGENUM, NULL); + if (rc != NRF_SUCCESS) { + NRF_LOG_ERROR("nrf_fstorage_erase() returned: %s\n", nrf_strerror_get(rc)); + } + + /* Copy the data to write in flash. + * Because the fstorage interface is asynchrounous, the data must be kept in memory before get + * the NRF_FSTORAGE_EVT_WRITE_RESULT event. This memory will be free in fstorage_evt_handler(). + */ + p_write_buf = (void *)malloc(len); + if (NULL == p_write_buf) { + NRF_LOG_ERROR("fstorage_write() malloc size %d error", len); + return 0; + } + + memset(p_write_buf, 0, len); + memcpy(p_write_buf, p_data, write_len); + + rc = nrf_fstorage_write(&fstorage, addr, p_write_buf, len, NULL); + if (rc != NRF_SUCCESS) { + NRF_LOG_ERROR("nrf_fstorage_write() returned: %s\n", nrf_strerror_get(rc)); + return 0; + } + + return write_len; +} + +static void fstorage_evt_handler(nrf_fstorage_evt_t *p_evt) +{ + if (p_evt->result != NRF_SUCCESS) { + NRF_LOG_INFO("fstorage event received: ERROR while executing an fstorage operation."); + return; + } + + switch (p_evt->id) { + case NRF_FSTORAGE_EVT_WRITE_RESULT: { + free(p_write_buf); + p_write_buf = NULL; + NRF_LOG_INFO("fstorage event received: wrote %d bytes at address 0x%x.", p_evt->len, p_evt->addr); + } break; + + case NRF_FSTORAGE_EVT_ERASE_RESULT: { + NRF_LOG_INFO("fstorage event received: erased %d page from address 0x%x.", p_evt->len, p_evt->addr); + } break; + + default: + break; + } +} + +/** + * @brief While fstorage is busy, sleep and wait for an event. + * + * @param p_fstorage nrf_fstorage_t obj + */ +void wait_for_flash_ready(nrf_fstorage_t const *p_fstorage) +{ + /* While fstorage is busy, sleep and wait for an event. */ + while (nrf_fstorage_is_busy(p_fstorage)) { + power_manage(); + } +} diff --git a/examples/nimble_llsync/flash_storage.h b/examples/nimble_llsync/flash_storage.h new file mode 100644 index 00000000..e48b251e --- /dev/null +++ b/examples/nimble_llsync/flash_storage.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +/** + * @brief initialize of flash storage + * + */ +void fstorage_init(void); + +/** + * @brief read data from flash + * + * @param addr read address from flash + * @param read_len length of data to read + * @param p_data point to read buf + * @return read length is success, other is error + */ +int fstorage_read(uint32_t addr, uint32_t read_len, void *p_data); + +/** + * @brief write data to flash, must erase before write + * + * @param addr write address in flash + * @param write_len length of data to write + * @param p_data point to write buf + * @return write length is success, other is error + */ +int fstorage_write(uint32_t addr, uint32_t write_len, void const *p_data); + +/** + * @brief erase one page + * + * @param addr address must align to page. For example, one page is 4096 bytes, + * you want to erase address 0x1020, you should set address 0x1000 + * @return 0 is succcess, other is error + */ +int fstorage_erase(uint32_t addr); diff --git a/examples/nimble_llsync/fprintf/nrf_fprintf.c b/examples/nimble_llsync/fprintf/nrf_fprintf.c new file mode 100644 index 00000000..419b3dad --- /dev/null +++ b/examples/nimble_llsync/fprintf/nrf_fprintf.c @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(NRF_FPRINTF) +#include + +#include "nrf_assert.h" +#include "nrf_fprintf_format.h" + +void nrf_fprintf_buffer_flush(nrf_fprintf_ctx_t * const p_ctx) +{ + ASSERT(p_ctx != NULL); + + if (p_ctx->io_buffer_cnt == 0) + { + return; + } + + p_ctx->fwrite(p_ctx->p_user_ctx, + p_ctx->p_io_buffer, + p_ctx->io_buffer_cnt); + p_ctx->io_buffer_cnt = 0; +} + +void nrf_fprintf(nrf_fprintf_ctx_t * const p_ctx, + char const * p_fmt, + ...) +{ + ASSERT(p_ctx != NULL); + ASSERT(p_ctx->fwrite != NULL); + ASSERT(p_ctx->p_io_buffer != NULL); + ASSERT(p_ctx->io_buffer_size > 0); + + if (p_fmt == NULL) + { + return; + } + + va_list args = {0}; + va_start(args, p_fmt); + + nrf_fprintf_fmt(p_ctx, p_fmt, &args); + + va_end(args); +} + +#endif // NRF_MODULE_ENABLED(NRF_FPRINTF) + diff --git a/examples/nimble_llsync/fprintf/nrf_fprintf.h b/examples/nimble_llsync/fprintf/nrf_fprintf.h new file mode 100644 index 00000000..3edb2c70 --- /dev/null +++ b/examples/nimble_llsync/fprintf/nrf_fprintf.h @@ -0,0 +1,114 @@ +/** + * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef NRF_FPRINTF_H__ +#define NRF_FPRINTF_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (* nrf_fprintf_fwrite)(void const * p_user_ctx, char const * p_str, size_t length); + +/** + * @brief fprintf context + */ +typedef struct nrf_fprintf_ctx +{ + char * const p_io_buffer; ///< Pointer to IO buffer. + size_t const io_buffer_size; ///< IO buffer size. + size_t io_buffer_cnt; ///< IO buffer usage. + bool auto_flush; ///< Auto flush configurator. + + void const * const p_user_ctx; ///< Pointer to user data to be passed to the fwrite funciton. + + nrf_fprintf_fwrite fwrite; ///< Pointer to function sending data stream. +} nrf_fprintf_ctx_t; + + +/** + * @brief Macro for defining nrf_fprintf instance. + * + * @param name Instance name. + * @param _p_user_ctx Pointer to user data. + * @param _p_io_buffer Pointer to IO buffer + * @param _io_buffer_size Size of IO buffer. + * @param _auto_flush Indicator if IO buffer shall be automatically flush. + * @param _fwrite Pointer to function sending data stream. + * */ +#define NRF_FPRINTF_DEF(name, _p_user_ctx, _p_io_buffer, _io_buffer_size, _auto_flush, _fwrite) \ + static nrf_fprintf_ctx_t name = \ + { \ + .p_io_buffer = _p_io_buffer, \ + .io_buffer_size = _io_buffer_size, \ + .io_buffer_cnt = 0, \ + .auto_flush = _auto_flush, \ + .p_user_ctx = _p_user_ctx, \ + .fwrite = _fwrite \ + } + +/** + * @brief fprintf like function which send formated data stream to output specified by user + * @ref nrf_fprintf_ctx_t + * + * @param p_ctx fprintf context. + * @param p_fmt Format string. + * @param ... List of parameters to print. + * */ +void nrf_fprintf(nrf_fprintf_ctx_t * const p_ctx, + char const * p_fmt, + ...); + +/** + * @brief function flushing data stored in io_buffer @ref nrf_fprintf_ctx_t + * + * @param p_ctx fprintf context + */ +void nrf_fprintf_buffer_flush(nrf_fprintf_ctx_t * const p_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* NRF_FPRINTF_H__ */ + diff --git a/examples/nimble_llsync/fprintf/nrf_fprintf_format.c b/examples/nimble_llsync/fprintf/nrf_fprintf_format.c new file mode 100644 index 00000000..b5b3e218 --- /dev/null +++ b/examples/nimble_llsync/fprintf/nrf_fprintf_format.c @@ -0,0 +1,516 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH & Co. KG * +* The Embedded Experts * +********************************************************************** +* * +* (c) 2014 - 2017 SEGGER Microcontroller GmbH & Co. KG * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* conditions are met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this list of conditions and the following disclaimer. * +* * +* o Redistributions in binary form must reproduce the above * +* copyright notice, this list of conditions and the following * +* disclaimer in the documentation and/or other materials provided * +* with the distribution. * +* * +* o Neither the name of SEGGER Microcontroller GmbH & Co. KG * +* nor the names of its contributors may be used to endorse or * +* promote products derived from this software without specific * +* prior written permission. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.14d * +* * +*********************************************************************/ + +#include "sdk_common.h" +#if NRF_MODULE_ENABLED(NRF_FPRINTF) + +#include + +#include "nrf_assert.h" +#include "nrf_fprintf.h" +#include "nrf_fprintf_format.h" + +#define NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY (1u << 0) +#define NRF_CLI_FORMAT_FLAG_PAD_ZERO (1u << 1) +#define NRF_CLI_FORMAT_FLAG_PRINT_SIGN (1u << 2) + +static void buffer_add(nrf_fprintf_ctx_t * const p_ctx, char c) +{ +#if NRF_MODULE_ENABLED(NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF) + if (c == '\n') + { + buffer_add(p_ctx, '\r'); + } +#endif + p_ctx->p_io_buffer[p_ctx->io_buffer_cnt++] = c; + + if (p_ctx->io_buffer_cnt >= p_ctx->io_buffer_size) + { + nrf_fprintf_buffer_flush(p_ctx); + } +} + +static void string_print(nrf_fprintf_ctx_t * const p_ctx, + char const * p_str, + uint32_t FieldWidth, + uint32_t FormatFlags) +{ + uint32_t Width = 0; + char c; + + if ((FormatFlags & NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY) == NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY) + { + while ((c = *p_str) != '\0') + { + p_str++; + Width++; + buffer_add(p_ctx, c); + } + + while ((FieldWidth > Width) && (FieldWidth > 0)) + { + FieldWidth--; + buffer_add(p_ctx, ' '); + } + } + else + { + if (p_str != 0) + { + Width = strlen(p_str); + } + + while ((FieldWidth > Width) && (FieldWidth > 0)) + { + FieldWidth--; + buffer_add(p_ctx, ' '); + } + + while ((c = *p_str) != '\0') + { + p_str++; + Width++; + buffer_add(p_ctx, c); + } + } +} + +static void unsigned_print(nrf_fprintf_ctx_t * const p_ctx, + uint32_t v, + uint32_t Base, + uint32_t NumDigits, + uint32_t FieldWidth, + uint32_t FormatFlags) +{ + static const char _aV2C[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F' }; + uint32_t Div; + uint32_t Value; + uint32_t Width; + char c; + + Value = v; + // + // Get actual field width + // + Width = 1u; + while (Value >= Base) + { + Value = (Value / Base); + Width++; + } + if (NumDigits > Width) + { + Width = NumDigits; + } + // + // Print leading chars if necessary + // + if ((FormatFlags & NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY) == 0u) + { + if (FieldWidth != 0u) + { + if (((FormatFlags & NRF_CLI_FORMAT_FLAG_PAD_ZERO) == NRF_CLI_FORMAT_FLAG_PAD_ZERO) && + (NumDigits == 0u)) + { + c = '0'; + } + else + { + c = ' '; + } + while ((FieldWidth != 0u) && (Width < FieldWidth)) + { + FieldWidth--; + buffer_add(p_ctx, c); + } + } + } + + Value = 1; + /* + * Compute Digit. + * Loop until Digit has the value of the highest digit required. + * Example: If the output is 345 (Base 10), loop 2 times until Digit is 100. + */ + while (1) + { + /* User specified a min number of digits to print? => Make sure we loop at least that + * often, before checking anything else (> 1 check avoids problems with NumDigits + * being signed / unsigned) + */ + if (NumDigits > 1u) + { + NumDigits--; + } + else + { + Div = v / Value; + // Is our divider big enough to extract the highest digit from value? => Done + if (Div < Base) + { + break; + } + } + Value *= Base; + } + // + // Output digits + // + do + { + Div = v / Value; + v -= Div * Value; + buffer_add(p_ctx, _aV2C[Div]); + Value /= Base; + } while (Value); + // + // Print trailing spaces if necessary + // + if ((FormatFlags & NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY) == NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY) + { + if (FieldWidth != 0u) + { + while ((FieldWidth != 0u) && (Width < FieldWidth)) + { + FieldWidth--; + buffer_add(p_ctx, ' '); + } + } + } +} + +static void int_print(nrf_fprintf_ctx_t * const p_ctx, + int32_t v, + uint32_t Base, + uint32_t NumDigits, + uint32_t FieldWidth, + uint32_t FormatFlags) +{ + uint32_t Width; + int32_t Number; + + Number = (v < 0) ? -v : v; + + // + // Get actual field width + // + Width = 1u; + while (Number >= (int32_t)Base) + { + Number = (Number / (int32_t)Base); + Width++; + } + if (NumDigits > Width) + { + Width = NumDigits; + } + if ((FieldWidth > 0u) && ((v < 0) || + ((FormatFlags & NRF_CLI_FORMAT_FLAG_PRINT_SIGN) == NRF_CLI_FORMAT_FLAG_PRINT_SIGN))) + { + FieldWidth--; + } + // + // Print leading spaces if necessary + // + if ((((FormatFlags & NRF_CLI_FORMAT_FLAG_PAD_ZERO) == 0u) || (NumDigits != 0u)) && + ((FormatFlags & NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY) == 0u)) + { + if (FieldWidth != 0u) + { + while ((FieldWidth != 0u) && (Width < FieldWidth)) + { + FieldWidth--; + buffer_add(p_ctx, ' '); + } + } + } + // + // Print sign if necessary + // + if (v < 0) + { + v = -v; + buffer_add(p_ctx, '-'); + } + else if ((FormatFlags & NRF_CLI_FORMAT_FLAG_PRINT_SIGN) == NRF_CLI_FORMAT_FLAG_PRINT_SIGN) + { + buffer_add(p_ctx, '+'); + } + else + { + /* do nothing */ + } + // + // Print leading zeros if necessary + // + if (((FormatFlags & NRF_CLI_FORMAT_FLAG_PAD_ZERO) == NRF_CLI_FORMAT_FLAG_PAD_ZERO) && + ((FormatFlags & NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY) == 0u) && (NumDigits == 0u)) + { + if (FieldWidth != 0u) + { + while ((FieldWidth != 0u) && (Width < FieldWidth)) + { + FieldWidth--; + buffer_add(p_ctx, '0'); + } + } + } + // + // Print number without sign + // + unsigned_print(p_ctx, (uint32_t)v, Base, NumDigits, FieldWidth, FormatFlags); +} + +void nrf_fprintf_fmt(nrf_fprintf_ctx_t * const p_ctx, + char const * p_fmt, + va_list * p_args) +{ + ASSERT(p_ctx != NULL); + + ASSERT(p_ctx->fwrite != NULL); + ASSERT(p_ctx->p_io_buffer != NULL); + ASSERT(p_ctx->io_buffer_size > 0); + + if (p_fmt == NULL) + { + return; + } + + char c; + int32_t v; + uint32_t NumDigits; + uint32_t FormatFlags; + uint32_t FieldWidth; + + do + { + c = *p_fmt; + p_fmt++; + + if (c == 0u) + { + break; + } + if (c == '%') + { + // + // Filter out flags + // + FormatFlags = 0u; + v = 1; + + do + { + c = *p_fmt; + switch (c) + { + case '-': + FormatFlags |= NRF_CLI_FORMAT_FLAG_LEFT_JUSTIFY; + p_fmt++; + break; + case '0': + FormatFlags |= NRF_CLI_FORMAT_FLAG_PAD_ZERO; + p_fmt++; + break; + case '+': + FormatFlags |= NRF_CLI_FORMAT_FLAG_PRINT_SIGN; + p_fmt++; + break; + default: + v = 0; + break; + } + } while (v); + + // + // filter out field width + // + FieldWidth = 0u; + do + { + if (c == '*') + { + /*lint -save -e64 -e56*/ + FieldWidth += va_arg(*p_args, unsigned); + /*lint -restore*/ + p_fmt++; + break; + } + c = *p_fmt; + if ((c < '0') || (c > '9')) + { + break; + } + p_fmt++; + FieldWidth = (FieldWidth * 10u) + (c - '0'); + } while (1); + + // + // Filter out precision (number of digits to display) + // + NumDigits = 0u; + c = *p_fmt; + if (c == '.') + { + p_fmt++; + do + { + c = *p_fmt; + if ((c < '0') || (c > '9')) + { + break; + } + p_fmt++; + NumDigits = NumDigits * 10u + (c - '0'); + } while (1); + } + // + // Filter out length modifier + // + c = *p_fmt; + do + { + if ((c == 'l') || (c == 'h')) + { + p_fmt++; + c = *p_fmt; + } + else + { + break; + } + } while (1); + // + // Handle specifiers + // + /*lint -save -e64*/ + switch (c) + { + case 'c': + { + char c0; + v = va_arg(*p_args, int32_t); + c0 = (char)v; + buffer_add(p_ctx, c0); + break; + } + case 'd': + case 'i': + v = va_arg(*p_args, int32_t); + int_print(p_ctx, + v, + 10u, + NumDigits, + FieldWidth, + FormatFlags); + break; + case 'u': + v = va_arg(*p_args, int32_t); + unsigned_print(p_ctx, + (uint32_t)v, + 10u, + NumDigits, + FieldWidth, + FormatFlags); + break; + case 'x': + case 'X': + v = va_arg(*p_args, int32_t); + unsigned_print(p_ctx, + (uint32_t)v, + 16u, + NumDigits, + FieldWidth, + FormatFlags); + break; + case 's': + { + char const * p_s = va_arg(*p_args, const char *); + string_print(p_ctx, p_s, FieldWidth, FormatFlags); + break; + } + case 'p': + v = va_arg(*p_args, int32_t); + buffer_add(p_ctx, '0'); + buffer_add(p_ctx, 'x'); + unsigned_print(p_ctx, (uint32_t)v, 16u, 8u, 8u, 0); + break; + case '%': + buffer_add(p_ctx, '%'); + break; + default: + break; + } + /*lint -restore*/ + p_fmt++; + } + else + { + buffer_add(p_ctx, c); + } + } while (*p_fmt != '\0'); + + if (p_ctx->auto_flush) + { + nrf_fprintf_buffer_flush(p_ctx); + } +} + +#endif // NRF_MODULE_ENABLED(NRF_FPRINTF) + diff --git a/examples/nimble_llsync/fprintf/nrf_fprintf_format.h b/examples/nimble_llsync/fprintf/nrf_fprintf_format.h new file mode 100644 index 00000000..920e6859 --- /dev/null +++ b/examples/nimble_llsync/fprintf/nrf_fprintf_format.h @@ -0,0 +1,86 @@ +/********************************************************************* +* SEGGER Microcontroller GmbH & Co. KG * +* The Embedded Experts * +********************************************************************** +* * +* (c) 2014 - 2017 SEGGER Microcontroller GmbH & Co. KG * +* * +* www.segger.com Support: support@segger.com * +* * +********************************************************************** +* * +* SEGGER RTT * Real Time Transfer for embedded targets * +* * +********************************************************************** +* * +* All rights reserved. * +* * +* SEGGER strongly recommends to not make any changes * +* to or modify the source code of this software in order to stay * +* compatible with the RTT protocol and J-Link. * +* * +* Redistribution and use in source and binary forms, with or * +* without modification, are permitted provided that the following * +* conditions are met: * +* * +* o Redistributions of source code must retain the above copyright * +* notice, this list of conditions and the following disclaimer. * +* * +* o Redistributions in binary form must reproduce the above * +* copyright notice, this list of conditions and the following * +* disclaimer in the documentation and/or other materials provided * +* with the distribution. * +* * +* o Neither the name of SEGGER Microcontroller GmbH & Co. KG * +* nor the names of its contributors may be used to endorse or * +* promote products derived from this software without specific * +* prior written permission. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * +* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * +* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * +* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * +* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * +* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * +* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +********************************************************************** +* * +* RTT version: 6.14d * +* * +*********************************************************************/ + +#ifndef NRF_FPRINTF_FORMAT_H__ +#define NRF_FPRINTF_FORMAT_H__ + +#include +#include "nrf_fprintf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Printf like function which sends formated data stream to output. + * + * @param nrf_fprintf_ctx_t Print context. + * @param p_fmt Format string. + * @param p_args List of parameters to print. + * */ +void nrf_fprintf_fmt(nrf_fprintf_ctx_t * const p_ctx, + char const * p_fmt, + va_list * p_args); + + +#ifdef __cplusplus +} +#endif + +#endif /* NRF_FPRINTF_FORMAT_H__ */ + diff --git a/examples/nimble_llsync/gatt_svr.c b/examples/nimble_llsync/gatt_svr.c new file mode 100644 index 00000000..1ebcabe8 --- /dev/null +++ b/examples/nimble_llsync/gatt_svr.c @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +#include +#include "host/ble_hs.h" +#include "host/ble_uuid.h" +// #include "blehr_sens.h" + +#include "services/dis/ble_svc_dis.h" +#include "services/bas/ble_svc_bas.h" + +#define GATT_DEVICE_INFO_UUID 0x180A +#define GATT_MANUFACTURER_NAME_UUID 0x2A29 +#define GATT_MODEL_NUMBER_UUID 0x2A24 + +#define REPLY_BUFFER_SIZE 100 +static char reply[REPLY_BUFFER_SIZE]; + +static int gatt_svr_chr_access_device_info_manufacturer( + uint16_t conn_handle, uint16_t attr_handle, + struct ble_gatt_access_ctxt *ctxt, void *arg); + +static int gatt_svr_chr_access_device_info_model( + uint16_t conn_handle, uint16_t attr_handle, + struct ble_gatt_access_ctxt *ctxt, void *arg); + +/* define several bluetooth services for our device */ +static const struct ble_gatt_svc_def gatt_svr_svcs[] = { + /* + * access_cb defines a callback for read and write access events on + * given characteristics + */ + { + /* Service: Device Information */ + .type = BLE_GATT_SVC_TYPE_PRIMARY, + .uuid = BLE_UUID16_DECLARE(GATT_DEVICE_INFO_UUID), + .characteristics = (struct ble_gatt_chr_def[]) { { + /* Characteristic: * Manufacturer name */ + .uuid = BLE_UUID16_DECLARE(GATT_MANUFACTURER_NAME_UUID), + .access_cb = gatt_svr_chr_access_device_info_manufacturer, + .flags = BLE_GATT_CHR_F_READ, + }, { + /* Characteristic: Model number string */ + .uuid = BLE_UUID16_DECLARE(GATT_MODEL_NUMBER_UUID), + .access_cb = gatt_svr_chr_access_device_info_model, + .flags = BLE_GATT_CHR_F_READ, + }, { + 0, /* No more characteristics in this service */ + }, } + }, + { + 0, /* No more services */ + }, +}; + +static int gatt_svr_chr_access_device_info_manufacturer( + uint16_t conn_handle, uint16_t attr_handle, + struct ble_gatt_access_ctxt *ctxt, void *arg) +{ + printf("service 'device info: manufacturer' callback triggered\n"); + + snprintf(reply, REPLY_BUFFER_SIZE, "This is TencentOS tiny\n"); + printf("reply: %s\n", reply); + + int rc = os_mbuf_append(ctxt->om, reply, strlen(reply)); + + printf("\n"); + + return rc; +} + +static int gatt_svr_chr_access_device_info_model( + uint16_t conn_handle, uint16_t attr_handle, + struct ble_gatt_access_ctxt *ctxt, void *arg) +{ + printf("service 'device info: model' callback triggered\n"); + + snprintf(reply, REPLY_BUFFER_SIZE, "running TencentOS tiny on nordic ble board"); + printf("reply: %s\n", reply); + + int rc = os_mbuf_append(ctxt->om, reply, strlen(reply)); + + printf("\n"); + + return rc; +} + +void +gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg) +{ + char buf[BLE_UUID_STR_LEN]; + + switch (ctxt->op) { + case BLE_GATT_REGISTER_OP_SVC: + MODLOG_DFLT(DEBUG, "registered service %s with handle=%d\n", + ble_uuid_to_str(ctxt->svc.svc_def->uuid, buf), + ctxt->svc.handle); + break; + + case BLE_GATT_REGISTER_OP_CHR: + MODLOG_DFLT(DEBUG, "registering characteristic %s with " + "def_handle=%d val_handle=%d\n", + ble_uuid_to_str(ctxt->chr.chr_def->uuid, buf), + ctxt->chr.def_handle, + ctxt->chr.val_handle); + break; + + case BLE_GATT_REGISTER_OP_DSC: + MODLOG_DFLT(DEBUG, "registering descriptor %s with handle=%d\n", + ble_uuid_to_str(ctxt->dsc.dsc_def->uuid, buf), + ctxt->dsc.handle); + break; + + default: + assert(0); + break; + } +} + +int +gatt_svr_init(void) +{ + int rc; + + rc = ble_gatts_count_cfg(gatt_svr_svcs); + if (rc != 0) { + return rc; + } + + rc = ble_gatts_add_svcs(gatt_svr_svcs); + if (rc != 0) { + return rc; + } + + return 0; +} + diff --git a/examples/nimble_llsync/main.c b/examples/nimble_llsync/main.c new file mode 100644 index 00000000..5c26b096 --- /dev/null +++ b/examples/nimble_llsync/main.c @@ -0,0 +1,142 @@ +#include +#include +#include + +#include "nimble/nimble_port_tencentos_tiny.h" + +#include "host/ble_hs.h" +#include "host/util/util.h" +#include "host/ble_gatt.h" +#include "services/gap/ble_svc_gap.h" +#include "services/gatt/ble_svc_gatt.h" + +#include "boards.h" +#include "ble_qiot_config.h" +#include "flash_storage.h" + +#include "ble_qiot_export.h" +#include "ble_qiot_import.h" + + +extern int gatt_svr_init(void); +extern void board_init(void); +extern void nimble_port_init(void); + +static const char device_name[] = "TOS LLSync"; + +static uint8_t ble_addr_type; + +void ble_boot(void *arg) +{ + int rc = 0; + + extern void nimble_port_run(void); + nimble_port_tencentos_tiny_init(nimble_port_run); + + /* make sure synchronization of host and controller is done */ + while (!ble_hs_synced()) { + ; + } + + rc = ble_hs_util_ensure_addr(0); + assert(rc == 0); + rc = ble_hs_id_infer_auto(0, &ble_addr_type); + assert(rc == 0); + + ble_svc_gap_init(); + ble_svc_gatt_init(); + + /* verify and add our custom services */ + rc = gatt_svr_init(); + assert(rc == 0); + + /* init llsync, add llsync services */ + ble_qiot_explorer_init(); + + /* set the device name */ + rc = ble_svc_gap_device_name_set(device_name); + assert(rc == 0); + + /* reload the GATT server to link our added services */ + ble_gatts_start(); + + /* llsync start advertising */ + ble_qiot_advertising_start(); + + return; +} + +static void leds_init(void) +{ + bsp_board_init(BSP_INIT_LEDS); +} + +void property_power_switch(const char *data, uint16_t len) +{ + if (data[0]) { + bsp_board_led_on(BSP_BOARD_LED_0); + printf("Received LED ON!"); + } else { + bsp_board_led_off(BSP_BOARD_LED_0); + printf("Received LED OFF!"); + } + return; +} + +void action_led_blink(int ms) +{ + bsp_board_led_on(BSP_BOARD_LED_1); + tos_sleep_ms(ms); + bsp_board_led_off(BSP_BOARD_LED_1); + tos_sleep_ms(ms); + bsp_board_led_on(BSP_BOARD_LED_1); + tos_sleep_ms(ms); + bsp_board_led_off(BSP_BOARD_LED_1); + tos_sleep_ms(ms); + bsp_board_led_on(BSP_BOARD_LED_1); + tos_sleep_ms(ms); + bsp_board_led_off(BSP_BOARD_LED_1); +} + +void report_reply_blink(void) +{ + bsp_board_led_on(BSP_BOARD_LED_2); + tos_sleep_ms(200); + bsp_board_led_off(BSP_BOARD_LED_2); + tos_sleep_ms(200); + bsp_board_led_on(BSP_BOARD_LED_2); + tos_sleep_ms(200); + bsp_board_led_off(BSP_BOARD_LED_2); +} + + +k_task_t ble_boot_task; +k_stack_t ble_boot_stack[2048]; + +int main(void) +{ + board_init(); + + // other devices init + leds_init(); + + /* init flash that llsync need to save some device info */ + fstorage_init(); + + /* Initialize OS */ + tos_knl_init(); + + nimble_port_init(); + + /* + in this case, ble_boot_task's priority must lower than MYNEWT_VAL_BLE_HOST_TASK_PRIORITY && MYNEWT_VAL_BLE_LL_TASK_PRIORITY, + numerically bigger + to give the host and ll task a chance to run first just after the nimble_port_tencentos_tiny_init. + */ + tos_task_create(&ble_boot_task, "boot", ble_boot, NULL, + 6, + ble_boot_stack, sizeof(ble_boot_stack), + 0); + tos_knl_start(); +} +