Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Loading...
Searching...
No Matches
tempsense_app.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2019, Cascoda Ltd.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the copyright holder nor the
17 * names of its contributors may be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
34
35#ifndef TEMPSENSE_APP_H
36#define TEMPSENSE_APP_H
37
38/******************************************************************************/
39/****** System Definitions ******/
40/******************************************************************************/
42#define APP_WAKEUPINTERVALL 5
44#define APP_TIMEOUTINTERVALL 15
46#define APP_DEVICETIMEOUT 1000
48#define APP_DEVICE_MAX_RETRIES 1
50#define APP_MAX_DEVICES 32
52#define APP_DEFAULT_PDN_MODE PDM_DPD
54#define APP_USE_EXTERNAL_CLOCK 1
56#define APP_LQI_LIMIT 75
58#define APP_ED_LIMIT 50
60#define APP_VBAT_LIMIT 1862 /* = 2.5 V */
62#define APP_REPORT_VBATT 1
64#define APP_REPORT_LQI 1
66#define APP_REPORT_ED 1
68#define APP_COORD_REPORTN 1
70#define APP_COORD_SREINIT 0
72#define APP_USE_DEBUG 0
73
74/******************************************************************************/
75/****** MAC PIB Default Values ******/
76/******************************************************************************/
77#define MAC_PANID 0xCA5C
78#define MAC_SHORTADD 0xCA00
79#define MAC_LONGADD \
80 { \
81 0x00, 0x00, 0x00, 0x00, 0xA0, 0x0D, 0x5C, 0xCA \
82 }
83#define MAC_CHANNELLIST \
84 { \
85 11, 18, 24 \
86 }
87
88/******************************************************************************/
89/****** Application State Definitions ******/
90/******************************************************************************/
91#define APP_ST_NORMAL 0
92#define APP_ST_COORDINATOR 1
93#define APP_ST_DEVICE 2
94
95/******************************************************************************/
96/****** Communication State Definitions ******/
97/******************************************************************************/
98#define APP_CST_DONE 0x00
99#define APP_CST_WAKEUP_REQUESTED 0x01
100#define APP_CST_WAKEUP_CONFIRMED 0x02
101#define APP_CST_WAKEUP_RECEIVED 0x03
102#define APP_CST_C_DATA_REQUESTED 0x04
103#define APP_CST_C_DATA_CONFIRMED 0x05
104#define APP_CST_C_DATA_RECEIVED 0x06
105#define APP_CST_D_DATA_REQUESTED 0x07
106#define APP_CST_GO_POWERDOWN 0x08
107#define APP_CST_ASSOC_REQUESTED 0x09 //|< assoc. request sent (device)
108#define APP_CST_SCANNING 0x0A //|< scanning in progress (device)
109
110/******************************************************************************/
111/****** Data Packet Types, defined by MSDU[0] ******/
112/******************************************************************************/
113#define PT_MSDU_D_WAKEUP 0x01
114#define PT_MSDU_C_DATA 0x02
115#define PT_MSDU_D_DATA 0x03
116
117/******************************************************************************/
118/****** Global Variables ******/
119/******************************************************************************/
120extern u8_t APP_STATE;
121extern u8_t APP_STATE_new;
122extern u8_t APP_INITIALISE;
123extern u8_t APP_CONNECTED;
124
125extern u16_t APP_PANId;
127extern u8_t APP_LongAddress[8];
128extern u8_t APP_Channel;
129
130/******************************************************************************/
131/****** APP Functions ******/
132/******************************************************************************/
133/* tempsense_app */
134
135/******************************************************************************/
136/***************************************************************************/
140void TEMPSENSE_APP_Handler(struct ca821x_dev *pDeviceRef);
141
142/******************************************************************************/
143/***************************************************************************/
147void TEMPSENSE_APP_Initialise(struct ca821x_dev *pDeviceRef);
148
149/******************************************************************************/
150/***************************************************************************/
155
156/******************************************************************************/
157/***************************************************************************/
162
163/******************************************************************************/
164/***************************************************************************/
168void TEMPSENSE_APP_InitPIB(struct ca821x_dev *pDeviceRef);
169
170/******************************************************************************/
171/***************************************************************************/
178
179/******************************************************************************/
180/***************************************************************************/
187
188/******************************************************************************/
189/***************************************************************************/
196
197/******************************************************************************/
198/***************************************************************************/
203
204/******************************************************************************/
205/***************************************************************************/
210
211/******************************************************************************/
212/***************************************************************************/
217
218/* tempsense_app_coord */
219
220/******************************************************************************/
221/***************************************************************************/
225void TEMPSENSE_APP_Coordinator_Handler(struct ca821x_dev *pDeviceRef);
226
227/******************************************************************************/
228/***************************************************************************/
232void TEMPSENSE_APP_Coordinator_Initialise(struct ca821x_dev *pDeviceRef);
233
234/******************************************************************************/
235/***************************************************************************/
241void TEMPSENSE_APP_Coordinator_Start(struct ca821x_dev *pDeviceRef);
242
243/******************************************************************************/
244/***************************************************************************/
248void TEMPSENSE_APP_Coordinator_ProcessScanCnf(struct MLME_SCAN_confirm_pset *params, struct ca821x_dev *pDeviceRef);
249
250/******************************************************************************/
251/***************************************************************************/
256 struct ca821x_dev *pDeviceRef);
257
258/******************************************************************************/
259/***************************************************************************/
264
265/******************************************************************************/
266/***************************************************************************/
270void TEMPSENSE_APP_Coordinator_ProcessDataCnf(struct MCPS_DATA_confirm_pset *params, struct ca821x_dev *pDeviceRef);
271
272/******************************************************************************/
273/***************************************************************************/
283 u8_t edcoord,
284 struct MCPS_DATA_indication_pset *params,
285 struct ca821x_dev *pDeviceRef);
286
287/******************************************************************************/
288/***************************************************************************/
293
294/******************************************************************************/
295/***************************************************************************/
302
303/******************************************************************************/
304/***************************************************************************/
311void TEMPSENSE_APP_Coordinator_CheckLQI(u8_t lqi_ts, u8_t lqi_coord);
312
313/******************************************************************************/
314/***************************************************************************/
321void TEMPSENSE_APP_Coordinator_CheckED(u8_t ed_ts, u8_t ed_coord);
322
323/******************************************************************************/
324/***************************************************************************/
328void TEMPSENSE_APP_Coordinator_SoftReinit(struct ca821x_dev *pDeviceRef);
329
330/******************************************************************************/
331/***************************************************************************/
336/* tempsense_app_device */
337
338/******************************************************************************/
339/***************************************************************************/
343void TEMPSENSE_APP_Device_Handler(struct ca821x_dev *pDeviceRef);
344
345/******************************************************************************/
346/***************************************************************************/
350void TEMPSENSE_APP_Device_Initialise(struct ca821x_dev *pDeviceRef);
351
352/******************************************************************************/
353/***************************************************************************/
358
359/******************************************************************************/
360/***************************************************************************/
364void TEMPSENSE_APP_Device_Start(struct ca821x_dev *pDeviceRef);
365
366/******************************************************************************/
367/***************************************************************************/
371void TEMPSENSE_APP_Device_ProcessScanCnf(struct MLME_SCAN_confirm_pset *params, struct ca821x_dev *pDeviceRef);
372
373/******************************************************************************/
374/***************************************************************************/
379 struct ca821x_dev *pDeviceRef);
380
381/******************************************************************************/
382/***************************************************************************/
386void TEMPSENSE_APP_Device_ProcessDataInd(struct MCPS_DATA_indication_pset *params, struct ca821x_dev *pDeviceRef);
387
388/******************************************************************************/
389/***************************************************************************/
393void TEMPSENSE_APP_Device_ProcessDataCnf(struct MCPS_DATA_confirm_pset *params, struct ca821x_dev *pDeviceRef);
394
395/******************************************************************************/
396/***************************************************************************/
400void TEMPSENSE_APP_Device_ExchangeData(struct ca821x_dev *pDeviceRef);
401
402/******************************************************************************/
403/***************************************************************************/
407void TEMPSENSE_APP_Device_CheckTimeout(struct ca821x_dev *pDeviceRef);
408
409/******************************************************************************/
410/***************************************************************************/
414void TEMPSENSE_APP_Device_GoPowerDown(struct ca821x_dev *pDeviceRef);
415
416/******************************************************************************/
417/***************************************************************************/
422
423/******************************************************************************/
424/***************************************************************************/
429
430#endif // TEMPSENSE_APP_H
Internal Function definitions for communicating with a host using UART/USB.
struct SerialBuffer SerialRxBuffer
Type definitions used by Cascoda baremetal drivers.
unsigned long u32_t
Definition cascoda_types.h:50
unsigned char u8_t
Definition cascoda_types.h:46
unsigned short u16_t
Definition cascoda_types.h:48
MCPS_DATA_confirm parameter set.
Definition mac_messages.h:357
MCPS_DATA_indication parameter set.
Definition mac_messages.h:384
MLME_ASSOCIATE_confirm parameter set.
Definition mac_messages.h:469
MLME_ASSOCIATE_indication parameter set.
Definition mac_messages.h:461
MLME_SCAN_confirm parameter set.
Definition mac_messages.h:507
Structure of serial transfers.
Definition cascoda_serial.h:50
CA-821x Device reference struct.
Definition ca821x_api.h:123
void TEMPSENSE_APP_Device_GoPowerDown(struct ca821x_dev *pDeviceRef)
TEMPSENSE App.
Definition tempsense_app_device.c:522
void TEMPSENSE_APP_Device_ProcessAssociateCnf(struct MLME_ASSOCIATE_confirm_pset *params, struct ca821x_dev *pDeviceRef)
Device Process incoming Data Indications.
Definition tempsense_app_device.c:240
void TEMPSENSE_APP_Coordinator_DisplayData(u8_t device, u8_t edcoord, struct MCPS_DATA_indication_pset *params, struct ca821x_dev *pDeviceRef)
TEMPSENSE App.
Definition tempsense_app_coord.c:543
void TEMPSENSE_APP_Device_Initialise(struct ca821x_dev *pDeviceRef)
TEMPSENSE Application Initialisation for Sensor Device.
Definition tempsense_app_device.c:87
void TEMPSENSE_APP_Device_ExchangeData(struct ca821x_dev *pDeviceRef)
TEMPSENSE App.
Definition tempsense_app_device.c:425
u8_t TEMPSENSE_APP_GetTempVal(void)
TEMPSENSE App.
Definition tempsense_app.c:214
void TEMPSENSE_APP_Coordinator_SoftReinit(struct ca821x_dev *pDeviceRef)
TEMPSENSE App.
Definition tempsense_app_coord.c:705
void TEMPSENSE_APP_Device_ProcessDataCnf(struct MCPS_DATA_confirm_pset *params, struct ca821x_dev *pDeviceRef)
Device Process incoming Data Confirms.
Definition tempsense_app_device.c:375
void TEMPSENSE_APP_Coordinator_ProcessDataInd(struct MCPS_DATA_indication_pset *params, struct ca821x_dev *pDeviceRef)
Coordinator Process incoming Data Indications.
Definition tempsense_app_coord.c:312
u16_t TEMPSENSE_APP_GetVoltsVal(void)
TEMPSENSE App.
Definition tempsense_app.c:228
void TEMPSENSE_APP_Device_SaveStateToFlash(void)
TEMPSENSE App.
Definition tempsense_app_device.c:600
void TEMPSENSE_APP_Device_ProcessDataInd(struct MCPS_DATA_indication_pset *params, struct ca821x_dev *pDeviceRef)
Device Process incoming Data Indications.
Definition tempsense_app_device.c:269
u8_t APP_STATE
module state
Definition tempsense_app.c:54
void TEMPSENSE_APP_Coordinator_Start(struct ca821x_dev *pDeviceRef)
TEMPSENSE App.
Definition tempsense_app_coord.c:103
void TEMPSENSE_APP_Device_Start(struct ca821x_dev *pDeviceRef)
TEMPSENSE App.
Definition tempsense_app_device.c:127
void TEMPSENSE_APP_Device_ProcessScanCnf(struct MLME_SCAN_confirm_pset *params, struct ca821x_dev *pDeviceRef)
Device Process incoming Scan Confirm.
Definition tempsense_app_device.c:155
u8_t APP_STATE_new
module state set in interrupts
Definition tempsense_app.c:55
u8_t APP_LongAddress[8]
Definition tempsense_app.c:62
void TEMPSENSE_APP_Coordinator_CheckTimeouts(struct ca821x_dev *pDeviceRef)
TEMPSENSE App.
Definition tempsense_app_coord.c:597
void TEMPSENSE_APP_LED_Handler(void)
module LEDs signalling
Definition tempsense_app.c:284
void TEMPSENSE_APP_Coordinator_ProcessScanCnf(struct MLME_SCAN_confirm_pset *params, struct ca821x_dev *pDeviceRef)
Coordinator Process incoming Scan Confirm.
Definition tempsense_app_coord.c:128
void TEMPSENSE_APP_Coordinator_ProcessDataCnf(struct MCPS_DATA_confirm_pset *params, struct ca821x_dev *pDeviceRef)
Coordinator Process incoming Data Confirmations.
Definition tempsense_app_coord.c:508
void TEMPSENSE_APP_Coordinator_CheckLQI(u8_t lqi_ts, u8_t lqi_coord)
TEMPSENSE App.
Definition tempsense_app_coord.c:675
u16_t APP_ShortAddress
Definition tempsense_app.c:61
void TEMPSENSE_APP_Coordinator_Handler(struct ca821x_dev *pDeviceRef)
TEMPSENSE Application Handler for Coordinator.
Definition tempsense_app_coord.c:64
void TEMPSENSE_APP_SwitchMode(u8_t mode)
TEMPSENSE Switch Mode.
Definition tempsense_app.c:151
void TEMPSENSE_APP_Coordinator_CheckED(u8_t ed_ts, u8_t ed_coord)
TEMPSENSE App.
Definition tempsense_app_coord.c:690
void TEMPSENSE_APP_Device_RestoreStateFromFlash(struct ca821x_dev *pDeviceRef)
TEMPSENSE App.
Definition tempsense_app_device.c:647
void TEMPSENSE_APP_Initialise(struct ca821x_dev *pDeviceRef)
TEMPSENSE Application Initialisation of MAC etc.
Definition tempsense_app.c:89
void TEMPSENSE_APP_Coordinator_ReportStatus(void)
TEMPSENSE App.
Definition tempsense_app_coord.c:737
u8_t APP_INITIALISE
flag for re-initialising application
Definition tempsense_app.c:56
void TEMPSENSE_APP_Coordinator_AssociateResponse(struct MLME_ASSOCIATE_indication_pset *params, struct ca821x_dev *pDeviceRef)
TEMPSENSE App.
Definition tempsense_app_coord.c:205
u32_t TEMPSENSE_APP_GetScanChannels(void)
TEMPSENSE App.
Definition tempsense_app.c:239
void TEMPSENSE_APP_Device_CheckTimeout(struct ca821x_dev *pDeviceRef)
TEMPSENSE App.
Definition tempsense_app_device.c:496
int TEMPSENSE_APP_UpStreamDispatch(struct SerialBuffer *SerialRxBuffer, struct ca821x_dev *pDeviceRef)
TEMPSENSE Dispatch Branch (UpStream, Serial)
Definition tempsense_app.c:136
void TEMPSENSE_APP_Handler(struct ca821x_dev *pDeviceRef)
TEMPSENSE Application Handler.
Definition tempsense_app.c:65
u8_t APP_Channel
Definition tempsense_app.c:63
u8_t APP_CONNECTED
sensor module is connected to coordinator
Definition tempsense_app.c:57
void TEMPSENSE_APP_Device_Handler(struct ca821x_dev *pDeviceRef)
TEMPSENSE Application Handler for Sensor Device.
Definition tempsense_app_device.c:65
void TEMPSENSE_APP_Coordinator_Initialise(struct ca821x_dev *pDeviceRef)
TEMPSENSE Application Initialisation for Coordinator.
Definition tempsense_app_coord.c:75
void TEMPSENSE_APP_InitPIB(struct ca821x_dev *pDeviceRef)
TEMPSENSE Application Initialisation of MAC PIB.
Definition tempsense_app.c:166
void TEMPSENSE_APP_Coordinator_CheckVbatt(u16_t vbat)
TEMPSENSE App.
Definition tempsense_app_coord.c:658
void TEMPSENSE_APP_PrintSeconds(void)
Prints AboluteTime in Seconds.
Definition tempsense_app.c:279
void TEMPSENSE_APP_Device_GetLongAddress(void)
TEMPSENSE Get Device LongAddress from Dataflash.
Definition tempsense_app_device.c:115
u16_t APP_PANId
Definition tempsense_app.c:60
void TEMPSENSE_APP_PrintScanChannels(void)
TEMPSENSE App.
Definition tempsense_app.c:261