Wirepas SDK
wms_app.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
13#ifndef APP_H_
14#define APP_H_
15
16#include <stdlib.h>
17#include <stdint.h>
18
19/* TODO: Move to a separate header */
20#define __STATIC_INLINE static inline
21
28#define APP_API_VERSION 0x200
29
31#define APP_V2_TAG ("APP2\171\306\073\165" \
32 "\263\303\334\322\035\266\006\115")
33
35#define APP_V2_TAG_LENGTH 16
36
38#define APP_V2_TAG_OFFSET 48
39
40
42#define APP_V2_TAG_MIN_API_VERSION 0x200
43
45#define APP_API_V1_VERSION 0x100
46
48typedef union
49{
50 uint8_t bytes[APP_V2_TAG_LENGTH];
51 uint32_t array[APP_V2_TAG_LENGTH / 4];
53
61typedef struct
62{
64 uint32_t api_version;
66 uint32_t start_address;
68 uint32_t length;
72
79typedef union
80{
81 struct
82 {
84 uint8_t devel;
86 uint8_t maint;
88 uint8_t minor;
90 uint8_t major;
91 };
92 uint32_t version;
94
102typedef uint32_t (*app_get_api_version_f)(void);
103
109
152typedef const void * (*app_open_library_f)(uint32_t name, uint32_t version);
153
163
176intptr_t App_entrypoint(const void * functions,
177 size_t reserved1,
178 const void ** reserved2,
179 void ** ram_top);
180
182typedef uint32_t (*get_api_version_compatible_f)(void);
183
184__STATIC_INLINE uint32_t App_getApiVersion(const void * const global_cb)
185{
186 uint32_t version =
187 ((const get_api_version_compatible_f)*(const void **)global_cb)();
188 if (version < APP_API_V1_VERSION)
189 {
190 // Called function was actually the getCurrentRole() function,
191 // so the firmware only supports the v1 application API
192 return APP_API_V1_VERSION;
193 }
194 return version;
195}
196
222
228typedef uint32_t app_addr_t;
229
233typedef enum
234{
236 APP_ADDR_ANYSINK = 0xfffffffeu,
245 APP_ADDR_BROADCAST = 0xffffffffu,
251 APP_ADDR_MULTICAST = 0x80000000u,
256
257#endif /* APP_H_ */
app_special_addr_e
Special destination addresses for sending packets.
Definition wms_app.h:234
@ APP_ADDR_ANYSINK
Definition wms_app.h:236
@ APP_ADDR_MULTICAST
Definition wms_app.h:251
@ APP_ADDR_BROADCAST
Send packet as broadcast to all nodes.
Definition wms_app.h:245
@ APP_ADDR_MULTICAST_LAST
Definition wms_app.h:254
#define APP_V2_TAG_LENGTH
Definition wms_app.h:35
#define APP_API_V1_VERSION
Definition wms_app.h:45
app_get_stack_firmware_version_f getStackFirmwareVersion
Definition wms_app.h:160
uint32_t start_ram_address
Definition wms_app.h:70
app_res_e
Definition wms_app.h:202
@ APP_RES_OK
Definition wms_app.h:204
@ APP_RES_INVALID_CONFIGURATION
Definition wms_app.h:214
@ APP_RES_INVALID_VALUE
Definition wms_app.h:210
@ APP_RES_NOT_IMPLEMENTED
Definition wms_app.h:208
@ APP_RES_RESOURCE_UNAVAILABLE
Definition wms_app.h:216
@ APP_RES_INVALID_NULL_POINTER
Definition wms_app.h:212
@ APP_RES_ACCESS_DENIED
Definition wms_app.h:220
@ APP_RES_INVALID_STACK_STATE
Definition wms_app.h:218
@ APP_RES_UNSPECIFIED_ERROR
Definition wms_app.h:206
uint32_t(* app_get_api_version_f)(void)
Definition wms_app.h:102
static uint32_t App_getApiVersion(const void *const global_cb)
Definition wms_app.h:184
const void *(* app_open_library_f)(uint32_t name, uint32_t version)
Open a library.
Definition wms_app.h:152
app_get_api_version_f getApiVersion
Definition wms_app.h:159
#define __STATIC_INLINE
Definition wms_app.h:20
app_open_library_f openLibrary
Definition wms_app.h:161
uint32_t app_addr_t
Definition wms_app.h:228
uint32_t(* get_api_version_compatible_f)(void)
Definition wms_app.h:182
intptr_t App_entrypoint(const void *functions, size_t reserved1, const void **reserved2, void **ram_top)
Application initial entrypoint.
app_firmware_version_t(* app_get_stack_firmware_version_f)(void)
Get stack firmware version.
Definition wms_app.h:108
Application information header.
Definition wms_app.h:62
List of global functions, passed to App_entrypoint()
Definition wms_app.h:158