Skip to content

Commit 709c58b

Browse files
authored
Merge pull request #99 from SmartThingsCommunity/master_rel_1_7_0
Master rel 1 7 0
2 parents 4367e87 + 2fd18ac commit 709c58b

24 files changed

+1291
-16
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# HISTORY
22

3+
## 1.7.0 : Changes until v1.7.0
4+
5+
New Improvements or features:
6+
- Add changing device name feature
7+
* New API : st_change_device_name() added
8+
- Add 'esp32c3' bsp and modify related component.mk/cmake file
9+
- Add capability helper for 'mode' capability
10+
11+
Enhancements or amendments:
12+
- Add the history feed displaying control options of the struct iot_cap_attr_option_t
13+
* To control whether the event should be displayed in the history feed of the mobile App
14+
15+
Bug fixed:
16+
- Fix Static Code Analysis report
17+
* iot_api:iot_main: Uses 'type casting' to fit in printf format sepcifier
18+
- Fix multiple definition of main error for deps/json : prevent cJSON/test.c building
19+
320
## 1.6.2 : Changes until v1.6.2
421

522
New Improvements or features:

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ We also provide the additional Reference repository so that you can refer to how
1212

1313
It is distributed in source form and written in C99 for the purpose of portability to most platforms.
1414

15-
## Announcements
16-
17-
Good news! We have launched the new commercial program for MQTT devices. You will be able to submit for certification into the SmartThings mobile app later this month. To prepare for submission, please perform the necessary steps with your current integrations:
18-
19-
- Update to the latest SmartThings SDK for Direct Connected Devices for C
20-
- Please use the SDK v1.3.3 or later
21-
- Downlaod the updated onboarding_config.json for your devices.
22-
- Re-register any test devices you have registered previously.
23-
- Update to the latest SmartThings mobile app to test your device
24-
- Please use SmartThings mobile application v1.7.51 (for Android), v1.6.51 (for iOS) or later
25-
2615
## Main features
2716

2817
This core device library provides the following features :

src/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ config STDK_IOT_CORE_BSP_SUPPORT_ESP32
147147
bool "ESP32"
148148
config STDK_IOT_CORE_BSP_SUPPORT_ESP32S2
149149
bool "ESP32S2"
150+
config STDK_IOT_CORE_BSP_SUPPORT_ESP32C3
151+
bool "ESP32C3"
150152
endchoice
151153

152154
choice STDK_IOT_CORE_OS_SUPPORT

src/component.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ if(CONFIG_STDK_IOT_CORE)
1616
elseif(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32S2)
1717
set(STDK_SRC_PATH "${STDK_SRC_PATH}" port/bsp/esp32s2)
1818
set(STDK_INCLUDE_PATH "${STDK_INCLUDE_PATH}" include/bsp/esp32s2)
19+
elseif(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32C3)
20+
set(STDK_SRC_PATH "${STDK_SRC_PATH}" port/bsp/esp32c3)
21+
set(STDK_INCLUDE_PATH "${STDK_INCLUDE_PATH}" include/bsp/esp32c3)
1922
elseif(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_RTL8195)
2023
set(STDK_SRC_PATH "${STDK_SRC_PATH}" port/bsp/rtl8195)
2124
set(STDK_INCLUDE_PATH "${STDK_INCLUDE_PATH}" include/bsp/rtl8195)

src/component.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ else ifeq ($(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32),y)
1717
else ifeq ($(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32S2),y)
1818
COMPONENT_SRCDIRS += port/bsp/esp32s2
1919
COMPONENT_ADD_INCLUDEDIRS += include/bsp/esp32s2
20+
else ifeq ($(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_ESP32C3),y)
21+
COMPONENT_SRCDIRS += port/bsp/esp32c3
22+
COMPONENT_ADD_INCLUDEDIRS += include/bsp/esp32c3
2023
else ifeq ($(CONFIG_STDK_IOT_CORE_BSP_SUPPORT_RTL8195),y)
2124
COMPONENT_SRCDIRS += port/bsp/rtl8195
2225
COMPONENT_ADD_INCLUDEDIRS += include/bsp/rtl8195

src/deps/json/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ PREFIX := cJSON_
55

66
LOCAL_CFLAGS := -I$(SRCDIR)
77

