summaryrefslogtreecommitdiffhomepage
path: root/digital/beacon/src/Bitcloud_stack/Components/APS/include/private/apsDataManager.h
blob: 510a55b0d6c5d42b7922a8facabe17b47f0ee705 (plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*************************************************************************//**
  \file apsDataManager.h

  \brief APS Data Manager header file

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
  History:
    06/06/07 A. Potashov - Created.
*****************************************************************************/


#ifndef _APS_DATAMANAGER_H
#define _APS_DATAMANAGER_H

/******************************************************************************
                   Includes section
******************************************************************************/
#include <bcEndian.h>
#include <aps.h>
#include <nwk.h>
#include <appTimer.h>
#include <apsFrames.h>
#include <apsMemoryManager.h>

/******************************************************************************
                   Types section
******************************************************************************/
typedef enum _ApsFragmentationState_t
{
  APS_FRAG_WAITING_BLOCK_0,
  APS_FRAG_WAITING_NEXT_BLOCK,
  APS_FRAG_SENDING_ACK,
  APS_FRAG_SENDING_LAST_ACK
} ApsFragmentationState_t;

typedef enum _ApsTransmittedDataHandlerState_t
{
  START_DATA_HANDLING_STATE,
  DATA_DECRYPTION_STATE,
  SEND_DATA_TO_BOUND_DEVICES_STATE,
  FINISH_DATA_HANDLING_STATE
} ApsTransmittedDataHandlerState_t;

/******************************************************************************
                   Prototypes section
******************************************************************************/

/*****************************************************************************
  Make a reset of APS Data Manager
  Parameters: fullReset - reset all internal variables of APS-layer or not.
  Returns:    None
*****************************************************************************/
APS_PRIVATE void apsResetDataManager(const bool fullReset);


/*****************************************************************************
  APS Stop Event Handler
  Parameters: options - options field APS_StopReq value
  Returns:    None
******************************************************************************/
APS_PRIVATE void apsStopDataManager(void);

/*****************************************************************************
  APS Data Manager Process function
  Parameters: None
  Returns: None
*****************************************************************************/
APS_PRIVATE void apsDataTaskHandler(void);

/*****************************************************************************
  APS Data Manager apsCounter get function
  Parameters: None
  Returns: apsCounter value
*****************************************************************************/
APS_PRIVATE uint8_t apsGetApsCounter(void);

/*****************************************************************************
  Routine for IEEE addressing. NWK address by Extended 64-bit address
  mapping function.
  Parameters: extAddr - extended 64-bit IEEE address pointer
  Returns: valid unicast NWK short address pointer
           NULL in other case
*****************************************************************************/
APS_PRIVATE const ShortAddr_t *apsFindShortByExt(const ExtAddr_t *const extAddr);

APS_PRIVATE void apsMakeNwkDataResp(NWK_DataInd_t *ind);

APS_PRIVATE void apsDmHotReset(void);

/**************************************************************************//***
  \brief  Further processing of frame which have been indicated from NWK, 
          passed initial checkings and optionally was decrypted.

  \param  nwkInd - NLDE-DATA.indication primitive pointer.
          securityStatus - securityStatus field value should be used in
          APS_DataInd primitive.
  \return true -  if the NWK Data Response needs to be executed for this
          indication, false - in other case.
*******************************************************************************/
APS_PRIVATE bool apsContinueNwkDataIndProcessing(NWK_DataInd_t *nwkDataInd,
  APS_Status_t securityStatus);

/*****************************************************************************
  APSDE-DATA.request with Short Addressing Mode process function
  Parameters: apsDataReq - APS_DataReq will be process
              nwkDataReqMem - buffer for NWK_DataReq
  Returns: APS_Status_t - status of operation
*****************************************************************************/
APS_PRIVATE APS_Status_t apsProcessShortAddrModeDataReq(APS_DataReq_t *apsDataReq,
  ApsDataBuffer_t *buffer);

/*****************************************************************************
  \brief Prepare and call NLDE-DATA.request primitive.

  \param[in] req - pointer to NLDE-DATA.request's parameters.
  \return None.
 *****************************************************************************/
APS_PRIVATE void apsSendNwkDataReq(NWK_DataReq_t *req);

/*****************************************************************************
  \brief Main APS Handler of NLDE-DATA.confirm.

  \param[in] conf - pointer to NLDE-DATA.confirm's parameters.
  \return None.
 *****************************************************************************/
APS_PRIVATE void apsDataManagerNwkDataConf(NWK_DataConf_t *conf);

/**************************************************************************//**
  \brief Recalculates transmission timeouts.

  \param transmission radius
  \return APS Ack timeout
 ******************************************************************************/
APS_PRIVATE uint32_t apsCalculateApsAckTimeout(uint8_t radius);

#if defined _SECURITY_ && defined _LINK_SECURITY_
/*************************************************************************//**
  \brief Frame encryption is finished

  \param buffer - buffer wich was encrypted
  \param status - status of operation
  \return none
*****************************************************************************/
APS_PRIVATE void apsEncryptDataFrameConf(ApsDataBuffer_t *buffer, uint8_t* pdu,
   uint8_t pduLength, uint8_t status);

/*****************************************************************************
  Indicates that sent frame which was previously encrypted is decrypted.
  Parameters: buffer - APS memory buffer pointer.
  Returns: None
*****************************************************************************/
APS_PRIVATE void apsDecryptSentFrameConf(ApsDataBuffer_t *buffer);
#endif /* _SECURITY_ and _LINK_SECURITY_ */

#endif  //#ifndef _APSDATAMANAGER_H
//eof apsDataManager.h