Digi XBee(R) ANSI C Host Library
Data Structures | Macros | Enumerations | Functions
xbee_firmware.c File Reference

API related to updating XBee firmware on the local XBee module. More...

#include <errno.h>
#include <stdio.h>
#include "xbee/platform.h"
#include "xbee/atmode.h"
#include "xbee/byteorder.h"
#include "xbee/firmware.h"

Data Structures

struct  xbee_oem_header_t
 

Macros

#define _xbee_firmware_debug
 
#define _TIME_ELAPSED(x)   (xbee_millisecond_timer() - source->timer > (x))
 
#define XBEE_OEM_MAGIC_NUMBER   0x93FD
 
#define XBEE_OEM_OFS_MAGIC_NUMBER   0
 
#define XBEE_OEM_OFS_CHECKSUM   2
 
#define XBEE_OEM_OFS_IMAGE_LEN   4
 
#define XBEE_OEM_OFS_HEADER_LEN   8
 
#define XBEE_OEM_OFS_MODULE_ID   10
 
#define XBEE_OEM_OFS_SW_COMPAT_LEVEL   11
 
#define XBEE_OEM_OFS_FW_VERSION   12
 
#define XBEE_BOOTLOADER_ACK   'U'
 
#define XBEE_BOOTLOADER_NAK   0x11
 
#define XBEE_OEM_FLAG_NONE   0x0000
 
#define XBEE_OEM_FLAG_FORCEUPDATE   0x0001
 
#define _TIME_ELAPSED(x)   (xbee_millisecond_timer() - source->timer > (x))
 

Enumerations

enum  {
  XBEE_FW_STATE_INIT, XBEE_FW_STATE_RESET, XBEE_FW_STATE_TOGGLE, XBEE_FW_STATE_BREAK,
  XBEE_FW_STATE_PROMPT, XBEE_FW_STATE_XMODEM_WAIT, XBEE_FW_STATE_XMODEM_SEND, XBEE_FW_STATE_XMODEM_DONE,
  XBEE_FW_STATE_FINAL_PROMPT, XBEE_FW_STATE_CMD_PENDING, XBEE_FW_STATE_CMD, XBEE_FW_STATE_PARSE_RESPONSE,
  XBEE_FW_STATE_CMD_HV, XBEE_FW_STATE_CMD_COMPAT, XBEE_FW_STATE_CMD_VR, XBEE_FW_STATE_CMD_CF1,
  XBEE_FW_STATE_CMD_SL, XBEE_FW_STATE_CMD_PROG, XBEE_FW_STATE_CMD_FR, XBEE_FW_STATE_BOOTLOADER,
  XBEE_FW_STATE_TX_START, XBEE_FW_STATE_TX_BLOCK, XBEE_FW_STATE_SENDING, XBEE_FW_STATE_RX_BLOCK,
  XBEE_FW_STATE_RX_FAIL, XBEE_FW_STATE_DONE, XBEE_FW_STATE_FAILURE, XBEE_FW_STATE_SUCCESS
}
 

Functions

int xbee_fw_install_init (xbee_dev_t *xbee, const wpan_address_t FAR *target, xbee_fw_source_t *source)
 
        Prepare to install new firmware on an attached XBee module.
More...
 
unsigned int xbee_fw_install_ebl_state (xbee_fw_source_t *source)
 Returns a unique value indicating the state of the .EBL/.GBL install process. More...
 
int xbee_fw_install_hcs08_tick (xbee_fw_source_t *source)
 Drive the firmware update process for the HCS08 application on Programmable XBee modules. More...
 
int xbee_fw_install_ebl_tick (xbee_fw_source_t *source)
 Drive the firmware update process for boards that use .EBL/.GBL files to store their firmware. More...
 
char FARxbee_fw_status_ebl (xbee_fw_source_t *source, char FAR *buffer)
 
  Update \a buffer with the current install status of \a source.
More...
 
int xbee_fw_read_byte (xbee_fw_source_t *source)
 
uint16_t xbee_fw_read_uint16 (xbee_fw_source_t *source)
 
uint32_t xbee_fw_read_uint32 (xbee_fw_source_t *source)
 
uint16_t xbee_fw_hex2word (const char *pString)
 
int _xbee_oem_verify (xbee_fw_source_t *source)
 
int _xbee_fw_send_request (xbee_fw_source_t *source, const FAR char *request, int next_state)
 
int xbee_fw_install_oem_tick (xbee_fw_source_t *source)
 Install the firmware image stored in source. More...
 
char FARxbee_fw_status_oem (xbee_fw_source_t *source, char FAR *buffer)
 Update buffer with the current install status of source. More...
 
int _xbee_fw_buffer_seek (void FAR *context, uint32_t offset)
 Helper function used when the source firmware image is entirely held in a buffer. More...
 
int _xbee_fw_buffer_read (void FAR *context, void FAR *buffer, int16_t bytes)
 Helper function used when the source firmware image is entirely held in a buffer. More...
 
int xbee_fw_buffer_init (xbee_fw_buffer_t *fw, uint32_t length, const char FAR *address)
 Helper function for setting up an xbee_fw_buffer_t for use with a source firmware image held entirely in a buffer. More...
 

Detailed Description

API related to updating XBee firmware on the local XBee module.

This could grow to support OTA (Over The Air) updates, via an expanded API.

Include helper API for initiating an update via firmware loaded to a far char buffer. An additional xbee_firmware_fat.lib could include helper functions for installing firmware from a file on the FAT filesystem.

Define XBEE_FIRMWARE_VERBOSE for debugging messages.

Define XBEE_FIRMWARE_DEBUG to make the functions in this file debuggable.

See xbee_bl_gen3.c and xbee/bl_gen3.h for "Gen3" bootloader support (using .ebin files).