123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #ifndef BLE_CENTRAL_H__
- #define BLE_CENTRAL_H__
- #include <stdint.h>
- #include <string.h>
- #include "nordic_common.h"
- #include "nrf.h"
- #include "ble_advdata.h"
- #include "ble_advertising.h"
- #include "ble_conn_params.h"
- #include "nrf_sdh.h"
- #include "nrf_sdh_soc.h"
- #include "nrf_sdh_ble.h"
- #include "nrf_ble_gatt.h"
- #include "nrf_ble_qwr.h"
- #include "app_timer.h"
- #include "app_error.h"
- #include "ble.h"
- #include "ble_err.h"
- #include "ble_hci.h"
- #include "ble_srv_common.h"
- #include "define.h"
- #include "app_button.h"
- #include "nrf_pwr_mgmt.h"
- #include "nrf_log.h"
- #include "nrf_log_ctrl.h"
- #include "nrf_log_default_backends.h"
- #include "ble_owned_c.h"
- #include "ble_conn_state.h"
- #include "nrf_ble_scan.h"
- #include "ble_db_discovery.h"
- #include "ble_config.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifndef BLE_DEVICE_NAME
- #define BLE_DEVICE_NAME NRF_BLE_ADV_NAME // 设备名称字符串
- #endif
- #ifndef APP_BLE_OBSERVER_PRIO
- #define APP_BLE_OBSERVER_PRIO 3 //应用程序BLE事件监视者优先级,应用程序不能修改该数值
- #endif
- #ifndef APP_BLE_CONN_CFG_TAG
- #define APP_BLE_CONN_CFG_TAG 1 //SoftDevice BLE配置标志
- #endif
-
- typedef void (* ble_central_wr_handler_t)(uint8_t *data,uint16_t len);
- typedef bool (* ble_central_scan_adv_handler_t)(const ble_gap_evt_adv_report_t * p_adv_report);
- typedef void (* ble_central_scan_timeout_t)(void);
- typedef void (* ble_central_scan_connect_t)(bool stat);
- typedef void (* ble_central_scan_disconnect_t)(void);
-
- typedef struct
- {
- ble_central_wr_handler_t wr_evt_handler;
- ble_central_scan_adv_handler_t scan_adv_evt_handler;
- ble_central_scan_timeout_t scan_timeout_handler;
- ble_central_scan_connect_t scan_connect_handler;
- ble_central_scan_disconnect_t scan_disconnect_handler;
- nrf_ble_scan_filter_type_t filter_type;
- void const * p_data;
- }ble_central_s;
- void on_ble_central_evt(ble_evt_t const * p_ble_evt);
- void Ble_Central_Scan_Filter_Init(bool stat);
- void Ble_Scan_Start(void);
- void Ble_Central_Init(void);
- int8_t get_Handle_Idx(uint16_t handle);
- uint32_t Ble_Send_ToDev(uint8_t idx,uint8_t *data,uint8_t len);
- void Ble_Central_Set_Wr_Evt_Handler(ble_central_wr_handler_t evt_handler);
- void Ble_Central_Set_Scan_Adv_Evt_Handler(ble_central_scan_adv_handler_t evt_handler);
- void Ble_Central_Set_Scan_Timeout_Evt_Handler(ble_central_scan_timeout_t evt_handler);
- void Ble_Central_Set_Scan_Connect_Evt_Handler(ble_central_scan_connect_t evt_handler);
- void Ble_Central_Set_Filter_Type(nrf_ble_scan_filter_type_t type,void const * p_data);
- void Ble_Central_Disconnect(int idx);
- extern int8_t adv_rssi[];
- extern uint16_t m_center_handle[];
- extern uint8_t m_target_periph_addr[BLE_CENTRAL_LINK_MAXCOUNT][BLE_GAP_ADDR_LEN];
- #ifdef __cplusplus
- }
- #endif
- #endif // BLE_CENTRAL_H__
- /** @} */
|