Trident IoT Zigbee SDK
Loading...
Searching...
No Matches
tr_over_the_air_bootloading_client.h
Go to the documentation of this file.
1
10#ifndef TR_OVER_THE_AIR_BOOTLOADING_CLIENT_H
11#define TR_OVER_THE_AIR_BOOTLOADING_CLIENT_H
12
13#include "tr_af.h"
14
15#ifndef TR_OVER_THE_AIR_BOOTLOADING_CLIENT_QUERY_DELAY_MINUTES
16#define TR_OVER_THE_AIR_BOOTLOADING_CLIENT_QUERY_DELAY_MINUTES 5
17#endif
18
19#define TR_OVER_THE_AIR_BOOTLOADING_CLIENT_QUERY_TIMER_INTERVAL (60L * ZB_TIME_ONE_SECOND * TR_OVER_THE_AIR_BOOTLOADING_CLIENT_QUERY_DELAY_MINUTES)
20
21// define this to a 1 to include the hardware version in the query next image request
22#ifndef TR_OVER_THE_AIR_BOOTLOADING_CLIENT_QUERY_INCLUDE_HW_VERSION
23#define TR_OVER_THE_AIR_BOOTLOADING_CLIENT_QUERY_INCLUDE_HW_VERSION 0
24#endif
25
26#ifndef TR_OVER_THE_AIR_BOOTLOADING_CLIENT_MAX_DATA_SIZE
27#define TR_OVER_THE_AIR_BOOTLOADING_CLIENT_MAX_DATA_SIZE 64
28#endif
29
30// define this to a 1 to include the IEEE address in image block requests
31// this indicates a file that is intended for this specific device such as
32// security credentials, configuration, or log data
33#ifndef TR_OVER_THE_AIR_BOOTLOADING_CLIENT_IMAGE_BLOCK_REQUEST_INCLUDE_IEEE_ADDRESS
34#define TR_OVER_THE_AIR_BOOTLOADING_CLIENT_IMAGE_BLOCK_REQUEST_INCLUDE_IEEE_ADDRESS 0
35#endif
36
37// max number of retries for an ota upgrade packet
38#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_MAX_ZCL_RETRIES 3
39
40// maximum jitter value for query next image command
41#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_QUERY_JITTER_MAX_VALUE 100
42
43// resend delay, used in case we don't get a response
44#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_RESEND_DELAY (ZB_TIME_ONE_SECOND * 15)
45
46// default values for attributes
47#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_FILE_OFFSET_DEF_VALUE 0xFFFFFFFF
48#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_CURRENT_FILE_VERSION_DEF_VALUE 0xFFFFFFFF
49#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_DOWNLOADED_FILE_VERSION_DEF_VALUE 0xFFFFFFFF
50#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_MFG_ID_DEF_VALUE 0xFFFF
51#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_IMAGE_TYPE_DEF_VALUE 0xFFFF
52#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_HW_VERSION_DEF_VALUE 0
53
54#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_UPGRADE_TIME_DEF_VALUE 0xFFFFFFFF
55
56// wildcard values for command arguments
57#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_MFG_CODE_WILDCARD_VALUE 0xFFFF
58#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_IMAGE_TYPE_WILDCARD_VALUE 0xFFFF
59#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_FILE_VERSION_WILDCARD_VALUE 0xFFFFFFFF
60
61// enum for image notify payload type
69
70// field control byte for the query next image request command
71typedef union
72{
73 struct
74 {
75 zb_uint8_t hw_version_present : 1;
76 zb_uint8_t unused : 7;
77 };
78
79 zb_uint8_t data;
81
82// field control byte for the image block request command
83typedef union
84{
85 struct
86 {
87 zb_uint8_t ieee_address_present : 1;
89 zb_uint8_t unused : 6;
90 };
91
92 zb_uint8_t data;
94
95// definition of the values for the image upgrade status attribute
107
108// command structure for Over the Air Bootloading image block response with status wait for data
109typedef ZB_PACKED_PRE struct
110{
111 zb_uint8_t status;
112 zb_uint32_t current_time;
113 zb_uint32_t request_time;
116
117// Structure for saving OTA server information
118typedef struct
119{
120 zb_uint32_t image_size;
121 zb_uint32_t fw_version;
122 zb_uint16_t short_addr;
123 zb_uint8_t endpoint;
125
126// Structure for saving OTA client information
127typedef struct
128{
129 zb_uint32_t fw_version;
132 zb_uint16_t image_type;
133 zb_uint16_t mfg_id;
134 zb_uint16_t hw_version;
136 zb_uint8_t endpoint;
138 zb_uint8_t end_req_retries;
139 zb_uint8_t end_req_status;
141
142typedef ZB_PACKED_PRE struct
143{
144 zb_uint32_t file_id;
145 zb_uint16_t header_version;
146 zb_uint16_t header_length;
147 zb_uint16_t fc;
148 zb_uint16_t manufacturer_code;
149 zb_uint16_t image_type;
150 zb_uint32_t file_version;
151 zb_uint16_t stack_version;
152 zb_char_t header_string[32];
153 zb_uint32_t total_image_size;
155
156typedef ZB_PACKED_PRE struct
157{
158 zb_uint16_t tag_id;
159 zb_uint32_t length;
160 zb_uint8_t value[1];
162
163#define TR_ZCL_OVER_THE_AIR_BOOTLOADING_TAG_HEADER_LENGTH (sizeof(tr_zcl_over_the_air_bootloading_sub_element_t) - 1)
164
177
181#if defined(TR_OVER_THE_AIR_BOOTLOADING_CLIENT_PLUGIN_PRINT_ENABLE) && (TR_OVER_THE_AIR_BOOTLOADING_CLIENT_PLUGIN_PRINT_ENABLE == 1)
182#define tr_over_the_air_bootloading_client_printf(...) tr_zcl_printf(__VA_ARGS__)
183#define tr_over_the_air_bootloading_client_println(...) tr_zcl_println(__VA_ARGS__)
184#else
185#define tr_over_the_air_bootloading_client_printf(...)
186#define tr_over_the_air_bootloading_client_println(...)
187#endif
188
194
198
202zb_bool_t tr_over_the_air_bootloading_client_command_received_cb(zb_zcl_parsed_hdr_t *cmd_info);
203
210 zb_uint16_t attr_id,
211 zb_uint8_t *new_value,
212 zb_uint16_t manuf_code);
213
223zb_bool_t tr_over_the_air_bootloading_client_image_notify_cb(zb_zcl_parsed_hdr_t *cmd_info,
224 zb_uint8_t endpoint,
225 zb_uint8_t payload_type,
226 zb_uint8_t query_jitter,
227 zb_uint16_t manufacturer_id,
228 zb_uint16_t image_type,
229 zb_uint32_t new_file_version);
230
241 zb_uint8_t endpoint,
242 zb_uint8_t status,
243 zb_uint16_t manufacturer_id,
244 zb_uint16_t image_type,
245 zb_uint32_t file_version,
246 zb_uint32_t image_size);
247
260 zb_uint8_t endpoint,
261 zb_uint8_t status,
262 zb_uint16_t manufacturer_id,
263 zb_uint16_t image_type,
264 zb_uint32_t file_version,
265 zb_uint32_t file_offset,
266 zb_uint8_t data_size,
267 /* TYPE WARNING: array array defaults to */ zb_uint8_t *image_data);
268
279 zb_uint8_t endpoint,
280 zb_uint16_t manufacturer_id,
281 zb_uint16_t image_type,
282 zb_uint32_t file_version,
283 zb_uint32_t current_time,
284 zb_uint32_t upgrade_time);
285
296 zb_uint8_t endpoint,
297 zb_uint8_t status,
298 zb_uint16_t manufacturer_id,
299 zb_uint16_t image_type,
300 zb_uint32_t file_version,
301 zb_uint32_t image_size);
302
310 zb_uint32_t *fw_version,
311 zb_uint16_t *mfg_id,
312 zb_uint16_t *image_type,
313 zb_uint16_t *hw_version);
314
320 zb_uint32_t image_size,
321 zb_uint32_t starting_offset);
322
326
330zb_bool_t tr_over_the_air_bootloading_client_check_for_zigbee_upgrade_cb(zb_uint32_t downloaded_fw_version);
331
334
336
342
346
350
355
359
362
365
367
373
374#endif // TR_OVER_THE_AIR_BOOTLOADING_CLIENT_H
zb_uint8_t query_jitter
Definition tr_zcl_cmd_structs.h:654
zb_uint32_t new_file_version
Definition tr_zcl_cmd_structs.h:657
zb_uint8_t * image_data
Definition tr_zcl_cmd_structs.h:679
zb_uint32_t file_offset
Definition tr_zcl_cmd_structs.h:612
zb_uint8_t payload_type
Definition tr_zcl_cmd_structs.h:653
zb_uint32_t image_size
Definition tr_zcl_cmd_structs.h:667
zb_uint16_t manufacturer_id
Definition tr_zcl_cmd_structs.h:599
zb_uint8_t data_size
Definition tr_zcl_cmd_structs.h:678
zb_uint32_t upgrade_time
Definition tr_zcl_cmd_structs.h:689
tr_over_the_air_bootloading_server_info_t * tr_over_the_air_bootloading_client_get_server_info(void)
API to get the OTA server info.
tr_zcl_over_the_air_bootloading_sub_element_t * tr_over_the_air_bootloading_client_find_tag_header(zb_uint16_t tag_id)
API to locate a specific tag header in the ota file that is in flash.
void tr_over_the_air_bootloading_client_start(void)
API to start the OTA upgrade client.
tr_over_the_air_bootloading_client_info_t * tr_over_the_air_bootloading_client_get_client_info(void)
API to get the OTA client info.
tr_zcl_over_the_air_bootloading_file_header_t * tr_over_the_air_bootloading_client_get_ota_header(void)
API to return a pointer to the downloaded OTA file header.
void tr_over_the_air_bootloading_client_stop(void)
API to stop the OTA upgrade client.
zb_bool_t tr_over_the_air_bootloading_client_image_notify_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t payload_type, zb_uint8_t query_jitter, zb_uint16_t manufacturer_id, zb_uint16_t image_type, zb_uint32_t new_file_version)
Callback that user can declare to handle over the air bootloading cluster image notify command.
void tr_over_the_air_bootloading_client_upgrade_start_cb(zb_uint32_t image_version, zb_uint32_t image_size, zb_uint32_t starting_offset)
Callback fires to notify the application that an OTA download is about to start.
void tr_over_the_air_bootloading_client_mfg_tag_found_cb(tr_zcl_over_the_air_bootloading_sub_element_t *tag_header)
Callback fires when a file is fully downloaded and verified, and has manufacturer specific tags.
void tr_over_the_air_bootloading_client_version_cb(zb_uint8_t endpoint, zb_uint32_t *fw_version, zb_uint16_t *mfg_id, zb_uint16_t *image_type, zb_uint16_t *hw_version)
Callback that user can declare to override image upgrade parameters.
void tr_over_the_air_bootloading_client_write_attr_cb(zb_uint8_t endpoint, zb_uint16_t attr_id, zb_uint8_t *new_value, zb_uint16_t manuf_code)
Callback fires when an Over the Air Bootloading client attribute is about to be written.
zb_bool_t tr_over_the_air_bootloading_client_upgrade_end_response_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint16_t manufacturer_id, zb_uint16_t image_type, zb_uint32_t file_version, zb_uint32_t current_time, zb_uint32_t upgrade_time)
Callback that user can declare to handle over the air bootloading cluster upgrade end response comman...
void tr_over_the_air_bootloading_client_server_not_found_cb(void)
Callback to notify the application that no ota upgrade server was found.
void tr_over_the_air_bootloading_client_init_cb(zb_uint8_t endpoint)
Callback fires when the Over the Air Bootloading client cluster plugin is initialized.
zb_bool_t tr_over_the_air_bootloading_client_query_specific_file_response_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t status, zb_uint16_t manufacturer_id, zb_uint16_t image_type, zb_uint32_t file_version, zb_uint32_t image_size)
Callback that user can declare to handle over the air bootloading cluster query specific file respons...
zb_bool_t tr_over_the_air_bootloading_client_command_received_cb(zb_zcl_parsed_hdr_t *cmd_info)
Callback that user can declare to handle any Over the Air Bootloading client commands.
zb_bool_t tr_over_the_air_bootloading_client_image_block_response_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t status, zb_uint16_t manufacturer_id, zb_uint16_t image_type, zb_uint32_t file_version, zb_uint32_t file_offset, zb_uint8_t data_size, zb_uint8_t *image_data)
Callback that user can declare to handle over the air bootloading cluster image block response comman...
zb_bool_t tr_over_the_air_bootloading_client_check_for_zigbee_upgrade_cb(zb_uint32_t downloaded_fw_version)
Callback to allow the application to determine if the zigbee firmware needs to be upgraded.
zb_bool_t tr_over_the_air_bootloading_client_query_next_image_response_cb(zb_zcl_parsed_hdr_t *cmd_info, zb_uint8_t endpoint, zb_uint8_t status, zb_uint16_t manufacturer_id, zb_uint16_t image_type, zb_uint32_t file_version, zb_uint32_t image_size)
Callback that user can declare to handle over the air bootloading cluster query next image response c...
Definition tr_over_the_air_bootloading_client.h:128
zb_uint16_t mfg_id
Definition tr_over_the_air_bootloading_client.h:133
zb_uint32_t download_file_size
Definition tr_over_the_air_bootloading_client.h:130
zb_uint8_t endpoint
Definition tr_over_the_air_bootloading_client.h:136
zb_uint32_t offset_at_last_attr_save
Definition tr_over_the_air_bootloading_client.h:131
zb_uint16_t saved_min_block_period
Definition tr_over_the_air_bootloading_client.h:135
zb_uint8_t end_req_retries
Definition tr_over_the_air_bootloading_client.h:138
zb_uint8_t end_req_status
Definition tr_over_the_air_bootloading_client.h:139
zb_uint8_t block_req_retries
Definition tr_over_the_air_bootloading_client.h:137
zb_uint16_t image_type
Definition tr_over_the_air_bootloading_client.h:132
zb_uint16_t hw_version
Definition tr_over_the_air_bootloading_client.h:134
zb_uint32_t fw_version
Definition tr_over_the_air_bootloading_client.h:129
Definition tr_over_the_air_bootloading_client.h:119
zb_uint32_t image_size
Definition tr_over_the_air_bootloading_client.h:120
zb_uint8_t endpoint
Definition tr_over_the_air_bootloading_client.h:123
zb_uint16_t short_addr
Definition tr_over_the_air_bootloading_client.h:122
zb_uint32_t fw_version
Definition tr_over_the_air_bootloading_client.h:121
Trident application framework include.
tr_conn_state_e
Definition tr_af.h:24
tr_door_lock_user_status_t status
Definition tr_door_lock_server.h:26
zb_uint8_t endpoint
Definition tr_nvram_attr.h:176
zb_uint16_t manuf_code
Definition tr_nvram_attr.h:180
zb_uint16_t attr_id
Definition tr_nvram_attr.h:178
ZB_PACKED_PRE struct @215301053273224120306224226164135246007144231067 tr_over_the_air_bootloading_image_block_response_wait_for_data_cmd_t
zb_char_t header_string[32]
Definition tr_over_the_air_bootloading_client.h:152
ZB_PACKED_PRE struct @152126221307375011043075175234276362307071330300 tr_zcl_over_the_air_bootloading_sub_element_t
zb_uint32_t file_id
Definition tr_over_the_air_bootloading_client.h:144
zb_uint32_t request_time
Definition tr_over_the_air_bootloading_client.h:113
tr_over_the_air_bootloading_client_image_notify_payload_type_t
Definition tr_over_the_air_bootloading_client.h:63
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_IMAGE_NOTIFY_PAYLOAD_JITTER_CODE_IMAGE
Definition tr_over_the_air_bootloading_client.h:66
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_IMAGE_NOTIFY_PAYLOAD_JITTER
Definition tr_over_the_air_bootloading_client.h:64
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_IMAGE_NOTIFY_PAYLOAD_JITTER_CODE
Definition tr_over_the_air_bootloading_client.h:65
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_IMAGE_NOTIFY_PAYLOAD_JITTER_CODE_IMAGE_VER
Definition tr_over_the_air_bootloading_client.h:67
tr_over_the_air_bootloading_client_status_t
Definition tr_over_the_air_bootloading_client.h:97
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_CLIENT_STATUS_DOWNLOADING
Definition tr_over_the_air_bootloading_client.h:99
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_CLIENT_STATUS_WAITING_UPGRADE
Definition tr_over_the_air_bootloading_client.h:101
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_CLIENT_STATUS_WAIT_FOR_MORE
Definition tr_over_the_air_bootloading_client.h:103
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_CLIENT_STATUS_UNKNOWN
Definition tr_over_the_air_bootloading_client.h:105
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_CLIENT_STATUS_COUNT_DOWN
Definition tr_over_the_air_bootloading_client.h:102
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_CLIENT_STATUS_NORMAL
Definition tr_over_the_air_bootloading_client.h:98
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_CLIENT_STATUS_WAIT_TO_UPGRADE_VIA_EXT_EVENT
Definition tr_over_the_air_bootloading_client.h:104
@ TR_ZCL_OVER_THE_AIR_BOOTLOADING_CLIENT_STATUS_DOWNLOADED
Definition tr_over_the_air_bootloading_client.h:100
zb_uint32_t file_version
Definition tr_over_the_air_bootloading_client.h:150
zb_uint16_t manufacturer_code
Definition tr_over_the_air_bootloading_client.h:148
zb_uint16_t fc
Definition tr_over_the_air_bootloading_client.h:147
zb_uint32_t length
Definition tr_over_the_air_bootloading_client.h:159
zb_uint16_t header_version
Definition tr_over_the_air_bootloading_client.h:145
void tr_over_the_air_bootloading_client_init(void)
zb_uint16_t minimum_block_period
Definition tr_over_the_air_bootloading_client.h:114
zb_uint8_t value[1]
Definition tr_over_the_air_bootloading_client.h:160
zb_uint16_t stack_version
Definition tr_over_the_air_bootloading_client.h:151
ZB_PACKED_PRE struct @125105020254034332120146102374364003242067252221 tr_zcl_over_the_air_bootloading_file_header_t
void tr_over_the_air_bootloading_client_connection_state_cb(tr_conn_state_e conn_state)
zb_uint16_t image_type
Definition tr_over_the_air_bootloading_client.h:149
zb_uint32_t total_image_size
Definition tr_over_the_air_bootloading_client.h:153
tr_zcl_ota_upgrade_sub_element_tag
Definition tr_over_the_air_bootloading_client.h:166
@ TR_ZCL_OTA_UPGRADE_FILE_TAG_PICTURE_DATA
Definition tr_over_the_air_bootloading_client.h:171
@ TR_ZCL_OTA_UPGRADE_FILE_TAG_IMAGE_INTEGRITY_CODE
Definition tr_over_the_air_bootloading_client.h:170
@ TR_ZCL_OTA_UPGRADE_FILE_TAG_ECDSA
Definition tr_over_the_air_bootloading_client.h:168
@ TR_ZCL_OTA_UPGRADE_FILE_TAG_MANUF_MAX
Definition tr_over_the_air_bootloading_client.h:175
@ TR_ZCL_OTA_UPGRADE_FILE_TAG_UPGRADE_IMAGE
Definition tr_over_the_air_bootloading_client.h:167
@ TR_ZCL_OTA_UPGRADE_FILE_TAG_MANUF_MIN
Definition tr_over_the_air_bootloading_client.h:174
@ TR_ZCL_OTA_UPGRADE_FILE_TAG_ECDSA_CERT_V_2
Definition tr_over_the_air_bootloading_client.h:173
@ TR_ZCL_OTA_UPGRADE_FILE_TAG_ECDSA_V_2
Definition tr_over_the_air_bootloading_client.h:172
@ TR_ZCL_OTA_UPGRADE_FILE_TAG_ECDSA_CERT
Definition tr_over_the_air_bootloading_client.h:169
zb_uint16_t tag_id
Definition tr_over_the_air_bootloading_client.h:158
zb_uint32_t current_time
Definition tr_over_the_air_bootloading_client.h:112
zb_uint16_t header_length
Definition tr_over_the_air_bootloading_client.h:146
Definition tr_over_the_air_bootloading_client.h:84
zb_uint8_t data
Definition tr_over_the_air_bootloading_client.h:92
zb_uint8_t minimum_block_period_present
Definition tr_over_the_air_bootloading_client.h:88
zb_uint8_t unused
Definition tr_over_the_air_bootloading_client.h:89
zb_uint8_t ieee_address_present
Definition tr_over_the_air_bootloading_client.h:87
Definition tr_over_the_air_bootloading_client.h:72
zb_uint8_t hw_version_present
Definition tr_over_the_air_bootloading_client.h:75
zb_uint8_t unused
Definition tr_over_the_air_bootloading_client.h:76
zb_uint8_t data
Definition tr_over_the_air_bootloading_client.h:79