Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #65 from tuya/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
0x1abin authored Aug 3, 2021
2 parents 988c4d6 + b6cb9ef commit c735368
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Project information.
cmake_minimum_required( VERSION 3.2.0 )
project( TuyaIoTLinkSdkEmbeddedC
VERSION 202107.20
VERSION 202108.03
LANGUAGES C )

# Allow the project to be organized into folders.
Expand Down
4 changes: 4 additions & 0 deletions middleware/http_client_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ http_client_status_t http_client_request( const http_client_request_t* request,
rt = network_tls_init(&network, &(const TLSConnectParams){
.cacert = request->cacert,
.cacert_len = request->cacert_len,
.client_cert = NULL,
.client_cert_len = 0,
.client_key = NULL,
.client_key_len = 0,
.host = request->host,
.port = request->port,
.timeout_ms = request->timeout_ms,
Expand Down
4 changes: 4 additions & 0 deletions middleware/mqtt_client_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ mqtt_client_status_t mqtt_client_init(void* client, const mqtt_client_config_t*
&(const TLSConnectParams){
.cacert = context->config.cacert,
.cacert_len = context->config.cacert_len,
.client_cert = NULL,
.client_cert_len = 0,
.client_key = NULL,
.client_key_len = 0,
.host = context->config.host,
.port = context->config.port,
.timeout_ms = context->config.timeout_ms,
Expand Down
25 changes: 15 additions & 10 deletions src/atop_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,16 @@ int atop_service_client_reset(const char* id, const char* key)
return OPRT_MALLOC_FAILED;
}

buffer_len = snprintf(buffer, RESET_POST_BUFFER_LEN, "{\"t\":%d}", system_timestamp());
uint32_t timestamp = system_timestamp();
buffer_len = snprintf(buffer, RESET_POST_BUFFER_LEN, "{\"t\":%d}", timestamp);
TY_LOGV("POST JSON:%s", buffer);

/* atop_base_request object construct */
atop_base_request_t atop_request = {
.devid = id,
.key = key,
.path = "/d.json",
.timestamp = system_timestamp(),
.timestamp = timestamp,
.api = "tuya.device.reset",
.version = "4.0",
.data = buffer,
Expand Down Expand Up @@ -251,15 +252,16 @@ int atop_service_upgrade_info_get_v44(const char* id, const char* key, int chann
return OPRT_MALLOC_FAILED;
}

buffer_len = snprintf(buffer, ATOP_DEFAULT_POST_BUFFER_LEN, "{\"type\":%d,\"t\":%d}", channel, system_timestamp());
uint32_t timestamp = system_timestamp();
buffer_len = snprintf(buffer, ATOP_DEFAULT_POST_BUFFER_LEN, "{\"type\":%d,\"t\":%d}", channel, timestamp);
TY_LOGV("POST JSON:%s", buffer);

/* atop_base_request object construct */
atop_base_request_t atop_request = {
.devid = id,
.key = key,
.path = "/d.json",
.timestamp = system_timestamp(),
.timestamp = timestamp,
.api = "tuya.device.upgrade.get",
.version = "4.4",
.data = buffer,
Expand Down Expand Up @@ -294,15 +296,16 @@ int atop_service_auto_upgrade_info_get_v44(const char* id, const char* key, atop
return OPRT_MALLOC_FAILED;
}

buffer_len = snprintf(buffer, ATOP_DEFAULT_POST_BUFFER_LEN, "{\"subId\":null,\"t\":%d}", system_timestamp());
uint32_t timestamp = system_timestamp();
buffer_len = snprintf(buffer, ATOP_DEFAULT_POST_BUFFER_LEN, "{\"subId\":null,\"t\":%d}", timestamp);
TY_LOGV("POST JSON:%s", buffer);

/* atop_base_request object construct */
atop_base_request_t atop_request = {
.devid = id,
.key = key,
.path = "/d.json",
.timestamp = system_timestamp(),
.timestamp = timestamp,
.api = "tuya.device.upgrade.silent.get",
.version = "4.4",
.data = buffer,
Expand Down Expand Up @@ -337,16 +340,17 @@ int atop_service_upgrade_status_update_v41(const char* id, const char* key, int
return OPRT_MALLOC_FAILED;
}

uint32_t timestamp = system_timestamp();
buffer_len = snprintf(buffer, ATOP_DEFAULT_POST_BUFFER_LEN,
"{\"type\":%d,\"upgradeStatus\":%d,\"t\":%d}", channel, status, system_timestamp());
"{\"type\":%d,\"upgradeStatus\":%d,\"t\":%d}", channel, status, timestamp);
TY_LOGV("POST JSON:%s", buffer);

/* atop_base_request object construct */
atop_base_request_t atop_request = {
.devid = id,
.key = key,
.path = "/d.json",
.timestamp = system_timestamp(),
.timestamp = timestamp,
.api = "tuya.device.upgrade.status.update",
.version = "4.1",
.data = buffer,
Expand Down Expand Up @@ -392,15 +396,16 @@ int atop_service_version_update_v41(const char* id, const char* key, const char
return OPRT_MALLOC_FAILED;
}

buffer_len = snprintf(buffer, UPDATE_VERSION_BUFFER_LEN, "{\"versions\":\"%s\",\"t\":%d}", versions, system_timestamp());
uint32_t timestamp = system_timestamp();
buffer_len = snprintf(buffer, UPDATE_VERSION_BUFFER_LEN, "{\"versions\":\"%s\",\"t\":%d}", versions, timestamp);
TY_LOGV("POST JSON:%s", buffer);

/* atop_base_request object construct */
atop_base_request_t atop_request = {
.devid = id,
.key = key,
.path = "/d.json",
.timestamp = system_timestamp(),
.timestamp = timestamp,
.api = "tuya.device.versions.update",
.version = "4.1",
.data = buffer,
Expand Down

0 comments on commit c735368

Please sign in to comment.