123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- #ifndef BLE_LBS_C_H__
- #define BLE_LBS_C_H__
- #include <stdint.h>
- #include "ble.h"
- #include "ble_db_discovery.h"
- #include "ble_srv_common.h"
- #include "nrf_ble_gq.h"
- #include "nrf_sdh_ble.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define BLE_LBS_C_DEF(_name) \
- static ble_lbs_c_t _name; \
- NRF_SDH_BLE_OBSERVER(_name ## _obs, \
- BLE_LBS_C_BLE_OBSERVER_PRIO, \
- ble_lbs_c_on_ble_evt, &_name)
- #define BLE_LBS_C_ARRAY_DEF(_name, _cnt) \
- static ble_lbs_c_t _name[_cnt]; \
- NRF_SDH_BLE_OBSERVERS(_name ## _obs, \
- BLE_LBS_C_BLE_OBSERVER_PRIO, \
- ble_lbs_c_on_ble_evt, &_name, _cnt)
- #define LBS_UUID_BASE {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, \
- 0xDE, 0xEF, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00}
- #define LBS_UUID_SERVICE 0x1523
- #define LBS_UUID_BUTTON_CHAR 0x1524
- #define LBS_UUID_LED_CHAR 0x1525
- typedef enum
- {
- BLE_LBS_C_EVT_DISCOVERY_COMPLETE = 1,
- BLE_LBS_C_EVT_BUTTON_NOTIFICATION
- } ble_lbs_c_evt_type_t;
- typedef struct
- {
- uint8_t button_state;
- } ble_button_t;
- typedef struct
- {
- uint16_t button_cccd_handle;
- uint16_t button_handle;
- uint16_t led_handle;
- } lbs_db_t;
- typedef struct
- {
- ble_lbs_c_evt_type_t evt_type;
- uint16_t conn_handle;
- union
- {
- ble_button_t button;
- lbs_db_t peer_db;
- } params;
- } ble_lbs_c_evt_t;
- typedef struct ble_lbs_c_s ble_lbs_c_t;
- typedef void (* ble_lbs_c_evt_handler_t) (ble_lbs_c_t * p_ble_lbs_c, ble_lbs_c_evt_t * p_evt);
- struct ble_lbs_c_s
- {
- uint16_t conn_handle;
- lbs_db_t peer_lbs_db;
- ble_lbs_c_evt_handler_t evt_handler;
- ble_srv_error_handler_t error_handler;
- uint8_t uuid_type;
- nrf_ble_gq_t * p_gatt_queue;
- };
- typedef struct
- {
- ble_lbs_c_evt_handler_t evt_handler;
- nrf_ble_gq_t * p_gatt_queue;
- ble_srv_error_handler_t error_handler;
- } ble_lbs_c_init_t;
- uint32_t ble_lbs_c_init(ble_lbs_c_t * p_ble_lbs_c, ble_lbs_c_init_t * p_ble_lbs_c_init);
- void ble_lbs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context);
- uint32_t ble_lbs_c_button_notif_enable(ble_lbs_c_t * p_ble_lbs_c);
- void ble_lbs_on_db_disc_evt(ble_lbs_c_t * p_ble_lbs_c, const ble_db_discovery_evt_t * p_evt);
- uint32_t ble_lbs_c_handles_assign(ble_lbs_c_t * p_ble_lbs_c,
- uint16_t conn_handle,
- const lbs_db_t * p_peer_handles);
- uint32_t ble_lbs_led_status_send(ble_lbs_c_t * p_ble_lbs_c, uint8_t status);
- #ifdef __cplusplus
- }
- #endif
- #endif
|