Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0
ptu_registry.c File Reference
#include <stdint.h>
#include <string.h>
#include "nrf_assert.h"
#include "ptu_registry.h"

Go to the source code of this file.

Functions

API implementation.
void ptu_reg_init (void)
 Initialize registry database.
 
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. More...
 
ptu_reg_item_tptu_reg_item_get_from_conn_handle (uint16_t conn_handle)
 Get registry item from connection handle. More...
 
ptu_reg_item_tptu_reg_item_get_from_address (ble_gap_addr_t *address)
 Get registry item from GAP address. More...
 
ptu_reg_item_tptu_reg_item_oldest_get (ptu_reg_item_state_t state)
 Get oldest registry item having a specific state. More...
 
ptu_reg_item_tptu_reg_item_add (ble_gap_evt_adv_report_t *p_adv_report, ptu_reg_item_state_t init_state)
 Initiate registration of new device. More...
 
void ptu_reg_item_delete (ptu_reg_item_t *item)
 Delete item that has previoulsy been added to registry. More...
 
uint8_t ptu_reg_registered_devices_get (ptu_reg_item_t **registered_devices)
 Get handles for all registered devices. More...
 
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. More...
 
bool ptu_reg_all_charged (void)
 Function returning true if all items in registry are charged or there are not items in registry. More...
 
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 item. Should only be called with non-zero address values. More...
 

Static funcitons and variables.

static ptu_reg_t m_registry
 
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. More...
 
static ptu_reg_item_tm_reg_item_unused_get (void)
 Get unused (available) registry item. More...
 

Function Documentation

static void m_reg_item_init ( ptu_reg_item_t item)
static

Set all values in a registry item to default values. 'timer_id' will be retained.

Parameters
itemis a pointer to the item to initialize.

Definition at line 56 of file ptu_registry.c.

57 {
58  app_timer_id_t temp;
59  temp = item->timer_id;
60  memset(item, 0, sizeof(ptu_reg_item_t));
61  item->ble_wpts_c.conn_handle = BLE_CONN_HANDLE_INVALID;
62  item->timer_id = temp;
63 }
Registry item.
Definition: ptu_registry.h:47
uint16_t conn_handle
Definition: ble_wpts_c.h:66
ble_wpts_c_t ble_wpts_c
Definition: ptu_registry.h:52
app_timer_id_t timer_id
Definition: ptu_registry.h:56
static ptu_reg_item_t* m_reg_item_unused_get ( void  )
static

Get unused (available) registry item.

Returns
pointer to registry item. NULL if no item available.

Definition at line 69 of file ptu_registry.c.

70 {
71  int i;
72 
73  for(i = 0; i < PTU_MAX_CONNECTIONS; i++)
74  {
76  {
77  return &m_registry.items[i];
78  }
79  }
80 
81  return NULL;
82 }
ptu_reg_item_t items[PTU_MAX_CONNECTIONS]
Definition: ptu_registry.h:77
static ptu_reg_t m_registry
Definition: ptu_registry.c:51
#define PTU_MAX_CONNECTIONS
Definition: ptu_config.h:29
ptu_reg_item_state_t state
Definition: ptu_registry.h:49

Variable Documentation

ptu_reg_t m_registry
static

Registry database.

Definition at line 51 of file ptu_registry.c.