Skip to content

Commit bd77d6f

Browse files
committed
Fix init run slot with default data
1 parent 6ce4069 commit bd77d6f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

sample/CsmpAgentLib_sample.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,22 @@ void sample_data_init() {
8080
}
8181
#else // Platforms other than linux cuurenlty do not support image read/write to disk function,
8282
// run-slot will be initialized with default values during boot-up
83+
84+
ret = osal_read_slothdr(RUN_IMAGE, &g_slothdr[RUN_IMAGE]);
85+
if(ret<0){
86+
memcpy(&g_slothdr[RUN_IMAGE],&default_run_slot_image, sizeof(Csmp_Slothdr));
87+
(void) osal_write_slothdr(RUN_IMAGE, &g_slothdr[RUN_IMAGE]);
88+
DPRINTF("sample_data_init: Run slot not found!\n");
89+
}
8390
ret = osal_read_slothdr(UPLOAD_IMAGE, &g_slothdr[UPLOAD_IMAGE]);
8491
if(ret<0){
85-
memset(&g_slothdr[UPLOAD_IMAGE], 0, sizeof(Csmp_Slothdr));
92+
memcpy(&g_slothdr[UPLOAD_IMAGE],&default_run_slot_image, sizeof(Csmp_Slothdr));
8693
(void) osal_write_slothdr(UPLOAD_IMAGE, &g_slothdr[UPLOAD_IMAGE]);
8794
DPRINTF("sample_data_init: Upload slot not found!\n");
8895
}
8996
ret = osal_read_slothdr(BACKUP_IMAGE, &g_slothdr[BACKUP_IMAGE]);
9097
if(ret<0){
91-
memset(&g_slothdr[BACKUP_IMAGE], 0, sizeof(Csmp_Slothdr));
98+
memcpy(&g_slothdr[BACKUP_IMAGE],&default_run_slot_image, sizeof(Csmp_Slothdr));
9299
(void) osal_write_slothdr(BACKUP_IMAGE, &g_slothdr[BACKUP_IMAGE]);
93100
DPRINTF("sample_data_init: Backup slot not found!\n");
94101
}

sample/CsmpAgentLib_sample.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ enum {
117117
#define CSMP_AGENT_REG_INTERVAL_MAX 100U
118118

119119
/** \brief EUI64 Address of the Agent*/
120-
#define CSMP_AGENT_EUI64_ADDRESS "00173bab001003ff"
120+
#define CSMP_AGENT_EUI64_ADDRESS "00173bab001003fe"
121121

122122
/** \brief NMS Address*/
123123
#define CSMP_AGENT_NMS_ADDRESS "fd12:3456::2"

0 commit comments

Comments
 (0)