FR801XH 通过LED2显示蓝牙连接状态



  • 0_1635907066443_eb939943-0459-4084-9ad3-e4fa32f9247d-image.png
    引入
    #include "driver_pmu.h"//LED2
    switch(p_msg->msg_evt)
    {
    case GATTC_MSG_LINK_CREATE:
    //蓝牙连接
    if(gatt_get_mtu(p_msg->conn_idx)<247){
    p_msg->param.msg.msg_len=247;//MTU长度设置
    gatt_mtu_exchange_req(p_msg->conn_idx);
    }
    ool_write(PMU_REG_LED_CTRL, 0x04);//LED LOW
    SEGGER_RTT_printf(0,"Bluetooth connectivity\r\n");
    break;
    case GATTC_MSG_LINK_LOST:
    //蓝牙断开,重新开始广播
    ool_write(PMU_REG_LED_CTRL, 0x00);//LED HIGH
    ali_ota_start_advertising();
    SEGGER_RTT_printf(0,"Bluetooth Disconnect\r\n");
    break;
    }
    1.蓝牙连接成功通知:GATTC_MSG_LINK_CREATE
    点亮LED2函数
    ool_write(PMU_REG_LED_CTRL, 0x04);//LED LOW

    2.蓝牙断开通知:GATTC_MSG_LINK_LOST
    熄灭LED2函数
    ool_write(PMU_REG_LED_CTRL, 0x00);//LED HIGH

    蓝牙断开后要更新广播服务,不然搜索不到蓝牙
    ali_ota_start_advertising();

    到这里就实现了通过LED2显示蓝牙连接状态。



  • @zhangmm
    ool_write(PMU_REG_LED_CTRL, 0x04);//LED HIGH
    ool_write(PMU_REG_LED_CTRL, 0x04);//LED LOW
    开发板LED高电平点亮,低电平熄灭