From f5c7726206388d22e18becc60f1b8fb8129dfa56 Mon Sep 17 00:00:00 2001 From: stdk-scm <63764571+stdk-scm@users.noreply.github.com> Date: Wed, 10 May 2023 16:53:12 +0900 Subject: [PATCH] feat : Update Device Preference example Signed-off-by: stdk-scm <63764571+stdk-scm@users.noreply.github.com> --- apps/esp32/light_example/main/main.c | 18 +++++++++++++++++- iot-core | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/esp32/light_example/main/main.c b/apps/esp32/light_example/main/main.c index 0d13e35b..52af9f7d 100644 --- a/apps/esp32/light_example/main/main.c +++ b/apps/esp32/light_example/main/main.c @@ -246,7 +246,23 @@ static void iot_noti_cb(iot_noti_data_t *noti_data, void *noti_usr_data) } else if (noti_data->type == IOT_NOTI_TYPE_RATE_LIMIT) { printf("[rate limit] Remaining time:%d, sequence number:%d\n", noti_data->raw.rate_limit.remainingTime, noti_data->raw.rate_limit.sequenceNumber); - } + } else if(noti_data->type == IOT_NOTI_TYPE_PREFERENCE_UPDATED) { + for (int i = 0; i < noti_data->raw.preferences.preferences_num; i++) { + printf("[preference update] name : %s value : ", noti_data->raw.preferences.preferences_data[i].preference_name); + if (noti_data->raw.preferences.preferences_data[i].preference_data.type == IOT_CAP_VAL_TYPE_NULL) + printf("NULL\n"); + else if (noti_data->raw.preferences.preferences_data[i].preference_data.type == IOT_CAP_VAL_TYPE_STRING) + printf("%s\n", noti_data->raw.preferences.preferences_data[i].preference_data.string); + else if (noti_data->raw.preferences.preferences_data[i].preference_data.type == IOT_CAP_VAL_TYPE_NUMBER) + printf("%f\n", noti_data->raw.preferences.preferences_data[i].preference_data.number); + else if (noti_data->raw.preferences.preferences_data[i].preference_data.type == IOT_CAP_VAL_TYPE_INTEGER) + printf("%d\n", noti_data->raw.preferences.preferences_data[i].preference_data.integer); + else if (noti_data->raw.preferences.preferences_data[i].preference_data.type == IOT_CAP_VAL_TYPE_BOOLEAN) + printf("%s\n", noti_data->raw.preferences.preferences_data[i].preference_data.boolean ? "true" : "false"); + else + printf("Unknown type\n"); + } + } } void button_event(IOT_CAP_HANDLE *handle, int type, int count) diff --git a/iot-core b/iot-core index 3ccd694f..662f1aaf 160000 --- a/iot-core +++ b/iot-core @@ -1 +1 @@ -Subproject commit 3ccd694f8d6f4c2e8317a7022f024dda731bf779 +Subproject commit 662f1aafdcfc70241527cdac6841adc7511377ee