#define bk_malloc aic_malloc
#define bk_free aic_free
- // #define DMPTEST
+ #define DMPTEST
int get_dev_pass_MAX_len(void)//获取设备密码最大长度,注意要防止内存越界
{
//激活->登录的密钥
- const char *dev_pid = "cqxJZi5CNgzjS3mX21Zw";//PID
- const char *dev_key = "uKLrChwrxA1LklgBc3VwawYjUkbT3BgX";//密钥
+// const char *dev_pid = "cqxJZi5CNgzjS3mX21Zw";//PID
+// const char *dev_key = "uKLrChwrxA1LklgBc3VwawYjUkbT3BgX";//密钥
//电信
// const char *dev_pid = "DieBeXahZHLrjSnORbgN";//PID
// const char *dev_key = "FuXG4ptpGbzvKbdB4vpUypisbENgy2nB";//密钥
+//音箱
+//XbClE3xMZZGZTSnPjFjV
+//eWlTnlhmjk5ixBa4KpVTKUhNqLHXnEWy
+
+ const char *dev_pid = "XbClE3xMZZGZTSnPjFjV";//PID
+ const char *dev_key = "eWlTnlhmjk5ixBa4KpVTKUhNqLHXnEWy";//密钥
+
#define HTTP_DEMO_CLIENT_NAME "HTTP Demo Client"
#define HTTP_DEMO_URL "http://47.101.171.33/doc/download/10.txt"
static aos_thread_id http_demo_thread;
static aos_thread_id https_demo_thread;
-void aic_http_demotest()
+
+int32_t play_audio_done_duplex(const char *buf, uint32_t buf_len, uint32_t sample_rate, uint32_t is_file);
+
+extern int start_play_music_demo;
+void resetClose_time();
+
+void aic_http_demotest(char *url_play)
{
u32 status = 0;
long lbytes = 0;
u8 *buff;
- u32 bytes = 1500;
+ u32 bytes = 2048;
u32 total_length = 0;
u32 length_to_be_copied = 0;
u32 chunked_mode = 0;
bk_printf("aic_http_demotest1213...");
+ start_play_music_demo=1;
+
http_demo_handle = aic_http_client_create(HTTP_DEMO_CLIENT_NAME);
if (http_demo_handle == 0) {
return;
do {
- bk_printf("aic_http_demotest1213122...");
+ // bk_printf("aic_http_demotest1213122...");
+
+ if(start_play_music_demo!=1)
+ break;
lbytes = aic_https_client_response_data_get(http_demo_handle, buff, bytes,
HTTP_DEMO_WAIT_TIME);
bk_printf("aic_http_demotest1213123 lbytes %d...",lbytes);
if (lbytes <= 0) {
break;
} else {
+
+ bk_printf("https get data %d ",lbytes);
+
+ play_audio_done_duplex(buff, bytes, 16000, 0);
+
+ //audio_data(buff,lbytes,37);
+ resetClose_time();
+
+ aos_sleep(20);
+
chunked_mode = aic_http_client_chunked_mode_check(http_demo_handle);
length_to_be_copied = aic_https_client_total_receive_bytes_get(http_demo_handle);
if (!chunked_mode && length_to_be_copied) {
// aicx_error(0x1e6e26, "s", "http get data is %s", buff);
bk_printf("aic_http_demotest1213123 finish...");
-
- aic_http_client_delete(http_demo_handle);
+ bk_free(buff);
+ aic_http_client_delete(http_demo_handle);
return;
}
-int32_t play_audio_done_duplex(const char *buf, uint32_t buf_len, uint32_t sample_rate, uint32_t is_file);
-
-void resetClose_time();
-void aic_https_demotest()
+void aic_https_demotest(char *url_play)
{
u32 status = 0;
LONG lbytes = 0;
u32 chunked_mode = 0;
AIC_HTTPS_CLIENT_INSTANCE *client_ptr;
+ start_play_music_demo=1;
bk_printf("aic_https_demotest1213...");
https_demo_handle = aic_https_client_create(HTTP_DEMO_CLIENT_NAME);
/*wait pdp active,only for demo test.*/
// aos_sleep(HTTP_DEMO_SLEEP_TIME);
- status = aic_https_client_get_start(https_demo_handle, HTTPS_DEMO_URL, NULL,
+ VC_state=VC_State_TTSStart;
+ status = aic_https_client_get_start(https_demo_handle, url_play, NULL,
NULL, 443, HTTP_DEMO_WAIT_TIME);
if (status != NX_SUCCESS) {
aic_https_client_delete(https_demo_handle);
bk_printf("aic_https_demotest12132...");
do {
+
+ if(start_play_music_demo!=1)
+ break;
lbytes = aic_https_client_response_data_get(https_demo_handle, buff , bytes,
HTTP_DEMO_WAIT_TIME);
if (lbytes <= 0) {
bk_printf("https get data %d ",lbytes);
- play_audio_done_duplex(buff, bytes, 16000, 0);
+ // play_audio_done_duplex(buff, bytes, 16000, 0);
//audio_data(buff,lbytes,37);
resetClose_time();
- aos_sleep(20);
+ aos_sleep(20);
chunked_mode = aic_http_client_chunked_mode_check(https_demo_handle);
length_to_be_copied = aic_https_client_total_receive_bytes_get(https_demo_handle);
if (!chunked_mode && length_to_be_copied) {
} while (total_length < length_to_be_copied || chunked_mode);
// aicx_error(0x0f0971, "s", "https get data is %s", buff);
-
+ start_play_music_demo=0;
bk_printf("download123 finish %d...",total_length);
-
+ // VC_state=VC_State_TTSEnd;
+ bk_free(buff);
aic_https_client_delete(https_demo_handle);
return;
}
+
void get_alarm_info13(void)//设备激活
{
int ret;
// char *str_tmp = NULL;
-
+ // char *str_data=null;
+ // str_tmp = strstr(aut_buf,"\"time\":\"");
+
+ // while(str_tmp)//解析password
+ // {
+ // str_tmp += strlen("\"time\":\"");
+
+ // str_data=str_tmp;
+ // int count = str_count(str_tmp,'\"');
+ // bk_printf("count:%d",count);
+ // if(count < sizeof(ota_url))
+ // {
+ // memcpy(ota_url,str_tmp,count);
+ // ota_url[count] = 0;
+ // bk_printf("bargein:%s",ota_url);
+
+ // int temp_bag=atoi(ota_url);
+ // if(temp_bag>=0&&temp_bag<10){
+
+ // // if(temp_bag==1)
+ // // vc_cfg.VC_mode=0;
+ // // else
+ // vc_cfg.VC_mode=temp_bag;
+ // }
+ // // vc_cfg.VC_mode=
+
+ // // vc_cfg.VC_TTS_volume
+
+
+
+ // }
+ // else
+ // {
+ // bk_printf("bargein");
+ // }
+
+ // str_tmp = strstr(str_data,"\"time\":\"");
+ // }
+
+
aut_active_return:
// 释放内存
}
+
+
+void get_alarm_info12()
+{
+ u32 status = 0;
+ LONG lbytes = 0;
+ u8 *buff;
+ u32 bytes = 1024*2;
+ u32 total_length = 0;
+ u32 length_to_be_copied = 0;
+ u32 chunked_mode = 0;
+ AIC_HTTPS_CLIENT_INSTANCE *client_ptr;
+
+ bk_printf("get_alarm_info12...");
+
+ https_demo_handle = aic_https_client_create(HTTP_DEMO_CLIENT_NAME);
+ if (https_demo_handle == 0) {
+ return;
+ }
+
+ bk_printf("get_alarm_info12...");
+
+ char sign_url[300]={0};
+
+ char deviceId[30] = {0};
+
+ bk_get_imei(deviceId);
+
+ sprintf(sign_url,"https://wsiot-nocdn.raisound.com/ws-bus/alarm/system/list/%s?devToken=%s",deviceId,get_token());
+
+
+ bk_printf(sign_url);
+
+ /*for https test,set auth_type to 0, do not need certifica1*/
+ client_ptr = (AIC_HTTPS_CLIENT_INSTANCE *)https_demo_handle;
+ client_ptr->https_client->auth_type = 0;
+
+ /*wait pdp active,only for demo test.*/
+ // aos_sleep(HTTP_DEMO_SLEEP_TIME);
+
+ status = aic_https_client_get_start(https_demo_handle, sign_url, NULL,
+ NULL, 443, HTTP_DEMO_WAIT_TIME);
+ if (status != NX_SUCCESS) {
+ aic_https_client_delete(https_demo_handle);
+ return;
+ }
+
+ buff = aos_zalloc(bytes);
+
+ bk_printf("get_alarm_info12...");
+
+ do {
+ lbytes = aic_https_client_response_data_get(https_demo_handle, buff , bytes,
+ HTTP_DEMO_WAIT_TIME);
+ if (lbytes <= 0) {
+ break;
+ } else {
+
+ bk_printf("https get data %d ",lbytes);
+
+ // play_audio_done_duplex(buff, bytes, 16000, 0);
+
+ //audio_data(buff,lbytes,37);
+ // resetClose_time();
+
+ aos_sleep(20);
+ chunked_mode = aic_http_client_chunked_mode_check(https_demo_handle);
+ length_to_be_copied = aic_https_client_total_receive_bytes_get(https_demo_handle);
+ if (!chunked_mode && length_to_be_copied) {
+ total_length += lbytes;
+ }
+ }
+
+ } while (total_length < length_to_be_copied || chunked_mode);
+
+ // aicx_error(0x0f0971, "s", "https get data is %s", buff);
+
+ bk_printf("download123 finish %d...",total_length);
+
+ aic_https_client_delete(https_demo_handle);
+
+ return;
+}
+
+
+void get_alarm_info(void)//OTA更新
+{
+ int ret;
+ bk_printf("get_alarm_info");
+
+
+ AIC_HTTPS_CLIENT_INSTANCE *http_client;
+ char deviceId[30] = {0};
+ //char dev_pass_base64[100] ={0};
+
+ // http创建客户端句柄
+ u32 aut_active_http_handle = 0;
+ char *aut_buf =NULL;
+
+ //char *json_string =NULL;
+ //char form_data_string[200]={0};
+
+ char sign_url[200]={0};
+
+ cJSON *root = NULL;
+ aut_buf = bk_malloc(5*1024);
+ if(aut_buf)
+ memset(aut_buf , 0,5*1024);
+ else
+ goto aut_active_return;
+
+ bk_get_imei(deviceId);
+ //// DMPTEST
+
+
+ //http://app-api.raisound.com/dev/device/info/simple/867686073050930
+ #if 1
+ sprintf(sign_url,"https://wsiot-nocdn.raisound.com/ws-bus/alarm/system/list/%s?devToken=%s",deviceId,get_token());
+
+ #else
+ //https://app-api.raisound.com
+
+ sprintf(sign_url,"https://app-api.raisound.com/dev/device/info/simple/%s",deviceId);
+
+ #endif
+
+
+ bk_printf(sign_url);
+
+ u32 response = 0;
+ //创建客户端实例
+ aut_active_http_handle = aic_http_client_create("HTTP_DEMO_CLIENT_NAME");
+ if (aut_active_http_handle == 0) {
+ bk_printf("Failed to create HTTP client instance\n");
+ goto aut_active_return;
+ }
+ int url_value = aic_process_https_url(aut_active_http_handle,sign_url,AIC_HTTP_HEAD);
+ bk_printf("url_value:%d",url_value);
+ http_client = (AIC_HTTPS_CLIENT_INSTANCE *)aut_active_http_handle;
+ http_client->login_info.server_port = 80;
+ aic_http_client_connect(aut_active_http_handle, 5000);
+
+ // 创建JSON对象
+ root = cJSON_CreateObject();
+ if (root == NULL) {
+ bk_printf( "Failed to create JSON object\n");
+ goto aut_active_return; ;
+ }
+
+ // 输出JSON
+ // bk_printf("JSON output: %s\n", json_string);
+
+ aic_https_client_request_initialize(aut_active_http_handle,AIC_HTTPS_METHOD_GET, 0,
+ 0, NULL,NULL, 10000);
+
+
+ response = nx_web_http_client_request_send(http_client->https_client,10 * 1000);
+
+ ret=0;
+ if (ret == 0) {
+ bk_printf("数据发送成功\n");
+
+ } else {
+ // 处理错误
+ bk_printf("数据发送失败,错误码: %d\n", ret);
+ goto aut_active_return;
+ }
+
+ long read_bytes = aic_https_client_response_data_get(aut_active_http_handle,aut_buf,5*1024,10000);
+
+ bk_printf("read_bytes :%d\n",read_bytes);
+
+ if(read_bytes<=0)
+ goto aut_active_return;
+
+ bk_printf("get_alarm_info :%s",aut_buf);
+
+
+ char *str_tmp = NULL;
+
+ str_tmp = strstr(aut_buf,"\"bargein\":\"");
+ //bk_printf("str_tmp:%p",str_tmp);
+ // if(str_tmp)//解析password
+ // {
+ // str_tmp += strlen("\"bargein\":\"");
+ // int count = str_count(str_tmp,'\"');
+ // bk_printf("count:%d",count);
+ // if(count < sizeof(ota_url))
+ // {
+ // memcpy(ota_url,str_tmp,count);
+ // ota_url[count] = 0;
+ // bk_printf("bargein:%s",ota_url);
+
+ // int temp_bag=atoi(ota_url);
+ // if(temp_bag>=0&&temp_bag<10){
+
+ // // if(temp_bag==1)
+ // // vc_cfg.VC_mode=0;
+ // // else
+ // vc_cfg.VC_mode=temp_bag;
+ // }
+ // // vc_cfg.VC_mode=
+
+ // // vc_cfg.VC_TTS_volume
+
+
+
+ // }
+ // else
+ // {
+ // bk_printf("bargein");
+ // }
+ // }
+
+aut_active_return:
+ // 释放内存
+ if(aut_buf)
+ bk_free(aut_buf);
+ // if(json_string)
+ // cJSON_free(json_string);
+ if(root)
+ cJSON_Delete(root);
+ if(aut_active_http_handle)
+ aic_http_client_delete(aut_active_http_handle);
+}
+
+
void ota_check_version(void)//OTA更新
{
int ret;
}
-
-
+
aut_active_return:
// 释放内存
if(aut_buf)