Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions osal/efr32_wisun/osal_efr32_wisun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
16 changes: 16 additions & 0 deletions osal/freertos/osal_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
16 changes: 16 additions & 0 deletions osal/linux/osal_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
28 changes: 28 additions & 0 deletions osal/osal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/****************************************************************************

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR primarily intends to define dummy OSAL APIs proposed to persist group information for Group management TLVs (viz., 55,56,57,58) for all platforms.

Note: Per current agent design, platform specific implementation for TLV handlers are made under sample/tlvs/linux_tlvs.c/currenttime_get() - for Linux CurrentTime_TLV18 GET for example.

OSAL APIs are typically defined for abstracting platform infra related operations. There could be exceptions for some APIs consumed by TLV handlers as well.

Please give the current approach a thought of whether an OSAL API will be defined or platform specific TLV handlers will be defined to persist group information.

* @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
9 changes: 9 additions & 0 deletions src/csmpagent/csmp_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <stdio.h>
#include <string.h>
#include "csmp.h"
#include "osal.h"
#include "csmptlv.h"
#include "csmpagent.h"
#include "csmpfunction.h"
Expand All @@ -25,6 +26,11 @@
static uint32_t m_GroupIds[CSMP_GROUP_NUM_TYPES] = {0};
static bool m_bLastMatchValid;

int initGroups()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls perform initialization in sample_data_init() as discussed in the review discussion.

{
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};
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/csmpagent/csmpagent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls move this to sample_data_init() as discussed in the review discussion.


/**
* @brief check group
*
Expand Down
3 changes: 3 additions & 0 deletions src/csmpapi/csmpservice.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "csmpservice.h"
#include "cgmsagent.h"
#include "csmpserver.h"
#include "csmpagent.h"

uint8_t g_csmplib_status = SERVICE_NOT_START;

Expand All @@ -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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All app initialization are currently done in sample_data_init().
csmpservice.c is focused on handling csmp service and not recommended to do data inits for TLVs. Pls move this to sample_data_init() as discussed in the review discussion.


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;
Expand Down