Wirepas SDK
poslib.h File Reference

Go to the source code of this file.

Typedefs

typedef void(* poslib_events_listen_info_f) (POSLIB_FLAG_EVENT_info_t *msg)
 Function used with POSLIB_FLAG_EVENT_setCb. More...
 
typedef void(* poslib_events_callback_f) (poslib_events_listen_info_f callback)
 This callback is used to receive Poslib generated events. More...
 

Functions

poslib_ret_e PosLib_setConfig (poslib_settings_t *settings)
 Sets PosLib configuration. More...
 
poslib_ret_e PosLib_getConfig (poslib_settings_t *settings)
 Gets PosLib configuration. More...
 
poslib_ret_e PosLib_startPeriodic (void)
 Start the positioning updates according to provided configuration. Calls PosLib initialization function before start. More...
 
poslib_ret_e PosLib_stopPeriodic (void)
 Stops the positioning updates. More...
 
poslib_ret_e PosLib_startOneshot (void)
 Triggers one position update. If PosLib is started the scheduled operation will continue after the one-shot update with the respective schedule. If in stop mode then will stay in stop mode after the one-shot update. More...
 
poslib_ret_e PosLib_motion (poslib_motion_mode_e mode)
 Is used to indicate that the tag is static or dynamic. The update rate used will be adjusted according to the state: when moving from static → dynamic: an update will be triggered immediately if the last update is older than (current time - dynamic rate), otherwise the next update is re-scheduled as (last update + dynamic rate). More...
 
poslib_status_e PosLib_status (void)
 Returns the current status of PosLib. More...
 
poslib_ret_e PosLib_eventRegister (poslib_events_e event, poslib_events_listen_info_f cb, uint8_t *id)
 Register an event subscriber. More...
 
void PosLib_eventDeregister (uint8_t id)
 Clears a callback for the requested event. More...
 

Data Structures

struct  poslib_ble_mode_config_t
 defines BLE mode mode configration. More...
 
struct  ble_beacon_settings_t
 position library ble settings. More...
 
struct  poslib_motion_mon_settings_t
 position library motion settings. More...
 
struct  poslib_settings_t
 position library settings. More...
 
struct  poslib_aux_settings_t
 positioning library auxiliary settings More...
 
struct  POSLIB_FLAG_EVENT_info_t
 

Enumerations

enum  poslib_ret_e {
  POS_RET_OK = 0, POS_RET_INVALID_STATE = 1, POS_RET_INVALID_PARAM = 2, POS_RET_INVALID_DATA = 3,
  POS_RET_LIB_ERROR = 4, POS_RET_INTERNAL_ERROR = 5, POS_RET_NOT_CONFIGURED = 6, POS_RET_EVENT_REG_ERROR = 7,
  POS_RET_MOTION_NOT_ENABLED = 8
}
 Return codes of positioning functions. More...
 
enum  poslib_mode_e {
  POSLIB_MODE_NRLS_TAG = 1, POSLIB_MODE_AUTOSCAN_TAG = 2, POSLIB_MODE_AUTOSCAN_ANCHOR = 3, POSLIB_MODE_OPPORTUNISTIC_ANCHOR = 4,
  POSLIB_MODE_ENDS = 5
}
 defines the device's positioning mode. More...
 
enum  poslib_motion_mode_e { POSLIB_MOTION_STATIC = 1, POSLIB_MOTION_DYNAMIC = 2 }
 defines the position motion mode. More...
 
enum  poslib_ble_mode_e { POSLIB_BLE_OFF = 0, POSLIB_BLE_ON = 1, POSLIB_BLE_ON_WHEN_OFFLINE = 2 }
 defines the state (started/stopped) of the BLE beacon sent by PosLib More...
 
enum  poslib_class_e {
  POSLIB_CLASS_NODE_SPECIFIC = 0xF8, POSLIB_CLASS_DEFAULT = 0xF9, POSLIB_CLASS_A = 0xFA, POSLIB_CLASS_B = 0xFB,
  POSLIB_CLASS_C = 0xFC, POSLIB_CLASS_D = 0xFD, POSLIB_CLASS_E = 0xFE, POSLIB_CLASS_F = 0xFF
}
 defines the device's operational class. More...
 
