#ifndef __BLE_COMM__ #define __BLE_COMM__ #include "sdk_common.h" #include "ble_db_discovery.h" #include "sdk_errors.h" #include "app_error.h" #include "app_util.h" #include "bsp_btn_ble.h" #include "ble.h" #include "ble_gap.h" #include "ble_hci.h" #include "nrf_sdh.h" #include "nrf_sdh_ble.h" #include "nrf_sdh_soc.h" #include "ble_nus_c.h" #include "nrf_ble_gatt.h" #include "nrf_pwr_mgmt.h" #include "nrf_ble_scan.h" #include "app_timer.h" #include "ble_conn_state.h" #include "SEGGER_RTT.h" #include "nrf_delay.h" #include "main.h" #include "queue.h" #include "ringframe.h" // <<< Use Configuration Wizard in Context Menu >>>\r\n #define APP_BLE_CONN_CFG_TAG 1 // USE_LADDR - 广播名称是否添加地址后缀 #ifndef USE_LADDR #define USE_LADDR 1 #endif // USENAMEFR - 扫描是否采用名字匹配 #ifndef USENAMEFR #define USENAMEFR 1 #endif // USEMACNAME - 采用mac地址作为蓝牙名称 #ifndef USEMACNAME #define USEMACNAME 0 #endif // USEFIFO - 采用FIFO方式发送 #ifndef USEFIFO #define USEFIFO 1 #endif #define TARFET_LEN_MAX NRF_BLE_SCAN_NAME_MAX_LEN // BLE_PRINTF - 调试信息 #ifndef BLE_PRINTF #define BLE_PRINTF 0 #endif #if BLE_PRINTF #define BLE_PRINT(...) SEGGER_RTT_printf(0, __VA_ARGS__) #else #define BLE_PRINT(...) ; #endif #define APP_ERR_BASE 0 enum { APP_SUCCESS = APP_ERR_BASE, APP_ERR_DISCONN, APP_ERR_CONNECTED, APP_ERR_PARAMERR, APP_ERR_OVERLENGTH, APP_ERR_BUSY, }; void err(int err_num); typedef void (*Ble_receive_handler_t)(unsigned char *, int); typedef void (*Ble_evt_cb)(void); unsigned int send_bytes_server(uint8_t *bytes, uint16_t len); unsigned int send_bytes_client(unsigned char *bytes, uint16_t len); void host_init(Ble_receive_handler_t receive_handler); void slave_init(Ble_receive_handler_t receive_handler); unsigned char slave_isconnect(void); unsigned char host_isconnect(void); unsigned int host_set_scan_name(char *name, int len); unsigned int slave_set_adv_name(char *name, int len); void slave_get_advname_len(int *len); void slave_get_advname(char *name, int len); int Ble_Host_Connectd_Evt_Regist(Ble_evt_cb cb); int Ble_Host_Disconn_Evt_Regist(Ble_evt_cb cb); int Ble_Slave_Connectd_Evt_Regist(Ble_evt_cb cb); int Ble_Slave_Disconn_Evt_Regist(Ble_evt_cb cb); unsigned int Ble_update_conn_interval(float min_conn_interval, float max_conn_interval); unsigned int slave_update_conn_interval_request(float min_conn_interval, float max_conn_interval); void advertising_stop(void); void advertising_start(void); void scan_start(void); //关掉扫描直接调用 void nrf_ble_scan_stop(void); uint8_t Slave_Get7_5ms_interval(void); void slave_disconnect(void); void host_disconnect(void); void slave_get_conn_params(ble_gap_conn_params_t *p); void host_get_conn_params(ble_gap_conn_params_t *p); void slave_adv_init(void); signed char slave_get_rssi(void); signed char host_get_rssi(void); void IMU_Process_motion_queue(uint8_t IS_HOST, int32_t time_stamp, int16_t* _acc,int16_t* _gry, int16_t* front_mag, int16_t* back_mag, uint8_t _rssi); void IMU_Rec_data(uint8_t* pdat,uint8_t len); void IMU_Dtalige(void); void send_bytes_client_pcs(void); #endif