}
// wstp_cat1_print_dbg("wakeup Cat1! L30 high \r\n");
}else{
- // cat1_print_warning("sleep cat1\n");
+ cat1_print_warning("sleep cat1\n");
if(en_value == uapi_gpio_get_output_val(en_pin))
{
if(en_value)
char *g_device_token = NULL;//设备token,服务器获取
static char *g_device_iccid = NULL;
static char *g_device_model = NULL;
-static char *g_device_version = NULL;
+static char *g_device_version[128] = {0};
/* 记录最近一次 OTA 查询的升级类型与保存路径 */
int g_ln_last_update_type = -1; // -1:未知 0:可选 1:强制
char version_buf[128] = {0};
uint32_t version_len = 128;
uapi_get_buildversion((uint8_t *)version_buf, version_len);
- g_device_version = version_buf;
+ strcpy(g_device_version, version_buf);
printf("g_device_version: %s\n", g_device_version);
- return g_device_version;
+ return g_device_version;
}
/* 获取设备token: 优先读本地缓存,判断过期,否则刷新 */
char *uapi_ln_get_device_token(void)
return path;
}
+//中断语音对话播放
void uapi_ln_audio_download_is_cancel(int status)
{
g_ln_audio_download_cancel = status;
}
// 构建完整保存路径
- char save_path[512];
- snprintf(save_path, sizeof(save_path), "%s/%s", save_dir, filename);
+ size_t sp_cap = strlen(save_dir) + 1 + strlen(filename) + 1;
+ char *save_path = (char*)malloc(sp_cap);
+ if (!save_path)
+ {
+ printf("[SSE] malloc save_path failed\n");
+ return ERRCODE_FAIL;
+ }
+ snprintf(save_path, sp_cap, "%s/%s", save_dir, filename);
// 确保目录存在
if (access(save_dir, F_OK) == -1)
#if TEST_MP3_DOWNLOAD
fclose(fd);
#endif
+ free(save_path);
return ERRCODE_FAIL;
}
fclose(fd);
#endif
HttpClientUnprepare(&client_data);
+ free(save_path);
return ERRCODE_FAIL;
}
#endif
HttpClientClse(&client);
HttpClientUnprepare(&client_data);
+ free(save_path);
return ERRCODE_FAIL;
}
HttpClientClse(&client);
printf("[SSE] download completed, total bytes: %zu\n", total_written);
+ free(save_path);
return ERRCODE_SUCC;
}
cJSON *textContent = cJSON_GetObjectItem(push_data, "textContent");
if (textContent && cJSON_IsString(textContent))
{
+ // 发送开始对话标志
+ set_start_conversation_flag(1);
printf("[JSON_PARSE] textContent: %s\n", textContent->valuestring);
do_ln_http_server_recv_data(interface_type, textContent->valuestring, strlen(textContent->valuestring));
}
printf("[FILE_PARSE] processing completed: total lines=%d, success=%d, errors=%d\n",
line_count, success_count, error_count);
+ //语音对话结束
+ set_start_conversation_flag(0);
return (error_count == 0) ? ERRCODE_SUCC : ERRCODE_FAIL;
}
/* ============================ mp3下载功能 End ============================ */
ln_send_taskcfg.create_queue_handle = create_ln_http_send_queue;
ln_send_taskcfg.attr.name = "ln_http_server_send_task";
ln_send_taskcfg.attr.priority = osPriorityNormal;
- ln_send_taskcfg.attr.stack_size = 0x4000;
+ ln_send_taskcfg.attr.stack_size = LN_HTTP_BOARD_TASK_SIZE;
ln_send_taskcfg.func = ln_http_server_send_task;
ln_send_taskcfg.use_mem = USE_EXTEND_MEM;
client.isHttp = false;
client.remotePort = 443;
- char header_buf[512];
- int hdr = snprintf(header_buf, sizeof(header_buf),
+ char *header_buf = (char*)malloc(512);
+ if (!header_buf) return ERRCODE_FAIL;
+ int hdr = snprintf(header_buf, 512,
"deviceId: %s\r\n"
"deviceToken: %s\r\n"
"Content-Type: application/json\r\n",
device_id, device_token);
- if (hdr <= 0 || hdr >= (int)sizeof(header_buf))
+ if (hdr <= 0)
+ {
+ free(header_buf);
return ERRCODE_FAIL;
+ }
HttpClientSetCustomHeader(&client, header_buf);
printf("device getCharacter header %s\n", header_buf);
end:
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ free(header_buf);
return ERRCODE_SUCC;
}
client.isHttp = false;
client.remotePort = 443;
- char header_buf[512];
- int hdr = snprintf(header_buf, sizeof(header_buf),
+ char *header_buf2 = (char*)malloc(512);
+ if (!header_buf2) return ERRCODE_FAIL;
+ int hdr = snprintf(header_buf2, 512,
"deviceId: %s\r\n"
"deviceToken: %s\r\n"
"Content-Type: application/json\r\n",
device_id, device_token);
- if (hdr <= 0 || hdr >= (int)sizeof(header_buf))
+ if (hdr <= 0)
+ {
+ free(header_buf2);
return ERRCODE_FAIL;
- HttpClientSetCustomHeader(&client, header_buf);
+ }
+ HttpClientSetCustomHeader(&client, header_buf2);
- printf("device getUserId header %s\n", header_buf);
+ printf("device getUserId header %s\n", header_buf2);
HTTPC_RESULT prep = ln_http_prepare_auto(&clientData, 2048, 8 * 1024);
if (prep != HTTP_SUCCESS)
end:
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ free(header_buf2);
return ERRCODE_SUCC;
}
client.isHttp = false;
client.remotePort = 443;
- char header_buf[512];
- int hdr = snprintf(header_buf, sizeof(header_buf),
+ char *header_buf3 = (char*)malloc(512);
+ if (!header_buf3) {
+ return ERRCODE_FAIL;
+ }
+ int hdr = snprintf(header_buf3, 512,
"deviceId: %s\r\n"
"deviceToken: %s\r\n"
"Content-Type: application/json\r\n",
device_id, token);
- if (hdr <= 0 || hdr >= (int)sizeof(header_buf))
+ if (hdr <= 0)
{
+ free(header_buf3);
return ERRCODE_FAIL;
}
- HttpClientSetCustomHeader(&client, header_buf);
+ HttpClientSetCustomHeader(&client, header_buf3);
HTTPC_RESULT prep = ln_http_prepare_auto(&clientData, 2048, LN_CLIENT_PREPARE_SIZE * 2);
if (prep != HTTP_SUCCESS)
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ free(header_buf3);
return ERRCODE_SUCC;
}
{
if (!client || !device_id || !device_token)
return -1;
- char header_buf[512];
- int hdr = snprintf(header_buf, sizeof(header_buf),
+ char *header_buf = (char*)malloc(512);
+ if (!header_buf) return -1;
+ int hdr = snprintf(header_buf, 512,
"deviceId: %s\r\n"
"deviceToken: %s\r\n"
"Content-Type: application/json\r\n",
device_id, device_token);
- if (hdr <= 0 || hdr >= (int)sizeof(header_buf))
+ if (hdr <= 0)
return -1;
HttpClientSetCustomHeader(client, header_buf);
+ free(header_buf);
return 0;
}
#include "ln_api.h"
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
uint32_t ln_ota_get_task_http(const char *device_id,
const char *device_token,
client.remotePort = 443;
/* 头:与 device info 一致,额外带 model/version 可辅助服务端日志定位 */
- char header_buf[512];
- int hdr = snprintf(header_buf, sizeof(header_buf),
+ size_t hdr_cap = 64 + strlen(device_id) + strlen(device_token) +
+ (uapi_ln_get_device_model() ? strlen(uapi_ln_get_device_model()) : 5) +
+ (uapi_ln_get_device_version() ? strlen(uapi_ln_get_device_version()) : 5);
+ char *header_buf = (char *)malloc(hdr_cap + 128);
+ if (!header_buf)
+ return ERRCODE_FAIL;
+ int hdr = snprintf(header_buf, hdr_cap + 128,
"deviceId: %s\r\n"
"deviceToken: %s\r\n"
"deviceModel: %s\r\n"
device_id, device_token,
(uapi_ln_get_device_model() ? uapi_ln_get_device_model() : "AB101"),
(uapi_ln_get_device_version() ? uapi_ln_get_device_version() : "1.0.0"));
- if (hdr <= 0 || hdr >= (int)sizeof(header_buf))
+ if (hdr <= 0)
+ {
+ free(header_buf);
return ERRCODE_FAIL;
+ }
HttpClientSetCustomHeader(&client, header_buf);
HTTPC_RESULT prep = ln_http_prepare_auto(&clientData, 2048, 8 * 1024);
}
/* 拼 GET URL 参数 */
- char url_with_params[512] = {0};
- int ulen = snprintf(url_with_params, sizeof(url_with_params),
+ size_t url_cap = strlen(LN_OTA_GET_TASK_URL) + strlen(device_id) + strlen(source_version) + 64;
+ char *url_with_params = (char *)malloc(url_cap);
+ if (!url_with_params)
+ {
+ HttpClientUnprepare(&clientData);
+ free(header_buf);
+ return ERRCODE_FAIL;
+ }
+ int ulen = snprintf(url_with_params, url_cap,
"%s?deviceId=%s&sourceVersion=%s",
LN_OTA_GET_TASK_URL, device_id, source_version);
- if (ulen <= 0 || ulen >= (int)sizeof(url_with_params))
+ if (ulen <= 0 || (size_t)ulen >= url_cap)
{
HttpClientUnprepare(&clientData);
+ free(header_buf);
+ free(url_with_params);
return ERRCODE_FAIL;
}
end:
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ if (header_buf) free(header_buf);
+ if (url_with_params) free(url_with_params);
return ERRCODE_SUCC;
}
int ret = -1;
size_t total_written = 0; // 已写入文件的总字节数
int last_percent = -1; // 上次上报的进度百分比
+ char *prog = (char *)malloc(64);
+ if (!prog)
+ {
+ return -1;
+ }
// 打开文件准备写入
FILE *fd = fopen(save_path, "wb");
if (percent != last_percent)
{
last_percent = percent;
- char prog[64];
- int n = snprintf(prog, sizeof(prog),
+ int n = snprintf(prog, 64,
"{\"status\":%d,\"progress\":%d}",
OTA_DOWNLOAD_STATUS_PROGRESS, percent);
if (n > 0)
fclose(fd);
HttpClientClse(&client);
HttpClientUnprepare(&client_data);
+ if (prog) free(prog);
printf("[OTA] download process finished\n");
return ret;
printf("[OTA] no cached task to download, please GET_TASK first\n");
return ERRCODE_FAIL;
}
- char save_path[256];
- snprintf(save_path, sizeof(save_path), LN_OTA_SAVE_DIR "/%s.fwpkg", g_ln_last_target_version);
+ size_t sp_cap = strlen(LN_OTA_SAVE_DIR) + 1 + strlen(g_ln_last_target_version) + strlen(".fwpkg") + 1;
+ char *save_path = (char *)malloc(sp_cap);
+ if (!save_path)
+ {
+ return ERRCODE_FAIL;
+ }
+ snprintf(save_path, sp_cap, LN_OTA_SAVE_DIR "/%s.fwpkg", g_ln_last_target_version);
memset(g_ln_last_saved_path, 0, sizeof(g_ln_last_saved_path));
strncpy(g_ln_last_saved_path, save_path, sizeof(g_ln_last_saved_path) - 1);
}
if (dres != 0)
{
- char msg[256];
- int n = snprintf(msg, sizeof(msg), "{\"status\":%d,\"error\":\"download failed\"}", 2);
- if (n > 0)
- do_ln_http_server_recv_data(LN_HTTP_RECV_OTA_DOWNLOAD_MSG, msg, (uint32_t)n);
+ char *msg = (char *)malloc(64);
+ if (msg)
+ {
+ int n = snprintf(msg, 64, "{\"status\":%d,\"error\":\"download failed\"}", 2);
+ if (n > 0)
+ do_ln_http_server_recv_data(LN_HTTP_RECV_OTA_DOWNLOAD_MSG, msg, (uint32_t)n);
+ free(msg);
+ }
+ free(save_path);
return ERRCODE_FAIL;
}
- char done[512];
- int m = snprintf(done, sizeof(done), "{\"status\":%d,\"filePath\":\"%s\",\"md5\":\"%s\"}", 1, save_path, g_ln_last_package_md5);
- if (m > 0)
- do_ln_http_server_recv_data(LN_HTTP_RECV_OTA_DOWNLOAD_MSG, done, (uint32_t)m);
+ size_t done_cap = 64 + strlen(save_path) + strlen(g_ln_last_package_md5);
+ char *done = (char *)malloc(done_cap);
+ if (done)
+ {
+ int m = snprintf(done, done_cap, "{\"status\":%d,\"filePath\":\"%s\",\"md5\":\"%s\"}", 1, save_path, g_ln_last_package_md5);
+ if (m > 0)
+ do_ln_http_server_recv_data(LN_HTTP_RECV_OTA_DOWNLOAD_MSG, done, (uint32_t)m);
+ free(done);
+ }
+ free(save_path);
return ERRCODE_SUCC;
}
{
if (!boundary || !filename || !file_data || file_len <= 0 || !out_body || !out_len)
return -1;
- char head[512];
- int head_len = snprintf(head, sizeof(head),
+ char *head = (char*)malloc(512);
+ if (!head) return -1;
+ int head_len = snprintf(head, 512,
"--%s\r\n"
"Content-Disposition: form-data; name=\"file\"; filename=\"%s\"\r\n"
"Content-Type: audio/mpeg\r\n\r\n",
boundary, filename);
- char tail[128];
- int tail_len = snprintf(tail, sizeof(tail), "\r\n--%s--\r\n", boundary);
+ char *tail = (char*)malloc(128);
+ if (!tail) { free(head); return -1; }
+ int tail_len = snprintf(tail, 128, "\r\n--%s--\r\n", boundary);
int total = head_len + file_len + tail_len;
char *body = (char *)malloc((size_t)total);
if (!body)
memcpy(body, head, head_len);
memcpy(body + head_len, file_data, (size_t)file_len);
memcpy(body + head_len + file_len, tail, tail_len);
+ free(head);
+ free(tail);
*out_body = body;
*out_len = total;
if (out_content_type && ctype_len > 0)
HttpClientData clientData = (HttpClientData){0};
/* 自定义头:仅保留自定义业务头,Content-Type 交由 postContentType 指定 */
- char header_buf[512];
- int hdr = snprintf(header_buf, sizeof(header_buf),
+ char *header_buf = (char*)malloc(512);
+ if (!header_buf) { free(body); return ERRCODE_FAIL; }
+ int hdr = snprintf(header_buf, 512,
"deviceId: %s\r\n"
"deviceToken: %s\r\n"
"Accept: text/event-stream\r\n"
"Cache-Control: no-cache\r\n",
device_id, device_token);
- if (hdr <= 0 || hdr >= (int)sizeof(header_buf))
+ if (hdr <= 0)
{
free(body);
+ free(header_buf);
return ERRCODE_FAIL;
}
HttpClientSetCustomHeader(&client, header_buf);
{
if (!boundary || !filename || !file_data || file_len <= 0 || !out_body || !out_len)
return -1;
- char head[512];
- int head_len = snprintf(head, sizeof(head),
+ char *head = (char*)malloc(512);
+ if (!head) return -1;
+ int head_len = snprintf(head, 512,
"--%s\r\n"
"Content-Disposition: form-data; name=\"file\"; filename=\"%s\"\r\n"
"Content-Type: audio/mpeg\r\n\r\n",
boundary, filename);
- char tail[128];
- int tail_len = snprintf(tail, sizeof(tail), "\r\n--%s--\r\n", boundary);
+ char *tail = (char*)malloc(128);
+ if (!tail) { free(head); return -1; }
+ int tail_len = snprintf(tail, 128, "\r\n--%s--\r\n", boundary);
int total = head_len + file_len + tail_len;
char *body = (char *)malloc((size_t)total);
if (!body)
memcpy(body, head, head_len);
memcpy(body + head_len, file_data, (size_t)file_len);
memcpy(body + head_len + file_len, tail, tail_len);
+ free(head);
+ free(tail);
*out_body = body;
*out_len = total;
if (out_content_type && ctype_len > 0)
HttpClientData clientData = {0};
/* 设置请求头:精简头部,避免重复(Host/Connection 交由库设置) */
- char header_buf[1024];
- int hdr = snprintf(header_buf, sizeof(header_buf),
+ char *header_buf = (char*)malloc(1024);
+ if (!header_buf) { free(body); return ERRCODE_FAIL; }
+ int hdr = snprintf(header_buf, 1024,
"deviceId: %s\r\n"
"deviceToken: %s\r\n"
"Accept: text/event-stream\r\n"
"Cache-Control: no-cache\r\n",
device_id, device_token);
- if (hdr <= 0 || hdr >= (int)sizeof(header_buf))
+ if (hdr <= 0)
{
printf("story choose: build header failed\n");
free(body);
+ free(header_buf);
return ERRCODE_FAIL;
}
HttpClientSetCustomHeader(&client, header_buf);
client.remotePort = 443;
/* 普通JSON头 */
- char header_buf[512];
- int hdr = snprintf(header_buf, sizeof(header_buf),
+ char *header_buf = (char*)malloc(512);
+ if (!header_buf) return ERRCODE_FAIL;
+ int hdr = snprintf(header_buf, 512,
"deviceId: %s\r\ndeviceToken: %s\r\nContent-Type: application/json\r\n",
device_id, device_token);
printf("ln_story_finish_http header_buf: %s\n", header_buf);
- if (hdr <= 0 || hdr >= (int)sizeof(header_buf))
+ if (hdr <= 0)
+ {
+ free(header_buf);
return ERRCODE_FAIL;
+ }
HttpClientSetCustomHeader(&client, header_buf);
HTTPC_RESULT prep = ln_http_prepare_auto(&clientData, 2048, 8 * 1024);
end:
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ if (header_buf) free(header_buf);
return ERRCODE_SUCC;
}
client.isHttp = false;
client.remotePort = 443;
- char header_buf[512];
- int hdr = snprintf(header_buf, sizeof(header_buf),
+ char *header_buf = (char*)malloc(512);
+ if (!header_buf) return ERRCODE_FAIL;
+ int hdr = snprintf(header_buf, 512,
"deviceId: %s\r\ndeviceToken: %s\r\nContent-Type: application/json\r\n",
device_id, device_token);
- if (hdr <= 0 || hdr >= (int)sizeof(header_buf))
+ if (hdr <= 0)
+ {
return ERRCODE_FAIL;
+ }
HttpClientSetCustomHeader(&client, header_buf);
HTTPC_RESULT prep = ln_http_prepare_auto(&clientData, 2048, 8 * 1024);
end:
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ free(header_buf);
return ERRCODE_SUCC;
}
#include "ln_api.h"
#include <stdio.h>
+#include <stdlib.h>
#define story_random_file_path "/user/leiniao/story/random.txt"
client.remotePort = 443;
/* 设置请求头(包含Content-Type,保持与Python一致) */
- char header_buf[1024];
- int hdr = snprintf(header_buf, sizeof(header_buf),
+ char *header_buf = (char*)malloc(1024);
+ if (!header_buf) return ERRCODE_FAIL;
+ int hdr = snprintf(header_buf, 1024,
"deviceId: %s\r\n"
"deviceToken: %s\r\n"
- "Accept: text/event-stream\r\n"
- "Cache-Control: no-cache\r\n"
"Content-Type: application/json\r\n",
device_id, device_token);
- if (hdr <= 0 || hdr >= (int)sizeof(header_buf))
+ if (hdr <= 0)
{
- printf("story random: build header failed\n");
+ free(header_buf);
return ERRCODE_FAIL;
}
HttpClientSetCustomHeader(&client, header_buf);
if (prep != HTTP_SUCCESS)
{
printf("story random: prepare HTTP buffer failed (code: %d)\n", prep);
+ free(header_buf);
return ERRCODE_FAIL;
}
/* 构建 JSON 请求体(增加转义处理,避免格式错误)*/
- char json_body[256] = {0};
- char escaped_theme[256] = {0};
+ char *json_body = (char*)malloc(256);
+ char *escaped_theme = (char*)malloc(256);
+ if (!json_body || !escaped_theme)
+ {
+ if (json_body) free(json_body);
+ if (escaped_theme) free(escaped_theme);
+ free(header_buf);
+ return ERRCODE_FAIL;
+ }
int json_len = 0;
if (story_theme && story_theme[0])
{
- int i = 0, j = 0;
- while (story_theme[i] && j < (int)sizeof(escaped_theme) - 1)
+ /* 对 theme 做简单转义,避免引号破坏 JSON */
+ int ei = 0;
+ for (const char *p = story_theme; *p && ei < 255; ++p)
{
- if (story_theme[i] == '"')
- {
- escaped_theme[j++] = '\\';
- escaped_theme[j++] = '"';
- }
- else if (story_theme[i] == '\\')
- {
- escaped_theme[j++] = '\\';
- escaped_theme[j++] = '\\';
- }
- else
- {
- escaped_theme[j++] = story_theme[i];
- }
- i++;
+ if (*p == '"' || *p == '\\')
+ escaped_theme[ei++] = '\\';
+ escaped_theme[ei++] = *p;
}
- escaped_theme[j] = '\0';
- json_len = snprintf(json_body, sizeof(json_body), "{\"storyTheme\":\"%s\"}", escaped_theme);
+ escaped_theme[ei] = '\0';
+ json_len = snprintf(json_body, 256, "{\"storyTheme\":\"%s\"}", escaped_theme);
}
else
{
- json_len = snprintf(json_body, sizeof(json_body), "{}");
+ json_len = snprintf(json_body, 256, "{}");
}
- if (json_len <= 0 || json_len >= (int)sizeof(json_body))
+ if (json_len <= 0)
{
- printf("story random: build JSON body failed\n");
- HttpClientUnprepare(&clientData);
+ free(header_buf);
+ free(json_body);
+ free(escaped_theme);
return ERRCODE_FAIL;
}
if (ret != 0)
{
printf("[OTA] connection failed, ret=0x%x\n", ret);
+ free(header_buf);
+ free(json_body);
+ free(escaped_theme);
HttpClientUnprepare(&clientData);
return ret;
}
printf("[OTA] send request failed, ret=0x%x\n", ret);
HttpClientClse(&client);
HttpClientUnprepare(&clientData);
+ free(header_buf);
+ free(json_body);
+ free(escaped_theme);
return ret;
}
printf("story choose: fopen failed for %s:\n", story_random_file_path);
HttpClientClse(&client);
HttpClientUnprepare(&clientData);
+ free(header_buf);
+ free(json_body);
+ free(escaped_theme);
return ERRCODE_FAIL;
}
HttpClientClse(&client);
HttpClientUnprepare(&clientData);
fclose(fd);
+ free(header_buf);
+ free(json_body);
+ free(escaped_theme);
return ERRCODE_FAIL;
}
total_written += written;
ln_parse_story_random_file();
}
+ free(header_buf);
+ free(json_body);
+ free(escaped_theme);
return ERRCODE_SUCC;
}
ln_gen_nonce(nonce, sizeof(nonce));
/* 2. 计算签名: deviceId:deviceIccid:timestamp:nonce */
- char sign_data[256] = {0};
- (void)snprintf(sign_data, sizeof(sign_data), "%s:%s:%s:%s", device_id, device_iccid, timestamp, nonce);
+ size_t sd_cap = strlen(device_id) + strlen(device_iccid) + strlen(timestamp) + strlen(nonce) + 4 + 1;
+ char *sign_data = (char*)malloc(sd_cap);
+ if (!sign_data) return ERRCODE_FAIL;
+ (void)snprintf(sign_data, sd_cap, "%s:%s:%s:%s", device_id, device_iccid, timestamp, nonce);
char signature[65] = {0};
if (ln_hmac_sha256_hex(LN_SIGN_SECRET, sign_data, signature, sizeof(signature)) != 0)
{
}
/* 3. 组织自定义请求头 */
- char header_buf[1024] = {0};
- int hdr_len = snprintf(header_buf, sizeof(header_buf),
+ char *header_buf = (char*)malloc(1024);
+ if (!header_buf) { free(sign_data); return ERRCODE_FAIL; }
+ int hdr_len = snprintf(header_buf, 1024,
"deviceId: %s\r\n"
"deviceIccid: %s\r\n"
"timestamp: %s\r\n"
device_id, device_iccid, timestamp, nonce, signature,
(device_model && device_model[0]) ? device_model : "AB101",
(device_version && device_version[0]) ? device_version : "1.0.0");
- if (hdr_len <= 0 || hdr_len >= (int)sizeof(header_buf))
+ if (hdr_len <= 0)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ln_get_device_token_http: header build failed");
+ free(sign_data);
+ free(header_buf);
return ERRCODE_FAIL;
}
if (prep != HTTP_SUCCESS)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ln_get_device_token_http: HttpClientPrepare failed %d", prep);
+ free(sign_data);
+ free(header_buf);
return ERRCODE_FAIL;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ln_get_device_token_http: request failed %d", res);
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ free(sign_data);
+ free(header_buf);
return ERRCODE_FAIL;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ln_get_device_token_http: HTTP %d", code);
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ free(sign_data);
+ free(header_buf);
return ERRCODE_FAIL;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ln_get_device_token_http: empty body");
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ free(sign_data);
+ free(header_buf);
return ERRCODE_FAIL;
}
{
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ free(sign_data);
+ free(header_buf);
return ERRCODE_FAIL;
}
memcpy(json_text, clientData.responseBuf, (size_t)body_len);
free(json_text);
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ free(sign_data);
+ free(header_buf);
return ERRCODE_FAIL;
}
free(json_text);
HttpClientUnprepare(&clientData);
HttpClientClse(&client);
+ free(sign_data);
+ free(header_buf);
return ERRCODE_SUCC;
}
{
OHOS::ThunderBirdModel::GetInstance()->SetTextStr(text);
}
+// 是否开始对话标志
+static int g_start_conversation_flag = 0;
+void set_start_conversation_flag(int flag)
+{
+ printf("set_start_conversation_flag: %d\n", flag);
+ g_start_conversation_flag = flag;
+}
+
+// 获取是否开始对话标志
+int get_start_conversation_flag(void)
+{
+ printf("get_start_conversation_flag: %d\n", g_start_conversation_flag);
+ return g_start_conversation_flag;
+}
void push_ota_status(int status)
{
void push_ota_progress(int progress)
{
- printf("push_ota_progress: %d\n", progress);
}
void do_restore_factory_setting(void)
// 推送文本给ui
void push_text_to_ui(const char *text);
+//设置是否开始对话标志
+void set_start_conversation_flag(int flag);
+//获取开始对话标志
+int get_start_conversation_flag(void);
/*
ota升级状态
get_version_string(), BUILD_TIME);
#endif
- printf(str);
memset(para,0,para_len);
memcpy_s(para,para_len,str,strlen(str));