enum  poslib_ble_type_e { POSLIB_EDDYSTONE = 1, POSLIB_IBEACON, POSLIB_BEACON_ALL }
 Beacon devices types. More...
 
enum  poslib_events_e {
  POSLIB_FLAG_EVENT_NONE = 0, POSLIB_FLAG_EVENT_UPDATE_START = 1, POSLIB_FLAG_EVENT_UPDATE_END = 2, POSLIB_FLAG_EVENT_BLE_START = 4,
  POSLIB_FLAG_EVENT_BLE_STOP = 8, POSLIB_FLAG_EVENT_OFLINE = 16, POSLIB_FLAG_EVENT_ONLINE = 32, POSLIB_FLAG_EVENT_CONFIG_CHANGE = 64,
  POSLIB_FLAG_EVENT_LED_ON = 128, POSLIB_FLAG_EVENT_LED_OFF = 256, POSLIB_FLAG_EVENT_ALL = 511
}
 Defines the events triggered by PosLib. More...
 
enum  poslib_status_e { POSLIB_STOPPED = 0, POSLIB_IDLE = 1, POSLIB_UPDATE_START = 2 }
 defines status returned in PosLib_status(). More...
 

Macros

#define POS_DESTINATION_ENDPOINT   238
 Endpoints for measurements. More...
 
#define POS_SOURCE_ENDPOINT   238
 
#define POSLIB_MIN_MEAS_RATE_S   8 /* FixMe: adjust based on testing*/
 Update rate min/max. More...
 
#define POSLIB_MAX_MEAS_RATE_S   86400
 
#define POSLIB_VOLTAGE_SAMPLING_MAX_S   60
 Voltage sampling settings. More...
 
#define POSLIB_VOLTAGE_FILTER_SAMPLES   30
 
#define POSLIB_FLAG_EVENT_SUBSCRIBERS_MAX   8
 

Typedef Documentation

◆ poslib_events_callback_f

typedef void(* poslib_events_callback_f) (poslib_events_listen_info_f callback)

This callback is used to receive Poslib generated events.

Parameters
Callbackfunction type of poslib_events_listen_info_f.

Definition at line 241 of file poslib.h.

◆ poslib_events_listen_info_f

typedef void(* poslib_events_listen_info_f) (POSLIB_FLAG_EVENT_info_t *msg)

Function used with POSLIB_FLAG_EVENT_setCb.

Parameters
structfor poslib_events_listen_info_f struct for poslib_events_info_t data.

Definition at line 234 of file poslib.h.

Function Documentation

◆ PosLib_eventDeregister()

void PosLib_eventDeregister ( uint8_t  id)

Clears a callback for the requested event.

Parameters
requested_eventtype of poslib_events_e

◆ PosLib_eventRegister()

poslib_ret_e PosLib_eventRegister ( poslib_events_e  event,
poslib_events_listen_info_f  cb,
uint8_t *  id 
)

Register an event subscriber.

Parameters
eventEvents of interest (type of poslib_events_e)
cbCallback to be called (type poslib_events_listen_info_f)
idReturned subscriber ID
Returns
POS_RET_OK is succesful / POS_RET_EVENT_ERROR if failed
Examples
positioning_app/app.c.

◆ PosLib_getConfig()

poslib_ret_e PosLib_getConfig ( poslib_settings_t settings)

Gets PosLib configuration.

Parameters
poslib_settings_ttype pointer
Returns
See poslib_ret_e
Examples
positioning_app/app.c.

◆ PosLib_motion()

poslib_ret_e PosLib_motion ( poslib_motion_mode_e  mode)

Is used to indicate that the tag is static or dynamic. The update rate used will be adjusted according to the state: when moving from static → dynamic: an update will be triggered immediately if the last update is older than (current time - dynamic rate), otherwise the next update is re-scheduled as (last update + dynamic rate).

