Wirepas SDK
api.h
Go to the documentation of this file.
1 /* Copyright 2017 Wirepas Ltd. All Rights Reserved.
2  *
3  * See file LICENSE.txt for full license details.
4  *
5  */
6 
15 #ifndef API_H_
16 #define API_H_
17 
18 #include "app.h"
19 #include "data.h"
20 #include "otap.h"
21 #include "settings.h"
22 #include "state.h"
23 #include "storage.h"
24 #include "system.h"
25 #include "time.h"
26 #include "hardware.h"
27 // BLE beacons
28 #include "beacon_tx.h"
29 #include "beacon_rx.h"
30 #include "sleep.h"
31 #include "advertiser.h"
32 #include "memory_area.h"
33 #include "radio_config.h"
34 #include "joining.h"
35 
36 // Expose common APIs
37 extern const app_global_functions_t * global_func __attribute((weak));
38 extern const app_lib_data_t * lib_data __attribute((weak));
39 extern const app_lib_otap_t * lib_otap __attribute((weak));
40 extern const app_lib_settings_t * lib_settings __attribute((weak));
41 extern const app_lib_state_t * lib_state __attribute((weak));
42 extern const app_lib_storage_t * lib_storage __attribute((weak));
43 extern const app_lib_system_t * lib_system __attribute((weak));
44 extern const app_lib_time_t * lib_time __attribute((weak));
45 extern const app_lib_hardware_t * lib_hw __attribute((weak));
46 
47 // BLE beacons
48 extern const app_lib_beacon_tx_t * lib_beacon_tx __attribute((weak));
49 extern const app_lib_beacon_rx_t * lib_beacon_rx __attribute((weak));
50 extern const app_lib_advertiser_t * lib_advertiser __attribute((weak));
51 extern const app_lib_sleep_t * lib_sleep __attribute((weak));
52 extern const app_lib_memory_area_t * lib_memory_area __attribute((weak));
53 extern const app_lib_radio_cfg_t * lib_radio_cfg __attribute((weak));
54 extern const app_lib_joining_t * lib_joining __attribute((weak));
55 
56 
87 bool API_Open(const app_global_functions_t * functions);
88 
89 // Define error value for functions
90 #define ERR_NOT_OPEN APP_RES_INVALID_NULL_POINTER
91 
92 // System library
93 #define Sys_enterCriticalSection() \
94  lib_system ? lib_system->enterCriticalSection() : ERR_NOT_OPEN
95 
96 #define Sys_exitCriticalSection() \
97  lib_system ? lib_system->exitCriticalSection() : ERR_NOT_OPEN
98 
99 #define Sys_disableDs(_dis) \
100  lib_system ? lib_system->disableDeepSleep(_dis) : ERR_NOT_OPEN
101 
102 #define Sys_enableAppIrq(_irqn, _isr) \
103  lib_system ? lib_system->enableAppIrq(false, _irqn, APP_LIB_SYSTEM_IRQ_PRIO_LO, _isr) : ERR_NOT_OPEN
104 
105 #define Sys_disableAppIrq(_irqn) \
106  lib_system ? lib_system->disableAppIrq(_irqn) : ERR_NOT_OPEN
107 
108 #define Sys_enableFastAppIrq(_irqn, _prio, _isr) \
109  lib_system ? lib_system->enableAppIrq(true, _irqn, _prio, _isr) : ERR_NOT_OPEN
110 
111 #define Sys_clearFastAppIrq(_irqn) \
112  lib_system ? lib_system->clearPendingFastAppIrq(_irqn) : ERR_NOT_OPEN
113 
114 // BLE beacon scanner library
115 #define Ble_beaconRx_setRxCb(_cb) \
116  lib_beacon_rx ? lib_beacon_rx->setBeaconReceivedCb(_cb) : ERR_NOT_OPEN
117 
118 #define Ble_beaconRx_startScanner(_chan) \
119  lib_beacon_rx ? lib_beacon_rx->startScanner(_chan) : ERR_NOT_OPEN
120 
121 #define Ble_beaconRx_stopScanner() \
122  lib_beacon_rx ? lib_beacon_rx->stopScanner() : ERR_NOT_OPEN
123 
124 #define Ble_beaconRx_isStarted() \
125  (lib_beacon_rx ? lib_beacon_rx->isScannerStarted() : ERR_NOT_OPEN)
126 
127 
128 #endif /* API_H_ */
sleep.h
app_lib_memory_area_t
List of library functions.
Definition: memory_area.h:255
app_lib_advertiser_t
List of library functions.
Definition: advertiser.h:199
settings.h
joining.h
app_lib_data_t
List of library services.
Definition: data.h:817
otap.h
memory_area.h
app_lib_storage_t
Definition: storage.h:77
app_lib_settings_t
Definition: settings.h:837
API_Open
bool API_Open(const app_global_functions_t *functions)
Open API (open all libraries)
app_lib_beacon_tx_t
Definition: beacon_tx.h:225
app_lib_radio_cfg_t
List of library functions.
Definition: radio_config.h:234
app_lib_hardware_t
List of library functions.
Definition: hardware.h:177
radio_config.h
app_lib_joining_t
List of library functions.
Definition: joining.h:307
time.h
app_lib_otap_t
Definition: otap.h:485
app_lib_sleep_t
List of library functions.
Definition: sleep.h:154
beacon_tx.h
app_lib_time_t
List of library functions.
Definition: time.h:192
app_lib_state_t
List of library functions of v3 version (0x202)
Definition: state.h:722
system.h
hardware.h
beacon_rx.h
storage.h
app_lib_system_t
List of library functions.
Definition: system.h:507
__attribute
const app_global_functions_t *global_func __attribute((weak))
data.h
advertiser.h
app_lib_beacon_rx_t
List of library functions.
Definition: beacon_rx.h:189
state.h
app_global_functions_t
List of global functions, passed to App_entrypoint()
Definition: app.h:157