#include #include "yc11xx.h" #include "yc11xx_uart.h" #include "yc11xx_gpio.h" #include "yc_timer.h" #include "ipc.h" #include "yc_lpm.h" #include "system.h" #include "att.h" #include "yc11xx_bt_interface.h" #include "core_cm0.h" #define adv_len 30 /* dataPtr: adv receive data buf; len: receive data len */ typedef struct { uint8_t adv_type; uint8_t adv_rssi; uint8_t mac[6]; uint8_t adv_data_len; uint8_t ad_tye; uint16_t ad_id; uint8_t adv_data[100]; }ADV_ParseDef; #define ADV_IND 0 #define ADV_DIRECT_IND 1 #define ADV_NONCONN_IND 2 #define SCAN_REQ 3 #define SCAN_RSP 4 #define CONNECT_REQ 5 #define ADV_SCAN_IND 6 //#define adv_parse void adv_receive_back(uint8_t len,uint8_t *dataPtr) { #ifdef adv_parse int adv_type= *(dataPtr); int rssi = *(dataPtr+1); uint8_t mac[6]; printf("receive len=%d\r\n",len); switch(adv_type) { case 0: printf("\r\nadv type: ADV_IND\r\n"); break; case 1: printf("\r\nadv type: ADV_DIRECT_IND\r\n"); break; case 2: printf("\r\nadv type: ADV_NONCONN_IND\r\n"); break; case 3: printf("\r\nadv type: SCAN_REQ\r\n"); return; // break; case 4: printf("\r\nadv type: SCAN_RSP\r\n"); return; // break; case 5: printf("\r\nadv type: CONNECT_REQ\r\n"); return; // break; case 6: printf("\r\nadv type: ADV_SCAN_IND\r\n"); break; } printf("\r\n RSSI: -%x\r\n",rssi); memcpy(mac,dataPtr+2,6); printf("\r\n MAC: %x %x %x %x %x %x \r\n",mac[5],mac[4],mac[3],mac[2],mac[1],mac[0]); printf("receive data=\r\n"); for(int i=0;i