123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845 |
- extern "C" {
- enum BLE_GATTS_SVCS
- {
- SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE,
- SD_BLE_GATTS_INCLUDE_ADD,
- SD_BLE_GATTS_CHARACTERISTIC_ADD,
- SD_BLE_GATTS_DESCRIPTOR_ADD,
- SD_BLE_GATTS_VALUE_SET,
- SD_BLE_GATTS_VALUE_GET,
- SD_BLE_GATTS_HVX,
- SD_BLE_GATTS_SERVICE_CHANGED,
- SD_BLE_GATTS_RW_AUTHORIZE_REPLY,
- SD_BLE_GATTS_SYS_ATTR_SET,
- SD_BLE_GATTS_SYS_ATTR_GET,
- SD_BLE_GATTS_INITIAL_USER_HANDLE_GET,
- SD_BLE_GATTS_ATTR_GET,
- SD_BLE_GATTS_EXCHANGE_MTU_REPLY
- };
- enum BLE_GATTS_EVTS
- {
- BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE,
- BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST,
- BLE_GATTS_EVT_SYS_ATTR_MISSING,
- BLE_GATTS_EVT_HVC,
- BLE_GATTS_EVT_SC_CONFIRM,
- BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST,
- BLE_GATTS_EVT_TIMEOUT,
- BLE_GATTS_EVT_HVN_TX_COMPLETE
- };
- enum BLE_GATTS_CFGS
- {
- BLE_GATTS_CFG_SERVICE_CHANGED = BLE_GATTS_CFG_BASE,
- BLE_GATTS_CFG_ATTR_TAB_SIZE,
- };
- will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */
- typedef struct
- {
- uint8_t hvn_tx_queue_size;
- } ble_gatts_conn_cfg_t;
- typedef struct
- {
- ble_gap_conn_sec_mode_t read_perm;
- ble_gap_conn_sec_mode_t write_perm;
- uint8_t vlen :1;
- uint8_t vloc :2;
- uint8_t rd_auth :1;
- uint8_t wr_auth :1;
- } ble_gatts_attr_md_t;
- typedef struct
- {
- ble_uuid_t const *p_uuid;
- ble_gatts_attr_md_t const *p_attr_md;
- uint16_t init_len;
- uint16_t init_offs;
- uint16_t max_len;
- uint8_t *p_value;
- } ble_gatts_attr_t;
- typedef struct
- {
- uint16_t len;
- uint16_t offset;
- uint8_t *p_value;
- } ble_gatts_value_t;
- typedef struct
- {
- uint8_t format;
- int8_t exponent;
- uint16_t unit;
- uint8_t name_space;
- uint16_t desc;
- } ble_gatts_char_pf_t;
- typedef struct
- {
- ble_gatt_char_props_t char_props;
- ble_gatt_char_ext_props_t char_ext_props;
- uint8_t const *p_char_user_desc;
- uint16_t char_user_desc_max_size;
- uint16_t char_user_desc_size;
- ble_gatts_char_pf_t const *p_char_pf;
- ble_gatts_attr_md_t const *p_user_desc_md;
- ble_gatts_attr_md_t const *p_cccd_md;
- ble_gatts_attr_md_t const *p_sccd_md;
- } ble_gatts_char_md_t;
- typedef struct
- {
- uint16_t value_handle;
- uint16_t user_desc_handle;
- uint16_t cccd_handle;
- uint16_t sccd_handle;
- } ble_gatts_char_handles_t;
- typedef struct
- {
- uint16_t handle;
- uint8_t type;
- uint16_t offset;
- uint16_t *p_len;
- uint8_t const *p_data;
- } ble_gatts_hvx_params_t;
- typedef struct
- {
- uint16_t gatt_status;
- uint8_t update : 1;
- uint16_t offset;
- uint16_t len;
- uint8_t const *p_data;
- } ble_gatts_authorize_params_t;
- typedef struct
- {
- uint8_t type;
- union {
- ble_gatts_authorize_params_t read;
- ble_gatts_authorize_params_t write;
- } params;
- } ble_gatts_rw_authorize_reply_params_t;
- typedef struct
- {
- uint8_t service_changed : 1;
- } ble_gatts_cfg_service_changed_t;
- typedef struct
- {
- uint32_t attr_tab_size;
- } ble_gatts_cfg_attr_tab_size_t;
- typedef union
- {
- ble_gatts_cfg_service_changed_t service_changed;
- ble_gatts_cfg_attr_tab_size_t attr_tab_size;
- } ble_gatts_cfg_t;
- typedef struct
- {
- uint16_t handle;
- ble_uuid_t uuid;
- uint8_t op;
- uint8_t auth_required;
- uint16_t offset;
- uint16_t len;
- uint8_t data[1];
- } ble_gatts_evt_write_t;
- typedef struct
- {
- uint16_t handle;
- ble_uuid_t uuid;
- uint16_t offset;
- } ble_gatts_evt_read_t;
- typedef struct
- {
- uint8_t type;
- union {
- ble_gatts_evt_read_t read;
- ble_gatts_evt_write_t write;
- } request;
- } ble_gatts_evt_rw_authorize_request_t;
- typedef struct
- {
- uint8_t hint;
- } ble_gatts_evt_sys_attr_missing_t;
- typedef struct
- {
- uint16_t handle;
- } ble_gatts_evt_hvc_t;
- typedef struct
- {
- uint16_t client_rx_mtu;
- } ble_gatts_evt_exchange_mtu_request_t;
- typedef struct
- {
- uint8_t src;
- } ble_gatts_evt_timeout_t;
- typedef struct
- {
- uint8_t count;
- } ble_gatts_evt_hvn_tx_complete_t;
- typedef struct
- {
- uint16_t conn_handle;
- union
- {
- ble_gatts_evt_write_t write;
- ble_gatts_evt_rw_authorize_request_t authorize_request;
- ble_gatts_evt_sys_attr_missing_t sys_attr_missing;
- ble_gatts_evt_hvc_t hvc;
- ble_gatts_evt_exchange_mtu_request_t exchange_mtu_request;
- ble_gatts_evt_timeout_t timeout;
- ble_gatts_evt_hvn_tx_complete_t hvn_tx_complete;
- } params;
- } ble_gatts_evt_t;
- SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle));
- SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *p_include_handle));
- SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles));
- SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const *p_attr, uint16_t *p_handle));
- SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value));
- SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value));
- SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params));
- SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle));
- SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params));
- SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const *p_sys_attr_data, uint16_t len, uint32_t flags));
- SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t *p_sys_attr_data, uint16_t *p_len, uint32_t flags));
- SVCALL(SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, uint32_t, sd_ble_gatts_initial_user_handle_get(uint16_t *p_handle));
- SVCALL(SD_BLE_GATTS_ATTR_GET, uint32_t, sd_ble_gatts_attr_get(uint16_t handle, ble_uuid_t * p_uuid, ble_gatts_attr_md_t * p_md));
- SVCALL(SD_BLE_GATTS_EXCHANGE_MTU_REPLY, uint32_t, sd_ble_gatts_exchange_mtu_reply(uint16_t conn_handle, uint16_t server_rx_mtu));
- }
|