Skip to content

Commit

Permalink
Merge branch 'refactor/portable_pointers' into 'master'
Browse files Browse the repository at this point in the history
refactor: made pointers in rainmaker schedule more portable

See merge request app-frameworks/esp-rainmaker!444
  • Loading branch information
shahpiyushv committed Jun 19, 2024
2 parents e1fcc7c + a01d6c0 commit 8da28b0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions components/esp_rainmaker/src/core/esp_rmaker_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ typedef struct esp_rmaker_schedule {
/* Info is used to store additional information, it is limited to 128 bytes. */
char *info;
/* Index is used in the callback to get back the schedule. */
int32_t index;
long index;
/* Flags are used to identify the schedule. Eg. timing, countdown */
uint32_t flags;
bool enabled;
Expand Down Expand Up @@ -147,17 +147,17 @@ static esp_rmaker_schedule_t *esp_rmaker_schedule_get_schedule_from_id(const cha
return NULL;
}

static esp_rmaker_schedule_t *esp_rmaker_schedule_get_schedule_from_index(int32_t index)
static esp_rmaker_schedule_t *esp_rmaker_schedule_get_schedule_from_index(long index)
{
esp_rmaker_schedule_t *schedule = schedule_priv_data->schedule_list;
while(schedule) {
if (schedule->index == index) {
ESP_LOGD(TAG, "Schedule with index %"PRIi32" found in list for get.", index);
ESP_LOGD(TAG, "Schedule with index %ld found in list for get.", index);
return schedule;
}
schedule = schedule->next;
}
ESP_LOGD(TAG, "Schedule with index %"PRIi32" not found in list for get.", index);
ESP_LOGD(TAG, "Schedule with index %ld not found in list for get.", index);
return NULL;
}

Expand Down Expand Up @@ -285,10 +285,10 @@ static esp_err_t esp_rmaker_schedule_process_action(esp_rmaker_schedule_action_t

static void esp_rmaker_schedule_trigger_work_cb(void *priv_data)
{
int32_t index = (int32_t)priv_data;
long index = (long)priv_data;
esp_rmaker_schedule_t *schedule = esp_rmaker_schedule_get_schedule_from_index(index);
if (!schedule) {
ESP_LOGE(TAG, "Schedule with index %"PRIi32" not found for trigger work callback", index);
ESP_LOGE(TAG, "Schedule with index %ld not found for trigger work callback", index);
return;
}
esp_rmaker_schedule_process_action(&schedule->action);
Expand All @@ -307,10 +307,10 @@ static void esp_rmaker_schedule_trigger_common_cb(esp_schedule_handle_t handle,

static void esp_rmaker_schedule_timestamp_common_cb(esp_schedule_handle_t handle, uint32_t next_timestamp, void *priv_data)
{
int32_t index = (int32_t)priv_data;
long index = (long)priv_data;
esp_rmaker_schedule_t *schedule = esp_rmaker_schedule_get_schedule_from_index(index);
if (!schedule) {
ESP_LOGE(TAG, "Schedule with index %"PRIi32" not found for timestamp callback", index);
ESP_LOGE(TAG, "Schedule with index %ld not found for timestamp callback", index);
return;
}
schedule->trigger.next_timestamp = next_timestamp;
Expand Down

0 comments on commit 8da28b0

Please sign in to comment.