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 
48 typedef union
49 {
50  uint8_t bytes[APP_V2_TAG_LENGTH];
51  uint32_t array[APP_V2_TAG_LENGTH / 4];
52 } app_v2_tag_t;
53 
61 typedef struct
62 {
64  uint32_t api_version;
66  uint32_t start_address;
68  uint32_t length;
72 
79 typedef 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 
102 typedef uint32_t (*app_get_api_version_f)(void);
103 
109 
152 typedef const void * (*app_open_library_f)(uint32_t name, uint32_t version);
153 
157 typedef struct
158 {
163 
176 intptr_t App_entrypoint(const void * functions,
177  size_t reserved1,
178  const void ** reserved2,
179  void ** ram_top);
180 
182 typedef 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 
201 typedef enum
202 {
221 } app_res_e;
222 
228 typedef uint32_t app_addr_t;
229 
233 typedef enum
234 {
236  APP_ADDR_ANYSINK = 0xfffffffeu,
245  APP_ADDR_BROADCAST = 0xffffffffu,
251  APP_ADDR_MULTICAST = 0x80000000u,
254  APP_ADDR_MULTICAST_LAST = 0x80ffffffu,
256 
257 #endif /* APP_H_ */
APP_V2_TAG_LENGTH
#define APP_V2_TAG_LENGTH
Definition: wms_app.h:35
app_global_functions_t::getApiVersion
app_get_api_version_f getApiVersion
Definition: wms_app.h:159
app_information_header_t::start_ram_address
uint32_t start_ram_address
Definition: wms_app.h:70
app_information_header_t::api_version
uint32_t api_version
Definition: wms_app.h:64
app_information_header_t
Application information header.
Definition: wms_app.h:61
App_getApiVersion
static uint32_t App_getApiVersion(const void *const global_cb)
Definition: wms_app.h:184
app_v2_tag_t
Definition: wms_app.h:48
app_global_functions_t::openLibrary
app_open_library_f openLibrary
Definition: wms_app.h:161
APP_RES_RESOURCE_UNAVAILABLE
@ APP_RES_RESOURCE_UNAVAILABLE
Definition: wms_app.h:216
app_res_e
app_res_e
Definition: wms_app.h:201
App_entrypoint
intptr_t App_entrypoint(const void *functions, size_t reserved1, const void **reserved2, void **ram_top)
Application initial entrypoint.
APP_ADDR_BROADCAST
@ APP_ADDR_BROADCAST
Send packet as broadcast to all nodes.
Definition: wms_app.h:245
app_get_stack_firmware_version_f
app_firmware_version_t(* app_get_stack_firmware_version_f)(void)
Get stack firmware version.
Definition: wms_app.h:108
app_firmware_version_t
Definition: wms_app.h:79
APP_RES_NOT_IMPLEMENTED
@ APP_RES_NOT_IMPLEMENTED
Definition: wms_app.h:208
APP_RES_ACCESS_DENIED
@ APP_RES_ACCESS_DENIED
Definition: wms_app.h:220
APP_API_V1_VERSION
#define APP_API_V1_VERSION
Definition: wms_app.h:45
app_firmware_version_t::version
uint32_t version
Definition: wms_app.h:92
__STATIC_INLINE
#define __STATIC_INLINE
Definition: wms_app.h:20
APP_RES_OK
@ APP_RES_OK
Definition: wms_app.h:204
app_information_header_t::length
uint32_t length
Definition: wms_app.h:68
APP_RES_UNSPECIFIED_ERROR
@ APP_RES_UNSPECIFIED_ERROR
Definition: wms_app.h:206
app_information_header_t::start_address
uint32_t start_address
Definition: wms_app.h:66
APP_RES_INVALID_CONFIGURATION
@ APP_RES_INVALID_CONFIGURATION
Definition: wms_app.h:214
app_global_functions_t
List of global functions, passed to App_entrypoint()
Definition: wms_app.h:157
get_api_version_compatible_f
uint32_t(* get_api_version_compatible_f)(void)
Definition: wms_app.h:182
APP_ADDR_MULTICAST
@ APP_ADDR_MULTICAST
Definition: wms_app.h:251
APP_ADDR_MULTICAST_LAST
@ APP_ADDR_MULTICAST_LAST
Definition: wms_app.h:254
app_special_addr_e
app_special_addr_e
Special destination addresses for sending packets.
Definition: wms_app.h:233
APP_RES_INVALID_NULL_POINTER
@ APP_RES_INVALID_NULL_POINTER
Definition: wms_app.h:212
app_addr_t
uint32_t app_addr_t
Definition: wms_app.h:228
app_global_functions_t::getStackFirmwareVersion
app_get_stack_firmware_version_f getStackFirmwareVersion
Definition: wms_app.h:160
APP_ADDR_ANYSINK
@ APP_ADDR_ANYSINK
Definition: wms_app.h:236
app_get_api_version_f
uint32_t(* app_get_api_version_f)(void)
Definition: wms_app.h:102
APP_RES_INVALID_STACK_STATE
@ APP_RES_INVALID_STACK_STATE
Definition: wms_app.h:218
app_open_library_f
const typedef void *(* app_open_library_f)(uint32_t name, uint32_t version)
Open a library.
Definition: wms_app.h:152
APP_RES_INVALID_VALUE
@ APP_RES_INVALID_VALUE
Definition: wms_app.h:210