Parameters
modetype of poslib_motion_mode_e
Returns
See poslib_ret_e
Examples
positioning_app/app.c.

◆ PosLib_setConfig()

poslib_ret_e PosLib_setConfig ( poslib_settings_t settings)

Sets PosLib configuration.

Parameters
poslib_settings_ttype pointer
Returns
See poslib_ret_e
Examples
positioning_app/app.c.

◆ PosLib_startOneshot()

poslib_ret_e PosLib_startOneshot ( void  )

Triggers one position update. If PosLib is started the scheduled operation will continue after the one-shot update with the respective schedule. If in stop mode then will stay in stop mode after the one-shot update.

Note
If called during NRLS sleep, sleep is stopped which triggers one position update. NRLS period continues with the respective schedule.
Returns
See poslib_ret_e
Examples
positioning_app/app.c.

◆ PosLib_startPeriodic()

poslib_ret_e PosLib_startPeriodic ( void  )

Start the positioning updates according to provided configuration. Calls PosLib initialization function before start.

Note
Following shared libraries needs to be initialized before use PosLib_start(): Shared_Data_init(); Shared_Appconfig_init(); Shared_Neighbors_init(); Shared_Shutdown_init();
Returns
See poslib_ret_e
Examples
positioning_app/app.c.

◆ PosLib_status()

poslib_status_e PosLib_status ( void  )

Returns the current status of PosLib.

Returns
See poslib_ret_e

◆ PosLib_stopPeriodic()

poslib_ret_e PosLib_stopPeriodic ( void  )

Stops the positioning updates.

Returns
See poslib_ret_e

Data Structure Documentation

◆ poslib_ble_mode_config_t

struct poslib_ble_mode_config_t

defines BLE mode mode configration.

Definition at line 160 of file poslib.h.

Data Fields
app_lib_beacon_tx_channels_mask_e channels
uint16_t tx_interval_ms
int8_t tx_power

◆ ble_beacon_settings_t

struct ble_beacon_settings_t

position library ble settings.

Definition at line 170 of file poslib.h.

Data Fields
uint16_t activation_delay_s
poslib_ble_mode_config_t eddystone
poslib_ble_mode_config_t ibeacon
poslib_ble_mode_e mode
poslib_ble_type_e type

◆ poslib_motion_mon_settings_t

struct poslib_motion_mon_settings_t

position library motion settings.

Examples
positioning_app/app.c.

Definition at line 182 of file poslib.h.

Data Fields
uint16_t duration_ms
bool enabled
uint16_t threshold_mg

◆ poslib_settings_t

struct poslib_settings_t

position library settings.

Examples
positioning_app/app.c.

Definition at line 192 of file poslib.h.

Data Fields
ble_beacon_settings_t ble
poslib_motion_mon_settings_t motion
poslib_class_e node_class
poslib_mode_e node_mode
uint32_t update_period_dynamic_s
uint32_t update_period_offline_s
uint32_t update_period_static_s

◆ poslib_aux_settings_t

struct poslib_aux_settings_t

positioning library auxiliary settings

Definition at line 213 of file poslib.h.

Data Fields
uint8_t led_cmd_seq
uint16_t led_on_duration_s

◆ POSLIB_FLAG_EVENT_info_t

struct POSLIB_FLAG_EVENT_info_t

Helper structure to move data from PosLib events

Examples
positioning_app/app.c.

Definition at line 222 of file poslib.h.

Data Fields
uint8_t event_id
uint32_t nrls_sleep_time_sec
app_lib_time_timestamp_hp_t time_hp

Enumeration Type Documentation

◆ poslib_ble_mode_e

defines the state (started/stopped) of the BLE beacon sent by PosLib

Enumerator
POSLIB_BLE_OFF 
POSLIB_BLE_ON 
POSLIB_BLE_ON_WHEN_OFFLINE 

Definition at line 83 of file poslib.h.

