蓝牙配网
This commit is contained in:
parent
0c7a59823c
commit
5d137b6406
Binary file not shown.
@ -7,7 +7,10 @@
|
||||
"${workspaceFolder}/beken378/driver/include",
|
||||
"${workspaceFolder}/rt-thread/components/drivers/include",
|
||||
"${workspaceFolder}/rt-thread/include",
|
||||
"${workspaceFolder}/drivers"
|
||||
"${workspaceFolder}/drivers",
|
||||
"${workspaceFolder}/beken378/func/mbedtls/mbedtls-2.27.0/library",
|
||||
"${workspaceFolder}/beken378/func/include",
|
||||
"${workspaceFolder}/beken378/func/at_server/mqtt"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
|
@ -37,6 +37,46 @@
|
||||
"utility": "c",
|
||||
"app_sec.h": "c",
|
||||
"bkdriverflash.h": "c",
|
||||
"flash.h": "c"
|
||||
"flash.h": "c",
|
||||
"easyflash.h": "c",
|
||||
"saradc_intf.h": "c",
|
||||
"app_voice_player.h": "c",
|
||||
"charge.h": "c",
|
||||
"ef_def.h": "c",
|
||||
"ring_queue.h": "c",
|
||||
"player.h": "c",
|
||||
"mqtt_client.h": "c",
|
||||
"belon_ble.h": "c",
|
||||
"drv_oled.h": "c",
|
||||
"finsh.h": "c",
|
||||
"rtthread.h": "c",
|
||||
"ate_app.h": "c",
|
||||
"app.h": "c",
|
||||
"func_pub.h": "c",
|
||||
"app_temperature.h": "c",
|
||||
"mqtt_sample.h": "c",
|
||||
"mqtt_t.h": "c",
|
||||
"stdbool.h": "c",
|
||||
"qcloud_iot_common.h": "c",
|
||||
"mqtt_client_net.h": "c",
|
||||
"network_interface.h": "c",
|
||||
"_at_svr_opts.h": "c",
|
||||
"at_svr_opts.h": "c",
|
||||
"utils_list.h": "c",
|
||||
"atsvr_param_check.h": "c",
|
||||
"qcloud_iot_export_mqtt.h": "c",
|
||||
"include.h": "c",
|
||||
"rtdbg.h": "c",
|
||||
"wlan_ui_pub.h": "c",
|
||||
"rw_msg_pub.h": "c",
|
||||
"ble_pub.h": "c",
|
||||
"rtos_pub.h": "c",
|
||||
"error.h": "c",
|
||||
"power_save_pub.h": "c",
|
||||
"ieee802_11_demo.h": "c",
|
||||
"role_launch.h": "c",
|
||||
"rw_pub.h": "c",
|
||||
"ethernet_intf.h": "c",
|
||||
"sa_station.h": "c"
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ if GetDepend('RT_USING_DFS_ROMFS') == False:
|
||||
|
||||
group = DefineGroup('Application', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "app_voice_player.h"
|
||||
#ifdef PKG_USING_EASYFLASH
|
||||
#include "easyflash.h"
|
||||
|
||||
#endif
|
||||
|
||||
#include "saradc_intf.h"
|
||||
@ -25,6 +26,8 @@
|
||||
#include "ring_queue.h"
|
||||
#include "opus_encoder.h"
|
||||
#include "charge.h"
|
||||
#include "mqtt_client.h"
|
||||
|
||||
static app_temperature_info_t temperature_info;
|
||||
//static app_dev_info_t dev_info;
|
||||
static app_box_info_t box_info;
|
||||
@ -37,6 +40,10 @@ static beken_timer_t timer_idle;
|
||||
|
||||
int start_bind_detect = 0;
|
||||
int hall_key_down_count = 0;
|
||||
|
||||
uint32_t hall_first_down_tick = 0; // 记录第一次合盖的tick
|
||||
#define HALL_BIND_WINDOW_MS 5000
|
||||
|
||||
int hall_io_state = 0;
|
||||
|
||||
static ADC_OBJ box_batt_adc;
|
||||
@ -52,7 +59,11 @@ rt_thread_t tid_show_detect_temp;
|
||||
|
||||
static RingQueue ring_queue;
|
||||
|
||||
extern mqtt_client client; // 确保你能访问到mqtt_sample.c里的client对象
|
||||
|
||||
// 全局变量
|
||||
extern char last_ssid[33] ;
|
||||
extern char last_password[65];
|
||||
/**
|
||||
* 当前绑定的设备
|
||||
*/
|
||||
@ -112,10 +123,12 @@ int temperature_adv_get_name(recv_adv_t *r_ind,char *name){
|
||||
*/
|
||||
void temperature_adv_callback(recv_adv_t *r_ind)
|
||||
{
|
||||
|
||||
//获取BLE 设备名称
|
||||
char str_name[12] ={0};
|
||||
int ret = temperature_adv_get_name(r_ind,str_name);
|
||||
signed char rssi = (signed char)r_ind->rssi;
|
||||
|
||||
if(ret){
|
||||
#if 0
|
||||
bk_printf("ble dev (%s): %02x:%02x:%02x:%02x:%02x:%02x,rssi:%d\r\n",str_name,r_ind->adv_addr[0], r_ind->adv_addr[1], r_ind->adv_addr[2],
|
||||
@ -128,6 +141,7 @@ void temperature_adv_callback(recv_adv_t *r_ind)
|
||||
}
|
||||
//不等于 IT12 跳过!
|
||||
if(strstr(str_name,BLE_TEMPERATURE_DEVICE_IT12) == NULL){
|
||||
//bk_printf("%s\r\n",str_name);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -242,9 +256,17 @@ void temperature_adv_callback(recv_adv_t *r_ind)
|
||||
|
||||
//如果当前温度和之前相同 不刷新温度
|
||||
uint16_t temp_body = temperature_info.temperature_body;
|
||||
if(last_body_temp == temp_body){
|
||||
//return;
|
||||
|
||||
if(temp_body < 20){ //异常温度值
|
||||
bk_printf("temp_body == 0 \r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// if(last_body_temp == temp_body){
|
||||
// bk_printf("last_body_temp == temp_body \r\n");
|
||||
// return;
|
||||
// }
|
||||
|
||||
last_body_temp = temp_body;
|
||||
app_enter_ui(UI_SHOW_TEMPERATURE);
|
||||
|
||||
@ -295,11 +317,24 @@ void temperature_adv_callback(recv_adv_t *r_ind)
|
||||
voice_player_play_tts(VOICE_CN_DETECT_FINISH);
|
||||
rt_thread_mdelay(1500);
|
||||
voice_player_play_temperature(mean_value);
|
||||
mqtt_upload_temperature(mean_value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//MQTT上传温度
|
||||
void mqtt_upload_temperature(uint16_t t_value){
|
||||
uint16_t xy = t_value/100; //整数
|
||||
uint16_t y = xy % 10 ;//个位
|
||||
uint16_t x = (xy / 10) % 10 ;//十位
|
||||
uint16_t z = t_value/10%10 ;//小数点后一位
|
||||
char msg[64];
|
||||
rt_sprintf(msg, "{\"temperature\":%d%d.%d°C}", x,y,z);
|
||||
paho_mqtt_publish(&client, QOS1, "testtopic/2247", msg, strlen(msg));
|
||||
bk_printf("MQTT publish: %s\n", msg);
|
||||
}
|
||||
|
||||
|
||||
UINT32 usb_power_is_pluged(void)
|
||||
{
|
||||
@ -400,6 +435,7 @@ void app_show_box_battery(){
|
||||
//OLED_DrawCircle(15, 20, 7);
|
||||
OLED_ShowString(36,8,(u8 *)str_batt,24,1);
|
||||
}
|
||||
rt_kprintf("%s\r\n",str_batt);
|
||||
OLED_Refresh();
|
||||
}
|
||||
|
||||
@ -765,11 +801,26 @@ void timer_hall_detect_callback(void *arg){
|
||||
}
|
||||
hall_io_state = hall;
|
||||
box_info.hall_state = hall;
|
||||
uint32_t now_tick = rt_tick_get() * 1000 / RT_TICK_PER_SECOND; //当前开关盖的tick
|
||||
//rt_kprintf("now_tick :%d\r\n",now_tick);
|
||||
|
||||
if(hall == 0){
|
||||
|
||||
if(!start_bind_detect){
|
||||
start_bind_detect = 1;
|
||||
}
|
||||
|
||||
if(hall_key_down_count == 0){//记录第一次开盖的时间
|
||||
hall_first_down_tick = now_tick;
|
||||
rt_kprintf("hall_first_down_tick :%d\r\n",hall_first_down_tick);
|
||||
}else{
|
||||
// 判断是否超出5秒
|
||||
if(now_tick - hall_first_down_tick > HALL_BIND_WINDOW_MS){
|
||||
hall_key_down_count = 0;
|
||||
hall_first_down_tick = now_tick;
|
||||
}
|
||||
}
|
||||
|
||||
hall_key_down_count ++;
|
||||
rt_kprintf("detect hall down ,count :%d\r\n",hall_key_down_count);
|
||||
|
||||
@ -783,10 +834,12 @@ void timer_hall_detect_callback(void *arg){
|
||||
rtos_stop_timer(&timer_poweroff);
|
||||
}
|
||||
|
||||
if(start_bind_detect && hall_key_down_count == 5){
|
||||
// 只有在5秒内且开关盖次数达到5才进入绑定
|
||||
if(start_bind_detect && hall_key_down_count == 5 && (now_tick - hall_first_down_tick <= HALL_BIND_WINDOW_MS)){
|
||||
rt_kprintf("enter bind !!!\r\n");
|
||||
start_bind_detect = 0;
|
||||
hall_key_down_count = 0;
|
||||
hall_first_down_tick = 0;
|
||||
|
||||
rt_memset(ble_device_mac,0,sizeof(ble_device_mac));
|
||||
//收到的信号值 区域0 为越好
|
||||
@ -799,8 +852,14 @@ void timer_hall_detect_callback(void *arg){
|
||||
voice_player_play_tts(VOICE_CN_SEARCH_DEVICE);
|
||||
rtos_start_timer(&timer_bind);
|
||||
}
|
||||
|
||||
// 如果超时未达到5次,重置开关盖计数器
|
||||
if(now_tick - hall_first_down_tick > HALL_BIND_WINDOW_MS){
|
||||
hall_key_down_count = 0;
|
||||
hall_first_down_tick = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 中断触发的回调函数
|
||||
@ -859,7 +918,7 @@ static void box_adc_detect_callback(int new_mv, void *user_data)
|
||||
cnt = 0;
|
||||
rt_kprintf("adc channel%d voltage:%d,%x\r\n",box_batt_adc.channel,new_mv,box_batt_adc.user_data);
|
||||
int bat_volt = new_mv*2;
|
||||
int batt_min = 3300;
|
||||
int batt_min = 2500; //3300
|
||||
int batt_max = 4200;
|
||||
rt_kprintf("battery_calc --> bat_volt:%d\n",bat_volt);
|
||||
if (bat_volt < batt_min) {
|
||||
@ -907,7 +966,60 @@ void temperature_led_ble(bool onoff){
|
||||
}
|
||||
}
|
||||
|
||||
void connnect_wifi(char *oob_ssid,char *connect_key){//连接wifi
|
||||
/*定义一个结构体,用于传入参数*/
|
||||
network_InitTypeDef_st wNetConfig;
|
||||
int len;
|
||||
|
||||
/*把这个结构体置空*/
|
||||
os_memset(&wNetConfig, 0x0, sizeof(network_InitTypeDef_st));
|
||||
|
||||
/*检查SSID的长度,不能超过32字节*/
|
||||
len = os_strlen(oob_ssid);
|
||||
if(SSID_MAX_LEN < len)
|
||||
{
|
||||
bk_printf("ssid name more than 32 Bytes\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*将SSID跟密码传入结构体*/
|
||||
os_strcpy((char *)wNetConfig.wifi_ssid, oob_ssid);
|
||||
os_strcpy((char *)wNetConfig.wifi_key, connect_key);
|
||||
|
||||
/*当前为客户端模式*/
|
||||
wNetConfig.wifi_mode = BK_STATION;
|
||||
/*采用DHCP CLIENT的方式获得,从路由器动态获取IP地址*/
|
||||
wNetConfig.dhcp_mode = DHCP_CLIENT;
|
||||
wNetConfig.wifi_retry_interval = 100;
|
||||
bk_printf("ssid:%s key:%s\r\n", wNetConfig.wifi_ssid, wNetConfig.wifi_key);
|
||||
/*启动WiFi连接*/
|
||||
bk_wlan_start(&wNetConfig);
|
||||
//rt_thread_mdelay(5000);
|
||||
}
|
||||
|
||||
// 读取最新联网记录
|
||||
void wifi_read_ssid_pass(char *ssid, size_t ssid_len, char *password, size_t pass_len){
|
||||
char *t_ssid = ef_get_env(BLE_WIFI_FLASH_KEY_SSID);
|
||||
char *t_pass = ef_get_env(BLE_WIFI_FLASH_KEY_PASS);
|
||||
if(t_ssid) {
|
||||
strncpy(last_ssid, t_ssid, ssid_len - 1);
|
||||
last_ssid[ssid_len - 1] = '\0';
|
||||
}
|
||||
if(t_pass) {
|
||||
strncpy(last_password, t_pass, pass_len - 1);
|
||||
last_password[pass_len - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_init(){
|
||||
wifi_read_ssid_pass(last_ssid, sizeof(last_ssid), last_password, sizeof(last_password));
|
||||
if(last_ssid[0] != '\0' && last_password[0] != '\0') {
|
||||
bk_printf("Auto connect WiFi: SSID=%s, PASSWORD=%s\r\n", last_ssid, last_password);
|
||||
connnect_wifi(last_ssid, last_password);
|
||||
}else{
|
||||
bk_printf("NOT WiFi INFO\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
void temperature_init(void){
|
||||
|
||||
@ -944,8 +1056,13 @@ void temperature_init(void){
|
||||
app_enter_ui(UI_SHOW_MEMORY_INFO);
|
||||
//app_enter_ui(UI_WAIT_TEMPERATURE);
|
||||
|
||||
bk_wlan_status_register_cb(wifi_status_cb);
|
||||
//自动联网
|
||||
wifi_init();
|
||||
|
||||
//初始化BLE
|
||||
belon_ble_active();
|
||||
|
||||
//启动BLE MASTER 扫描BLE测温设备
|
||||
belon_ble_init_scan();
|
||||
rt_thread_mdelay(100);
|
||||
@ -956,6 +1073,7 @@ void temperature_init(void){
|
||||
rtos_start_timer(&timer_detect);
|
||||
|
||||
|
||||
//wifi_app_init("1603-5G","88888888");
|
||||
|
||||
//初始化HALL按键检测
|
||||
box_switch_init();
|
||||
|
@ -161,10 +161,13 @@ typedef enum
|
||||
UI_SHOW_MEMORY_INFO
|
||||
}app_ui_mode;
|
||||
|
||||
|
||||
void temperature_init(void);
|
||||
void temperature_adv_callback(recv_adv_t *r_ind);
|
||||
|
||||
void mqtt_upload_temperature(uint16_t t_value);
|
||||
int mqtt_start(int argc, char **argv);
|
||||
void app_enter_bind_mode(bool enter);
|
||||
void connnect_wifi(char *oob_ssid,char *connect_key);
|
||||
/**
|
||||
* 保存最新的一次记录
|
||||
*/
|
||||
|
@ -124,7 +124,7 @@ void voice_player_init()
|
||||
{
|
||||
audio_device_init();
|
||||
audio_device_set_rate(16000);
|
||||
audio_device_set_volume(90);
|
||||
audio_device_set_volume(30);
|
||||
audio_device_open();
|
||||
|
||||
//audio_device_mic_open();
|
||||
|
@ -5,11 +5,12 @@
|
||||
#include "ble_pub.h"
|
||||
#include "drv_oled.h"
|
||||
#include "flash.h"
|
||||
|
||||
|
||||
#include "wlan_ui_pub.h"
|
||||
#include "rw_pub.h"
|
||||
#include "belon_ble.h"
|
||||
#include "app_temperature.h"
|
||||
|
||||
|
||||
#if (CFG_BLE_VERSION == BLE_VERSION_5_2)
|
||||
#include "app_ble.h"
|
||||
#include "app_sdp.h"
|
||||
@ -18,6 +19,8 @@
|
||||
#include "app_sec.h"
|
||||
#endif
|
||||
#include "kernel_mem.h"
|
||||
#include "easyflash.h"
|
||||
|
||||
#define BUILD_UINT16(loByte, hiByte) \
|
||||
((uint16_t)(((loByte) & 0x00FF) + (((hiByte) & 0x00FF) << 8)))
|
||||
|
||||
@ -29,8 +32,17 @@
|
||||
#define INDICATE_CHARACTERISTIC_128 {0x02,0xFF,0,0,0x34,0x56,0,0,0,0,0x28,0x37,0,0,0,0}
|
||||
#define NOTIFY_CHARACTERISTIC_128 {0x03,0xFF,0,0,0x34,0x56,0,0,0,0,0x28,0x37,0,0,0,0}
|
||||
|
||||
#define BLE_WIFI_FLASH_KEY_SSID "wifi_ssid"
|
||||
#define BLE_WIFI_FLASH_KEY_PASS "wifi_pass"
|
||||
// 全局变量
|
||||
char last_ssid[33] = {0};
|
||||
char last_password[65] = {0};
|
||||
|
||||
static const uint8_t test_svc_uuid[16] = {0xFF,0xFF,0,0,0x34,0x56,0,0,0,0,0x28,0x37,0,0,0,0};
|
||||
app_dev_config_t dev_config = {0};
|
||||
extern int hostapd_scan_started; //扫描wifi全局变量
|
||||
#define BLE_IDLE_TIMEOUT_MS 10000 // 10秒无操作超时
|
||||
static beken_timer_t ble_idle;
|
||||
|
||||
enum
|
||||
{
|
||||
@ -168,6 +180,88 @@ void ble_cmd_cb(ble_cmd_t cmd, ble_cmd_param_t *param)
|
||||
}
|
||||
|
||||
|
||||
void scan_cb(void *ctxt, uint8_t param){//扫描wifi
|
||||
int ret;
|
||||
ScanResult_adv apList;
|
||||
if (bk_wlan_ap_is_up() > 0 || hostapd_scan_started)
|
||||
ret = wlan_ap_scan_result(&apList);
|
||||
else
|
||||
ret = wlan_sta_scan_result(&apList);
|
||||
|
||||
if (!ret) {
|
||||
int ap_num = apList.ApNum;
|
||||
int i;
|
||||
int offset = 0;
|
||||
char msg[256] = {0};
|
||||
|
||||
offset += snprintf(msg + offset, sizeof(msg) - offset, "AT+SSID=");
|
||||
for (i = 0; i < ap_num; i++)
|
||||
if(strcmp(apList.ApList[i].ssid, "") != 0){//过滤掉空SSID
|
||||
offset += snprintf(msg + offset, sizeof(msg) - offset, "%s", apList.ApList[i].ssid);
|
||||
offset += snprintf(msg + offset, sizeof(msg) - offset, ",");
|
||||
}
|
||||
bk_printf("AT+SSID=%s\r\n", msg);
|
||||
bk_ble_send_ntf_value(strlen(msg), (uint8_t*)msg, 0, TEST_IDX_FF03_VAL_VALUE); //发送notify
|
||||
os_free(apList.ApList);
|
||||
}
|
||||
}
|
||||
|
||||
void ble_report_state(int state)//发送状态值
|
||||
{
|
||||
char msg[32];
|
||||
snprintf(msg, sizeof(msg), "AT+STATE=%d", state);
|
||||
bk_ble_send_ntf_value(strlen(msg), (uint8_t*)msg, 0, TEST_IDX_FF03_VAL_VALUE);
|
||||
}
|
||||
|
||||
void wifi_save_ssid_pass(const char *ssid, const char *password)//保存最后一次连接的wifi信息
|
||||
{
|
||||
EfErrCode result;
|
||||
result = ef_set_env(BLE_WIFI_FLASH_KEY_SSID, ssid);
|
||||
result = ef_set_env(BLE_WIFI_FLASH_KEY_PASS, password);
|
||||
result = ef_save_env();
|
||||
if(result == EF_NO_ERR)
|
||||
bk_printf("wifi_save_ssid_pass success!\r\n");
|
||||
else
|
||||
bk_printf("wifi_save_ssid_pass failed!\r\n");
|
||||
}
|
||||
|
||||
void wifi_status_cb(void *param)//注册WIFI回调
|
||||
{
|
||||
LinkStatusTypeDef *status = (LinkStatusTypeDef *)param;
|
||||
//char *argv[] = {"mqtt_start"};
|
||||
bk_printf("wifi_status_cb: conn_state=%d\r\n", status->conn_state);
|
||||
if(status->conn_state == 12) {
|
||||
bk_printf("WiFi: SSID=%s, PASSWORD=%s\r\n", last_ssid, last_password);
|
||||
wifi_save_ssid_pass(last_ssid, last_password);
|
||||
ble_report_state(3);//连接成功
|
||||
//mqtt_start(1, argv);
|
||||
}
|
||||
}
|
||||
|
||||
void ble_connnect_wifi(uint8_t data[]){
|
||||
char ssid[33] = {0};
|
||||
char password[65] = {0};
|
||||
char *p = strchr((char *)data + 8, ',');
|
||||
rtos_reload_timer(&ble_idle);
|
||||
if(p) {
|
||||
size_t ssid_len = p - ((char *)data + 8);
|
||||
if(ssid_len < sizeof(ssid)) {
|
||||
strncpy(ssid, (char *)data + 8, ssid_len);
|
||||
ssid[ssid_len] = '\0';
|
||||
strncpy(password, p + 1, sizeof(password) - 1);
|
||||
// 连接WiFi
|
||||
strncpy(last_ssid, ssid, sizeof(last_ssid)-1);
|
||||
strncpy(last_password, password, sizeof(last_password)-1);
|
||||
ble_report_state(2); // 开始连接
|
||||
connnect_wifi(ssid,password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ble_idle_timeout_cb(void *parameter){
|
||||
ble_report_state(0); // 无操作
|
||||
}
|
||||
|
||||
void ble_notice_cb(ble_notice_t notice, void *param)
|
||||
{
|
||||
switch (notice) {
|
||||
@ -179,7 +273,6 @@ void ble_notice_cb(ble_notice_t notice, void *param)
|
||||
write_req_t *w_req = (write_req_t *)param;
|
||||
bk_printf("write_cb:conn_idx:%d, prf_id:%d, add_id:%d, len:%d, data[0]:%02x\r\n",
|
||||
w_req->conn_idx, w_req->prf_id, w_req->att_idx, w_req->len, w_req->value[0]);
|
||||
|
||||
bk_printf("data:%s\r\n",w_req->value);
|
||||
uint8_t data[32]="";
|
||||
memcpy(data, w_req->value, w_req->len);
|
||||
@ -192,6 +285,18 @@ void ble_notice_cb(ble_notice_t notice, void *param)
|
||||
//flash_write((uint8_t *)&dev_config, sizeof(dev_config), (UINT32)0x1FD000);
|
||||
|
||||
}
|
||||
|
||||
if(strstr((char *)data,"AT+SCAN")!=NULL){ //扫描wifi命令:AT+SCAN
|
||||
bk_printf("start WiFi scan...\r\n");
|
||||
rtos_reload_timer(&ble_idle);
|
||||
ble_report_state(1); // 开始扫描
|
||||
mhdr_scanu_reg_cb(scan_cb, 0);
|
||||
bk_wlan_start_scan();
|
||||
}
|
||||
|
||||
if(strncmp((char *)data, "AT+WIFI:", 8) == 0){ //连接WiFi命令:AT+WIFI:SSID,PASSWORD
|
||||
ble_connnect_wifi(data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BLE_5_READ_EVENT:
|
||||
@ -343,6 +448,8 @@ void ble_notice_cb(ble_notice_t notice, void *param)
|
||||
case BLE_5_CREATE_DB:
|
||||
{
|
||||
create_db_t *cd_ind = (create_db_t *)param;
|
||||
rtos_init_timer(&ble_idle, BLE_IDLE_TIMEOUT_MS, ble_idle_timeout_cb, NULL);
|
||||
rtos_start_timer(&ble_idle);
|
||||
bk_printf("cd_ind:prf_id:%d, status:%d\r\n", cd_ind->prf_id, cd_ind->status);
|
||||
break;
|
||||
}
|
||||
@ -711,7 +818,8 @@ void belon_ble_init_scan() {
|
||||
struct scan_param scan_info;
|
||||
scan_info.channel_map = 7;
|
||||
scan_info.interval = 100;
|
||||
scan_info.window = 30;
|
||||
scan_info.window = 60; //window大小越接近interval 广播包漏掉的越少,但耗能更高
|
||||
|
||||
actv_idx = app_ble_get_idle_actv_idx_handle(SCAN_ACTV);
|
||||
bk_printf("actv_idx_scan : (%d) \r\n",actv_idx);
|
||||
bk_ble_scan_start(actv_idx, &scan_info, ble_cmd_cb);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef BELON_CONFIG_H_
|
||||
#define BELON_CONFIG_H_
|
||||
|
||||
#define BLE_WIFI_FLASH_KEY_SSID "wifi_ssid"
|
||||
#define BLE_WIFI_FLASH_KEY_PASS "wifi_pass"
|
||||
#include "stdint.h"
|
||||
|
||||
typedef struct
|
||||
@ -22,5 +23,7 @@ void belon_ble_init_adv();
|
||||
void belon_ble_scan_start();
|
||||
void belon_ble_scan_stop();
|
||||
|
||||
void wifi_status_cb(void *param);
|
||||
|
||||
#endif // BELON_CONFIG_H_
|
||||
|
||||
|
@ -64,6 +64,8 @@
|
||||
static int wlan_app_init(void);
|
||||
|
||||
#include "app_temperature.h"
|
||||
#include "mqtt_t.h"
|
||||
|
||||
extern const struct romfs_dirent romfs_root;
|
||||
#define DFS_ROMFS_ROOT (&romfs_root)
|
||||
extern rt_err_t rt_audio_codec_hw_init(void);
|
||||
@ -73,7 +75,7 @@ extern void user_main( beken_thread_arg_t args );
|
||||
extern int rt_hw_flash_disk_readonly_init(const char *name, uint32_t base, uint32_t sector_size, uint32_t capacity);
|
||||
extern void rt_hw_wdg_start(int argc, char **argv);
|
||||
extern int bk_wlan_dtim_rf_ps_mode_enable(void );
|
||||
|
||||
//extern int mqtt_start(int argc, char **argv);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@ -165,9 +167,13 @@ static int wlan_app_init(void)
|
||||
app_start();
|
||||
//iic_bus_attach();
|
||||
temperature_init();
|
||||
|
||||
|
||||
//opous_encoder_start();
|
||||
|
||||
//rt_pin_mode(5, PIN_MODE_OUTPUT);
|
||||
// char *mqtt_argv[] = {"mqtt_start"};
|
||||
// mqtt_start(1, mqtt_argv);
|
||||
//rt_pin_mode(5, PIN_MODE_OUTPUT);
|
||||
//rt_pin_write(5, PIN_HIGH);
|
||||
|
||||
//rt_pin_mode(36, PIN_MODE_OUTPUT);
|
||||
|
13
beken_rtt_sdk_release-SDK_3.0.76/applications/mqtt_t.h
Normal file
13
beken_rtt_sdk_release-SDK_3.0.76/applications/mqtt_t.h
Normal file
@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef __MQTT_SAMPLE_H__
|
||||
#define __MQTT_SAMPLE_H__
|
||||
|
||||
int mqtt_start(int argc, char **argv);
|
||||
int mqtt_stop(int argc, char **argv);
|
||||
int mqtt_publish(int argc, char **argv);
|
||||
int mqtt_subscribe(int argc, char **argv);
|
||||
int mqtt_unsubscribe(int argc, char **argv);
|
||||
|
||||
#endif
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user