Skip to content

Commit bd1ab52

Browse files
hdlee27Kwang-Hui
authored andcommitted
caps_sample:update sample file in apps
(cherry-picked from commit 85fc22c) Signed-off-by: Hyundo Lee <[email protected]>
1 parent 452cd53 commit bd1ab52

File tree

11 files changed

+75
-96
lines changed

11 files changed

+75
-96
lines changed

apps/emw3080/light_example/main/caps_activityLightingMode.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ static int caps_activityLightingMode_attr_lightingMode_str2idx(const char *value
3131
if (!strcmp(value, caps_helper_activityLightingMode.attr_lightingMode.values[index])) {
3232
return index;
3333
}
34-
}
35-
return -1;
34+
}
35+
return -1;
3636
}
3737

3838
static const char *caps_activityLightingMode_get_lightingMode_value(caps_activityLightingMode_data_t *caps_data)
@@ -58,9 +58,7 @@ static void caps_activityLightingMode_set_lightingMode_value(caps_activityLighti
5858

5959
static void caps_activityLightingMode_attr_lightingMode_send(caps_activityLightingMode_data_t *caps_data)
6060
{
61-
IOT_EVENT *cap_evt;
62-
uint8_t evt_num = 1;
63-
int sequence_no;
61+
int sequence_no = -1;
6462

6563
if (!caps_data || !caps_data->handle) {
6664
printf("fail to get handle\n");
@@ -71,19 +69,18 @@ static void caps_activityLightingMode_attr_lightingMode_send(caps_activityLighti
7169
return;
7270
}
7371

74-
cap_evt = st_cap_attr_create_string((char *)caps_helper_activityLightingMode.attr_lightingMode.name,
75-
caps_data->lightingMode_value, NULL);
76-
if (!cap_evt) {
77-
printf("fail to create cap_evt\n");
78-
return;
79-
}
72+
ST_CAP_SEND_ATTR_STRING(caps_data->handle,
73+
(char *)caps_helper_activityLightingMode.attr_lightingMode.name,
74+
caps_data->lightingMode_value,
75+
NULL,
76+
NULL,
77+
sequence_no);
8078

81-
sequence_no = st_cap_attr_send(caps_data->handle, evt_num, &cap_evt);
8279
if (sequence_no < 0)
8380
printf("fail to send lightingMode value\n");
81+
else
82+
printf("Sequence number return : %d\n", sequence_no);
8483

85-
printf("Sequence number return : %d\n", sequence_no);
86-
st_cap_attr_free(cap_evt);
8784
}
8885

8986

apps/emw3080/light_example/main/caps_colorTemperature.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,24 @@ static void caps_colorTemperature_set_colorTemperature_unit(caps_colorTemperatur
6161

6262
static void caps_colorTemperature_attr_colorTemperature_send(caps_colorTemperature_data_t *caps_data)
6363
{
64-
IOT_EVENT *cap_evt;
65-
uint8_t evt_num = 1;
66-
int sequence_no;
64+
int sequence_no = -1;
6765

6866
if (!caps_data || !caps_data->handle) {
6967
printf("fail to get handle\n");
7068
return;
7169
}
7270

73-
cap_evt = st_cap_attr_create_int((char *) caps_helper_colorTemperature.attr_colorTemperature.name, caps_data->colorTemperature_value, caps_data->colorTemperature_unit);
74-
if (!cap_evt) {
75-
printf("fail to create cap_evt\n");
76-
return;
77-
}
71+
ST_CAP_SEND_ATTR_NUMBER(caps_data->handle,
72+
(char *)caps_helper_colorTemperature.attr_colorTemperature.name,
73+
caps_data->colorTemperature_value,
74+
caps_data->colorTemperature_unit,
75+
NULL,
76+
sequence_no);
7877

79-
sequence_no = st_cap_attr_send(caps_data->handle, evt_num, &cap_evt);
8078
if (sequence_no < 0)
8179
printf("fail to send colorTemperature value\n");
82-
83-
printf("Sequence number return : %d\n", sequence_no);
84-
st_cap_attr_free(cap_evt);
80+
else
81+
printf("Sequence number return : %d\n", sequence_no);
8582
}
8683

8784

apps/emw3080/light_example/main/caps_dustSensor.c

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,24 @@ static void caps_dustSensor_set_fineDustLevel_unit(caps_dustSensor_data_t *caps_
6161

6262
static void caps_dustSensor_attr_fineDustLevel_send(caps_dustSensor_data_t *caps_data)
6363
{
64-
IOT_EVENT *cap_evt;
65-
uint8_t evt_num = 1;
66-
int sequence_no;
64+
int sequence_no = -1;
6765

6866
if (!caps_data || !caps_data->handle) {
6967
printf("fail to get handle\n");
7068
return;
7169
}
7270

73-
cap_evt = st_cap_attr_create_int((char *) caps_helper_dustSensor.attr_fineDustLevel.name, caps_data->fineDustLevel_value, caps_data->fineDustLevel_unit);
74-
if (!cap_evt) {
75-
printf("fail to create cap_evt\n");
76-
return;
77-
}
71+
ST_CAP_SEND_ATTR_NUMBER(caps_data->handle,
72+
(char *)caps_helper_dustSensor.attr_fineDustLevel.name,
73+
caps_data->fineDustLevel_value,
74+
caps_data->fineDustLevel_unit,
75+
NULL,
76+
sequence_no);
7877

79-
sequence_no = st_cap_attr_send(caps_data->handle, evt_num, &cap_evt);
8078
if (sequence_no < 0)
8179
printf("fail to send fineDustLevel value\n");
82-
83-
printf("Sequence number return : %d\n", sequence_no);
84-
st_cap_attr_free(cap_evt);
80+
else
81+
printf("Sequence number return : %d\n", sequence_no);
8582
}
8683

8784

@@ -123,27 +120,24 @@ static void caps_dustSensor_set_dustLevel_unit(caps_dustSensor_data_t *caps_data
123120

124121
static void caps_dustSensor_attr_dustLevel_send(caps_dustSensor_data_t *caps_data)
125122
{
126-
IOT_EVENT *cap_evt;
127-
uint8_t evt_num = 1;
128-
int sequence_no;
123+
int sequence_no = -1;
129124

130125
if (!caps_data || !caps_data->handle) {
131126
printf("fail to get handle\n");
132127
return;
133128
}
134129

135-
cap_evt = st_cap_attr_create_int((char *) caps_helper_dustSensor.attr_dustLevel.name, caps_data->dustLevel_value, caps_data->dustLevel_unit);
136-
if (!cap_evt) {
137-
printf("fail to create cap_evt\n");
138-
return;
139-
}
130+
ST_CAP_SEND_ATTR_NUMBER(caps_data->handle,
131+
(char *)caps_helper_dustSensor.attr_dustLevel.name,
132+
caps_data->dustLevel_value,
133+
caps_data->dustLevel_unit,
134+
NULL,
135+
sequence_no);
140136

141-
sequence_no = st_cap_attr_send(caps_data->handle, evt_num, &cap_evt);
142137
if (sequence_no < 0)
143138
printf("fail to send dustLevel value\n");
144-
145-
printf("Sequence number return : %d\n", sequence_no);
146-
st_cap_attr_free(cap_evt);
139+
else
140+
printf("Sequence number return : %d\n", sequence_no);
147141
}
148142

149143

apps/emw3080/light_example/main/caps_switch.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ static int caps_switch_attr_switch_str2idx(const char *value)
3131
if (!strcmp(value, caps_helper_switch.attr_switch.values[index])) {
3232
return index;
3333
}
34-
}
35-
return -1;
34+
}
35+
return -1;
3636
}
3737

3838
static const char *caps_switch_get_switch_value(caps_switch_data_t *caps_data)
@@ -58,9 +58,7 @@ static void caps_switch_set_switch_value(caps_switch_data_t *caps_data, const ch
5858

5959
static void caps_switch_attr_switch_send(caps_switch_data_t *caps_data)
6060
{
61-
IOT_EVENT *cap_evt;
62-
uint8_t evt_num = 1;
63-
int sequence_no;
61+
int sequence_no = -1;
6462

6563
if (!caps_data || !caps_data->handle) {
6664
printf("fail to get handle\n");
@@ -71,19 +69,18 @@ static void caps_switch_attr_switch_send(caps_switch_data_t *caps_data)
7169
return;
7270
}
7371

74-
cap_evt = st_cap_attr_create_string((char *)caps_helper_switch.attr_switch.name,
75-
caps_data->switch_value, NULL);
76-
if (!cap_evt) {
77-
printf("fail to create cap_evt\n");
78-
return;
79-
}
72+
ST_CAP_SEND_ATTR_STRING(caps_data->handle,
73+
(char *)caps_helper_switch.attr_switch.name,
74+
caps_data->switch_value,
75+
NULL,
76+
NULL,
77+
sequence_no);
8078

81-
sequence_no = st_cap_attr_send(caps_data->handle, evt_num, &cap_evt);
8279
if (sequence_no < 0)
8380
printf("fail to send switch value\n");
81+
else
82+
printf("Sequence number return : %d\n", sequence_no);
8483

85-
printf("Sequence number return : %d\n", sequence_no);
86-
st_cap_attr_free(cap_evt);
8784
}
8885

8986

apps/emw3080/light_example/main/caps_switchLevel.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,24 @@ static void caps_switchLevel_set_level_unit(caps_switchLevel_data_t *caps_data,
6161

6262
static void caps_switchLevel_attr_level_send(caps_switchLevel_data_t *caps_data)
6363
{
64-
IOT_EVENT *cap_evt;
65-
uint8_t evt_num = 1;
66-
int sequence_no;
64+
int sequence_no = -1;
6765

6866
if (!caps_data || !caps_data->handle) {
6967
printf("fail to get handle\n");
7068
return;
7169
}
7270

73-
cap_evt = st_cap_attr_create_int((char *) caps_helper_switchLevel.attr_level.name, caps_data->level_value, caps_data->level_unit);
74-
if (!cap_evt) {
75-
printf("fail to create cap_evt\n");
76-
return;
77-
}
71+
ST_CAP_SEND_ATTR_NUMBER(caps_data->handle,
72+
(char *)caps_helper_switchLevel.attr_level.name,
73+
caps_data->level_value,
74+
caps_data->level_unit,
75+
NULL,
76+
sequence_no);
7877

79-
sequence_no = st_cap_attr_send(caps_data->handle, evt_num, &cap_evt);
8078
if (sequence_no < 0)
8179
printf("fail to send level value\n");
82-
83-
printf("Sequence number return : %d\n", sequence_no);
84-
st_cap_attr_free(cap_evt);
80+
else
81+
printf("Sequence number return : %d\n", sequence_no);
8582
}
8683

8784

apps/emw3080/switch_example/main/caps_switch.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ static int caps_switch_attr_switch_str2idx(const char *value)
3131
if (!strcmp(value, caps_helper_switch.attr_switch.values[index])) {
3232
return index;
3333
}
34-
}
35-
return -1;
34+
}
35+
return -1;
3636
}
3737

3838
static const char *caps_switch_get_switch_value(caps_switch_data_t *caps_data)
@@ -58,9 +58,7 @@ static void caps_switch_set_switch_value(caps_switch_data_t *caps_data, const ch
5858

5959
static void caps_switch_attr_switch_send(caps_switch_data_t *caps_data)
6060
{
61-
IOT_EVENT *cap_evt;
62-
uint8_t evt_num = 1;
63-
int sequence_no;
61+
int sequence_no = -1;
6462

6563
if (!caps_data || !caps_data->handle) {
6664
printf("fail to get handle\n");
@@ -71,19 +69,18 @@ static void caps_switch_attr_switch_send(caps_switch_data_t *caps_data)
7169
return;
7270
}
7371

74-
cap_evt = st_cap_attr_create_string((char *)caps_helper_switch.attr_switch.name,
75-
caps_data->switch_value, NULL);
76-
if (!cap_evt) {
77-
printf("fail to create cap_evt\n");
78-
return;
79-
}
72+
ST_CAP_SEND_ATTR_STRING(caps_data->handle,
73+
(char *)caps_helper_switch.attr_switch.name,
74+
caps_data->switch_value,
75+
NULL,
76+
NULL,
77+
sequence_no);
8078

81-
sequence_no = st_cap_attr_send(caps_data->handle, evt_num, &cap_evt);
8279
if (sequence_no < 0)
8380
printf("fail to send switch value\n");
81+
else
82+
printf("Sequence number return : %d\n", sequence_no);
8483

85-
printf("Sequence number return : %d\n", sequence_no);
86-
st_cap_attr_free(cap_evt);
8784
}
8885

8986

apps/rtl8720c/light_example/main/caps_activityLightingMode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ caps_activityLightingMode_data_t *caps_activityLightingMode_initialize(IOT_CTX *
140140
err = st_cap_cmd_set_cb(caps_data->handle, caps_helper_activityLightingMode.cmd_setLightingMode.name, caps_activityLightingMode_cmd_setLightingMode_cb, caps_data);
141141
if (err) {
142142
printf("fail to set cmd_cb for setLightingMode of activityLightingMode\n");
143-
}
143+
}
144144
} else {
145145
printf("fail to init activityLightingMode handle\n");
146146
}

apps/rtl8720c/light_example/main/caps_colorTemperature.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ caps_colorTemperature_data_t *caps_colorTemperature_initialize(IOT_CTX *ctx, con
134134
err = st_cap_cmd_set_cb(caps_data->handle, caps_helper_colorTemperature.cmd_setColorTemperature.name, caps_colorTemperature_cmd_setColorTemperature_cb, caps_data);
135135
if (err) {
136136
printf("fail to set cmd_cb for setColorTemperature of colorTemperature\n");
137-
}
137+
}
138138
} else {
139139
printf("fail to init colorTemperature handle\n");
140140
}

