diff --git a/osal/efr32_wisun/osal_efr32_wisun.c b/osal/efr32_wisun/osal_efr32_wisun.c index 6e90340..9c0fa02 100644 --- a/osal/efr32_wisun/osal_efr32_wisun.c +++ b/osal/efr32_wisun/osal_efr32_wisun.c @@ -746,5 +746,21 @@ osal_basetype_t osal_copy_firmware(uint8_t source_slotid, uint8_t dest_slotid, C return OSAL_FAILURE; } + return OSAL_SUCCESS; +} + +osal_basetype_t osal_read_groups(uint32_t *groups, uint8_t num_groups) +{ + /* Silence compiler warnings about unused parameters. */ + (void) groups; + (void) num_groups; + return OSAL_SUCCESS; +} + +osal_basetype_t osal_write_groups(uint32_t *groups, uint8_t num_groups) +{ + /* Silence compiler warnings about unused parameters. */ + (void) groups; + (void) num_groups; return OSAL_SUCCESS; } \ No newline at end of file diff --git a/osal/freertos/osal_freertos.c b/osal/freertos/osal_freertos.c index 42aa369..2d299ab 100644 --- a/osal/freertos/osal_freertos.c +++ b/osal/freertos/osal_freertos.c @@ -635,4 +635,20 @@ osal_basetype_t osal_copy_firmware(uint8_t source_slotid, uint8_t dest_slotid, C DPRINTF("osal_copy_firmware: Copied Slothdr Successfully\n"); return OSAL_SUCCESS; +} + +osal_basetype_t osal_read_groups(uint32_t *groups, uint8_t num_groups) +{ + /* Silence compiler warnings about unused parameters. */ + (void) groups; + (void) num_groups; + return OSAL_SUCCESS; +} + +osal_basetype_t osal_write_groups(uint32_t *groups, uint8_t num_groups) +{ + /* Silence compiler warnings about unused parameters. */ + (void) groups; + (void) num_groups; + return OSAL_SUCCESS; } \ No newline at end of file diff --git a/osal/linux/osal_linux.c b/osal/linux/osal_linux.c index 4d3f3f5..c9f2171 100644 --- a/osal/linux/osal_linux.c +++ b/osal/linux/osal_linux.c @@ -679,3 +679,19 @@ int osal_copy_firmware(uint8_t source_slotid, uint8_t dest_slotid, Csmp_Slothdr DPRINTF("osal_copy_firmware: Copied Slothdr Successfully\n"); return OSAL_SUCCESS; } + +osal_basetype_t osal_read_groups(uint32_t *groups, uint8_t num_groups) +{ + /* Silence compiler warnings about unused parameters. */ + (void) groups; + (void) num_groups; + return OSAL_SUCCESS; +} + +osal_basetype_t osal_write_groups(uint32_t *groups, uint8_t num_groups) +{ + /* Silence compiler warnings about unused parameters. */ + (void) groups; + (void) num_groups; + return OSAL_SUCCESS; +} \ No newline at end of file diff --git a/osal/osal.h b/osal/osal.h index 15f35cc..ffd4858 100644 --- a/osal/osal.h +++ b/osal/osal.h @@ -675,4 +675,32 @@ osal_basetype_t osal_write_slothdr(uint8_t slotid, Csmp_Slothdr* slot); * @return returns 0 on success and -1 on error *****************************************************************************/ osal_basetype_t osal_copy_firmware(uint8_t source_slotid, uint8_t dest_slotid, Csmp_Slothdr *slots); + +/**************************************************************************** + * @fn osal_read_groups + * + * @brief read group ids from storage (file/flash) + * + * input parameters + * @param[in] groups pointer to array with group ids + * @param[in] num_groups size of the array + * + * output parameters + * @return returns 0 on success and -1 on error + *****************************************************************************/ +osal_basetype_t osal_read_groups(uint32_t *groups, uint8_t num_groups); + +/**************************************************************************** + * @fn osal_write_groups + * + * @brief write group ids to storage (file/flash) + * + * input parameters + * @param[in] groups pointer to array with group ids + * @param[in] num_groups size of the array + * + * output parameters + * @return returns 0 on success and -1 on error + *****************************************************************************/ +osal_basetype_t osal_write_groups(uint32_t *groups, uint8_t num_groups); #endif diff --git a/src/csmpagent/csmp_group.c b/src/csmpagent/csmp_group.c index 0f83d7a..4ef25e8 100755 --- a/src/csmpagent/csmp_group.c +++ b/src/csmpagent/csmp_group.c @@ -17,6 +17,7 @@ #include #include #include "csmp.h" +#include "osal.h" #include "csmptlv.h" #include "csmpagent.h" #include "csmpfunction.h" @@ -25,6 +26,11 @@ static uint32_t m_GroupIds[CSMP_GROUP_NUM_TYPES] = {0}; static bool m_bLastMatchValid; +int initGroups() +{ + return osal_read_groups(m_GroupIds, CSMP_GROUP_NUM_TYPES); +} + bool checkGroup(const uint8_t *buf, uint32_t len) { uint32_t msglen; tlvid_t tlvid = {0,GROUP_MATCH_TLVID}; @@ -115,7 +121,10 @@ int csmp_put_groupAssign(tlvid_t tlvid, const uint8_t *buf, size_t len, uint8_t case CSMP_GROUP_TYPE_CONF: case CSMP_GROUP_TYPE_FW: if (m_GroupIds[GroupAssignMsg->type] != GroupAssignMsg->id) + { m_GroupIds[GroupAssignMsg->type] = GroupAssignMsg->id; + osal_write_groups(m_GroupIds, CSMP_GROUP_NUM_TYPES); + } break; default: break; diff --git a/src/csmpagent/csmpagent.h b/src/csmpagent/csmpagent.h index ac703a1..79ea9c7 100644 --- a/src/csmpagent/csmpagent.h +++ b/src/csmpagent/csmpagent.h @@ -62,6 +62,13 @@ int csmpagent_post(tlvid_t tlvid, const uint8_t *buf, size_t len, uint8_t *out_b */ int checkSignature(const uint8_t *buf, uint32_t len, bool agent); +/** + * @brief init group information + * + * @return int 0 is success + */ +int initGroups(); + /** * @brief check group * diff --git a/src/csmpapi/csmpservice.c b/src/csmpapi/csmpservice.c index ccd20d2..bf9b614 100644 --- a/src/csmpapi/csmpservice.c +++ b/src/csmpapi/csmpservice.c @@ -21,6 +21,7 @@ #include "csmpservice.h" #include "cgmsagent.h" #include "csmpserver.h" +#include "csmpagent.h" uint8_t g_csmplib_status = SERVICE_NOT_START; @@ -47,6 +48,8 @@ int csmp_service_start(dev_config_t *devconfig, csmp_handle_t *csmp_handle) { if((devconfig == NULL) || (csmp_handle == NULL)) return -2; + initGroups(); + memset(g_csmplib_eui64, 0, sizeof(g_csmplib_eui64)); memcpy(g_csmplib_eui64, devconfig->ieee_eui64.data, sizeof(g_csmplib_eui64)); g_csmplib_reginterval_min = devconfig->reginterval_min;