zoukankan      html  css  js  c++  java
  • 5.2蓝牙配网

    我们使用蓝牙为开发板配网连接路由器,并使用NTP来获取网络时间。下载蓝牙配网软件:https://pan.baidu.com/s/18Wox5lCUAU29nyLhingYLw
    提取码:6666 ,在主程序中建立蓝牙配网的任务:

    在任务中调用APIble_oneshot(4)配置模式为蓝牙配网:
    void ble_task(void)
    {
    u32 cnt=0;
    u32 i=0;
    struct tls_ethif *ethif;

    LED_Init();
    bt_enable(uart_1,TLS_BT_LOG_NONE);
    tls_os_time_delay(HZ);//enable之后扫描需要做一点延迟,否则会出现not ready情形
    ethif=tls_netif_get_ethif();
    init_wifi_config();//用于配置wifi相关设置如自动连接等
    printf("onshoot in progress
    ");
    ble_oneshot(4);//demo_connect_net中关于oneshoot模式
    printf("configing...");//等待配置过程中
    while(tls_wifi_get_oneshot_flag())//0 oneshot close 1 oneshotopen
    tls_os_time_delay(HZ);//当oneshot打开时延时1s
    while(1)
    {
    
    
        if(ethif->status)
    	{
    
    		ntp_updata_time();//获取ntp服务器函数,参照ntp.c demo拿取ntp服务器数据
    		tls_os_time_delay(HZ);
    		printf("更新第 %d 次time
    ",++i);
    	}
    
    	else
    	{
    		printf("press key 3s...
    ");
    		tls_os_time_delay(3*HZ);
    	}
    }
    

    }

    程序编译下载到开发板运行后使用蓝牙配网软件(WMBleWiFi)进行一键配网出现蓝牙名称为WM-*********开头的蓝牙,配置好wifi名字和密码即可联网。注意此时需要连接的wifi为2.4GHZ.配网成功后,无需每次上电配网,重启后自动联网获取ntp时间。配网完成后,串口会一直获取ntp时间。

  • 相关阅读:
    datagridview 保存为excel输出
    将excel导入到datatable
    Json 转换为c#数组
    css 没有图片则隐藏或者显示默认图片
    模拟Get请求
    根据多个字符分隔字符串
    DbHelperSQL
    数据库相关
    json对象
    ajax滚动条懒加载
  • 原文地址:https://www.cnblogs.com/doiting/p/14109215.html
Copyright © 2011-2022 走看看