84 {
85  POSLIB_BLE_OFF = 0, // OFF
86  POSLIB_BLE_ON = 1, // always ON
87  POSLIB_BLE_ON_WHEN_OFFLINE = 2 //activated when outside coverage

◆ poslib_ble_type_e

Beacon devices types.

Enumerator
POSLIB_EDDYSTONE 
POSLIB_IBEACON 
POSLIB_BEACON_ALL 

Definition at line 108 of file poslib.h.

109 {
110  POSLIB_EDDYSTONE = 1,

◆ poslib_class_e

defines the device's operational class.

Enumerator
POSLIB_CLASS_NODE_SPECIFIC 
POSLIB_CLASS_DEFAULT 
POSLIB_CLASS_A 
POSLIB_CLASS_B 
POSLIB_CLASS_C 
POSLIB_CLASS_D 
POSLIB_CLASS_E 
POSLIB_CLASS_F 

Definition at line 93 of file poslib.h.

94 {
96  POSLIB_CLASS_DEFAULT = 0xF9,
97  POSLIB_CLASS_A = 0xFA,
98  POSLIB_CLASS_B = 0xFB,
99  POSLIB_CLASS_C = 0xFC,
100  POSLIB_CLASS_D = 0xFD,
101  POSLIB_CLASS_E = 0xFE,
102  POSLIB_CLASS_F = 0xFF

◆ poslib_events_e

Defines the events triggered by PosLib.

Enumerator
POSLIB_FLAG_EVENT_NONE 

No event Position measurement update started

POSLIB_FLAG_EVENT_UPDATE_START 

Position measurement update ended

POSLIB_FLAG_EVENT_UPDATE_END 

BLE beacon transmission started

POSLIB_FLAG_EVENT_BLE_START 

BLE beacon transmission stopped

POSLIB_FLAG_EVENT_BLE_STOP 

PosLib requested WM to enter offline

POSLIB_FLAG_EVENT_OFLINE 

PosLib WM is in online, NRLS update starts

POSLIB_FLAG_EVENT_ONLINE 

PosLib configuration changed

POSLIB_FLAG_EVENT_CONFIG_CHANGE 

Led status on

POSLIB_FLAG_EVENT_LED_ON 

Led status off

POSLIB_FLAG_EVENT_LED_OFF 

Global flag for subscribing to all events

POSLIB_FLAG_EVENT_ALL 

Definition at line 121 of file poslib.h.

◆ poslib_mode_e

defines the device's positioning mode.

Enumerator
POSLIB_MODE_NRLS_TAG 
POSLIB_MODE_AUTOSCAN_TAG 
POSLIB_MODE_AUTOSCAN_ANCHOR 
POSLIB_MODE_OPPORTUNISTIC_ANCHOR 
POSLIB_MODE_ENDS 

Definition at line 62 of file poslib.h.

◆ poslib_motion_mode_e

defines the position motion mode.

Enumerator
POSLIB_MOTION_STATIC 
POSLIB_MOTION_DYNAMIC 

Definition at line 74 of file poslib.h.

◆ poslib_ret_e

Return codes of positioning functions.

Enumerator
POS_RET_OK 

Operation is a success. Positioning not in a valid state.

POS_RET_INVALID_STATE 

Invalid parameters.

POS_RET_INVALID_PARAM 

Invalid data.

POS_RET_INVALID_DATA 

Positioning library error.

POS_RET_LIB_ERROR 

Internal error (no more task, ...).

POS_RET_INTERNAL_ERROR 

Not configured

POS_RET_NOT_CONFIGURED 

Error registering for event

POS_RET_EVENT_REG_ERROR 
POS_RET_MOTION_NOT_ENABLED 

Motion monitoring not enabled

Definition at line 37 of file poslib.h.

◆ poslib_status_e

defines status returned in PosLib_status().

Enumerator
POSLIB_STOPPED 
POSLIB_IDLE 
POSLIB_UPDATE_START 

Definition at line 150 of file poslib.h.

151 {
152  POSLIB_STOPPED = 0,
153  POSLIB_IDLE = 1,

Macro Definition Documentation

◆ POS_DESTINATION_ENDPOINT

#define POS_DESTINATION_ENDPOINT   238

Endpoints for measurements.

Copyright 2020 Wirepas Ltd. All Rights Reserved.

See file LICENSE.txt for full license details.

Definition at line 18 of file poslib.h.

◆ POS_SOURCE_ENDPOINT

#define POS_SOURCE_ENDPOINT   238

Definition at line 19 of file poslib.h.

◆ POSLIB_FLAG_EVENT_SUBSCRIBERS_MAX

#define POSLIB_FLAG_EVENT_SUBSCRIBERS_MAX   8
Examples
positioning_app/app.c.

Definition at line 115 of file poslib.h.

◆ POSLIB_MAX_MEAS_RATE_S

#define POSLIB_MAX_MEAS_RATE_S   86400

Definition at line 25 of file poslib.h.

◆ POSLIB_MIN_MEAS_RATE_S

#define POSLIB_MIN_MEAS_RATE_S   8 /* FixMe: adjust based on testing*/

Update rate min/max.

Definition at line 24 of file poslib.h.

◆ POSLIB_VOLTAGE_FILTER_SAMPLES

#define POSLIB_VOLTAGE_FILTER_SAMPLES   30

Definition at line 31 of file poslib.h.

◆ POSLIB_VOLTAGE_SAMPLING_MAX_S

#define POSLIB_VOLTAGE_SAMPLING_MAX_S   60

Voltage sampling settings.

Definition at line 30 of file poslib.h.

POSLIB_FLAG_EVENT_OFLINE
@ POSLIB_FLAG_EVENT_OFLINE
Definition: poslib.h:134
POSLIB_FLAG_EVENT_UPDATE_END
@ POSLIB_FLAG_EVENT_UPDATE_END
Definition: poslib.h:128
POSLIB_EDDYSTONE
@ POSLIB_EDDYSTONE
Definition: poslib.h:110
POSLIB_CLASS_F
@ POSLIB_CLASS_F
Definition: poslib.h:102
POSLIB_FLAG_EVENT_CONFIG_CHANGE
@ POSLIB_FLAG_EVENT_CONFIG_CHANGE
Definition: poslib.h:138
POSLIB_MOTION_STATIC
@ POSLIB_MOTION_STATIC
Definition: poslib.h:76
POSLIB_IBEACON
@ POSLIB_IBEACON
Definition: poslib.h:111
POSLIB_FLAG_EVENT_ONLINE
@ POSLIB_FLAG_EVENT_ONLINE
Definition: poslib.h:136
POS_RET_OK
@ POS_RET_OK
Definition: poslib.h:40
POSLIB_BLE_OFF
@ POSLIB_BLE_OFF
Definition: poslib.h:85
poslib_motion_mode_e
poslib_motion_mode_e
defines the position motion mode.
Definition: poslib.h:74
POSLIB_CLASS_B
@ POSLIB_CLASS_B
Definition: poslib.h:98
POSLIB_FLAG_EVENT_LED_OFF
@ POSLIB_FLAG_EVENT_LED_OFF
Definition: poslib.h:142
poslib_ret_e
poslib_ret_e
Return codes of positioning functions.
Definition: poslib.h:37
POSLIB_CLASS_A
@ POSLIB_CLASS_A
Definition: poslib.h:97
POSLIB_CLASS_DEFAULT
@ POSLIB_CLASS_DEFAULT
Definition: poslib.h:96
poslib_mode_e
poslib_mode_e
defines the device's positioning mode.
Definition: poslib.h:62
POS_RET_INVALID_STATE
@ POS_RET_INVALID_STATE
Definition: poslib.h:42
poslib_ble_mode_e
poslib_ble_mode_e
defines the state (started/stopped) of the BLE beacon sent by PosLib
Definition: poslib.h:83
POSLIB_BLE_ON
@ POSLIB_BLE_ON
Definition: poslib.h:86
POSLIB_MODE_NRLS_TAG
@ POSLIB_MODE_NRLS_TAG
Definition: poslib.h:64
POSLIB_MODE_AUTOSCAN_ANCHOR
@ POSLIB_MODE_AUTOSCAN_ANCHOR
Definition: poslib.h:66
POS_RET_EVENT_REG_ERROR
@ POS_RET_EVENT_REG_ERROR
Definition: poslib.h:54
POSLIB_BLE_ON_WHEN_OFFLINE
@ POSLIB_BLE_ON_WHEN_OFFLINE
Definition: poslib.h:87
POSLIB_MOTION_DYNAMIC
@ POSLIB_MOTION_DYNAMIC
Definition: poslib.h:77
poslib_events_e
poslib_events_e
Defines the events triggered by PosLib.
Definition: poslib.h:121
POSLIB_MODE_OPPORTUNISTIC_ANCHOR
@ POSLIB_MODE_OPPORTUNISTIC_ANCHOR
Definition: poslib.h:67
POSLIB_CLASS_C
@ POSLIB_CLASS_C
Definition: poslib.h:99
POSLIB_IDLE
@ POSLIB_IDLE
Definition: poslib.h:153
POS_RET_MOTION_NOT_ENABLED
@ POS_RET_MOTION_NOT_ENABLED
Definition: poslib.h:56
POSLIB_UPDATE_START
@ POSLIB_UPDATE_START
Definition: poslib.h:154
POSLIB_FLAG_EVENT_NONE
@ POSLIB_FLAG_EVENT_NONE
Definition: poslib.h:124
POSLIB_FLAG_EVENT_ALL
@ POSLIB_FLAG_EVENT_ALL
Definition: poslib.h:144
poslib_class_e
poslib_class_e
defines the device's operational class.
Definition: poslib.h:93
POS_RET_INVALID_DATA
@ POS_RET_INVALID_DATA
Definition: poslib.h:46
POSLIB_CLASS_NODE_SPECIFIC
@ POSLIB_CLASS_NODE_SPECIFIC
Definition: poslib.h:95
POSLIB_STOPPED
@ POSLIB_STOPPED
Definition: poslib.h:152
POS_RET_NOT_CONFIGURED
@ POS_RET_NOT_CONFIGURED
Definition: poslib.h:52
POSLIB_MODE_ENDS
@ POSLIB_MODE_ENDS
Definition: poslib.h:68
poslib_ble_type_e
poslib_ble_type_e
Beacon devices types.
Definition: poslib.h:108
POSLIB_CLASS_E
@ POSLIB_CLASS_E
Definition: poslib.h:101
POSLIB_MODE_AUTOSCAN_TAG
@ POSLIB_MODE_AUTOSCAN_TAG
Definition: poslib.h:65
POSLIB_CLASS_D
@ POSLIB_CLASS_D
Definition: poslib.h:100
POSLIB_BEACON_ALL
@ POSLIB_BEACON_ALL
Definition: poslib.h:112
POS_RET_INVALID_PARAM
@ POS_RET_INVALID_PARAM
Definition: poslib.h:44
POSLIB_FLAG_EVENT_UPDATE_START
@ POSLIB_FLAG_EVENT_UPDATE_START
Definition: poslib.h:126
POSLIB_FLAG_EVENT_BLE_STOP
@ POSLIB_FLAG_EVENT_BLE_STOP
Definition: poslib.h:132
POS_RET_LIB_ERROR
@ POS_RET_LIB_ERROR
Definition: poslib.h:48
POSLIB_FLAG_EVENT_BLE_START
@ POSLIB_FLAG_EVENT_BLE_START
Definition: poslib.h:130
POS_RET_INTERNAL_ERROR
@ POS_RET_INTERNAL_ERROR
Definition: poslib.h:50
poslib_status_e
poslib_status_e
defines status returned in PosLib_status().
Definition: poslib.h:150
POSLIB_FLAG_EVENT_LED_ON
@ POSLIB_FLAG_EVENT_LED_ON
Definition: poslib.h:140