summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/ZCL/include/zclOtauManager.h
blob: ad091491b7d469c4a351e9c7fb5253d14f466961 (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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/**************************************************************************//**
  \file zclOTAUManager.h

  \brief Declaration of the OTAU manager interface

  \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:
    16.05.11 A. Khromykh - Created.
*******************************************************************************/
#ifndef _ZCLOTAUMANAGER_H
#define _ZCLOTAUMANAGER_H

/******************************************************************************
                           Types section
******************************************************************************/
typedef struct
{ /* memory for storage of server discovery result */
  struct
  {
    void *next;
  } service;

  bool        busy;
  Endpoint_t  serverEndpoint;
  ShortAddr_t serverShortAddress;
  ExtAddr_t   serverExtAddress;
} ZclOtauDiscoveryResult_t;

typedef struct
{
  struct
  {
    void *next;
  } service;

  bool                           busy;
  uint8_t                        id;
  ZCL_Addressing_t               addressing;
  ZCL_Request_t                  zclCommandReq;

  union
  {
    ZCL_OtauQueryNextImageReq_t  queryNextImageReq;
    ZCL_OtauQueryNextImageResp_t queryNextImageResp;
    ZCL_OtauImageBlockReq_t      imageBlockReq;
    ZCL_OtauImageBlockResp_t     imageBlockResp;
    ZCL_OtauUpgradeEndReq_t      upgradeEndReq;
    ZCL_OtauUpgradeEndResp_t     upgradeEndResp;
  };
  ZCL_OtauImagePageReq_t         imagePageReq;
} ZclOtauServerTransac_t;

typedef struct
{
  uint32_t fileOffset;
  uint16_t size;
} ZclOtauMissedBlockResponses_t;

typedef struct
{
  uint8_t                        quantity;
  uint8_t                        internalBlockOffset;
  bool                           blockGetting;
  ZclOtauMissedBlockResponses_t *missedBlockResponses;
} otauMissedBlocksBuffer_t;

typedef struct
{
  OtauReqMemory_t              reqMem;
  OtauZclReqMemory_t           zclReqMem;
  HAL_AppTimer_t               genericTimer;
  HAL_AppTimer_t               pageRequestTimer;
  ZclOtauClientImageBuffer_t   otauParam;
  OtauImageAuxVar_t            imageAuxParam;
  OFD_MemoryAccessParam_t      memParam;
  ZCL_OtauFirmwareVersion_t    newFirmwareVersion;

  uint8_t                      discoveredServerAmount;
  ZclOtauDiscoveryResult_t    *discoveredServerMem;

  uint16_t                     pageReminderSize;
  otauMissedBlocksBuffer_t     missedBlocks;
} ZCL_OtauClientMem_t;

typedef struct
{
  ZCL_Request_t            unsolicitedReq;
  ZCL_OtauUpgradeEndResp_t unsolicitedUpgradeEndResp;

  uint8_t                  transacAmount;
  ZclOtauServerTransac_t  *serverTransac;
  uint16_t                 pageReminderSize;
} ZCL_OtauServerMem_t;

typedef struct
{
  ZCL_OtauStatInd_t     otauInd;
  ZCL_OtauInitParams_t  initParam;
  union
  {
    ZCL_OtauClientMem_t clientMem;
    ZCL_OtauServerMem_t serverMem;
  };
} ZclOtauMem_t;

/******************************************************************************
                           External variables section
******************************************************************************/
/** zclOtauMem is defined in zclOtauManager.c */
extern ZclOtauMem_t zclOtauMem;
extern bool isOtauBusy;

/******************************************************************************
                           Inline functions section
******************************************************************************/
INLINE ZclOtauMem_t* zclGetOtauMem(void)
{
  return &zclOtauMem;
}

INLINE ZCL_OtauClientMem_t* zclGetOtauClientMem(void)
{
  return &zclOtauMem.clientMem;
}

INLINE ZCL_OtauServerMem_t* zclGetOtauServerMem(void)
{
  return &zclOtauMem.serverMem;
}

/******************************************************************************
                   Prototypes section
******************************************************************************/
/***************************************************************************//**
\brief Lift otau cluster action for customer.

\param[in] action - the OTAU action for a customer.
******************************************************************************/
void zclRaiseCustomMessage (const ZCL_OtauAction_t action);

/***************************************************************************//**
\brief Start otau client service
******************************************************************************/
void zclStartOtauClient(void);

/***************************************************************************//**
\brief Start otau server service
******************************************************************************/
void zclStartOtauServer(void);

/***************************************************************************//**
\brief Stop otau server service
******************************************************************************/
void zclStopOtauServer(void);

/***************************************************************************//**
\brief Clear otau server memory.
******************************************************************************/
void zclClearOtauServerMemory(void);

/***************************************************************************//**
\brief Clear otau client memory.
******************************************************************************/
void zclClearOtauClientMemory(void);

/***************************************************************************//**
\brief Find empty cell in memory pool.

\return pointer to empty cell.
******************************************************************************/
ZclOtauServerTransac_t * zclFindEmptyCell(void);

#endif /* _ZCLOTAUMANAGER_H */