apps/rtl8720c/light_example/main/caps_switch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ caps_switch_data_t *caps_switch_initialize(IOT_CTX *ctx, const char *component,
145145
err = st_cap_cmd_set_cb(caps_data->handle, caps_helper_switch.cmd_on.name, caps_switch_cmd_on_cb, caps_data);
146146
if (err) {
147147
printf("fail to set cmd_cb for on of switch\n");
148-
}
148+
}
149149
err = st_cap_cmd_set_cb(caps_data->handle, caps_helper_switch.cmd_off.name, caps_switch_cmd_off_cb, caps_data);
150150
if (err) {
151151
printf("fail to set cmd_cb for off of switch\n");
152-
}
152+
}
153153
} else {
154154
printf("fail to init switch handle\n");
155155
}

apps/rtl8720c/light_example/main/caps_switchLevel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ caps_switchLevel_data_t *caps_switchLevel_initialize(IOT_CTX *ctx, const char *c
134134
err = st_cap_cmd_set_cb(caps_data->handle, caps_helper_switchLevel.cmd_setLevel.name, caps_switchLevel_cmd_setLevel_cb, caps_data);
135135
if (err) {
136136
printf("fail to set cmd_cb for setLevel of switchLevel\n");
137-
}
137+
}
138138
} else {
139139
printf("fail to init switchLevel handle\n");
140140
}

0 commit comments

Comments
 (0)