All Projects → tuya → tuya-iot-link-sdk-embedded-c

tuya / tuya-iot-link-sdk-embedded-c

Licence: MIT License
Provide core capabilities like device connection, uplink and downlink communication and OTA across platforms and operating systems.

Programming Languages

c
50402 projects - #5 most used programming language

Labels

Projects that are alternatives of or similar to tuya-iot-link-sdk-embedded-c

tuyasmart android sdk
No description or website provided.
Stars: ✭ 34 (-10.53%)
Mutual labels:  tuya
tinytuya
Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
Stars: ✭ 236 (+521.05%)
Mutual labels:  tuya
tuyaface
Python Tuya client that allows you to locally communicate with tuya devices
Stars: ✭ 44 (+15.79%)
Mutual labels:  tuya
tuya-panel-kit
高效、统一、可视化
Stars: ✭ 16 (-57.89%)
Mutual labels:  tuya
TUYA IPC SDK
No description or website provided.
Stars: ✭ 72 (+89.47%)
Mutual labels:  tuya
tuya-home-ios-sdk
Tuya Smart Life App SDK is designed to promote the development of apps with multiple smart device features, such as device pairing, device control, firmware updates, scheduled tasks, and smart scenes.
Stars: ✭ 17 (-55.26%)
Mutual labels:  tuya
ESPHome-Devices
A collection of ESPHome custom components, configuration files, and custom code for my various ESP8266/ESP32 devices that integrate with Home Assistant.
Stars: ✭ 83 (+118.42%)
Mutual labels:  tuya
tuya-connector
tuya-connector helps you efficiently create cloud development projects regarding the OpenAPI or message subscription capabilities. You can put all the focus on business logic without taking care of server-side programming nor relational databases.
Stars: ✭ 28 (-26.32%)
Mutual labels:  tuya
tuya-iotos-embeded-sdk-wifi-ble-bk7231t
TuyaOS Embedded SDK is designed to promote the development of smart products with BK7231T that enables communication over Wi-Fi and Bluetooth Low Energy (LE).
Stars: ✭ 32 (-15.79%)
Mutual labels:  tuya
join-us
IoT made easy!
Stars: ✭ 120 (+215.79%)
Mutual labels:  tuya
tuyasmart home ios sdk
Tuya Smart iOS Home SDK
Stars: ✭ 48 (+26.32%)
Mutual labels:  tuya
tuya-local
Local support for Tuya devices in Home Assistant
Stars: ✭ 150 (+294.74%)
Mutual labels:  tuya
tysdk for esp8266
No description or website provided.
Stars: ✭ 36 (-5.26%)
Mutual labels:  tuya
tuyapower
Python module to read status and energy monitoring data from Tuya based WiFi smart devices. This includes state (on/off), current (mA), voltage (V), and power (wattage).
Stars: ✭ 101 (+165.79%)
Mutual labels:  tuya
Tuya-v2-Supported-Devices
A collection of all of the known working Tuya v2 Devices
Stars: ✭ 30 (-21.05%)
Mutual labels:  tuya
tuyagateway
Local Python Gateway for Tuya devices
Stars: ✭ 102 (+168.42%)
Mutual labels:  tuya
tuya-iotos-embeded-sdk-wifi-ble-bk7231n
Tuya IoTOS Embeded SDK WiFi & BLE for BK7231N
Stars: ✭ 21 (-44.74%)
Mutual labels:  tuya
tuya-panel-demo
Tuya IoT Panel demo provides a series of common template codes.
Stars: ✭ 37 (-2.63%)
Mutual labels:  tuya
tuyasmart ios sdk
No description or website provided.
Stars: ✭ 22 (-42.11%)
Mutual labels:  tuya
tuya-iot-python-sdk
Tuya IoT Python SDK for Tuya Open API.
Stars: ✭ 56 (+47.37%)
Mutual labels:  tuya

Tuya IoT Link SDK for Embedded C(beta)

Table of Contents

Overview

Tuya IoTOS Link SDK provides core capabilities, such as device connection, uplink and downlink communication, and OTA across platforms and operating systems. The SDK is implemented in the C programming language and does not depend on the specific device platform and OS environment. It only needs to support the TCP/IP protocol stack and provide the necessary system-dependent interfaces of the SDK to complete the integration.

Get started

Prerequisites

Ubuntu and Debian

sudo apt-get install make cmake libqrencode-dev

Clone the repository

git clone https://github.com/tuya/tuya-iot-link-sdk-embedded-c.git --recurse-submodules

Compile the code

mkdir build && cd build
cmake ..
make

Run the demo

./bin/switch_demo

Usage example

  1. Initialize a client object tuya_iot_client_t client. tuya_iot_config_t is used to initialize the product ID, authorization information, and other configuration parameters.
/* Instantiate the client */
tuya_iot_client_t client; 

/* Instantiate the config */
tuya_iot_config_t config = {
    .software_ver = "1.0.0",
    .productkey = <Product ID>,
    .uuid = <UUID>,
    .authkey = <AUTHKEY>,
    .event_handler = user_event_handler_on
};

/* Initialize the client */
tuya_iot_init(&client, &config);
  1. Define application layer event callbacks. The callback function is used for the application layer to receive SDK event notifications, such as data point (DP) delivery and cloud connection status notifications:
/* Tuya SDK event callback */
void user_event_handler_on(tuya_iot_client_t* client, tuya_event_msg_t* event)
{
    switch(event->id){
    case TUYA_EVENT_DP_RECEIVE:
        TY_LOGI("DP recv:%s", (const char*)event->data);
        /* After receiving the DP distribution, 
        the DP data needs to be reported to synchronize the APP status. */
        break;

    case TUYA_EVENT_MQTT_CONNECTED:
        TY_LOGI("Device MQTT Connected!");
        break;
    ...

    default:
        break;
    }
}
  1. Start the Tuya Link SDK service.
tuya_iot_start(&client);
  1. A loop is called to yield the current thread to the underlying Tuya Link SDK client.
tuya_iot_yield(&client);

Report example:

/* Boolean */
const char bool_value[] = {"{\"101\":true}"};
tuya_iot_dp_report_json(&client, bool_value);

/* Integer */
const char int_value[] = {"{\"102\":123}"};
tuya_iot_dp_report_json(&client, int_value);

/* String*/
const char string_value[] = {"{\"103\":\"helloworld\"}"};
tuya_iot_dp_report_json(&client, string_value);

/* Enum */
const char enum_value[] = {"{\"104\":\"auto\"}"};
tuya_iot_dp_report_json(&client, enum_value);

/* RAW */
const char raw_value[] = {"{\"105\":\"aGVsZA==\"}"};
tuya_iot_dp_report_json(&client, raw_value);

/* Multiple combinations */
const char multiple_value[] = {"{\"101\":true,\"102\":123,\"103\":\"hellowrold\",\"104\":\"auto\",\"105\":\"aGVsZA==\"}"};
tuya_iot_dp_report_json(&client, multiple_value);

License

Distributed under the MIT License. For more information, see LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].