Skip to content
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

Revert "WebPA Sync Notification handling during Factory reset cloud sync" #286

Merged
merged 1 commit into from
Dec 20, 2024
Merged
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
2 changes: 0 additions & 2 deletions source/broadband/include/webpa_notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,3 @@ WDMP_STATUS validate_webpa_notification_data(char *notify_param_name, char *writ

pthread_cond_t *get_global_sync_condition(void);
pthread_mutex_t *get_global_sync_mutex(void);

void FR_CloudSyncCheck();
53 changes: 3 additions & 50 deletions source/broadband/webpa_notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void sendNotificationForFactoryReset();
void sendNotificationForFirmwareUpgrade();
static WDMP_STATUS addOrUpdateFirmwareVerToConfigFile(char *value);
static WDMP_STATUS processParamNotification(ParamNotify *paramNotify, unsigned int *cmc, char **cid);
static WDMP_STATUS getCmcCidValues(unsigned int *cmc, char **cid);
static WDMP_STATUS processParamNotificationRetry(unsigned int *cmc, char **cid);
static void processConnectedClientNotification(NodeData *connectedNotify, char *deviceId, char **version, char ** nodeMacId, char **timeStamp, char **destination);
static WDMP_STATUS processFactoryResetNotification(ParamNotify *paramNotify, unsigned int *cmc, char **cid, char **reason);
static WDMP_STATUS processFirmwareUpgradeNotification(ParamNotify *paramNotify, unsigned int *cmc, char **cid);
Expand Down Expand Up @@ -1036,59 +1036,12 @@ static void addNotifyMsgToQueue(NotifyData *notifyData)
WalPrint("*****Returned from addNotifyMsgToQueue*****\n");
}

/*
* @brief To delay sync notifications until FR cloud sync is acknowledged by cloud with Test and Set request for max wait period of 60s
*/
void FR_CloudSyncCheck()
{
char *cid = NULL;
unsigned int cmc = 0;
int FR_cloud_sync_completed = false;
WDMP_STATUS ret = WDMP_FAILURE;

for(int i=0;i<12;i++)
{
ret = getCmcCidValues(&cmc, &cid);
if (ret != WDMP_SUCCESS)
{
WalError("Unable to get dbCID/CMC value during FR cloud sync check\n");
}
else if ((strcmp(cid, "0") == 0) && cmc != 512) //To check whether the device is up after factory reset
{
WalInfo("Factory reset cloud sync is in progress, wait for 5sec to process sync notifications\n");
WAL_FREE(cid);
}
else
{
FR_cloud_sync_completed = true;
WAL_FREE(cid);
break;
}
sleep(5);
}

if(FR_cloud_sync_completed == false)
{
WalInfo("Factory reset cloud sync is failed after 60sec, proceeding to sync notifications without FR cloud sync\n");
}else
{
WalInfo("Factory reset cloud sync is completed, proceeding to sync notifications\n");
}
}

/*
* @brief To monitor notification events in Notification queue
*/
static void handleNotificationEvents()
{
char *reboot_reason = NULL;
reboot_reason = getParameterValue(PARAM_REBOOT_REASON);
if( (NULL != reboot_reason) && (strcmp(reboot_reason,"factory-reset")==0) )
{
WAL_FREE(reboot_reason);
FR_CloudSyncCheck();
}

while(1)
{
pthread_mutex_lock (&mut);
Expand Down Expand Up @@ -1462,7 +1415,7 @@ void processNotification(NotifyData *notifyData)
case PARAM_NOTIFY_RETRY:
{
strcpy(dest, "event:SYNC_NOTIFICATION");
ret = getCmcCidValues(&cmc, &cid);
ret = processParamNotificationRetry(&cmc, &cid);
if (ret != WDMP_SUCCESS)
{
free(dest);
Expand Down Expand Up @@ -1564,7 +1517,7 @@ static WDMP_STATUS processParamNotification(ParamNotify *paramNotify,
return status;
}

static WDMP_STATUS getCmcCidValues(unsigned int *cmc, char **cid)
static WDMP_STATUS processParamNotificationRetry(unsigned int *cmc, char **cid)
{
char *dbCID = NULL, *dbCMC = NULL;

Expand Down
Loading