ble_peripheral.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #if NRF_BLE_ADVDATA_INCLUDE_BAT == 1
  50. uint8_t bat_percent;
  51. #else
  52. uint8_t value_null;
  53. #endif
  54. uint8_t m_addr[BLE_GAP_ADDR_LEN]; //设备mac地址
  55. }ble_adv_manuf_data;
  56. #ifndef BLE_DEVICE_NAME
  57. #define BLE_DEVICE_NAME NRF_BLE_ADV_NAME // 设备名称字符串
  58. #endif
  59. #ifndef APP_BLE_OBSERVER_PRIO
  60. #define APP_BLE_OBSERVER_PRIO 3 //应用程序BLE事件监视者优先级,应用程序不能修改该数值
  61. #endif
  62. #ifndef APP_BLE_CONN_CFG_TAG
  63. #define APP_BLE_CONN_CFG_TAG 1 //SoftDevice BLE配置标志
  64. #endif
  65. uint32_t advertising_init(void);
  66. void Ble_Peripheral_Init(set_dfu_func func,uint16_t **conn_handle);
  67. void Peripheral_Start(void);
  68. void Peripheral_Stop(void);
  69. void ble_peripheral_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context);
  70. void user_ble_advertising_modes_config_set(ble_adv_modes_config_t const * const p_adv_modes_config);
  71. #if NRF_MODULE_ENABLED(BLE_DFU)
  72. void dfu_service_init(void);
  73. #endif
  74. void set_ble_tx_power_level(int8_t rssi);
  75. void set_ble_adv_interval(uint32_t time);
  76. extern bool m_ready_for_reset;//检查是否准备好关机
  77. extern uint8_t dev_reg_stat;
  78. extern uint32_t ble_adv_interval;
  79. extern uint32_t ble_adv_duration;
  80. extern bool ble_adv_stat;
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif // BLE_PERIPHERAL_H__
  85. /** @} */