ble_peripheral.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef BLE_PERIPHERAL_H__
  2. #define BLE_PERIPHERAL_H__
  3. #include <stdint.h>
  4. #include "_string.h"
  5. #include "nordic_common.h"
  6. #include "nrf.h"
  7. #include "ble_advdata.h"
  8. #include "ble_advertising.h"
  9. #include "ble_conn_params.h"
  10. #include "nrf_sdh.h"
  11. #include "nrf_sdh_soc.h"
  12. #include "nrf_sdh_ble.h"
  13. #include "nrf_ble_gatt.h"
  14. #include "nrf_ble_qwr.h"
  15. #include "app_timer.h"
  16. #include "app_error.h"
  17. #include "ble.h"
  18. #include "ble_err.h"
  19. #include "ble_hci.h"
  20. #include "ble_srv_common.h"
  21. #include "define.h"
  22. #include "app_button.h"
  23. #include "nrf_pwr_mgmt.h"
  24. #include "nrf_log.h"
  25. #include "nrf_log_ctrl.h"
  26. #include "nrf_log_default_backends.h"
  27. #include "ble_config.h"
  28. #if WECHAT_SERVER_ENABLED==1
  29. #include "ble_wechat.h"
  30. #include "mpbledev.h"
  31. #endif
  32. #if OWNED_SERVER_ENABLED==1
  33. #include "ble_owned.h"
  34. #endif
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. typedef void (*set_dfu_func)(bool stat);
  39. typedef struct
  40. {
  41. set_dfu_func dfu_func;
  42. bool dfu_stat;
  43. }ble_peripheral_s;
  44. typedef struct
  45. {
  46. uint8_t product_type;
  47. uint8_t dev_version;
  48. uint8_t dev_reg_stat;
  49. uint8_t bat_percent;
  50. uint8_t m_addr[BLE_GAP_ADDR_LEN]; //设备mac地址
  51. }ble_adv_manuf_data;
  52. #ifndef BLE_DEVICE_NAME
  53. #define BLE_DEVICE_NAME NRF_BLE_ADV_NAME // 设备名称字符串
  54. #endif
  55. #ifndef APP_BLE_OBSERVER_PRIO
  56. #define APP_BLE_OBSERVER_PRIO 3 //应用程序BLE事件监视者优先级,应用程序不能修改该数值
  57. #endif
  58. #ifndef APP_BLE_CONN_CFG_TAG
  59. #define APP_BLE_CONN_CFG_TAG 1 //SoftDevice BLE配置标志
  60. #endif
  61. uint32_t advertising_init(void);
  62. void Ble_Peripheral_Init(set_dfu_func func,uint16_t **conn_handle);
  63. void Peripheral_Start(void);
  64. void Peripheral_Stop(void);
  65. void ble_peripheral_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context);
  66. void user_ble_advertising_modes_config_set(ble_adv_modes_config_t const * const p_adv_modes_config);
  67. #if NRF_MODULE_ENABLED(BLE_DFU)
  68. void dfu_service_init(void);
  69. #endif
  70. void set_ble_tx_power_level(int8_t rssi);
  71. void set_ble_adv_interval(uint32_t time);
  72. extern bool m_ready_for_reset;//检查是否准备好关机
  73. extern uint8_t dev_reg_stat;
  74. extern uint32_t ble_adv_interval;
  75. extern uint32_t ble_adv_duration;
  76. extern bool ble_adv_stat;
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif // BLE_PERIPHERAL_H__
  81. /** @} */