]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/tidep0084.git/blob - example/collector/csf.h
Updated to use the latest TI 15.4-Stack v2.1.0 from the SimpleLink CC13x0 SDK v1.30.
[apps/tidep0084.git] / example / collector / csf.h
1 /******************************************************************************
3  @file csf.h
5  @brief Collector Specific Functions API
7  Group: WCS LPC
8  $Target Devices: Linux: AM335x, Embedded Devices: CC1310, CC1350$
10  ******************************************************************************
11  $License: BSD3 2016 $
12   
13    Copyright (c) 2015, Texas Instruments Incorporated
14    All rights reserved.
15   
16    Redistribution and use in source and binary forms, with or without
17    modification, are permitted provided that the following conditions
18    are met:
19   
20    *  Redistributions of source code must retain the above copyright
21       notice, this list of conditions and the following disclaimer.
22   
23    *  Redistributions in binary form must reproduce the above copyright
24       notice, this list of conditions and the following disclaimer in the
25       documentation and/or other materials provided with the distribution.
26   
27    *  Neither the name of Texas Instruments Incorporated nor the names of
28       its contributors may be used to endorse or promote products derived
29       from this software without specific prior written permission.
30   
31    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
33    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34    PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
35    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
36    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
37    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
38    OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
40    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
41    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42  ******************************************************************************
43  $Release Name: TI-15.4Stack Linux x64 SDK ENG$
44  $Release Date: Mar 08, 2017 (2.01.00.10)$
45  *****************************************************************************/
46 #ifndef CSF_H
47 #define CSF_H
49 /******************************************************************************
50  Includes
51  *****************************************************************************/
53 #include <stdbool.h>
54 #include <stdint.h>
56 #include "llc.h"
57 #include "cllc.h"
58 #include "smsgs.h"
60 #ifdef __cplusplus
61 extern "C"
62 {
63 #endif
65 /******************************************************************************
66  Constants
67  *****************************************************************************/
69 /*! CSF Events - Key Event */
70 #define CSF_KEY_EVENT 0x0001
72 #define CSF_INVALID_SHORT_ADDR   0xFFFF
74 /******************************************************************************
75  Typedefs
76  *****************************************************************************/
79 /******************************************************************************
80  Function Prototypes
81  *****************************************************************************/
83 /*!
84  * @brief       The application calls this function during initialization.
85  *
86  * @param       sem - pointer to semaphore used by MAC API
87  */
88 extern void Csf_init(void *sem);
90 /*!
91  * @brief       The application must call this function periodically to
92  *              process any events that this module needs to process.
93  */
94 extern void Csf_processEvents(void);
96 /*!
97  * @brief       The application calls this function to retrieve the stored
98  *              network information.  The stored network information was saved
99  *              after starting a network.
100  *              <BR>
101  *              NOTE: If the "fh" is true you will need to free the
102  *              pInfo->info.fhNetInfo.fhInfo.bcNumChans and
103  *              pInfo->info.fhNetInfo.fhInfo.pUnicastChans buffers through
104  *              Csf_free().
105  *
106  * @param       pInfo - pointer to network information structure
107  *
108  * @return      True if the network information is available
109  */
110 extern bool Csf_getNetworkInformation(Llc_netInfo_t *pInfo);
112 /*!
113  * @brief       The application calls this function to indicate that it has 
114  *              started or restored the device in a network.
115  *
116  *              The information will be saved and used to determine if a 
117  *              network was already started and should be restored instead
118  *              of started.
119  *
120  * @param       restored - true if restored in network
121  * @param       pNetworkInfo - network information structure
122  */
123 extern void Csf_networkUpdate(bool restored, Llc_netInfo_t *pNetworkInfo);
125 /*!
126  * @brief       The application calls this function to indicate that a device
127  *              has joined the network.
128  *
129  *              The information will be saved.
130  *
131  * @param       pDevInfo - pointer to the device information
132  * @param       capInfo - capability information of the joining device.
133  *
134  * @return      ApiMac_assocStatus_success, ApiMac_assocStatus_panAtCapacity,
135  *              or ApiMac_assocStatus_panAccessDenied
136  */
137 extern ApiMac_assocStatus_t Csf_deviceUpdate(
138                 ApiMac_deviceDescriptor_t *pDevInfo,
139                 ApiMac_capabilityInfo_t *pCapInfo);
141 /*!
142  * @brief       The application calls this function to indicate that a device
143  *              is no longer active in the network.  This function will be
144  *              called when the device doesn't respond to the tracking request.
145  *
146  *              The information will be saved.
147  *
148  * @param       pDevInfo - pointer to the device information
149  * @param       timeout - true if not active because of tracking timeout.
150  *              meaning that the device didn't respond to the tracking request
151  *              within the timeout period.
152  */
153 extern void Csf_deviceNotActiveUpdate(ApiMac_deviceDescriptor_t *pDevInfo,
154                                       bool timeout);
156 /*!
157  * @brief       The application calls this function to indicate that a device
158  *              has responded to a Config Request.
159  *
160  *              The information will be saved.
161  *
162  * @param       pSrcAddr - short address of the device that sent the message
163  * @param       rssi - the received packet's signal strength
164  * @param       pMsg - pointer to the Config Response message
165  */
166 extern void Csf_deviceConfigUpdate(ApiMac_sAddr_t *pSrcAddr, int8_t rssi,
167                                    Smsgs_configRspMsg_t *pMsg);
169 /*!
170  * @brief       The application calls this function to indicate that a device
171  *              has reported sensor data.
172  *
173  *              The information will be saved.
174  *
175  * @param       pSrcAddr - short address of the device that sent the message
176  * @param       rssi - the received packet's signal strength
177  * @param       pMsg - pointer to the Sensor Data message
178  */
179 extern void Csf_deviceSensorDataUpdate(ApiMac_sAddr_t *pSrcAddr, int8_t rssi,
180                                        Smsgs_sensorMsg_t *pMsg);
182 /*!
183  * @brief       The application calls this function to indicate that a device
184  *              set a Toggle LED Response message.
185  *
186  * @param       pSrcAddr - short address of the device that sent the message
187  * @param       ledState - 0 is off, 1 is on
188  */
189 extern void Csf_toggleResponseReceived(ApiMac_sAddr_t *pSrcAddr, bool ledState);
191 /*!
192  * @brief       The application calls this function to indicate that the 
193  *              Coordinator's state has changed.
194  *
195  * @param       state - new state
196  */
197 extern void Csf_stateChangeUpdate(Cllc_states_t state);
199 /*!
200  * @brief       Initialize the tracking clock.
201  */
202 extern void Csf_initializeTrackingClock(void);
204 /*!
205  * @brief       set the tracking clock.
206  *
207  * @param       trackingTime - set timer this value (in msec)
208  */
209 extern void Csf_setTrackingClock(uint32_t trackingTime);
211 /*!
212  * @brief       Initialize the trickle timer clock
213  */
214 extern void Csf_initializeTrickleClock(void);
216 /*!
217  * @brief       Initialize the clock setting join permit duration
218  */
219 extern void Csf_initializeJoinPermitClock(void);
221 /*!
222  * @brief       Initialize the clock setting config request delay
223  */
224 extern void Csf_initializeConfigClock(void);
226 /*!
227  * @brief       Set trickle clock
228  *
229  * @param       trickleTime - duration of trickle timer( in msec)
230  * @param       frameType - type of Async frame
231  */
232 extern void Csf_setTrickleClock(uint32_t trickleTime, uint8_t frameType);
234 /*!
235  * @brief       Set Join Permit clock
236  *
237  * @param       joinDuration - duration for which join permit is TRUE( in msec)
238  */
239 extern void Csf_setJoinPermitClock(uint32_t joinDuration);
241 /*!
242  * @brief       Set Config request delay clock
243  *
244  * @param       delay - duration config request event is set( in msec)
245  */
246 extern void Csf_setConfigClock(uint32_t delay);
248 /*!
249  * @brief       Read the number of device list items stored
250  *
251  * @return      number of entries in the device list
252  */
253 extern uint16_t Csf_getNumDeviceListEntries(void);
255 /*!
256  * @brief       Find the short address from a given extended address
257  *
258  * @param       pExtAddr - extended address
259  *
260  * @return      CSF_INVALID_SHORT_ADDR if not found, otherwise the short address
261  */
262 extern uint16_t Csf_getDeviceShort(ApiMac_sAddrExt_t *pExtAddr);
264 /*!
265  * @brief       Find entry in device list from an address
266  *
267  * @param       pDevAddr - device address
268  * @param       pItem - place to put the device information
269  *
270  * @return      true if found, false if not
271  */
272 extern bool Csf_getDevice(ApiMac_sAddr_t *pDevAddr, Llc_deviceListItem_t *pItem);
274 /*!
275  * @brief       Find entry in device list
276  *
277  * @param       devIndex - Device number (not address)
278  * @param       pItem - place to put the device information
279  *
280  * @return      true if found, false if not
281  */
282 extern bool Csf_getDeviceItem(uint16_t devIndex, Llc_deviceListItem_t *pItem);
284 /*!
285  * @brief       Find entry in device list
286  *
287  * @param       size - number of bytes to allocate from heap
288  *
289  * @return      true if found, false if not
290  */
291 extern void *Csf_malloc(uint16_t size);
293 /*!
294  * @brief       Csf implementation for memory de-allocation
295  *
296  * @param       ptr - a valid pointer to the memory to free
297  */
298 extern void Csf_free(void *ptr);
300 /*!
301  * @brief       Update the Frame Counter
302  *
303  * @param       pDevAddr - pointer to device's address. If this pointer
304  *                         is NULL, it means that this is the frame counter
305  *                         for this device.
306  * @param       frameCntr -  valur of frame counter
307  */
308 extern void Csf_updateFrameCounter(ApiMac_sAddr_t *pDevAddr,
309                                    uint32_t frameCntr);
311 /*!
312  * @brief       Get the Frame Counter
313  *
314  * @param       pDevAddr - pointer to device's address. If this pointer
315  *                         is NULL, it means that this is the frame counter
316  *                         for this device.
317  * @param       pFrameCntr -  pointer to place to put the frame counter
318  *
319  * @return      true if the frame counter existed, false if not.
320  */
321 extern bool Csf_getFrameCounter(ApiMac_sAddr_t *pDevAddr,
322                                    uint32_t *pFrameCntr);
324 /*!
325  * @brief       Delete an entry from the device list
326  *
327  * @param       pAddr - address to remove from device list.
328  */
329 extern void Csf_removeDeviceListItem(ApiMac_sAddrExt_t *pAddr);
331 /*!
332  * @brief       Assert Indication
333  *
334  * @param       reason - Reason for Assert
335  *                     2 - HAL/ICALL
336  *                     3 - MAC
337  *                     4 - TIRTOS
338  */
339 extern void Csf_assertInd(uint8_t reason);
341 /*!
342  * @brief       Clear all the NV Items
343  */
344 extern void Csf_clearAllNVItems(void);
346 /*!
347  * @brief       Add an entry into the black list
348  *
349  * @param       pAddr - address to add into the black list. The address
350  *                      can be either short or extended.
351  *
352  * @return      true if added or already existed, false if problem
353  */
354 extern bool Csf_addBlackListItem(ApiMac_sAddr_t *pAddr);
356 /*!
357  * @brief       Check if config timer is active
358  *
359  * @return      true if active, false if not active
360  */
361 extern bool Csf_isConfigTimerActive(void);
363 /*!
364  * @brief       Check if tracking timer is active
365  *
366  * @return      true if active, false if not active
367  */
368 extern bool Csf_isTrackingTimerActive(void);
370 #ifdef __cplusplus
372 #endif
374 #endif /* CSF_H */
376 /*
377  *  ========================================
378  *  Texas Instruments Micro Controller Style
379  *  ========================================
380  *  Local Variables:
381  *  mode: c
382  *  c-file-style: "bsd"
383  *  tab-width: 4
384  *  c-basic-offset: 4
385  *  indent-tabs-mode: nil
386  *  End:
387  *  vim:set  filetype=c tabstop=4 shiftwidth=4 expandtab=true
388  */