8-
SRCS = $(wildcard $(SRCDIR)/*.c)
8+
SRCS = $(SRCDIR)/cJSON.c
99
OBJS = $(SRCS:.c=.o)
1010

1111
all: $(OBJS)

src/easysetup/iot_easysetup_st_mqtt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ void *_iot_es_mqtt_registration_json(struct iot_context *ctx,
694694
}
695695
#endif /* STDK_IOT_CORE_SERIALIZE_CBOR */
696696

697+
STATIC_FUNCTION
697698
iot_error_t _iot_es_mqtt_registration(struct iot_context *ctx, st_mqtt_client mqtt_ctx)
698699
{
699700
int ret;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* ***************************************************************************
2+
*
3+
* Copyright 2021 Samsung Electronics All Rights Reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14+
* either express or implied. See the License for the specific
15+
* language governing permissions and limitations under the License.
16+
*
17+
****************************************************************************/
18+
19+
#ifndef _IOT_BSP_CUSTOM_H_
20+
#define _IOT_BSP_CUSTOM_H_
21+
22+
#include "sdkconfig.h"
23+
24+
#endif /* _IOT_BSP_CUSTOM_H_ */
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* ***************************************************************************
2+
*
3+
* Copyright 2019-2021 Samsung Electronics All Rights Reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14+
* either express or implied. See the License for the specific
15+
* language governing permissions and limitations under the License.
16+
*
17+
****************************************************************************/
18+
19+
#ifndef _IOT_CAPS_HELPER_MODE_
20+
#define _IOT_CAPS_HELPER_MODE_
21+
22+
#include "iot_caps_helper.h"
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
const static struct iot_caps_mode {
29+
const char *id;
30+
const struct mode_attr_supportedModes {
31+
const char *name;
32+
const unsigned char property;
33+
const unsigned char valueType;
34+
} attr_supportedModes;
35+
const struct mode_attr_mode {
36+
const char *name;
37+
const unsigned char property;
38+
const unsigned char valueType;
39+
} attr_mode;
40+
const struct mode_cmd_setMode { const char* name; } cmd_setMode;
41+
} caps_helper_mode = {
42+
.id = "mode",
43+
.attr_supportedModes = {
44+
.name = "supportedModes",
45+
.property = ATTR_SET_VALUE_ARRAY,
46+
.valueType = VALUE_TYPE_STRING,
47+
},
48+
.attr_mode = {
49+
.name = "mode",
50+
.property = ATTR_SET_VALUE_REQUIRED,
51+
.valueType = VALUE_TYPE_STRING,
52+
},
53+
.cmd_setMode = { .name = "setMode" }, // arguments: mode(string)
54+
};
55+
56+
#ifdef __cplusplus
57+
}
58+
#endif
59+
60+
#endif /* _IOT_CAPS_HERLPER_MODE_ */

src/include/iot_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#define IOT_SUB_TOPIC_COMMAND "/v1/commands/%s/cbor"
4747
#define IOT_SUB_TOPIC_NOTIFICATION "/v1/notifications/%s/cbor"
4848
#define IOT_PUB_TOPIC_HEALTH "/v1/health/cbor"
49+
#define IOT_PUB_TOPIC_DEVICES_UPDATE "/v1/devices/update/cbor"
4950
#else
5051
#define IOT_PUB_TOPIC_REGISTRATION "/v1/registrations"
5152
#define IOT_SUB_TOPIC_REGISTRATION "/v1/registrations/notification/%s"
@@ -54,6 +55,7 @@
5455
#define IOT_SUB_TOPIC_COMMAND "/v1/commands/%s"
5556
#define IOT_SUB_TOPIC_NOTIFICATION "/v1/notifications/%s"
5657
#define IOT_PUB_TOPIC_HEALTH "/v1/health"
58+
#define IOT_PUB_TOPIC_DEVICES_UPDATE "/v1/devices/update"
5759
#endif
5860

5961
#define IOT_PUB_TOPIC_DELETE "/v1/devices/delete"

src/include/iot_main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#define IOT_MQTT_CONNECT_CRITICAL_REJECT_MAX 3
5555
#define IOT_RATE_LIMIT_BREAK_TIME 60000
5656

57+
#define IOT_DEVICE_NAME_MAX_LENGTH 20
58+
5759
enum _iot_noti_type {
5860
/* Common notifications */
5961
_IOT_NOTI_TYPE_UNKNOWN = IOT_NOTI_TYPE_UNKNOWN,

src/include/st_dev.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ typedef struct {
121121
typedef struct {
122122
uint8_t state_change; /**< @brief force this attribute value update event */
123123
char *command_id; /**< @brief event related commandId, if not used, set NULL */
124+
bool *displayed; /**< @brief whether the event should be displayed in the history feed, if not used, set NULL */
124125
} iot_cap_attr_option_t;
125126

126127
#define MAX_CAP_ARG (5)
@@ -687,6 +688,15 @@ int st_create_log_dump(IOT_CTX *iot_ctx, char **log_dump_output, size_t max_log_
687688
*/
688689
int st_change_health_period(IOT_CTX *iot_ctx, unsigned int new_period);
689690

691+
/**
692+
* @brief change device name
693+
* @details This function changes device name. It reflects ST app's device name.
694+
* @param[in] iot_ctx iot_context handle generated by st_conn_init()
695+
* @param[in] new_name new device name null-terminated string
696+
* @return return `(0)` if it works successfully, non-zero for error case.
697+
*/
698+
int st_change_device_name(IOT_CTX *iot_ctx, const char *new_name);
699+
690700
#ifdef __cplusplus
691701
}
692702
#endif

src/include/st_dev_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
#define VER_MAJOR 1
2424

2525
/* minor: feature added. keep api backward compatibility */
26-
#define VER_MINOR 6
26+
#define VER_MINOR 7
2727

2828
/* patch: bug fix */
29-
#define VER_PATCH 2
29+
#define VER_PATCH 0
3030

3131
#define _STDK_STR(s) #s
3232
#define _STDK_VERSION_STR(a, b, c) _STDK_STR(a) "." _STDK_STR(b) "." _STDK_STR(c)

src/iot_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ iot_error_t iot_misc_info_store(iot_misc_info_t type, const void *in_data)
12521252
json = JSON_PARSE(old_misc_info);
12531253
if (json == NULL) {
12541254
IOT_WARN("old misc_info(%s/%u) parsing failed",
1255-
old_misc_info, old_misc_info_len);
1255+
old_misc_info, (unsigned int)old_misc_info_len);
12561256
json = JSON_CREATE_OBJECT();
12571257
} else {
12581258
old_misc_avail = true;

src/iot_capability.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,49 @@ IOT_EVENT* st_cap_create_attr_with_option(IOT_CAP_HANDLE *cap_handle, const char
232232
if (options->command_id)
233233
{
234234
evt_data->options.command_id = iot_os_strdup(options->command_id);
235+
if (evt_data->options.command_id == NULL)
236+
{
237+
goto failed_creat_attr_option;
238+
}
239+
}
240+
241+
if (options->displayed != NULL)
242+
{
243+
evt_data->options.displayed = (bool *)iot_os_malloc(sizeof(bool));
244+
if (evt_data->options.displayed != NULL)
245+
{
246+
*(evt_data->options.displayed) = *(options->displayed);
247+
}
248+
else
249+
{
250+
goto failed_creat_attr_option;
251+
}
235252
}
236253
}
237254

238255
return (IOT_EVENT*)evt_data;
256+
257+
failed_creat_attr_option:
258+
259+
if (evt_data->options.displayed != NULL)
260+
{
261+
iot_os_free(evt_data->options.displayed);
262+
evt_data->options.displayed = NULL;
263+
}
264+
265+
if (evt_data->options.command_id != NULL)
266+
{
267+
iot_os_free(evt_data->options.command_id);
268+
evt_data->options.command_id = NULL;
269+
}
270+
271+
if (evt_data != NULL)
272+
{
273+
_iot_free_evt_data(evt_data);
274+
iot_os_free(evt_data);
275+
}
276+
277+
return NULL;
239278
}
240279

241280
DEPRECATED void st_cap_attr_free(IOT_EVENT* event)
@@ -967,6 +1006,7 @@ static JSON_H *_iot_make_evt_data(const char* component, const char* capability,
9671006
JSON_H *evt_subjson = NULL;
9681007
JSON_H *evt_subdata = NULL;
9691008
JSON_H *prov_data = NULL;
1009+
JSON_H *visibility_data = NULL;
9701010
char time_in_ms[16]; /* 155934720000 is '2019-06-01 00:00:00.00 UTC' */
9711011

9721012
evt_item = JSON_CREATE_OBJECT();
@@ -1021,6 +1061,15 @@ static JSON_H *_iot_make_evt_data(const char* component, const char* capability,
10211061
JSON_ADD_ITEM_TO_OBJECT(evt_item, "data", evt_subdata);
10221062
}
10231063

1064+
/* visibility */
1065+
if (evt_data->options.displayed != NULL)
1066+
{
1067+
visibility_data = JSON_CREATE_OBJECT();
1068+
JSON_ADD_BOOL_TO_OBJECT(visibility_data, "displayed", *(evt_data->options.displayed));
1069+
1070+
JSON_ADD_ITEM_TO_OBJECT(evt_item, "visibility", visibility_data);
1071+
}
1072+
10241073
/* providerData */
10251074
prov_data = JSON_CREATE_OBJECT();
10261075
JSON_ADD_NUMBER_TO_OBJECT(prov_data, "sequenceNumber", seq_num);
@@ -1132,5 +1181,9 @@ static void _iot_free_evt_data(iot_cap_evt_data_t* evt_data)
11321181
if (evt_data->options.command_id != NULL) {
11331182
iot_os_free(evt_data->options.command_id);
11341183
}
1184+
1185+
if (evt_data->options.displayed != NULL) {
1186+
iot_os_free(evt_data->options.displayed);
1187+
}
11351188
}
11361189
/* External API */

0 commit comments

Comments
 (0)