Compare commits
2 Commits
0c7475e0d3
...
1f75345fb3
Author | SHA1 | Date | |
---|---|---|---|
1f75345fb3 | |||
cbf2f1bbf0 |
@ -675,8 +675,12 @@ static void handle_system_event(key_event_t event)
|
||||
thing_init();
|
||||
init_bat_timer();
|
||||
// spi_led_init();
|
||||
<<<<<<< HEAD
|
||||
bk_printf("VER:%s\r\n","1.0.6");
|
||||
=======
|
||||
bk_printf("bk_misc_get_reset_reason = 0x%02X \n",bk_misc_get_reset_reason());
|
||||
bk_printf("VER:1.0.3 2025.05.27\r\n");
|
||||
>>>>>>> 0c7475e0d398483dba561d0acb30a572a0d6c861
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -696,6 +696,25 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
}
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
}
|
||||
/*
|
||||
*11.蓝牙控制助眠仪工作等级
|
||||
发送: AT+SLEEP_LEVEL=1 (1-9 代表9个等级强度)
|
||||
回复: AT+SLEEP_LEVEL=OK
|
||||
*/
|
||||
else if (NULL != (ptr = strstr((char *)recv, "AT+VERSION")))
|
||||
{
|
||||
wboard_loge("AT+VERSION!!");
|
||||
uint8_t str_respone[32] = {0};
|
||||
memset(str_respone, 0, sizeof(str_respone));
|
||||
char level[12] = {0};
|
||||
memset(level, 0, sizeof(level));
|
||||
sscanf((char *)recv, "AT+VERSION=%s", level);
|
||||
if (strcmp(level, "?") == 0)
|
||||
{
|
||||
sprintf((char *)str_respone, "AT+VERSION=%s", IOT_LAMP_DEVICE_VERSION);
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 蓝牙控制OTA
|
||||
|
||||
|
@ -131,6 +131,9 @@ int rtc_websocket_audio_send_data(rtc_session *rtc_session, uint8_t *data_ptr, s
|
||||
void rtc_websocket_audio_receive_data(rtc_session *rtc_session, uint8 *data, uint32_t len);
|
||||
void rtc_websocket_audio_receive_data_opus(rtc_session *rtc_session, uint8 *data, uint32_t len);
|
||||
int rtc_websocket_send_text(transport web_socket, void *str, enum MsgType msgtype);
|
||||
//helloyifa
|
||||
int rtc_websocket_send_json(transport web_socket, void *str, size_t data_len);
|
||||
|
||||
int rtc_websocket_parse_hello(cJSON *root);
|
||||
void rtc_websocket_parse_text(text_info_t *text, cJSON *root);
|
||||
void rtc_fill_audio_info(audio_info_t *info, char *type, uint32_t adc_rate, uint32_t dac_rate, uint32_t enc_ms, uint32_t dec_ms, uint32_t size);
|
||||
|
@ -23,12 +23,7 @@
|
||||
#define LOGD(...) BK_LOGD(TAG, ##__VA_ARGS__)
|
||||
|
||||
|
||||
#define IOT_LAMP_DEVICE_NAME "lamp"
|
||||
#define IOT_LAMP_DEVICE_FUNS_SET_BRIGHTNESS "SetBrightness"
|
||||
#define IOT_LAMP_DEVICE_GET_BATTERY "GetBattery"
|
||||
#define IOT_LAMP_DEVICE_OTA "ota"
|
||||
|
||||
#define IOT_LAMP_DEVICE_VERSION "1.0.5"
|
||||
#define IOT_LAMP_DEVICE_OTA_CHECK_URL "http://106.52.233.130:8888/ir58/ir58.json"
|
||||
|
||||
void lamp_init(){
|
||||
@ -56,6 +51,17 @@ cJSON* iot_lamp_get_device_desc(){
|
||||
cJSON_AddItemToObjectCS(lamp_desc,"properties",properties);
|
||||
|
||||
|
||||
//定义version属性
|
||||
cJSON *version = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(version, "description", "当前拍拍灯软件版本");
|
||||
cJSON_AddStringToObject(version, "type", "string");
|
||||
//添加brightness属性到properties
|
||||
cJSON_AddItemToObjectCS(properties,"version",version);
|
||||
|
||||
//添加properties 到lamp_desc 描述
|
||||
cJSON_AddItemToObjectCS(lamp_desc,"properties",properties);
|
||||
|
||||
|
||||
//定义方法methods
|
||||
cJSON *methods = cJSON_CreateObject();
|
||||
|
||||
|
@ -16,7 +16,12 @@ extern "C" {
|
||||
//#include "beken_config.h"
|
||||
//#include "bk_websocket_client.h"
|
||||
#include "cJSON.h"
|
||||
#define IOT_LAMP_DEVICE_NAME "lamp"
|
||||
#define IOT_LAMP_DEVICE_FUNS_SET_BRIGHTNESS "SetBrightness"
|
||||
#define IOT_LAMP_DEVICE_GET_BATTERY "GetBattery"
|
||||
#define IOT_LAMP_DEVICE_OTA "ota"
|
||||
|
||||
#define IOT_LAMP_DEVICE_VERSION "1.0.6"
|
||||
|
||||
void lamp_init();
|
||||
void lamp_http_ota_start(char *url);
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include <driver/gpio.h>
|
||||
#include "gpio_driver.h"
|
||||
|
||||
#include "thing.h"
|
||||
#include "iot_sleep_helper.h"
|
||||
|
||||
#define TAG "sleep_helper"
|
||||
@ -180,7 +180,7 @@ typedef struct
|
||||
sleep_model_level level;
|
||||
} sleep_msg_t;
|
||||
|
||||
|
||||
extern char *getGlobalSessionId(void);
|
||||
static void sleep_helper_thread(void *arg)
|
||||
{
|
||||
|
||||
@ -267,6 +267,7 @@ void sleep_helper_set_mode(sleep_mode mode){
|
||||
sleep_msg_t msg;
|
||||
msg.mode = mode;
|
||||
rtos_push_to_queue(&sleep_helper_msg_que, &msg, BEKEN_NO_WAIT);
|
||||
//thing_report_iot_state_number(getGlobalSessionId(),IOT_SLEEP_HELPER_DEVICE_NAME,IOT_SLEEP_HELPER_DEVICE_PARAM_MODE,mode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,6 +323,7 @@ void sleep_helper_set_level(sleep_model_level level){
|
||||
config.duty_cycle = s_period*g_mode_level[level-1]/100;
|
||||
LOGE("sleep_helper_set_level %d \n",g_mode_level[level-1]);
|
||||
bk_pwm_set_period_duty(pwm_chan,&config);
|
||||
//thing_report_iot_state_number(getGlobalSessionId(),IOT_SLEEP_HELPER_DEVICE_NAME,IOT_SLEEP_HELPER_DEVICE_PARAM_LEVEL,level);
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,6 +355,7 @@ void sleep_helper_open(){
|
||||
//默认模式1
|
||||
sleep_helper_set_mode(SLEEP_MODE_1);
|
||||
sleep_helper_start_timer();
|
||||
//thing_report_iot_state_number(getGlobalSessionId(),IOT_SLEEP_HELPER_DEVICE_NAME,IOT_SLEEP_HELPER_DEVICE_PARAM_MODE,SLEEP_MODE_1);
|
||||
}
|
||||
|
||||
void sleep_helper_close(){
|
||||
@ -365,6 +368,8 @@ void sleep_helper_close(){
|
||||
// 关闭电源输出
|
||||
bk_gpio_set_output_low(GPIO_44);
|
||||
bk_gpio_set_output_low(GPIO_45);
|
||||
|
||||
//thing_report_iot_state_number(getGlobalSessionId(),IOT_SLEEP_HELPER_DEVICE_NAME,IOT_SLEEP_HELPER_DEVICE_PARAM_MODE,0);
|
||||
}
|
||||
|
||||
cJSON* iot_sleep_helper_get_device_desc()
|
||||
@ -374,12 +379,21 @@ cJSON* iot_sleep_helper_get_device_desc()
|
||||
cJSON_AddStringToObject(sleep_helper_desc, "description", "这是助眠仪(睡眠辅助仪器)");
|
||||
|
||||
cJSON *properties = cJSON_CreateObject();
|
||||
//volume 属性
|
||||
//mode 属性
|
||||
cJSON *mode = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(mode, "description", "当前设备的模式");
|
||||
cJSON_AddStringToObject(mode, "description", "当前工作模式 0表示关闭 1-3表示3种不同的模式");
|
||||
cJSON_AddStringToObject(mode, "type", "number");
|
||||
//添加brightness属性到properties
|
||||
cJSON_AddItemToObjectCS(properties,"mode",mode);
|
||||
//添加mode属性到properties
|
||||
cJSON_AddItemToObjectCS(properties,IOT_SLEEP_HELPER_DEVICE_PARAM_MODE,mode);
|
||||
|
||||
//level 属性
|
||||
cJSON *param_level = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(param_level, "description", "当前工作等级");
|
||||
cJSON_AddStringToObject(param_level, "type", "number");
|
||||
//添加mode属性到properties
|
||||
cJSON_AddItemToObjectCS(properties,IOT_SLEEP_HELPER_DEVICE_PARAM_LEVEL,param_level);
|
||||
|
||||
|
||||
//添加properties speaker_desc 描述
|
||||
cJSON_AddItemToObjectCS(sleep_helper_desc,"properties",properties);
|
||||
|
||||
@ -388,24 +402,24 @@ cJSON* iot_sleep_helper_get_device_desc()
|
||||
cJSON *methods = cJSON_CreateObject();
|
||||
//设置模式的方法
|
||||
cJSON *setMode = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(setMode, "description", "设置助眠仪的工作模式");
|
||||
cJSON_AddStringToObject(setMode, "description", "设置助眠仪工作模式");
|
||||
cJSON *parameters = cJSON_CreateObject();
|
||||
cJSON *p_mode = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(p_mode, "type", "number");
|
||||
cJSON_AddStringToObject(p_mode, "description", "1到3之间的整数");
|
||||
cJSON_AddItemToObjectCS(parameters,"mode",p_mode);
|
||||
cJSON_AddItemToObjectCS(parameters,IOT_SLEEP_HELPER_DEVICE_PARAM_MODE,p_mode);
|
||||
cJSON_AddItemToObjectCS(setMode,"parameters",parameters);
|
||||
cJSON_AddItemToObjectCS(methods,IOT_SLEEP_HELPER_DEVICE_FUNS_SET_MODE,setMode);
|
||||
|
||||
|
||||
//设置工作等级的方法
|
||||
cJSON *setLevel = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(setLevel, "description", "设置助眠仪的工作等级强度");
|
||||
cJSON_AddStringToObject(setLevel, "description", "设置助眠仪工作等级强度");
|
||||
cJSON *parameters_set_level = cJSON_CreateObject();
|
||||
cJSON *p_level = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(p_level, "type", "number");
|
||||
cJSON_AddStringToObject(p_level, "description", "1到9之间的整数");
|
||||
cJSON_AddItemToObjectCS(parameters_set_level,"level",p_level);
|
||||
cJSON_AddItemToObjectCS(parameters_set_level,IOT_SLEEP_HELPER_DEVICE_PARAM_LEVEL,p_level);
|
||||
cJSON_AddItemToObjectCS(setLevel,"parameters",parameters_set_level);
|
||||
cJSON_AddItemToObjectCS(methods,IOT_SLEEP_HELPER_DEVICE_FUNS_SET_LEVEL,setLevel);
|
||||
|
||||
|
@ -14,6 +14,10 @@ extern "C" {
|
||||
#include "cJSON.h"
|
||||
|
||||
#define IOT_SLEEP_HELPER_DEVICE_NAME "sleep_helper"
|
||||
|
||||
#define IOT_SLEEP_HELPER_DEVICE_PARAM_MODE "mode"
|
||||
#define IOT_SLEEP_HELPER_DEVICE_PARAM_LEVEL "level"
|
||||
|
||||
#define IOT_SLEEP_HELPER_DEVICE_FUNS_SET_MODE "setMode"
|
||||
#define IOT_SLEEP_HELPER_DEVICE_FUNS_SET_LEVEL "setLevel"
|
||||
#define IOT_SLEEP_HELPER_DEVICE_OPEN "open"
|
||||
|
@ -22,6 +22,8 @@
|
||||
#endif
|
||||
#include "motor.h"
|
||||
#endif
|
||||
#include "iot_speaker.h"
|
||||
#include "thing.h"
|
||||
|
||||
#define TAG "iot_speaker"
|
||||
#define LOGI(...) BK_LOGI(TAG, ##__VA_ARGS__)
|
||||
@ -158,16 +160,16 @@ uint32_t speaker_volume_get_level_count()
|
||||
cJSON* iot_speaker_get_device_desc()
|
||||
{
|
||||
cJSON *speaker_desc = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(speaker_desc, "name", "speaker");
|
||||
cJSON_AddStringToObject(speaker_desc, "description", "扬声器 音量调节");
|
||||
cJSON_AddStringToObject(speaker_desc, "name", IOT_SPEAKER_DEVICE_NAME);
|
||||
cJSON_AddStringToObject(speaker_desc, "description", "音量调节");
|
||||
|
||||
cJSON *properties = cJSON_CreateObject();
|
||||
//volume 属性
|
||||
cJSON *volume = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(volume, "description", "当前设备音量");
|
||||
cJSON_AddStringToObject(volume, "description", "当前设备音量 0-100");
|
||||
cJSON_AddStringToObject(volume, "type", "number");
|
||||
//添加brightness属性到properties
|
||||
cJSON_AddItemToObjectCS(properties,"volume",volume);
|
||||
cJSON_AddItemToObjectCS(properties,IOT_SPEAKER_DEVICE_PARAM_VOL,volume);
|
||||
//添加properties speaker_desc 描述
|
||||
cJSON_AddItemToObjectCS(speaker_desc,"properties",properties);
|
||||
|
||||
@ -175,7 +177,7 @@ cJSON* iot_speaker_get_device_desc()
|
||||
//定义方法methods
|
||||
cJSON *methods = cJSON_CreateObject();
|
||||
cJSON *setVolume = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(setVolume, "description", "设置音量");
|
||||
cJSON_AddStringToObject(setVolume, "description", "设置音量和声音大小");
|
||||
|
||||
cJSON *parameters = cJSON_CreateObject();
|
||||
cJSON *p_volume = cJSON_CreateObject();
|
||||
@ -187,7 +189,7 @@ cJSON* iot_speaker_get_device_desc()
|
||||
cJSON_AddItemToObjectCS(setVolume,"parameters",parameters);
|
||||
|
||||
//cJSON_AddStringToObject(SetBrightness, "type", "number");
|
||||
cJSON_AddItemToObjectCS(methods,"setVolume",setVolume);
|
||||
cJSON_AddItemToObjectCS(methods,IOT_SPEAKER_DEVICE_FUNS_SET_VOL,setVolume);
|
||||
cJSON_AddItemToObjectCS(speaker_desc,"methods",methods);
|
||||
|
||||
//打印一下描述
|
||||
@ -217,6 +219,8 @@ void iot_speaker_parser_invoke(char* cmd,char * paramters_json){
|
||||
int level = volume/10;
|
||||
LOGE("speaker_setVolume--> volume :%d level:%d\n",volume,level);
|
||||
speaker_volume_set_abs(level,0);
|
||||
//extern char *getGlobalSessionId(void);
|
||||
//thing_report_iot_state_number(getGlobalSessionId(),IOT_SPEAKER_DEVICE_NAME,IOT_SPEAKER_DEVICE_PARAM_VOL,volume);
|
||||
}
|
||||
cJSON_Delete(params);
|
||||
}
|
||||
|
@ -5,6 +5,11 @@ extern "C" {
|
||||
#endif
|
||||
#include "cJSON.h"
|
||||
|
||||
|
||||
#define IOT_SPEAKER_DEVICE_NAME "speaker"
|
||||
#define IOT_SPEAKER_DEVICE_PARAM_VOL "volume"
|
||||
#define IOT_SPEAKER_DEVICE_FUNS_SET_VOL "setVolume"
|
||||
|
||||
void speaker_volume_init();
|
||||
|
||||
cJSON* iot_speaker_get_device_desc();
|
||||
|
@ -16,31 +16,14 @@
|
||||
#include "iot_lamp.h"
|
||||
#include "iot_speaker.h"
|
||||
#include "iot_sleep_helper.h"
|
||||
|
||||
#include "beken_rtc.h"
|
||||
#define TAG "thing"
|
||||
#define LOGI(...) BK_LOGI(TAG, ##__VA_ARGS__)
|
||||
#define LOGW(...) BK_LOGW(TAG, ##__VA_ARGS__)
|
||||
#define LOGE(...) BK_LOGE(TAG, ##__VA_ARGS__)
|
||||
#define LOGD(...) BK_LOGD(TAG, ##__VA_ARGS__)
|
||||
|
||||
|
||||
/**
|
||||
* 生成IOT 描述文件 用于意图识别控制
|
||||
*/
|
||||
void thing_init()
|
||||
{
|
||||
#ifdef IOT_LAMP
|
||||
lamp_init();
|
||||
#endif
|
||||
|
||||
#ifdef IOT_SPEAKER
|
||||
speaker_volume_init();
|
||||
#endif
|
||||
|
||||
#ifdef IOT_SLEEP_HELPER
|
||||
sleep_helper_init();
|
||||
//sleep_helper_set_mode(SLEEP_MODE_1);
|
||||
#endif
|
||||
}
|
||||
extern rtc_session *__get_beken_rtc(void);
|
||||
|
||||
cJSON* thing_gen_iot_descriptors(char *session_id)
|
||||
{
|
||||
@ -75,6 +58,65 @@ cJSON* thing_gen_iot_descriptors(char *session_id)
|
||||
return messageRoot;
|
||||
}
|
||||
|
||||
//{"session_id":"14c23594","type":"iot","update":true,"states":[{"name":"AudioSpeaker","state":{"volume":50}}]}
|
||||
void thing_report_iot_state(char * session_id, char * device,char * properties_key, char* state){
|
||||
cJSON *messageRoot = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(messageRoot, "session_id", session_id);
|
||||
cJSON_AddStringToObject(messageRoot, "type", "iot");
|
||||
cJSON_AddBoolToObject(messageRoot, "update", true);
|
||||
cJSON *stateArray = cJSON_CreateArray();
|
||||
|
||||
cJSON *states_desc = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(states_desc, "name", device);
|
||||
|
||||
//cJSON *state_obj = cJSON_CreateObject();
|
||||
|
||||
//{"volume":50}
|
||||
cJSON *param = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(param, properties_key, state);
|
||||
//"state":{"volume":50}}
|
||||
cJSON_AddItemToObjectCS(states_desc,"state",param);
|
||||
|
||||
cJSON_AddItemToArray(stateArray, states_desc);
|
||||
cJSON_AddItemToObject(messageRoot, "states", stateArray);
|
||||
char *message = cJSON_PrintUnformatted(messageRoot);
|
||||
LOGE("iot -->(len:%d) %s\n",strlen(message),message);
|
||||
|
||||
rtc_session *beken_rtc = __get_beken_rtc();
|
||||
transport bk_rtc_ws = beken_rtc->bk_rtc_client;
|
||||
websocket_client_send_text(bk_rtc_ws, message, strlen(message), 10*1000);
|
||||
cJSON_Delete(messageRoot);
|
||||
}
|
||||
|
||||
void thing_report_iot_state_number(char * session_id, char * device,char * properties_key, int state){
|
||||
cJSON *messageRoot = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(messageRoot, "session_id", session_id);
|
||||
cJSON_AddStringToObject(messageRoot, "type", "iot");
|
||||
cJSON_AddBoolToObject(messageRoot, "update", true);
|
||||
cJSON *stateArray = cJSON_CreateArray();
|
||||
|
||||
cJSON *states_desc = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(states_desc, "name", device);
|
||||
|
||||
//cJSON *state_obj = cJSON_CreateObject();
|
||||
|
||||
//{"volume":50}
|
||||
cJSON *param = cJSON_CreateObject();
|
||||
cJSON_AddNumberToObject(param, properties_key, state);
|
||||
//"state":{"volume":50}}
|
||||
cJSON_AddItemToObjectCS(states_desc,"state",param);
|
||||
|
||||
cJSON_AddItemToArray(stateArray, states_desc);
|
||||
cJSON_AddItemToObject(messageRoot, "states", stateArray);
|
||||
char *message = cJSON_PrintUnformatted(messageRoot);
|
||||
LOGE("iot -->(len:%d) %s\n",strlen(message),message);
|
||||
|
||||
rtc_session *beken_rtc = __get_beken_rtc();
|
||||
transport bk_rtc_ws = beken_rtc->bk_rtc_client;
|
||||
websocket_client_send_text(bk_rtc_ws, message, strlen(message), 10*1000);
|
||||
cJSON_Delete(messageRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析平台下发的IOT指令,获取响应的参数调用不同的硬件功能
|
||||
* 物联网指令:
|
||||
@ -138,4 +180,23 @@ void thing_iot_invoke(char *iot_json){
|
||||
// AddBooleanProperty
|
||||
// AddMethod
|
||||
|
||||
/**
|
||||
* 生成IOT 描述文件 用于意图识别控制
|
||||
*/
|
||||
void thing_init()
|
||||
{
|
||||
#ifdef IOT_LAMP
|
||||
lamp_init();
|
||||
#endif
|
||||
|
||||
#ifdef IOT_SPEAKER
|
||||
speaker_volume_init();
|
||||
#endif
|
||||
|
||||
#ifdef IOT_SLEEP_HELPER
|
||||
sleep_helper_init();
|
||||
//sleep_helper_set_mode(SLEEP_MODE_1);
|
||||
#endif
|
||||
|
||||
//thing_report_iot_state("111","lamp","version","1.0.6");
|
||||
}
|
||||
|
@ -34,12 +34,22 @@ cJSON * thing_add_string_property(char * name,char *description);
|
||||
},*/
|
||||
cJSON * thing_add_number_property(char * name,char *description);
|
||||
|
||||
|
||||
/**
|
||||
* # Sending IoT descriptors
|
||||
[{"name":"AudioSpeaker","description":"The audio speaker of the device","properties":{"volume":{"description":"Current audio volume value","type":"number"}},"methods":{"set_volume":{"description":"Set the audio volume","parameters":{"volume":{"description":"An integer between 0 and 100","type":"number"}}}}},{"name":"Lamp","description":"A test lamp","properties":{"power":{"description":"Whether the lamp is on","type":"boolean"}},"methods":{"turn_on":{"description":"Turn on the lamp","parameters":{}},"turn_off":{"description":"Turn off the lamp","parameters":{}}}}]
|
||||
# Sending IoT states
|
||||
{"session_id":"14c23594","type":"iot","update":true,"states":[{"name":"AudioSpeaker","state":{"volume":50}}]}
|
||||
|
||||
*/
|
||||
//AddStringProperty
|
||||
//AddNumberProperty
|
||||
//AddBooleanProperty
|
||||
//AddMethod
|
||||
|
||||
void thing_report_iot_state(char * session_id, char * device,char * properties_key, char* state);
|
||||
|
||||
void thing_report_iot_state_number(char * session_id, char * device,char * properties_key, int state);
|
||||
/**
|
||||
* 生成IOT 描述文件 用于意图识别控制
|
||||
*/
|
||||
|
@ -590,6 +590,7 @@ int demo_network_auto_reconnect(bool val) // val true means from disconnect to r
|
||||
/*0x01110001:sta, 0x01110010:softap, 0x01110100:pan*/
|
||||
if ((info.flag & 0x71l) == 0x71l)
|
||||
{
|
||||
BK_LOGE(TAG, "aaaaaaaaaaaaaaaa\n");
|
||||
if (val == false)
|
||||
{
|
||||
network_reconnect_stop_timeout_check();
|
||||
@ -597,6 +598,7 @@ int demo_network_auto_reconnect(bool val) // val true means from disconnect to r
|
||||
app_event_send_msg(APP_EVT_RECONNECT_NETWORK, 0);
|
||||
network_disc_evt_posted = 0;
|
||||
}
|
||||
BK_LOGE(TAG, "bbbbbbbbbbb\n");
|
||||
demo_sta_app_init((char *)info.sta_ssid, (char *)info.sta_pwd);
|
||||
return 0x71l;
|
||||
}
|
||||
@ -605,6 +607,7 @@ int demo_network_auto_reconnect(bool val) // val true means from disconnect to r
|
||||
demo_softap_app_init((char *)info.ap_ssid, (char *)info.ap_pwd, NULL);
|
||||
return 0x72l;
|
||||
}
|
||||
BK_LOGE(TAG, "ccccccccccccc\n");
|
||||
#if CONFIG_NET_PAN
|
||||
if ((info.flag & 0x74l) == 0x74l)
|
||||
{
|
||||
@ -625,6 +628,7 @@ int demo_network_auto_reconnect(bool val) // val true means from disconnect to r
|
||||
|
||||
int demo_save_network_auto_restart_info(netif_if_t type, void *val)
|
||||
{
|
||||
BK_LOGE(TAG, "demo_save_network_auto_restart_info type:%d\n",type);
|
||||
BK_FAST_CONNECT_D info_tmp = {0};
|
||||
__maybe_unused wifi_ap_config_t *ap_config = NULL;
|
||||
__maybe_unused wifi_sta_config_t *sta_config = NULL;
|
||||
@ -644,6 +648,7 @@ int demo_save_network_auto_restart_info(netif_if_t type, void *val)
|
||||
os_memset((char *)info_tmp.sta_pwd, 0x0, 65);
|
||||
os_strcpy((char *)info_tmp.sta_ssid, (char *)sta_config->ssid);
|
||||
os_strcpy((char *)info_tmp.sta_pwd, (char *)sta_config->password);
|
||||
BK_LOGE(TAG, "demo_save_network :%s %s\n",(char *)info_tmp.sta_ssid,(char *)info_tmp.sta_pwd);
|
||||
}
|
||||
else if (type == NETIF_IF_AP)
|
||||
{
|
||||
@ -725,6 +730,7 @@ static int bk_genie_sconf_netif_event_cb(void *arg, event_module_t event_module,
|
||||
{
|
||||
case EVENT_NETIF_GOT_IP4:
|
||||
// helloyifa
|
||||
BK_LOGE(TAG, "!!!!!!!!!!!!!!!!!!!!!!!\n");
|
||||
result = rtos_init_timer(&led_wifi_connected_timer,
|
||||
5000,
|
||||
led_wifi_connected,
|
||||
@ -744,12 +750,14 @@ static int bk_genie_sconf_netif_event_cb(void *arg, event_module_t event_module,
|
||||
bk_printf("hi ws2812_led_wifi_connected\n");
|
||||
network_disc_evt_posted = 0;
|
||||
got_ip = (netif_event_got_ip4_t *)event_data;
|
||||
BK_LOGI(TAG, "%s got ip %s.\n", got_ip->netif_if == NETIF_IF_STA ? "STA" : "BK PAN", got_ip->ip);
|
||||
BK_LOGE(TAG, "%s got ip %s.\n", got_ip->netif_if == NETIF_IF_STA ? "STA" : "BK PAN", got_ip->ip);
|
||||
if (smart_config_running)
|
||||
{
|
||||
app_event_send_msg(APP_EVT_NETWORK_PROVISIONING_SUCCESS, 0);
|
||||
bk_wifi_sta_get_config(&sta_config);
|
||||
BK_LOGE(TAG, "22222222222222222\n");
|
||||
demo_save_network_auto_restart_info(got_ip->netif_if, &sta_config);
|
||||
|
||||
msg.event = DBEVT_WIFI_STATION_CONNECTED;
|
||||
bk_genie_send_msg(&msg);
|
||||
#if CONFIG_STA_AUTO_RECONNECT
|
||||
@ -882,6 +890,7 @@ void be_set_smart_config_running(){
|
||||
}
|
||||
void bk_genie_prepare_for_smart_config(void)
|
||||
{
|
||||
BK_LOGE(TAG, "bk_genie_prepare_for_smart_config !!\n", __func__);
|
||||
smart_config_running = true;
|
||||
#if CONFIG_STA_AUTO_RECONNECT
|
||||
first_time_for_network_provisioning = true;
|
||||
@ -914,7 +923,7 @@ void bk_genie_prepare_for_smart_config(void)
|
||||
int bk_genie_smart_config_init(void)
|
||||
{
|
||||
int flag;
|
||||
|
||||
BK_LOGE(TAG, "6666666 bk_genie_smart_config_init !!\n" );
|
||||
event_handler_init();
|
||||
flag = demo_network_auto_reconnect(false);
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "audio_process.h"
|
||||
#include "thing.h"
|
||||
#include "iot_ota.h"
|
||||
#include "iot_lamp.h"
|
||||
|
||||
#define TAG "WS_MAIN"
|
||||
#define LOGI(...) BK_LOGI(TAG, ##__VA_ARGS__)
|
||||
@ -769,6 +770,8 @@ void rtc_websocket_event_handler(void *event_handler_arg, char *event_base, int3
|
||||
|
||||
rtos_delay_milliseconds(100);
|
||||
rtc_websocket_send_text(client, (void *)(&audio_info), BEKEN_RTC_SEND_IOT_DESC);
|
||||
rtos_delay_milliseconds(20);
|
||||
thing_report_iot_state(getGlobalSessionId(), IOT_LAMP_DEVICE_NAME,"version", IOT_LAMP_DEVICE_VERSION);
|
||||
// rtc_websocket_send_text(client, (void *)(&audio_info), BEKEN_RTC_SEND_START_LISTEN);
|
||||
// rtos_delay_milliseconds(200);
|
||||
// rtc_websocket_send_text(client, (void *)(&audio_info), BEKEN_RTC_SEND_LISTEN);
|
||||
|
Loading…
x
Reference in New Issue
Block a user