Skip to content

Commit f5c7726

Browse files
committed
feat : Update Device Preference example
Signed-off-by: stdk-scm <63764571+stdk-scm@users.noreply.github.com>
1 parent e2188c7 commit f5c7726

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

apps/esp32/light_example/main/main.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,23 @@ static void iot_noti_cb(iot_noti_data_t *noti_data, void *noti_usr_data)
246246
} else if (noti_data->type == IOT_NOTI_TYPE_RATE_LIMIT) {
247247
printf("[rate limit] Remaining time:%d, sequence number:%d\n",
248248
noti_data->raw.rate_limit.remainingTime, noti_data->raw.rate_limit.sequenceNumber);
249-
}
249+
} else if(noti_data->type == IOT_NOTI_TYPE_PREFERENCE_UPDATED) {
250+
for (int i = 0; i < noti_data->raw.preferences.preferences_num; i++) {
251+
printf("[preference update] name : %s value : ", noti_data->raw.preferences.preferences_data[i].preference_name);
252+
if (noti_data->raw.preferences.preferences_data[i].preference_data.type == IOT_CAP_VAL_TYPE_NULL)
253+
printf("NULL\n");
254+
else if (noti_data->raw.preferences.preferences_data[i].preference_data.type == IOT_CAP_VAL_TYPE_STRING)
255+
printf("%s\n", noti_data->raw.preferences.preferences_data[i].preference_data.string);
256+
else if (noti_data->raw.preferences.preferences_data[i].preference_data.type == IOT_CAP_VAL_TYPE_NUMBER)
257+
printf("%f\n", noti_data->raw.preferences.preferences_data[i].preference_data.number);
258+
else if (noti_data->raw.preferences.preferences_data[i].preference_data.type == IOT_CAP_VAL_TYPE_INTEGER)
259+
printf("%d\n", noti_data->raw.preferences.preferences_data[i].preference_data.integer);
260+
else if (noti_data->raw.preferences.preferences_data[i].preference_data.type == IOT_CAP_VAL_TYPE_BOOLEAN)
261+
printf("%s\n", noti_data->raw.preferences.preferences_data[i].preference_data.boolean ? "true" : "false");
262+
else
263+
printf("Unknown type\n");
264+
}
265+
}
250266
}
251267

252268
void button_event(IOT_CAP_HANDLE *handle, int type, int count)

iot-core

Submodule iot-core updated 83 files

0 commit comments

Comments
 (0)