Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0
PTU profile API

Macros

#define APP_TIMER_PRESCALER   0
 
#define APP_TIMER_OP_QUEUE_SIZE   19
 
#define PTU_SM_CURRENT_STATE()   ptu_sm_execute((ptu_sm_signal_type_t)NULL, NULL)
 

Typedefs

typedef void(* ptu_sm_handler_t) (ptu_sm_signal_type_t signal)
 
typedef void(* app_sm_evt_handler_t) (ptu_sm_signal_type_t signal, const ptu_sm_state_vars_t *p_state_vars)
 

General API functions

void ptu_init (app_sm_evt_handler_t sm_evt_handler)
 Initialize PTU. This function must be called before any other PTU function can be called. More...
 
void ptu_on_ble_evt (ble_evt_t *p_ble_evt)
 Dispatches a BLE stack event to PTU. More...
 
void ptu_start (void)
 Start ptu profile. Here "start" means that profile can start generating events through ptu_evt_handler().
 

API implementation

void terminate (void)
 Needs to be implemented by application. Perform all requried actions before jump to DFU application can be done.
 
bool dfu_check (void)
 Needs to be implemented by application. Check if it is OK to jump to the DFU application. More...
 

Detailed Description

Macro Definition Documentation

#define APP_TIMER_PRESCALER   0

Prescaling for internal timers.

Definition at line 33 of file ptu.h.

#define APP_TIMER_OP_QUEUE_SIZE   19

Max number of internal timers.

Definition at line 34 of file ptu.h.

#define PTU_SM_CURRENT_STATE ( )    ptu_sm_execute((ptu_sm_signal_type_t)NULL, NULL)

Get current state of PTU state machine.

Definition at line 36 of file ptu.h.

Typedef Documentation

typedef void(* ptu_sm_handler_t) (ptu_sm_signal_type_t signal)

State machine event handler.

Definition at line 30 of file ptu.h.

typedef void(* app_sm_evt_handler_t) (ptu_sm_signal_type_t signal, const ptu_sm_state_vars_t *p_state_vars)

Application State machine event handler.

Definition at line 31 of file ptu.h.

Function Documentation

void ptu_init ( app_sm_evt_handler_t  sm_evt_handler)

Initialize PTU. This function must be called before any other PTU function can be called.

Parameters
sm_evt_handlerOptional handle state machine event callback. Set to NULL if no callback is required.

Definition at line 331 of file ptu.c.

332 {
333  uint32_t err_code;
334 
335  m_app_sm_evt_handler = sm_evt_handler;
336 
337  m_timers_init();
338 
339  m_services_init();
340 
341  ptu_reg_init();
342 
343  err_code = ptu_cm_init(m_ptu_sm_execute);
344  APP_ERROR_CHECK(err_code);
345 
347  APP_ERROR_CHECK(err_code);
348 
350  APP_ERROR_CHECK(err_code);
351 
353 
355  APP_ERROR_CHECK(err_code);
356 
358  APP_ERROR_CHECK(err_code);
359 
360  err_code = tmux_init(); // Initializes HAL as well
361  APP_ERROR_CHECK(err_code);
362 }
static void m_services_init(void)
Initialize Client Service.
Definition: ptu.c:285
#define PTU_MS_FROM_BEACON_STOP_TO_ACTIVATE_DISTANT_LIST
Definition: ptu_config.h:46
uint32_t ptu_cm_init(ptu_sm_handler_t sm_handler)
Initialize connection manager.
Definition: ptu_conn_man.c:861
uint32_t ptu_sensors_init(ptu_sm_handler_t sm_handler)
Initialize PTU Sensors. This function must be called before any other PTU Sensors function can be cal...
Definition: ptu_sensors.c:284
void ptu_beacons_init(void)
Initialize beacons handling.
Definition: ptu_beacons.c:192
static void m_timers_init(void)
Initialize timers.
Definition: ptu.c:299
uint32_t ptu_dlh_init(ptu_dlh_init_t const *p_init)
Check if device with provided address is in the distant list.
void ptu_reg_init(void)
Initialize registry database.
Definition: ptu_registry.c:91
static void m_ptu_sm_execute(ptu_sm_signal_type_t signal)
Used when executing state machine events.
Definition: ptu.c:42
uint32_t ptu_latching_fault_init(ptu_sm_handler_t sm_handler)
Initialize latching fault module.
uint32_t tmux_init(void)
Initialize the PTU's test multiplexer.
Definition: pru_test_mux.c:53
uint32_t ptu_power_sharing_init(ptu_sm_handler_t sm_handler)
Initialize power sharing module.
static app_sm_evt_handler_t m_app_sm_evt_handler
Definition: ptu.c:37
void ptu_on_ble_evt ( ble_evt_t *  p_ble_evt)

Dispatches a BLE stack event to PTU.

Parameters
[in]p_ble_evtBluetooth stack event.

Definition at line 319 of file ptu.c.

320 {
321  ptu_reg_item_t * reg_item;
322 
323  ptu_cm_on_ble_evt(p_ble_evt);
324 
325  if ((reg_item = ptu_reg_item_get_from_conn_handle(p_ble_evt->evt.common_evt.conn_handle)) != NULL)
326  {
327  ble_wpts_c_on_ble_evt(&reg_item->ble_wpts_c, p_ble_evt);
328  }
329 }
Registry item.
Definition: ptu_registry.h:47
ble_wpts_c_t ble_wpts_c
Definition: ptu_registry.h:52
void ptu_cm_on_ble_evt(ble_evt_t *p_ble_evt)
BLE event handler.
Definition: ptu_conn_man.c:894
void ble_wpts_c_on_ble_evt(ble_wpts_c_t *p_wpts_c, ble_evt_t *p_ble_evt)
WPT Service Client BLE stack event handler.
Definition: ble_wpts_c.c:311
ptu_reg_item_t * ptu_reg_item_get_from_conn_handle(uint16_t conn_handle)
Get registry item from connection handle.
Definition: ptu_registry.c:137
bool dfu_check ( void  )

Needs to be implemented by application. Check if it is OK to jump to the DFU application.

Returns
true if it is OK to jump to DFU application. False otherwise.

Definition at line 385 of file ptu.c.

386 {
387  return (ptu_reg_n_entries_get() == 0);
388 }
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.
Definition: ptu_registry.c:268