-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp_init.h
132 lines (119 loc) · 4.11 KB
/
app_init.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/***************************************************************************//**
* @file
* @brief app_init.h
*******************************************************************************
* # License
* <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b>
*
* This code was modified by Semtech
*******************************************************************************
*
* SPDX-License-Identifier: Zlib
*
* The licensor of this software is Silicon Laboratories Inc.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*
******************************************************************************/
#ifndef APP_INIT_H
#define APP_INIT_H
#ifdef __cplusplus
extern "C" {
#endif
// -----------------------------------------------------------------------------
// Includes
// -----------------------------------------------------------------------------
#include <stdint.h>
#include <stdbool.h>
#include "FreeRTOS.h"
#include "queue.h"
// -----------------------------------------------------------------------------
// Macros and Typedefs
// -----------------------------------------------------------------------------
// Sidewalk Events
enum event_type{
EVENT_TYPE_SIDEWALK = 0,
#if defined(SL_BLE_SUPPORTED)
EVENT_TYPE_CONNECTION_REQUEST,
EVENT_TYPE_GET_CONNECTION_STATUS,
#endif
EVENT_TYPE_SEND_COUNTER_UPDATE,
EVENT_TYPE_FACTORY_RESET,
EVENT_TYPE_LINK_SWITCH,
EVENT_TYPE_GET_TIME,
EVENT_TYPE_GET_MTU,
EVENT_TYPE_REGISTERED,
EVENT_TYPE_SEND,
// CSS TIMESYNC BACKOFF WORKAROUND BEGIN
#if defined(SL_CSS_SUPPORTED)
EVENT_TYPE_CSS_TIMESYNC_CHECK,
EVENT_TYPE_CSS_TIMESYNC_TIMEOUT,
#endif
// CSS TIMESYNC BACKOFF WORKAROUND END
EVENT_TYPE_WIFI_SCAN_START,
EVENT_TYPE_GNSS_SCAN_START,
EVENT_TYPE_SCAN_RESULT_SEND,
EVENT_TYPE_INVALID
};
// Sidewalk States defined in application context
enum app_state{
STATE_INIT = 0,
STATE_SIDEWALK_READY,
STATE_SIDEWALK_NOT_READY,
STATE_SIDEWALK_SECURE_CONNECTION
};
// Application context
typedef struct app_context{
TaskHandle_t main_task;
QueueHandle_t event_queue;
struct sid_handle *sidewalk_handle;
enum app_state state;
uint8_t counter;
uint32_t current_link_type;
#if defined(SL_BLE_SUPPORTED)
bool connection_request;
#endif
struct {
uint8_t index;
uint8_t nbytes_sent_this_fragment;
uint8_t current_fragment;
uint8_t total_fragments;
uint8_t total_bytes;
uint8_t num_bytes_sending;
size_t mtu;
uint8_t frag_type;
const uint8_t *buffer;
uint16_t app_send_msg_id;
} scan_result;
} app_context_t;
// -----------------------------------------------------------------------------
// Global Variables
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Public Function Declarations
// -----------------------------------------------------------------------------
/**************************************************************************//**
* The function is used for application initialization.
*
* @param None
* @returns None
*****************************************************************************/
void app_init(void);
#ifdef __cplusplus
}
#endif
#endif // APP_INIT_H