1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 #ifndef __CUSTOMPARAM_SECTION_H__ 5 #define __CUSTOMPARAM_SECTION_H__ 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 // Could be customized 12 #define CUSTOMPARAM_MAGIC_CODE 0x54534542 13 #define CUSTOMPARAM_VERSION 1 14 15 #define CUSTOMPARAM_SECTION_SIZE 4096 // one flash page 16 17 typedef struct 18 { 19 uint32_t magic_code; // fixed value as CUSTOMPARAM_MAGIC_CODE 20 uint16_t version; 21 uint16_t length; // length in bytes of the following data in the section 22 uint16_t entryCount; 23 // following are parameter entries 24 25 } __attribute__((packed)) CUSTOM_PARAM_SECTION_HEADER_T; 26 27 typedef struct 28 { 29 uint16_t paramIndex; 30 uint16_t paramLen; 31 // following are the parameter content with length paramLen 32 } __attribute__((packed)) CUSTOM_PARAM_ENTRY_HEADER_T; 33 34 #define CUSTOM_PARAM_Mode_ID_INDEX 0 35 #define CUSTOM_PARAM_Model_ID_LEN 3 36 37 #define CUSTOM_PARAM_SERIAL_NUM_INDEX 0 38 #define CUSTOM_PARAM_SERIAL_NUM_LEN 16 39 40 #ifdef BES_BLE_MESH_ENABLE 41 typedef void (*ble_addr_set)(unsigned char* addr); 42 43 #define CUSTOM_PARAM_SECRET_NUM_INDEX 0 44 #define CUSTOM_PARAM_PID_NUM_INDEX 1 45 #define CUSTOM_PARAM_MAC_NUM_INDEX 2 46 47 #define GENIE_SIZE_PID 4 48 #define GENIE_SIZE_KEY 16 49 #define GENIE_SIZE_MAC 6 50 51 void nv_custom_register(ble_addr_set callback); 52 uint8_t *genie_tri_tuple_get_uuid(void); 53 uint8_t *genie_tri_tuple_get_auth(void); 54 55 #endif 56 57 typedef struct 58 { 59 uint8_t sn[CUSTOM_PARAM_SERIAL_NUM_LEN]; 60 } CUSTOM_PARAM_SERIAL_NUM_T; 61 62 // TODO: 63 // Add your own custom parameters here 64 65 66 void nv_custom_parameter_section_init(void); 67 bool nv_custom_parameter_section_get_entry( 68 uint16_t paramIndex, uint8_t* pParamVal, uint32_t* pParamLen); 69 uint32_t Get_ModelId(void); 70 71 #ifdef __cplusplus 72 } 73 #endif 74 #endif 75 76