中科蓝汛--AB5335系列 蓝牙信号超出距离的处理

1.超出距离的消息处理
会执行到下面这个函数的消息处理

void bt_emit_notice(uint evt, u32 param)
case BT_NOTICE_LOSTCONNECT:
        connect_lost_flag = 1;
        piano_res_play(T_WARNING_NEXT_TRACK, 3);    //“滴”一声
        break;

2.超出距离重新连接
会执行void func_bt_disp_status(void)

 switch (f_bt.disp_status) {
       ......
         case BT_STA_CONNECTED:
            connect_lost_flag = 0;
            led_bt_connected();
            break;
        ......

3.在定时器处理蓝牙超出距离的灯闪
usr_tmr5ms_isr

 if ((cnt_5ms % 20) == 0){

        if( connt_lost_flag){
            count_bt_lost++;
            count_bt_lost_led++;
            if(count_bt_lost ==100){//10S timer process
            msg_enqueue(EVT_BT_LOSTCONNECT);
            count_bt_lost= 0;
            }
        }

        if(count_bt_lost_led == 5){
            led_on();
            rled_off();
        }else if(count_bt_lost_led == 10){
            led_off();
            rled_off();
            count_bt_lost_led=0;
        }

    }

4.超出距离提示音

提示音最好放到消息处理中播放

  msg_bt.c
  
  case EVT_BT_LOSTCONNECT:
        piano_res_play(T_WARNING_NEXT_TRACK, 3);    //“滴”一声
        break;

5.超出距离后重新连接

void bt_emit_notice(uint evt, u32 param)函数需要做一下处理,否则会一直嘀嘀响

 case BT_NOTICE_CONNECTED://连接上清除标志位
        connt_lost_flag = 0;
发布了65 篇原创文章 · 获赞 36 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/qq_40860986/article/details/103303313