-
Notifications
You must be signed in to change notification settings - Fork 10
Add OSAL hooks for persistent group membership storage #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
|
@@ -25,6 +26,11 @@ | |
| static uint32_t m_GroupIds[CSMP_GROUP_NUM_TYPES] = {0}; | ||
| static bool m_bLastMatchValid; | ||
|
|
||
| int initGroups() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}; | ||
|
|
@@ -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; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All app initialization are currently done in sample_data_init(). |
||
|
|
||
| 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; | ||
|
|
||
There was a problem hiding this comment.
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.