A major difference between V3.0.1 and earlier versions is that you can select the C files of specific features based on your business requirements and then compile the SDK in a custom manner. You are no longer required to use the built-in compiler of the SDK.
V3.0.1
The following section describes the differences between SDK V2.3.0, which was released in November 2018, and SDK V3.0.1, which was released in March 2019.
Porting by using the source code
This development method is suitable for on-premises machines that run
Ubuntu16.04 64-bit
,Windows XP
,Windows 7
, andWindows 10
.You can run the
make menuconfig
command on Ubuntu or click theconfig.bat
file on Windows to select the features.After you select the features based on your business requirements, you can run the
extract.sh
command on Ubuntu or click theextract.bat
file on Windows to extract the required source files.You can add the source files to your project on an on-premises machine and use a preferred method to compile the source code.
All hardware abstraction layer (HAL) interfaces that you must implement are automatically collected in the wrapper.c file in the output/eng/wrappers
directory.
In the past, you cannot perform development operations if you failed to cross-compile the SDK. SDK V3.0.1 improves the portability and usability.
Directory structure
SDK V3.0.1 uses a flat directory structure that is easy to use. For example, all .h and .c files about Message Queuing Telemetry Transport (MQTT) features on the cloud are stored in the
src/mqtt
directory.Except the
src/infra
directory that contains the infrastructure, asrc/xxx
directory is mapped to an SDK feature and contains all source files of the feature. The number ofsrc/xxx
directories are the same as the number of SDK features. Examples:src/dynamic_register
: contains all source files of the unique-certificate-per-product verification or dynamic registration feature.src/dev_sign
: contains all source files of the device signature feature.src/mqtt
: contains all source files of the MQTT connection feature.src/ota
: contains all source files of the over-the-air (OTA) firmware update feature.src/dev_model
: contains all source files of the Thing Specification Language (TSL) model management or sub-device management feature.
Presentation of APIs and HAL interfaces
In the earlier versions of the SDK, the global header file iot_import.h
contains external HAL_XXX()
interfaces on which the SDK depends and the global header file iot_export.h
contains the IOT_XXX
APIs that are provided by the SDK.
Specific customers assume that they must implement all of the more than 100 HAL interfaces in the iot_import.h
file and get familiar with all of the more than 200 APIs in the iot_import.h
file. This causes heavy workloads for the customers.
The following improvements are made in SDK V3.0.1:
The
iot_import.h
andiot_export.h
files are removed.The
include
directory in the root directory is removed.Source files are classified and stored in dedicated directories based on the SDK features to prevent excessive information display.
To use SDK V3.0.1, you must perform the following steps:
Make sure that you are familiar with the SDK features such as the MQTT connection to IoT Platform and OTA updates, determine the required features, and then configure and select the features in a graphical user interface (GUI).
Then, run the
extract.sh
script on Ubuntu or theextract.bat
script on Windows to obtain the source files of the selected features and store the source files in theoutput
directory.Implement APIs and HAL interfaces to use the SDK based on the following rules:
The
output/eng/xxx
directory stores source files of thexxx
feature. The source files are obtained from thesrc/xxx
directory.The
output/eng/xxx/xxx_api.h
file contains the APIs of thexxx
feature. The APIs are obtained from thesrc/xxx/xxx_api.h
file.All
HAL_XXX()
interfaces that you must implement to interact with a specific embedded system are automatically added to theoutput/eng/wrappers/wrapper.c
file.
You need to only view the source files of the required features in the
src/xxx/xxx_api.h
foroutput/eng/xxx/xxx_api.h
file. The API declarations that are irrelevant to your business requirements are not displayed.All HAL interfaces that you must implement are added to the
output/eng/wrappers/wrapper.c
file. The HAL interfaces that are irrelevant to your business requirements are not displayed.
For example, the basic feature of the SDK is to calculate the signature for establishing an MQTT connection to IoT Platform. This feature is supported by the src/dev_sign
or output/eng/dev_sign
interface.
In this case, only one interface of the signature calculation feature is visible to you in the
dev_sign_api.h
file.No HAL interfaces or no
wrapper.c
file is displayed because this feature has no dependencies and no C functions are required.
make.settings file
Apart from on-premises machines that run Linux, developers can run
config.bat
onWindows XP
,Windows 7
, orWindows 10
machines to configure required features in a GUI.The following table describes the
FEATURE_XXX
options whose names are changed.
Former name | New name | Description |
|
| The phone access point mode (phone-ap-config) for Wi-Fi setup. |
|
| The router configuration mode (router-config) for Wi-Fi setup. |
The following options are added:
FEATURE_AWSS_SUPPORT_SMARTCONFIG_WPS
: the point-to-point configuration mode for Wi-Fi setup.FEATURE_AWSS_SUPPORT_DEV_AP
: the device access point mode (dev-ap-config) for Wi-Fi setup.
MQTT interfaces
You can call the
IOT_MQTT_Construct()
interface to establish a Message Queuing Telemetry Transport (MQTT) connection. TheIOT_SetupConnInfo()
interface is no longer required.When you call the
IOT_MQTT_Construct()
interface, you can leave most connection parameters empty. The SDK automatically uses the default values and no errors are returned.
New features and interfaces
The device signature feature is added, which is the basic feature of an SDK.
Only the
IOT_Sign_MQTT()
interface is related to the feature.
The unique-certificate-per-product verification feature is added. The feature can be used when you burn a device certificate that includes a ProductKey, a DeviceName, and a DeviceSecret to all devices.
Only the
IOT_Dynamic_Register()
interface is related to the feature.
The device reset feature is added. The feature can be used to disassociate a sub-device with the corresponding gateway after the sub-device sends a disassociation request to IoT Platform.
Only the
IOT_DevReset_Report()
interface is related to the feature.
The HTTP/2 file upload feature is added. The feature can be used to upload large files to IoT Platform.
The
IOT_HTTP2_UploadFile_Connect()
,IOT_HTTP2_UploadFile_Request()
, andIOT_HTTP2_UploadFile_Disconnect()
interfaces are related to the feature.
Removed feature
CMake
is removed from the supported compilation tools because GNU make and porting based on the source code are supported.
V2.3.0
The following section describes the differences between SDK V2.2.1, which was released on August 31, 2018, and SDK V2.3.0, which was released in November 2018.
make.settings file
Developers can run the
make menuconfig
command onUbuntu16.04
64-bit
on-premises machines to configure themake.settings
file in a GUI.The following table describes the
FEATURE_XXX
options whose names are changed.
Former name | New name | Description |
|
| The switch for the Thing Specification Language (TSL) model management feature. The models must comply with the Alink JSON protocol. |
|
| The switch for the gateway feature in TSL model management. |
|
| The switch for the Wi-Fi setup feature. |
The following options are added:
FEATURE_DEVICE_BIND_ENABLED
: the switch for the device binding feature. If you use the Living Link console, you must turn on this switch to allow the Cloud Intelligence app to control devices.FEATURE_ALCS_CLIENT_ENABLED
: the switch for specific client features that are used in local communication. You must turn on this switch for edge gateways and other devices that manage IoT sub-devices.FEATURE_ALCS_SERVER_ENABLED
: the switch for specific server features that are used in local communication. You must turn on this switch for devices that are managed by mobile apps or edge gateways on the local area network (LAN).FEATURE_AWSS_SUPPORT_SMARTCONFIG
: the SmartConfig mode (smart-config) for Wi-Fi setup.FEATURE_AWSS_SUPPORT_ZEROCONFIG
: the zero configuration mode (zero-config) for Wi-Fi setup.FEATURE_AWSS_SUPPORT_ROUTER
: the router configuration mode (router-config) for Wi-Fi setup.FEATURE_AWSS_SUPPORT_PHONEASAP
: the phone access point mode (phone-ap-config) for Wi-Fi setup.
The following option is removed:
FEATURE_COAP_DTLS_SUPPORT
: the switch that determines whether a connection to IoT Platform over Constrained Application Protocol (CoAP) is encrypted by using the Datagram Transport Layer Security (DTLS) protocol. The switch is removed from custom configurations because the encryption is always enabled.
Global interfaces
The
IOT_OpenLog()
andIOT_CloseLog()
interfaces are removed. You can call theIOT_SetLogLevel()
interface to determine whether the SDK prints logs and the logs that you want the SDK to print.The
IOT_LOG_EMERG
log level is replaced by theIOT_LOG_NONE
log level.IOT_SetLogLevel(IOT_LOG_NONE)
specifies that the logging feature is disabled.The
IOT_Linkkit_Ioctl()
interface is removed. You can call theIOT_Ioctl()
interface to implement the features of the IOT_Linkkit_Ioctl() interface. For more information about the options of the IOT_Ioctl() interface, see the enumerated values of theiotx_ioctl_option_t
type.The
IOT_Ioctl()
interface is enhanced. TheIOTX_IOCTL_SET_MQTT_DOMAIN
andIOTX_IOCTL_SET_HTTP_DOMAIN
options are added to allow you to pass in custom MQTT or HTTP endpoints to establish connections for new service deployment sites outside China.
MQTT interfaces
In the following interfaces, you can set the
handle
parameter toNULL
to create a connection by using default parameter values or use the default connection:IOT_MQTT_Construct
IOT_MQTT_Destroy
IOT_MQTT_Yield
IOT_MQTT_LogPost
IOT_MQTT_CheckStateNormal
IOT_MQTT_Subscribe
IOT_MQTT_Unsubscribe
IOT_MQTT_Publish
IOT_MQTT_Subscribe_Sync
IOT_MQTT_Publish_Simple
The
pwrite_buf
andpread_buf
parameters are removed from theiotx_mqtt_param_t
struct.The
IOT_MQTT_Publish_Simple()
interface is added. You can pass in parameters of the string type to specify the topic and payload.int IOT_MQTT_Publish_Simple(void *handle, const char *topic_name, int qos, void *data, int len);
The
IOT_MQTT_Subscribe_Sync()
interface is added. You can perform the synchronous subscription in a blocking manner, and no data is returned until the subscription is successful.int IOT_MQTT_Subscribe_Sync(void *handle, const char *topic_filter, iotx_mqtt_qos_t qos, iotx_mqtt_event_handle_func_fpt topic_handle_func, void *pcontext, int timeout_ms);
The
IOT_MQTT_Subscribe()
interface is optimized. Before an MQTT connection is established, you can subscribe to offline messages. The SDK for C sends a subscription packet immediately after the connection is established.
OTA update interface
If the
handle
parameter of MQTT interfaces is set toNULL
, the third parameter of theIOT_OTA_Init
interface can also be set toNULL
to use the default connection. IOT_OTA_Init is the basic interface for over-the-air (OTA) updates.void *IOT_OTA_Init(const char *product_key, const char *device_name, void *ch_signal);
Removed interface
The linkkit_xxx() and linkkit_gateway_xxx() interfaces in the SDK of the earlier version are optional for compilation. By default, the interfaces are not displayed in the compilation configurations.
Note: 1. You can run the following command in the make.settings
file to display the linkkit_xxx() and linkkit_gateway_xxx() interfaces. In this case, new interfaces disappear.
FEATURE_DEPRECATED_LINKKIT=y
2. To reduce the memory usage of devices, the SDK no longer checks the validity of data formats when you call API operations of the SDK to submit messages about property changes and events. Therefore, you do not need to export the JSON file of TSL models from IoT Platform, convert the JSON data into strings in C, and add the strings to your code in C.
HAL interfaces
The
HAL_Sys_reboot
interface is removed because the corresponding feature is the same as the feature of theHAL_Reboot
interface.