增加可以设置基准电压值
This commit is contained in:
parent
c08c3d0604
commit
d0cc549048
@ -268,13 +268,14 @@ int battery_get_percent(){
|
||||
return batt_percent;
|
||||
}
|
||||
//AT+BAT_CALIBRTATION
|
||||
int battery_calibration(){
|
||||
int battery_calibration(int calibration_value){
|
||||
bk_err_t ret = prvStartBatteryAdcOneTime();
|
||||
|
||||
if (ret == BK_OK)
|
||||
{
|
||||
bk_printf("BAT_CALIBRTATION calibration_value: %d \r\n", calibration_value);
|
||||
ret = 1;
|
||||
bat_offset = 3980-vol;
|
||||
bat_offset = calibration_value-vol;
|
||||
|
||||
bk_config_write("bat_offset", (void *)&bat_offset, 4);
|
||||
bk_config_sync_flash_safely();
|
||||
|
@ -25,7 +25,7 @@ void init_bat_timer();
|
||||
void poweron_voice();
|
||||
void poweroff_voice();
|
||||
|
||||
int battery_calibration();
|
||||
int battery_calibration(int calibration_value);
|
||||
/**
|
||||
* 获取电量百分百
|
||||
*/
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "wifi_boarding_internal.h"
|
||||
#include "wifi_boarding_utils.h"
|
||||
|
||||
//helloyifa
|
||||
// helloyifa
|
||||
#include "bk_genie_smart_config.h"
|
||||
#include "../iot/iot_sleep_helper.h"
|
||||
#include "../iot/iot_lamp.h"
|
||||
@ -38,70 +38,80 @@ static bk_gatt_if_t s_gatts_if = 0;
|
||||
#define SYNC_CMD_TIMEOUT_MS 4000
|
||||
#define ADV_HANDLE 0
|
||||
|
||||
|
||||
#define BK_GATT_ATTR_TYPE(iuuid) {.len = BK_UUID_LEN_16, .uuid = {.uuid16 = iuuid}}
|
||||
#define BK_GATT_ATTR_CONTENT(iuuid) {.len = BK_UUID_LEN_16, .uuid = {.uuid16 = iuuid}}
|
||||
#define BK_GATT_ATTR_TYPE(iuuid) \
|
||||
{ \
|
||||
.len = BK_UUID_LEN_16, .uuid = {.uuid16 = iuuid } \
|
||||
}
|
||||
#define BK_GATT_ATTR_CONTENT(iuuid) \
|
||||
{ \
|
||||
.len = BK_UUID_LEN_16, .uuid = {.uuid16 = iuuid } \
|
||||
}
|
||||
#define BK_GATT_ATTR_VALUE(ilen, ivalue) {.attr_max_len = ilen, .attr_len = ilen, .attr_value = ivalue}
|
||||
|
||||
#define BK_GATT_ATTR_TYPE_128(iuuid) {.len = BK_UUID_LEN_128, .uuid = {.uuid128 = {iuuid[0], iuuid[1], iuuid[2], iuuid[3], iuuid[4], \
|
||||
iuuid[5], iuuid[6], iuuid[7], iuuid[8], iuuid[9], iuuid[10], iuuid[11], iuuid[12], iuuid[13], iuuid[14], iuuid[15]}}}
|
||||
#define BK_GATT_ATTR_TYPE_128(iuuid) \
|
||||
{ \
|
||||
.len = BK_UUID_LEN_128, .uuid = {.uuid128 = {iuuid[0], iuuid[1], iuuid[2], iuuid[3], iuuid[4], \
|
||||
iuuid[5], iuuid[6], iuuid[7], iuuid[8], iuuid[9], iuuid[10], iuuid[11], iuuid[12], iuuid[13], iuuid[14], iuuid[15]} } \
|
||||
}
|
||||
|
||||
#define BK_GATT_ATTR_CONTENT_128(iuuid) {.len = BK_UUID_LEN_128, .uuid = {.uuid128 = {iuuid[0], iuuid[1], iuuid[2], iuuid[3], iuuid[4], \
|
||||
iuuid[5], iuuid[6], iuuid[7], iuuid[8], iuuid[9], iuuid[10], iuuid[11], iuuid[12], iuuid[13], iuuid[14], iuuid[15]}}}
|
||||
#define BK_GATT_ATTR_CONTENT_128(iuuid) \
|
||||
{ \
|
||||
.len = BK_UUID_LEN_128, .uuid = {.uuid128 = {iuuid[0], iuuid[1], iuuid[2], iuuid[3], iuuid[4], \
|
||||
iuuid[5], iuuid[6], iuuid[7], iuuid[8], iuuid[9], iuuid[10], iuuid[11], iuuid[12], iuuid[13], iuuid[14], iuuid[15]} } \
|
||||
}
|
||||
|
||||
#define BK_GATT_PRIMARY_SERVICE_DECL(iuuid) \
|
||||
.att_desc =\
|
||||
{\
|
||||
.attr_type = BK_GATT_ATTR_TYPE(BK_GATT_UUID_PRI_SERVICE),\
|
||||
.attr_content = BK_GATT_ATTR_CONTENT(iuuid),\
|
||||
}
|
||||
#define BK_GATT_PRIMARY_SERVICE_DECL(iuuid) \
|
||||
.att_desc = \
|
||||
{ \
|
||||
.attr_type = BK_GATT_ATTR_TYPE(BK_GATT_UUID_PRI_SERVICE), \
|
||||
.attr_content = BK_GATT_ATTR_CONTENT(iuuid), \
|
||||
}
|
||||
|
||||
#define BK_GATT_PRIMARY_SERVICE_DECL_128(iuuid) \
|
||||
.att_desc =\
|
||||
{\
|
||||
.attr_type = BK_GATT_ATTR_TYPE(BK_GATT_UUID_PRI_SERVICE),\
|
||||
.attr_content = BK_GATT_ATTR_CONTENT_128(iuuid)\
|
||||
}
|
||||
#define BK_GATT_PRIMARY_SERVICE_DECL_128(iuuid) \
|
||||
.att_desc = \
|
||||
{ \
|
||||
.attr_type = BK_GATT_ATTR_TYPE(BK_GATT_UUID_PRI_SERVICE), \
|
||||
.attr_content = BK_GATT_ATTR_CONTENT_128(iuuid)}
|
||||
|
||||
#define BK_GATT_CHAR_DECL(iuuid, ilen, ivalue, iprop, iperm, irsp) \
|
||||
.att_desc = \
|
||||
{\
|
||||
.attr_type = BK_GATT_ATTR_TYPE(BK_GATT_UUID_CHAR_DECLARE),\
|
||||
.attr_content = BK_GATT_ATTR_CONTENT(iuuid),\
|
||||
.value = BK_GATT_ATTR_VALUE(ilen, ivalue),\
|
||||
.prop = iprop,\
|
||||
.perm = iperm,\
|
||||
},\
|
||||
.attr_control = {.auto_rsp = irsp}
|
||||
#define BK_GATT_CHAR_DECL(iuuid, ilen, ivalue, iprop, iperm, irsp) \
|
||||
.att_desc = \
|
||||
{ \
|
||||
.attr_type = BK_GATT_ATTR_TYPE(BK_GATT_UUID_CHAR_DECLARE), \
|
||||
.attr_content = BK_GATT_ATTR_CONTENT(iuuid), \
|
||||
.value = BK_GATT_ATTR_VALUE(ilen, ivalue), \
|
||||
.prop = iprop, \
|
||||
.perm = iperm, \
|
||||
}, \
|
||||
.attr_control = {.auto_rsp = irsp}
|
||||
|
||||
#define BK_GATT_CHAR_DECL_128(iuuid, ilen, ivalue, iprop, iperm, irsp) \
|
||||
.att_desc = \
|
||||
{\
|
||||
.attr_type = BK_GATT_ATTR_TYPE(BK_GATT_UUID_CHAR_DECLARE),\
|
||||
.attr_content = BK_GATT_ATTR_CONTENT_128(iuuid),\
|
||||
.value = BK_GATT_ATTR_VALUE(ilen, ivalue),\
|
||||
.prop = iprop,\
|
||||
.perm = iperm,\
|
||||
},\
|
||||
.attr_control = {.auto_rsp = irsp}
|
||||
.att_desc = \
|
||||
{ \
|
||||
.attr_type = BK_GATT_ATTR_TYPE(BK_GATT_UUID_CHAR_DECLARE), \
|
||||
.attr_content = BK_GATT_ATTR_CONTENT_128(iuuid), \
|
||||
.value = BK_GATT_ATTR_VALUE(ilen, ivalue), \
|
||||
.prop = iprop, \
|
||||
.perm = iperm, \
|
||||
}, \
|
||||
.attr_control = {.auto_rsp = irsp}
|
||||
|
||||
#define BK_GATT_CHAR_DESC_DECL(iuuid, ilen, ivalue, iperm, irsp) \
|
||||
.att_desc = \
|
||||
{\
|
||||
.attr_type = BK_GATT_ATTR_TYPE(iuuid),\
|
||||
.value = BK_GATT_ATTR_VALUE(ilen, ivalue),\
|
||||
.perm = iperm,\
|
||||
},\
|
||||
.attr_control = {.auto_rsp = irsp}
|
||||
.att_desc = \
|
||||
{ \
|
||||
.attr_type = BK_GATT_ATTR_TYPE(iuuid), \
|
||||
.value = BK_GATT_ATTR_VALUE(ilen, ivalue), \
|
||||
.perm = iperm, \
|
||||
}, \
|
||||
.attr_control = {.auto_rsp = irsp}
|
||||
|
||||
#define BK_GATT_CHAR_DESC_DECL_128(iuuid, ilen, ivalue, iperm, irsp) \
|
||||
.att_desc = \
|
||||
{\
|
||||
.attr_type = BK_GATT_ATTR_TYPE_128(iuuid),\
|
||||
.value = BK_GATT_ATTR_VALUE(ilen, ivalue),\
|
||||
.perm = iperm,\
|
||||
},\
|
||||
.attr_control = {.auto_rsp = irsp}
|
||||
.att_desc = \
|
||||
{ \
|
||||
.attr_type = BK_GATT_ATTR_TYPE_128(iuuid), \
|
||||
.value = BK_GATT_ATTR_VALUE(ilen, ivalue), \
|
||||
.perm = iperm, \
|
||||
}, \
|
||||
.attr_control = {.auto_rsp = irsp}
|
||||
|
||||
#define INVALID_ATTR_HANDLE 0
|
||||
|
||||
@ -111,62 +121,61 @@ static uint8_t s_password[64];
|
||||
static uint8_t s_cmd[64];
|
||||
static uint16_t s_conn_ind = ~0;
|
||||
|
||||
|
||||
static const bk_gatts_attr_db_t s_gatts_attr_db_service_boarding[] =
|
||||
{
|
||||
{
|
||||
BK_GATT_PRIMARY_SERVICE_DECL(0xfa00),
|
||||
},
|
||||
{
|
||||
BK_GATT_PRIMARY_SERVICE_DECL(0xfa00),
|
||||
},
|
||||
|
||||
{
|
||||
BK_GATT_CHAR_DECL(0xea01,
|
||||
0, NULL,
|
||||
BK_GATT_CHAR_PROP_BIT_NOTIFY,
|
||||
BK_GATT_PERM_READ,
|
||||
BK_GATT_RSP_BY_APP),
|
||||
},
|
||||
{
|
||||
BK_GATT_CHAR_DESC_DECL(BK_GATT_UUID_CHAR_CLIENT_CONFIG,
|
||||
sizeof(s_prop_cli_config), (uint8_t *)&s_prop_cli_config,
|
||||
BK_GATT_PERM_READ | BK_GATT_PERM_WRITE,
|
||||
BK_GATT_RSP_BY_APP),
|
||||
},
|
||||
{
|
||||
BK_GATT_CHAR_DECL(0xea01,
|
||||
0, NULL,
|
||||
BK_GATT_CHAR_PROP_BIT_NOTIFY,
|
||||
BK_GATT_PERM_READ,
|
||||
BK_GATT_RSP_BY_APP),
|
||||
},
|
||||
{
|
||||
BK_GATT_CHAR_DESC_DECL(BK_GATT_UUID_CHAR_CLIENT_CONFIG,
|
||||
sizeof(s_prop_cli_config), (uint8_t *)&s_prop_cli_config,
|
||||
BK_GATT_PERM_READ | BK_GATT_PERM_WRITE,
|
||||
BK_GATT_RSP_BY_APP),
|
||||
},
|
||||
|
||||
//operation
|
||||
{
|
||||
BK_GATT_CHAR_DECL(0xea02,
|
||||
0, NULL,
|
||||
BK_GATT_CHAR_PROP_BIT_WRITE,
|
||||
BK_GATT_PERM_WRITE,
|
||||
BK_GATT_RSP_BY_APP),
|
||||
},
|
||||
// operation
|
||||
{
|
||||
BK_GATT_CHAR_DECL(0xea02,
|
||||
0, NULL,
|
||||
BK_GATT_CHAR_PROP_BIT_WRITE,
|
||||
BK_GATT_PERM_WRITE,
|
||||
BK_GATT_RSP_BY_APP),
|
||||
},
|
||||
|
||||
//ssid
|
||||
{
|
||||
BK_GATT_CHAR_DECL(0xea05,
|
||||
sizeof(s_password), (uint8_t *)s_password,
|
||||
BK_GATT_CHAR_PROP_BIT_READ | BK_GATT_CHAR_PROP_BIT_WRITE,
|
||||
BK_GATT_PERM_READ | BK_GATT_PERM_WRITE,
|
||||
BK_GATT_AUTO_RSP),
|
||||
},
|
||||
// ssid
|
||||
{
|
||||
BK_GATT_CHAR_DECL(0xea05,
|
||||
sizeof(s_password), (uint8_t *)s_password,
|
||||
BK_GATT_CHAR_PROP_BIT_READ | BK_GATT_CHAR_PROP_BIT_WRITE,
|
||||
BK_GATT_PERM_READ | BK_GATT_PERM_WRITE,
|
||||
BK_GATT_AUTO_RSP),
|
||||
},
|
||||
|
||||
//password
|
||||
{
|
||||
BK_GATT_CHAR_DECL(0xea06,
|
||||
sizeof(s_ssid), (uint8_t *)s_ssid,
|
||||
BK_GATT_CHAR_PROP_BIT_READ | BK_GATT_CHAR_PROP_BIT_WRITE,
|
||||
BK_GATT_PERM_READ | BK_GATT_PERM_WRITE,
|
||||
BK_GATT_AUTO_RSP),
|
||||
},
|
||||
//helloyifa
|
||||
//cmd
|
||||
{
|
||||
BK_GATT_CHAR_DECL(0xea03,
|
||||
sizeof(s_cmd), (uint8_t *)s_cmd,
|
||||
BK_GATT_CHAR_PROP_BIT_READ | BK_GATT_CHAR_PROP_BIT_WRITE,
|
||||
BK_GATT_PERM_READ | BK_GATT_PERM_WRITE,
|
||||
BK_GATT_AUTO_RSP),
|
||||
},
|
||||
// password
|
||||
{
|
||||
BK_GATT_CHAR_DECL(0xea06,
|
||||
sizeof(s_ssid), (uint8_t *)s_ssid,
|
||||
BK_GATT_CHAR_PROP_BIT_READ | BK_GATT_CHAR_PROP_BIT_WRITE,
|
||||
BK_GATT_PERM_READ | BK_GATT_PERM_WRITE,
|
||||
BK_GATT_AUTO_RSP),
|
||||
},
|
||||
// helloyifa
|
||||
// cmd
|
||||
{
|
||||
BK_GATT_CHAR_DECL(0xea03,
|
||||
sizeof(s_cmd), (uint8_t *)s_cmd,
|
||||
BK_GATT_CHAR_PROP_BIT_READ | BK_GATT_CHAR_PROP_BIT_WRITE,
|
||||
BK_GATT_PERM_READ | BK_GATT_PERM_WRITE,
|
||||
BK_GATT_AUTO_RSP),
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
@ -176,67 +185,72 @@ static uint16_t s_char_desc_attr_handle = INVALID_ATTR_HANDLE;
|
||||
static uint16_t s_char_operation_char_handle = INVALID_ATTR_HANDLE;
|
||||
static uint16_t s_char_ssid_char_handle = INVALID_ATTR_HANDLE;
|
||||
static uint16_t s_char_password_char_handle = INVALID_ATTR_HANDLE;
|
||||
//helloyfia
|
||||
// helloyfia
|
||||
static uint16_t s_char_cmd_char_handle = INVALID_ATTR_HANDLE;
|
||||
|
||||
static uint16_t *const s_boarding_attr_handle_list[sizeof(s_gatts_attr_db_service_boarding) / sizeof(s_gatts_attr_db_service_boarding[0])] =
|
||||
{
|
||||
&s_service_attr_handle,
|
||||
&s_char_attr_handle,
|
||||
&s_char_desc_attr_handle,
|
||||
&s_char_operation_char_handle,
|
||||
&s_char_ssid_char_handle,
|
||||
&s_char_password_char_handle,
|
||||
//helloyifa
|
||||
&s_char_cmd_char_handle,
|
||||
{
|
||||
&s_service_attr_handle,
|
||||
&s_char_attr_handle,
|
||||
&s_char_desc_attr_handle,
|
||||
&s_char_operation_char_handle,
|
||||
&s_char_ssid_char_handle,
|
||||
&s_char_password_char_handle,
|
||||
// helloyifa
|
||||
&s_char_cmd_char_handle,
|
||||
};
|
||||
static boarding_state m_state = BOARDING_STATE_IDLE;
|
||||
int ble_notify_boarding_state(boarding_state state){
|
||||
if(m_state == state){
|
||||
static boarding_state m_state = BOARDING_STATE_IDLE;
|
||||
int ble_notify_boarding_state(boarding_state state)
|
||||
{
|
||||
if (m_state == state)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//在没有配置wifi情况下,不发送状态AP_NOFOUND PASSWORD_ERROR
|
||||
if(state== BOARDING_STATE_AP_NOFOUND && m_state != BOARDING_STATE_SETWIFI){
|
||||
// 在没有配置wifi情况下,不发送状态AP_NOFOUND PASSWORD_ERROR
|
||||
if (state == BOARDING_STATE_AP_NOFOUND && m_state != BOARDING_STATE_SETWIFI)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(state== BOARDING_STATE_PASSWORD_ERROR && m_state != BOARDING_STATE_SETWIFI){
|
||||
if (state == BOARDING_STATE_PASSWORD_ERROR && m_state != BOARDING_STATE_SETWIFI)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_state = state;
|
||||
uint8_t str_respone [32] = {0};
|
||||
memset(str_respone,0,sizeof(str_respone));
|
||||
uint8_t str_respone[32] = {0};
|
||||
memset(str_respone, 0, sizeof(str_respone));
|
||||
switch (state)
|
||||
{
|
||||
case BOARDING_STATE_IDLE:
|
||||
strcat((char*)&str_respone,"AT+STATE=0");
|
||||
break;
|
||||
case BOARDING_STATE_SCAN:
|
||||
strcat((char*)&str_respone,"AT+STATE=1");
|
||||
break;
|
||||
case BOARDING_STATE_SETWIFI:
|
||||
strcat((char*)&str_respone,"AT+STATE=2");
|
||||
break;
|
||||
case BOARDING_STATE_DONE:
|
||||
strcat((char*)&str_respone,"AT+STATE=3");
|
||||
break;
|
||||
case BOARDING_STATE_PASSWORD_ERROR:
|
||||
strcat((char*)&str_respone,"AT+STATE=6");
|
||||
break;
|
||||
case BOARDING_STATE_AP_NOFOUND:
|
||||
strcat((char*)&str_respone,"AT+STATE=7");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
{
|
||||
case BOARDING_STATE_IDLE:
|
||||
strcat((char *)&str_respone, "AT+STATE=0");
|
||||
break;
|
||||
case BOARDING_STATE_SCAN:
|
||||
strcat((char *)&str_respone, "AT+STATE=1");
|
||||
break;
|
||||
case BOARDING_STATE_SETWIFI:
|
||||
strcat((char *)&str_respone, "AT+STATE=2");
|
||||
break;
|
||||
case BOARDING_STATE_DONE:
|
||||
strcat((char *)&str_respone, "AT+STATE=3");
|
||||
break;
|
||||
case BOARDING_STATE_PASSWORD_ERROR:
|
||||
strcat((char *)&str_respone, "AT+STATE=6");
|
||||
break;
|
||||
case BOARDING_STATE_AP_NOFOUND:
|
||||
strcat((char *)&str_respone, "AT+STATE=7");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(strlen((char*)&str_respone) > 0){
|
||||
os_printf("notify:%s\r\n",str_respone);
|
||||
if (strlen((char *)&str_respone) > 0)
|
||||
{
|
||||
os_printf("notify:%s\r\n", str_respone);
|
||||
|
||||
wifi_boarding_notify(str_respone, strlen((char*)&str_respone));
|
||||
//uint8_t con_idx = s_conn_ind;
|
||||
//bk_ble_send_noti_value(con_idx, strlen((char*)&str_respone), str_respone, PRF_TASK_ID_BOARDING, BOARDING_IDX_CHAR_VALUE);
|
||||
}
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
// uint8_t con_idx = s_conn_ind;
|
||||
// bk_ble_send_noti_value(con_idx, strlen((char*)&str_respone), str_respone, PRF_TASK_ID_BOARDING, BOARDING_IDX_CHAR_VALUE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -458,53 +472,57 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
wboard_logi("password: %s", s_ble_boarding_info->password_value);
|
||||
}
|
||||
|
||||
|
||||
//<2F>ص<EFBFBD>
|
||||
if (s_ble_boarding_info && s_ble_boarding_info->set_wifi_cb)
|
||||
{
|
||||
//helloyifa
|
||||
// <20>ص<EFBFBD>
|
||||
if (s_ble_boarding_info && s_ble_boarding_info->set_wifi_cb)
|
||||
{
|
||||
// helloyifa
|
||||
be_set_smart_config_running();
|
||||
s_ble_boarding_info->set_wifi_cb(s_ble_boarding_info->ssid_value,s_ble_boarding_info->ssid_length,s_ble_boarding_info->password_value,s_ble_boarding_info->password_length);
|
||||
}
|
||||
s_ble_boarding_info->set_wifi_cb(s_ble_boarding_info->ssid_value, s_ble_boarding_info->ssid_length, s_ble_boarding_info->password_value, s_ble_boarding_info->password_length);
|
||||
}
|
||||
}
|
||||
//helloyifa
|
||||
// helloyifa
|
||||
else if (s_char_cmd_char_handle == param->handle)
|
||||
{
|
||||
bk_ble_gatts_get_attr_value(param->handle, &buff_size, &tmp_buff);
|
||||
if(param->len ==0 || param->value == NULL) return ret;
|
||||
uint8_t recv [param->len+1];
|
||||
os_memset(recv,0,sizeof(recv));
|
||||
if (param->len == 0 || param->value == NULL)
|
||||
return ret;
|
||||
uint8_t recv[param->len + 1];
|
||||
os_memset(recv, 0, sizeof(recv));
|
||||
os_memcpy((uint8_t *)recv, param->value, param->len);
|
||||
wboard_loge("recv: %s", recv);
|
||||
char* ptr;
|
||||
if (NULL != (ptr = strstr((char *)recv, "AT+SSID"))){
|
||||
char *ptr;
|
||||
if (NULL != (ptr = strstr((char *)recv, "AT+SSID")))
|
||||
{
|
||||
wboard_loge("start scan wifi!!");
|
||||
//<EFBFBD>ص<EFBFBD>
|
||||
// <EFBFBD>ص<EFBFBD>
|
||||
if (s_ble_boarding_info && s_ble_boarding_info->scan_wifi_cb)
|
||||
{
|
||||
s_ble_boarding_info->scan_wifi_cb();
|
||||
}
|
||||
}
|
||||
if (NULL != (ptr = strstr((char *)recv, "AT+SCAN"))){
|
||||
if (NULL != (ptr = strstr((char *)recv, "AT+SCAN")))
|
||||
{
|
||||
wboard_loge("start scan wifi!!");
|
||||
//<EFBFBD>ص<EFBFBD>
|
||||
// <EFBFBD>ص<EFBFBD>
|
||||
if (s_ble_boarding_info && s_ble_boarding_info->scan_wifi_cb)
|
||||
{
|
||||
s_ble_boarding_info->scan_wifi_cb();
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL != (ptr = strstr((char *)recv, "AT+WIFI"))){
|
||||
if (NULL != (ptr = strstr((char *)recv, "AT+WIFI")))
|
||||
{
|
||||
wboard_loge("recv wifi info!!");
|
||||
|
||||
char m_ssid[64] = {0};
|
||||
char m_pwd [64] = {0};
|
||||
memset(m_ssid,0,sizeof(m_ssid));
|
||||
memset(m_pwd,0,sizeof(m_pwd));
|
||||
sscanf((char *)recv,"AT+WIFI=%[^,],%[^,]", m_ssid,m_pwd);
|
||||
wboard_loge("%s %s ",m_ssid,m_pwd);
|
||||
//<2F><><EFBFBD><EFBFBD>SSID
|
||||
if(strlen(m_ssid) > 0){
|
||||
char m_ssid[64] = {0};
|
||||
char m_pwd[64] = {0};
|
||||
memset(m_ssid, 0, sizeof(m_ssid));
|
||||
memset(m_pwd, 0, sizeof(m_pwd));
|
||||
sscanf((char *)recv, "AT+WIFI=%[^,],%[^,]", m_ssid, m_pwd);
|
||||
wboard_loge("%s %s ", m_ssid, m_pwd);
|
||||
// <20><><EFBFBD><EFBFBD>SSID
|
||||
if (strlen(m_ssid) > 0)
|
||||
{
|
||||
if (s_ble_boarding_info->ssid_value)
|
||||
{
|
||||
os_free(s_ble_boarding_info->ssid_value);
|
||||
@ -512,10 +530,10 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
s_ble_boarding_info->ssid_length = 0;
|
||||
}
|
||||
|
||||
s_ble_boarding_info->ssid_length =strlen(m_ssid);
|
||||
s_ble_boarding_info->ssid_value = os_malloc(strlen(m_ssid)+1);
|
||||
s_ble_boarding_info->ssid_length = strlen(m_ssid);
|
||||
s_ble_boarding_info->ssid_value = os_malloc(strlen(m_ssid) + 1);
|
||||
|
||||
os_memset(s_ble_boarding_info->ssid_value, 0, strlen(m_ssid)+1);
|
||||
os_memset(s_ble_boarding_info->ssid_value, 0, strlen(m_ssid) + 1);
|
||||
os_memcpy((uint8_t *)s_ble_boarding_info->ssid_value, m_ssid, strlen(m_ssid));
|
||||
wboard_loge("ssid: %s", s_ble_boarding_info->ssid_value);
|
||||
}
|
||||
@ -527,10 +545,13 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
s_ble_boarding_info->password_length = 0;
|
||||
}
|
||||
|
||||
if(strlen(m_pwd) > 0){
|
||||
s_ble_boarding_info->password_length = 0 ;
|
||||
if (strlen(m_pwd) > 0)
|
||||
{
|
||||
s_ble_boarding_info->password_length = 0;
|
||||
s_ble_boarding_info->password_value = "";
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
s_ble_boarding_info->password_length = strlen(m_pwd);
|
||||
s_ble_boarding_info->password_value = os_malloc(strlen(m_pwd) + 1);
|
||||
|
||||
@ -539,17 +560,16 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
wboard_loge("password: %s", s_ble_boarding_info->password_value);
|
||||
}
|
||||
|
||||
//<EFBFBD>ص<EFBFBD>
|
||||
// <EFBFBD>ص<EFBFBD>
|
||||
if (s_ble_boarding_info && s_ble_boarding_info->set_wifi_cb)
|
||||
{
|
||||
//(char* ssid, int ssid_len ,char* password,int password_len);
|
||||
//helloyifa
|
||||
// helloyifa
|
||||
be_set_smart_config_running();
|
||||
wboard_loge("^^^be_set_smart_config_running!!");
|
||||
wboard_loge("^^^be_set_smart_config_running!!");
|
||||
|
||||
s_ble_boarding_info->set_wifi_cb(m_ssid,strlen(m_ssid),m_pwd,strlen(m_pwd));
|
||||
s_ble_boarding_info->set_wifi_cb(m_ssid, strlen(m_ssid), m_pwd, strlen(m_pwd));
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 7.蓝牙控制音量
|
||||
@ -580,7 +600,6 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
sprintf((char *)str_respone, "%s", "AT+VOLUME=OK");
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 蓝牙控制灯光亮度
|
||||
@ -630,10 +649,13 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
}
|
||||
else
|
||||
{
|
||||
int open = atoi(enable);
|
||||
if(open){
|
||||
int open = atoi(enable);
|
||||
if (open)
|
||||
{
|
||||
ws2812_open();
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
ws2812_close();
|
||||
}
|
||||
sprintf((char *)str_respone, "%s", "AT+BRIGHT_EN=OK");
|
||||
@ -660,10 +682,13 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
}
|
||||
else
|
||||
{
|
||||
int open = atoi(enable);
|
||||
if(open){
|
||||
int open = atoi(enable);
|
||||
if (open)
|
||||
{
|
||||
sleep_helper_open();
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
sleep_helper_close();
|
||||
}
|
||||
sprintf((char *)str_respone, "%s", "AT+SLEEP_EN=OK");
|
||||
@ -690,15 +715,16 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
else
|
||||
{
|
||||
int v = atoi(mode);
|
||||
switch(v){
|
||||
case 1:
|
||||
sleep_helper_set_mode(SLEEP_MODE_1);
|
||||
switch (v)
|
||||
{
|
||||
case 1:
|
||||
sleep_helper_set_mode(SLEEP_MODE_1);
|
||||
break;
|
||||
case 2:
|
||||
sleep_helper_set_mode(SLEEP_MODE_2);
|
||||
case 2:
|
||||
sleep_helper_set_mode(SLEEP_MODE_2);
|
||||
break;
|
||||
case 3:
|
||||
sleep_helper_set_mode(SLEEP_MODE_3);
|
||||
case 3:
|
||||
sleep_helper_set_mode(SLEEP_MODE_3);
|
||||
break;
|
||||
}
|
||||
sprintf((char *)str_respone, "%s", "AT+SLEEP_MODE=OK");
|
||||
@ -706,7 +732,8 @@ 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));
|
||||
}
|
||||
|
||||
else if(NULL != (ptr = strstr((char *)recv, "AT+RESET"))){
|
||||
else if (NULL != (ptr = strstr((char *)recv, "AT+RESET")))
|
||||
{
|
||||
extern int demo_erase_network_auto_reconnect_info();
|
||||
demo_erase_network_auto_reconnect_info();
|
||||
}
|
||||
@ -737,7 +764,6 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
sprintf((char *)str_respone, "%s", "AT+SLEEP_TIMEOUT=OK");
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
}
|
||||
|
||||
}
|
||||
else if (NULL != (ptr = strstr((char *)recv, "AT+BRIGHT_TIMEOUT=")))
|
||||
{
|
||||
@ -760,7 +786,6 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
sprintf((char *)str_respone, "%s", "AT+BRIGHT_TIMEOUT=OK");
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
*11.蓝牙控制助眠仪工作等级
|
||||
@ -800,7 +825,6 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
|
||||
sprintf((char *)str_respone, "AT+VERSION=%s", APPLICATION_VERSION);
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
|
||||
}
|
||||
|
||||
else if (NULL != (ptr = strstr((char *)recv, "AT+SETAIURL")))
|
||||
@ -817,13 +841,12 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
}
|
||||
else
|
||||
{
|
||||
wboard_loge("AI_URL:%s",ota_url);
|
||||
//int v = atoi(level);
|
||||
//sleep_helper_set_level(v);
|
||||
wboard_loge("AI_URL:%s", ota_url);
|
||||
// int v = atoi(level);
|
||||
// sleep_helper_set_level(v);
|
||||
sprintf((char *)str_respone, "%s", "AT+SETAIURL=OK");
|
||||
}
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
|
||||
}
|
||||
/**
|
||||
* 用于APP 查找设备
|
||||
@ -834,43 +857,55 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
ws2812_led_start_ota();
|
||||
rtos_delay_milliseconds(10000);
|
||||
ws2812_led_stop_ota();
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* 用于APP 校准电池
|
||||
*/
|
||||
else if (NULL != (ptr = strstr((char *)recv, "AT+BAT_CALIBRTATION")))
|
||||
else if (NULL != (ptr = strstr((char *)recv, "AT+BAT_CALIBRTATION")))
|
||||
{
|
||||
wboard_loge("AT+BAT_CALIBRTATION!!");
|
||||
|
||||
int ret = battery_calibration();
|
||||
int value = 0;
|
||||
char *eq_pos = strchr(ptr, '='); // 查找等号位置
|
||||
|
||||
bk_printf("AT+BAT_CALIBRTATION ret: %d\r\n", ret);
|
||||
uint8_t str_respone[32] = {0};
|
||||
memset(str_respone, 0, sizeof(str_respone));
|
||||
if(ret == 1){
|
||||
sprintf((char *)str_respone, "%s", "AT+BAT_CALIBRTATION=OK");
|
||||
}else{
|
||||
sprintf((char *)str_respone, "%s", "AT+BAT_CALIBRTATION=FAIL");
|
||||
if (eq_pos != NULL)
|
||||
{
|
||||
// 从等号后解析整数
|
||||
if (sscanf(eq_pos + 1, "%d", &value) == 1)
|
||||
{
|
||||
wboard_loge("AT+BAT_CALIBRTATION: %d", value);
|
||||
|
||||
int ret = battery_calibration(value);
|
||||
|
||||
bk_printf("AT+BAT_CALIBRTATION ret: %d\r\n", ret);
|
||||
uint8_t str_respone[32] = {0};
|
||||
memset(str_respone, 0, sizeof(str_respone));
|
||||
if (ret == 1)
|
||||
{
|
||||
sprintf((char *)str_respone, "%s", "AT+BAT_CALIBRTATION=OK");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf((char *)str_respone, "%s", "AT+BAT_CALIBRTATION=FAIL");
|
||||
}
|
||||
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
}
|
||||
/**
|
||||
* 12.获取设备状态
|
||||
发送: AT+STATE=?
|
||||
回复: AT+STATE=A,B,C,D,E,F,G,H
|
||||
A: WIFI 连接状态 0 - 表示当前没有连接WIFI 1- 当前已经连接wifi
|
||||
B: 设备音量 0 - 100 0 表示静音
|
||||
C: 设备灯光默认亮度 1 -100
|
||||
D: 助眠仪模式 0 - 3 0 表示关闭 1-3 分别代表三种模式
|
||||
E: 助眠仪等级 1 - 9 表示9个强度等级
|
||||
F: 电池电量 0-100
|
||||
G: 开灯延迟关闭时间 0-60 分钟
|
||||
H: 灯光当前是否打开 1 - 打开 0 关闭
|
||||
*/
|
||||
/**
|
||||
* 12.获取设备状态
|
||||
发送: AT+STATE=?
|
||||
回复: AT+STATE=A,B,C,D,E,F,G,H
|
||||
A: WIFI 连接状态 0 - 表示当前没有连接WIFI 1- 当前已经连接wifi
|
||||
B: 设备音量 0 - 100 0 表示静音
|
||||
C: 设备灯光默认亮度 1 -100
|
||||
D: 助眠仪模式 0 - 3 0 表示关闭 1-3 分别代表三种模式
|
||||
E: 助眠仪等级 1 - 9 表示9个强度等级
|
||||
F: 电池电量 0-100
|
||||
G: 开灯延迟关闭时间 0-60 分钟
|
||||
H: 灯光当前是否打开 1 - 打开 0 关闭
|
||||
*/
|
||||
else if (NULL != (ptr = strstr((char *)recv, "AT+STATE")))
|
||||
{
|
||||
wboard_loge("AT+STATE!!");
|
||||
@ -885,26 +920,27 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
os_printf("get sta link status fail!\n");
|
||||
}
|
||||
int connect_state = 0;
|
||||
if(link_status.state == WIFI_LINKSTATE_STA_GOT_IP){
|
||||
if (link_status.state == WIFI_LINKSTATE_STA_GOT_IP)
|
||||
{
|
||||
connect_state = 1;
|
||||
}
|
||||
os_printf("link_status.state:%d\n",link_status.state);
|
||||
int device_volme = speaker_volume_get_current();
|
||||
os_printf("link_status.state:%d\n", link_status.state);
|
||||
int device_volme = speaker_volume_get_current();
|
||||
int device_bright = lamp_get_bright();
|
||||
int sleep_mode = sleep_helper_get_mode();
|
||||
int sleep_level = sleep_helper_get_level();
|
||||
int sleep_mode = sleep_helper_get_mode();
|
||||
int sleep_level = sleep_helper_get_level();
|
||||
int sleep_work_time = sleep_helper_get_work_timeout();
|
||||
int battery_p = battery_get_percent();
|
||||
int battery_p = battery_get_percent();
|
||||
int bright_close_timeout = ws2812_get_work_timeout();
|
||||
int bright_open = ws2812_is_bright();
|
||||
sprintf((char *)str_respone, "AT+STATE=%d,%d,%d,%d,%d,%d,%d,%d,%d", connect_state,device_volme,device_bright,sleep_mode,sleep_level,sleep_work_time,battery_p,bright_close_timeout,bright_open);
|
||||
int bright_open = ws2812_is_bright();
|
||||
sprintf((char *)str_respone, "AT+STATE=%d,%d,%d,%d,%d,%d,%d,%d,%d", connect_state, device_volme, device_bright, sleep_mode, sleep_level, sleep_work_time, battery_p, bright_close_timeout, bright_open);
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
}
|
||||
|
||||
/**
|
||||
* 蓝牙控制OTA
|
||||
/**
|
||||
* 蓝牙控制OTA
|
||||
|
||||
*/
|
||||
*/
|
||||
else if (NULL != (ptr = strstr((char *)recv, "AT+OTA")))
|
||||
{
|
||||
wboard_loge("AT+OTA!!");
|
||||
@ -934,14 +970,17 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
{
|
||||
wboard_loge("OTA-->%s", ota_url);
|
||||
wboard_loge("OTA--len >%d", strlen(ota_url));
|
||||
//ws2812_led_start_ota();
|
||||
//lamp_http_ota_start(ota_url);
|
||||
//电量低于25 不允许执行OTA
|
||||
// ws2812_led_start_ota();
|
||||
// lamp_http_ota_start(ota_url);
|
||||
// 电量低于25 不允许执行OTA
|
||||
int battery = battery_get_percent();
|
||||
if(battery > 25){
|
||||
//iot_lamp_check_ota();
|
||||
if (battery > 25)
|
||||
{
|
||||
// iot_lamp_check_ota();
|
||||
lamp_http_ota_start(ota_url);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
app_event_send_msg(APP_EVT_LOW_VOLTAGE, 0);
|
||||
}
|
||||
free(ota_url);
|
||||
@ -955,22 +994,24 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
{
|
||||
uint8_t str_respone[32] = {0};
|
||||
memset(str_respone, 0, sizeof(str_respone));
|
||||
//电量低于25 不允许执行OTA
|
||||
// 电量低于25 不允许执行OTA
|
||||
int battery = battery_get_percent();
|
||||
if(battery > 25){
|
||||
if (battery > 25)
|
||||
{
|
||||
sprintf((char *)str_respone, "%s", "AT+CHECKOTA=1");
|
||||
iot_lamp_check_ota();
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
app_event_send_msg(APP_EVT_LOW_VOLTAGE, 0);
|
||||
sprintf((char *)str_respone, "%s", "AT+CHECKOTA=2");
|
||||
}
|
||||
wifi_boarding_notify(str_respone, strlen((char *)&str_respone));
|
||||
//wifi_boarding_notify(param->value,param->len);
|
||||
// wifi_boarding_notify(param->value,param->len);
|
||||
}
|
||||
//wifi_boarding_notify(param->value,param->len);
|
||||
// wifi_boarding_notify(param->value,param->len);
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
wboard_loge("invalid write handle %d", param->handle);
|
||||
@ -979,7 +1020,7 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
|
||||
if (param->need_rsp)
|
||||
{
|
||||
final_len = (param->len < buff_size - param->offset ? param->len : buff_size - param->offset);
|
||||
final_len = (param->len < buff_size - param->offset ? param->len : buff_size - param->offset);
|
||||
|
||||
if (tmp_buff)
|
||||
{
|
||||
@ -1043,8 +1084,6 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
wifi_boarding_notify(test_data, sizeof(test_data));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1115,21 +1154,20 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
param->remote_bda[2],
|
||||
param->remote_bda[1],
|
||||
param->remote_bda[0],
|
||||
param->conn_id
|
||||
);
|
||||
param->conn_id);
|
||||
|
||||
s_conn_ind = ~0;
|
||||
|
||||
//helloyifa
|
||||
//wifi_boarding_adv_stop();
|
||||
//wifi_boarding_adv_start();
|
||||
// helloyifa
|
||||
// wifi_boarding_adv_stop();
|
||||
// wifi_boarding_adv_start();
|
||||
|
||||
const bk_ble_gap_ext_adv_t ext_adv =
|
||||
{
|
||||
.instance = 0,
|
||||
.duration = 0,
|
||||
.max_events = 0,
|
||||
};
|
||||
{
|
||||
.instance = 0,
|
||||
.duration = 0,
|
||||
.max_events = 0,
|
||||
};
|
||||
|
||||
bk_ble_gap_adv_start(1, &ext_adv);
|
||||
}
|
||||
@ -1150,7 +1188,6 @@ static int32_t wifi_boarding_gatts_cb(bk_gatts_cb_event_t event, bk_gatt_if_t ga
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void dm_ble_gap_common_cb(bk_ble_gap_cb_event_t event, bk_ble_gap_cb_param_t *param)
|
||||
{
|
||||
wboard_logd("event %d", event);
|
||||
@ -1170,8 +1207,7 @@ static void dm_ble_gap_common_cb(bk_ble_gap_cb_event_t event, bk_ble_gap_cb_para
|
||||
evt->remote_bda[0],
|
||||
evt->status,
|
||||
evt->link_role,
|
||||
evt->hci_handle
|
||||
);
|
||||
evt->hci_handle);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1189,9 +1225,7 @@ static void dm_ble_gap_common_cb(bk_ble_gap_cb_event_t event, bk_ble_gap_cb_para
|
||||
evt->remote_bda_type,
|
||||
evt->status,
|
||||
evt->reason,
|
||||
evt->hci_handle
|
||||
);
|
||||
|
||||
evt->hci_handle);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1206,7 +1240,7 @@ static void dm_ble_gap_common_cb(bk_ble_gap_cb_event_t event, bk_ble_gap_cb_para
|
||||
|
||||
if (s_ble_sema != NULL)
|
||||
{
|
||||
rtos_set_semaphore( &s_ble_sema );
|
||||
rtos_set_semaphore(&s_ble_sema);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1296,7 +1330,6 @@ static void dm_ble_gap_common_cb(bk_ble_gap_cb_event_t event, bk_ble_gap_cb_para
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int wifi_boarding_init(ble_boarding_info_t *info)
|
||||
@ -1305,7 +1338,7 @@ int wifi_boarding_init(ble_boarding_info_t *info)
|
||||
|
||||
s_ble_boarding_info = info;
|
||||
|
||||
if(!s_ble_sema)
|
||||
if (!s_ble_sema)
|
||||
{
|
||||
ret = rtos_init_semaphore(&s_ble_sema, 1);
|
||||
|
||||
@ -1414,8 +1447,8 @@ int wifi_boarding_deinit()
|
||||
void dm_ble_gap_get_identity_addr(uint8_t *addr)
|
||||
{
|
||||
//
|
||||
//uint8_t base_mac[BK_MAC_ADDR_LEN] = {0};
|
||||
//bk_get_mac(base_mac, MAC_TYPE_BASE);
|
||||
// uint8_t base_mac[BK_MAC_ADDR_LEN] = {0};
|
||||
// bk_get_mac(base_mac, MAC_TYPE_BASE);
|
||||
//
|
||||
uint8_t *identity_addr = addr;
|
||||
bk_get_mac((uint8_t *)identity_addr, MAC_TYPE_BASE);
|
||||
@ -1438,11 +1471,11 @@ int wifi_boarding_adv_start(void)
|
||||
dm_ble_gap_get_identity_addr(identity_addr);
|
||||
|
||||
os_memcpy(current_addr, identity_addr, sizeof(identity_addr));
|
||||
wboard_loge("BT MAC %02x %02x %02x %02x %02x %02x ", current_addr[0],current_addr[1],current_addr[2],current_addr[3],current_addr[4],current_addr[5]);
|
||||
//current_addr[5] |= 0xc0;
|
||||
//current_addr[0]++;
|
||||
wboard_loge("BT MAC %02x %02x %02x %02x %02x %02x ", current_addr[0], current_addr[1], current_addr[2], current_addr[3], current_addr[4], current_addr[5]);
|
||||
// current_addr[5] |= 0xc0;
|
||||
// current_addr[0]++;
|
||||
|
||||
snprintf((char *)(adv_name), sizeof(adv_name) - 1, "iR58_%02X%02X",current_addr[1], current_addr[0]);
|
||||
snprintf((char *)(adv_name), sizeof(adv_name) - 1, "iR58_%02X%02X", current_addr[1], current_addr[0]);
|
||||
|
||||
wboard_logi("adv name %s", adv_name);
|
||||
|
||||
@ -1455,20 +1488,20 @@ int wifi_boarding_adv_start(void)
|
||||
}
|
||||
|
||||
bk_ble_gap_ext_adv_params_t adv_param =
|
||||
{
|
||||
.type = BK_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND,
|
||||
.interval_min = 120 * 1,
|
||||
.interval_max = 160 * 1,
|
||||
.channel_map = BK_ADV_CHNL_ALL,
|
||||
.filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
|
||||
.primary_phy = BK_BLE_GAP_PRI_PHY_1M,
|
||||
.secondary_phy = BK_BLE_GAP_PHY_1M,
|
||||
.sid = 0,
|
||||
.scan_req_notif = 0,
|
||||
.own_addr_type = BLE_ADDR_TYPE_RANDOM,//BLE_ADDR_TYPE_PUBLIC,
|
||||
};
|
||||
{
|
||||
.type = BK_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND,
|
||||
.interval_min = 120 * 1,
|
||||
.interval_max = 160 * 1,
|
||||
.channel_map = BK_ADV_CHNL_ALL,
|
||||
.filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
|
||||
.primary_phy = BK_BLE_GAP_PRI_PHY_1M,
|
||||
.secondary_phy = BK_BLE_GAP_PHY_1M,
|
||||
.sid = 0,
|
||||
.scan_req_notif = 0,
|
||||
.own_addr_type = BLE_ADDR_TYPE_RANDOM, // BLE_ADDR_TYPE_PUBLIC,
|
||||
};
|
||||
|
||||
ret = bk_ble_gap_set_adv_params(ADV_HANDLE, &adv_param);
|
||||
ret = bk_ble_gap_set_adv_params(ADV_HANDLE, &adv_param);
|
||||
|
||||
if (ret != kNoErr)
|
||||
{
|
||||
@ -1500,8 +1533,8 @@ int wifi_boarding_adv_start(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
#define BEKEN_COMPANY_ID (0x05F0)
|
||||
#define BOARDING_UUID (0xFE01)
|
||||
#define BEKEN_COMPANY_ID (0x05F0)
|
||||
#define BOARDING_UUID (0xFE01)
|
||||
|
||||
#if 0
|
||||
const uint8_t baording_service_uuid[16] =
|
||||
@ -1593,11 +1626,11 @@ int wifi_boarding_adv_start(void)
|
||||
}
|
||||
|
||||
const bk_ble_gap_ext_adv_t ext_adv =
|
||||
{
|
||||
.instance = 0,
|
||||
.duration = 0,
|
||||
.max_events = 0,
|
||||
};
|
||||
{
|
||||
.instance = 0,
|
||||
.duration = 0,
|
||||
.max_events = 0,
|
||||
};
|
||||
|
||||
ret = bk_ble_gap_adv_start(1, &ext_adv);
|
||||
|
||||
@ -1617,14 +1650,13 @@ int wifi_boarding_adv_start(void)
|
||||
|
||||
error:
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int wifi_boarding_adv_stop(void)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
|
||||
if(bk_bluetooth_get_status() != BK_BLUETOOTH_STATUS_ENABLED)
|
||||
if (bk_bluetooth_get_status() != BK_BLUETOOTH_STATUS_ENABLED)
|
||||
{
|
||||
wboard_loge("bluetooth not init !!!");
|
||||
return BK_FAIL;
|
||||
@ -1664,4 +1696,3 @@ int wifi_boarding_notify(uint8_t *data, uint16_t length)
|
||||
return BK_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user