12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- /*Includes ----------------------------------------------*/
- #include "system.h"
- #include "ble_comm.h"
- #include "hal_scan_manage.h"
- static scan_reslt_t scan_reslt_head ={
- .handle = NULL,
- .next =NULL,
- .scanname =NULL
- };
- void hal_ble_scan_result_Regist(scan_reslt_t *cb){
- scan_reslt_t *target = &scan_reslt_head;
- while(NULL != target->next){
- if(target->next == cb)return;//¼ì²éÊÇ·ñÒѾ´æÔÚ
- target = target->next;
- }
- cb->next = NULL;
- target->next = cb;
- }
- void hal_ble_scan_result_Clear(scan_reslt_t *cb){
- scan_reslt_t *target = &scan_reslt_head;
- while(NULL != target->next){
- if(cb == target->next){
- target->next = cb->next;
- return;
- }
- target = target->next;
- }
- }
- static void scan_report_cb(uint8_t *adv_data, uint16_t adv_data_len,int8_t rssi)
- {
- scan_reslt_t *target = &scan_reslt_head;
- while(NULL != target->next){
- if(NULL != target->next->scanname){
- if(advdata_name_find(adv_data, adv_data_len,target->next->scanname)){
- target->next->scanflag =1;
- }
- }
- target = target->next;
- }
- }
- static void hal_scan_process(void)
- {
- scan_reslt_t *target = &scan_reslt_head;
- while(NULL != target->next){
- if(target->next->scanflag){
- target->next->scanflag =0;
- if(target->next->handle)
- target->next->handle();
- }
- target = target->next;
- }
- }
- void hal_ble_scan_Init(void)
- {
- advdata_report_Evt_Regist(scan_report_cb);
- Process_Start(10,"hal_scan_process",hal_scan_process);
- }
|