Digi XBee(R) ANSI C Host Library
Files | Data Structures | Macros | Functions

        Code for a device to send over-the-air firmware updates to a
        Programmable XBee.
More...

Files

file  pxbee_ota_client.h
 
file  pxbee_ota_client.c
 Support code for over-the-air (OTA) firmware updates of application code on Programmable XBee target.
 

Data Structures

struct  pxbee_ota_t
 Structure for tracking state of over-the-air update. More...
 

Macros

#define PXBEE_OTA_MAX_AUTH_LENGTH   64
 
#define PXBEE_OTA_DATA_CLIENT_CLUST_ENTRY(ota, flags)
 Macro for adding the OTA receive cluster (Digi Transparent Serial) to the cluster list for WPAN_ENDPOINT_DIGI_DATA. More...
 
#define PXBEE_OTA_CMD_CLIENT_CLUST_ENTRY(handler, context, flag)
 

Functions

int pxbee_ota_init (pxbee_ota_t *ota, wpan_dev_t *dev, const addr64 *target)
 Initialize an pxbee_ota_t structure to send firmware updates to target using dev. More...
 
int _pxbee_ota_transparent_rx (const wpan_envelope_t FAR *envelope, void FAR *context)
 Cluster handler for "Digi Transparent Serial" cluster. More...
 
int _pxbee_ota_xmodem_read (void FAR *context, void FAR *buffer, int16_t bytes)
 
int _pxbee_ota_xmodem_write (void FAR *context, const void FAR *buffer, int16_t bytes)
 

Detailed Description

        Code for a device to send over-the-air firmware updates to a
        Programmable XBee.

Support code for over-the-air (OTA) firmware updates of application code on Programmable XBee target.

Macro Definition Documentation

#define PXBEE_OTA_CMD_CLIENT_CLUST_ENTRY (   handler,
  context,
  flag 
)
Value:
Start OTA update of PXBee App.
Definition: aps.h:143
#define WPAN_CLUST_FLAG_CLIENT
alias name for output cluster (uses ZCL terminology)
Definition: aps.h:236
#define WPAN_CLUST_FLAG_NOT_ZCL
this cluster is NOT using the ZigBee Cluster Library (ZCL)
Definition: aps.h:248
#define PXBEE_OTA_DATA_CLIENT_CLUST_ENTRY (   ota,
  flags 
)
Value:
Serial data.
Definition: aps.h:130
int _pxbee_ota_transparent_rx(const wpan_envelope_t FAR *envelope, void FAR *context)
Cluster handler for "Digi Transparent Serial" cluster.
Definition: pxbee_ota_client.c:47
#define WPAN_CLUST_FLAG_INOUT
both client and server cluster
Definition: aps.h:232
#define WPAN_CLUST_FLAG_NOT_ZCL
this cluster is NOT using the ZigBee Cluster Library (ZCL)
Definition: aps.h:248

Macro for adding the OTA receive cluster (Digi Transparent Serial) to the cluster list for WPAN_ENDPOINT_DIGI_DATA.

Parameters
[in]otapointer to an pxbee_ota_t structure for tracking update state
[in]flagsadditional flags for the cluster; typically 0 or WPAN_CLUST_FLAG_ENCRYPT

Function Documentation

int _pxbee_ota_transparent_rx ( const wpan_envelope_t FAR envelope,
void FAR context 
)

Cluster handler for "Digi Transparent Serial" cluster.

Used in the cluster table of WPAN_ENDPOINT_DIGI_DATA (0xE8) for cluster DIGI_CLUST_SERIAL (0x0011).

This is a preliminary API and WILL change in a future release. This version is dedicated to processing responses in OTA (over-the-air) firmware updates and has not been generalized for other uses.

Parameters
[in]envelopeinformation about the frame (addresses, endpoint, profile, cluster, etc.)
[in,out]contextpointer to pxbee_ota_t structure
Return values
0handled data
!0some sort of error processing data
See also
wpan_aps_handler_fn()

References FAR, hex_dump(), HEX_DUMP_FLAG_TAB, and xbee_cbuf_put().

int _pxbee_ota_xmodem_read ( void FAR context,
void FAR buffer,
int16_t  bytes 
)

Function assigned to the stream.read function pointer of an xbee_xmodem_state_t object. Reads data from the target specified in the pxbee_ota_t structure.

Parameters
[in]contextpxbee_ota_t structure
[in,out]bufferbuffer to store read data
[in]bytesmaximum number of bytes to write to buffer
See also
xbee_xmodem_read_fn()

References EINVAL, FAR, and xbee_cbuf_get().

Referenced by pxbee_ota_init().

int _pxbee_ota_xmodem_write ( void FAR context,
const void FAR buffer,
int16_t  bytes 
)

Function assigned to the stream.write function pointer of an xbee_xmodem_state_t object. Sends data to the target specified in the pxbee_ota_t structure.

Parameters
[in]contextpxbee_ota_t structure
[in,out]buffersource of data to send
[in]bytesnumber of bytes to send
Returns
Number of bytes sent to target.
See also
xbee_xmodem_write_fn()

References wpan_envelope_t::dev, EINVAL, FAR, wpan_envelope_t::length, wpan_envelope_t::payload, PXBEE_OTA_FLAG_APS_ENCRYPT, WPAN_CLUST_FLAG_ENCRYPT, wpan_envelope_create(), WPAN_NET_ADDR_UNDEFINED, and xbee_transparent_serial().

Referenced by pxbee_ota_init().

int pxbee_ota_init ( pxbee_ota_t ota,
wpan_dev_t dev,
const addr64 target 
)

Initialize an pxbee_ota_t structure to send firmware updates to target using dev.

Calls xbee_xmodem_tx_init and xbee_xmodem_set_stream (therefore unnecessary to do so in main program).

Note that when performing OTA updates, you MUST use XBEE_XMODEM_FLAG_64 (64-byte xmodem blocks) if calling xbee_xmodem_tx_init directly.

Sends frames to the target to have it start the update cycle.

Parameters
[in,out]otastate-tracking structure for sending update
[in]devdevice to use for sending update
[in]target64-bit address of target device
Return values
0successfully initialized
-EINVALinvalid parameter passed in

References _pxbee_ota_xmodem_read(), _pxbee_ota_xmodem_write(), pxbee_ota_t::auth_data, pxbee_ota_t::auth_length, pxbee_ota_t::cbuf, wpan_envelope_t::cluster_id, wpan_envelope_t::dest_endpoint, pxbee_ota_t::dev, DIGI_CLUST_PROG_XBEE_OTA_UPD, DIGI_CLUST_SERIAL, EINVAL, pxbee_ota_t::flags, wpan_envelope_t::length, wpan_envelope_t::payload, wpan_envelope_t::profile_id, PXBEE_OTA_FLAG_APS_ENCRYPT, wpan_envelope_t::source_endpoint, pxbee_ota_t::target, WPAN_CLUST_FLAG_ENCRYPT, WPAN_ENDPOINT_DIGI_DATA, wpan_envelope_create(), wpan_envelope_send(), WPAN_NET_ADDR_UNDEFINED, WPAN_PROFILE_DIGI, WPAN_SEND_FLAG_NONE, xbee_cbuf_init(), XBEE_XMODEM_FLAG_64, xbee_xmodem_set_stream(), xbee_xmodem_tx_init(), and pxbee_ota_t::xbxm.