18 #include "nrf_assert.h"
26 #if PTU_MAX_CONNECTIONS > 0
29 #if PTU_MAX_CONNECTIONS > 1
32 #if PTU_MAX_CONNECTIONS > 2
35 #if PTU_MAX_CONNECTIONS > 3
38 #if PTU_MAX_CONNECTIONS > 4
41 #if PTU_MAX_CONNECTIONS > 5
44 #if PTU_MAX_CONNECTIONS > 6
47 #if PTU_MAX_CONNECTIONS > 7
77 return &m_registry.
items[i];
100 #if PTU_MAX_CONNECTIONS > 0
103 #if PTU_MAX_CONNECTIONS > 1
106 #if PTU_MAX_CONNECTIONS > 2
109 #if PTU_MAX_CONNECTIONS > 3
112 #if PTU_MAX_CONNECTIONS > 4
115 #if PTU_MAX_CONNECTIONS > 5
118 #if PTU_MAX_CONNECTIONS > 6
121 #if PTU_MAX_CONNECTIONS > 7
130 *item = &m_registry.
items[index];
134 return NRF_ERROR_INVALID_PARAM;
139 if(m_registry.
n_entries > 0 && conn_handle != BLE_CONN_HANDLE_INVALID)
146 return &m_registry.
items[i];
159 if(memcmp(m_registry.
items[i].
address.addr, address->addr, BLE_GAP_ADDR_LEN) == 0 && \
162 return &m_registry.
items[i];
181 retval = &m_registry.
items[i];
193 ASSERT(reg_item == NULL);
209 APP_ERROR_CHECK(err_code);
211 memcpy(®_item->
address, &p_adv_report->peer_addr,
sizeof(ble_gap_addr_t));
213 reg_item->
state = init_state;
226 if(item == &m_registry.
items[i])
233 ASSERT(i < PTU_MAX_CONNECTIONS);
256 uint8_t n_devices = 0;
262 registered_devices[n_devices++] = &m_registry.
items[i];
289 uint8_t zero_address[BLE_GAP_ADDR_LEN] = {0};
290 if (memcmp(zero_address, address, BLE_GAP_ADDR_LEN) == 0)
291 return NRF_ERROR_INVALID_ADDR;
295 memcpy(reg_item_p->
address.addr, address, BLE_GAP_ADDR_LEN);
void ptu_reg_item_delete(ptu_reg_item_t *item)
Delete item that has previoulsy been added to registry.
ptu_reg_item_t items[PTU_MAX_CONNECTIONS]
uint32_t ble_wpts_service_data_read(ble_gap_evt_adv_report_t *p_adv_report, ble_wpts_service_data_t *p_service_data)
ptu_reg_item_t * ptu_reg_item_add(ble_gap_evt_adv_report_t *p_adv_report, ptu_reg_item_state_t init_state)
Initiate registration of new device.
uint8_t ptu_reg_registered_devices_get(ptu_reg_item_t **registered_devices)
Get handles for all registered devices.
ptu_reg_item_t * ptu_reg_item_get_from_address(ble_gap_addr_t *address)
Get registry item from GAP address.
uint32_t ptu_reg_item_get_from_index(uint8_t index, ptu_reg_item_t **item)
Get registry item from index in database. Index must be < PTU_MAX_CONNECTIONS.
uint8_t ptu_reg_n_entries_get(void)
Get the number of devices currently in registry. This will include all connected devices, as well as all devices which is currently being registered.
APP_TIMER_DEF(m_battery_timer_id)
void ble_wpts_char_handles_update(uint16_t prim_service_handle, ble_wpts_c_t *p_wpts_c)
Struct holding contents of "Service data AD type".
static ptu_reg_t m_registry
ptu_reg_item_state_t
Registry item status.
static void m_reg_item_init(ptu_reg_item_t *item)
Set all values in a registry item to default values. 'timer_id' will be retained. ...
bool ptu_reg_all_charged(void)
Function returning true if all items in registry are charged or there are not items in registry...
uint32_t ptu_reg_set_device_waiting_to_connect(ptu_reg_item_t *reg_item_p, uint8_t *address)
Set the state of registry item to "ready to connect" state. Associates the address with the registry ...
ptu_reg_item_t * ptu_reg_item_oldest_get(ptu_reg_item_state_t state)
Get oldest registry item having a specific state.
void ptu_reg_init(void)
Initialize registry database.
ptu_reg_item_t * ptu_reg_item_get_from_conn_handle(uint16_t conn_handle)
Get registry item from connection handle.
uint16_t gatt_prim_srv_handle
#define PTU_MAX_CONNECTIONS
ptu_reg_item_state_t state
static ptu_reg_item_t * m_reg_item_unused_get(void)
Get unused (available) registry item.