252 lines
9.2 KiB
C
252 lines
9.2 KiB
C
/**
|
|
* @ingroup XBee
|
|
* @defgroup at_commands at commands
|
|
* at commands
|
|
* @brief DI XBee driver premade local and remote at commands
|
|
* @date March 30, 2017
|
|
* @author svlies
|
|
* @copyright 2017 Dual Inventive Technology Centre B.V.
|
|
*
|
|
* DI XBee driver modules
|
|
* @{
|
|
*/
|
|
#ifndef INCLUDE_DI_DRV_XBEE_CMD_H_
|
|
#define INCLUDE_DI_DRV_XBEE_CMD_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <di/types.h>
|
|
|
|
#include <di/drv/xbee.h>
|
|
|
|
struct di_drv_xbee_ctx;
|
|
|
|
/*
|
|
* AT commands for local xbee radio:
|
|
*/
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to set the baudrate.
|
|
* @param ctx Xbee driver context.
|
|
* @param baudrate enum baudrate for the UART.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_set_baudrate(struct di_drv_xbee_ctx *ctx, enum di_drv_xbee_baudrate baudrate);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to set the stopbits for the UART.
|
|
* @param ctx Xbee driver context.
|
|
* @param stopbits Number of stopbits for the UART.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_set_stopbit(struct di_drv_xbee_ctx *ctx, uint8_t stopbits);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to set the sleep time.
|
|
* @param ctx Xbee driver context.
|
|
* @param sleep_ms 24 bit hex sleep time in ms. if sleep coordinator, this is the sleep time of the network.
|
|
* @param wake_ms 24 bit hex wake time in ms. if sleep coordinator, this is the sleep time of the network.
|
|
* @param sleep_mode The sleepmode of the local xbee radio.
|
|
* @param options the sleep options of the local xbee radio.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_set_sleep_settings(struct di_drv_xbee_ctx *ctx,
|
|
uint32_t sleep_ms,
|
|
uint32_t wake_ms,
|
|
enum di_drv_xbee_sleep_mode sleep_mode,
|
|
enum di_drv_xbee_sleep_options opt);
|
|
/**
|
|
* Sends AT command to local XBee radio to set the network mode.
|
|
* @param ctx Xbee driver context.
|
|
* @param network_type 8 bit hex network type with options.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_set_network_type(struct di_drv_xbee_ctx *ctx, uint8_t network_type);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to set the API mode.
|
|
* @param ctx Xbee driver context.
|
|
* @param mode enum of the API mode.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_set_api_mode(struct di_drv_xbee_ctx *ctx, enum di_drv_xbee_api_modes mode);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to set the max hops.
|
|
* @param ctx Xbee driver context.
|
|
* @param hops max hops in the network.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_set_max_hops(struct di_drv_xbee_ctx *ctx, uint8_t hops);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to set the network ID, SN must be known before using this function.
|
|
* @param ctx Xbee driver context.
|
|
* @param fixed_id If true the network ID is always 0x3000, if false the network ID is calculated with the SN.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_set_network_id(struct di_drv_xbee_ctx *ctx, bool fixed_id);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to set the preamble ID.
|
|
* @param ctx Xbee driver context.
|
|
* @param preamble preamble ID of the Xbee radio.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_preamble_id(struct di_drv_xbee_ctx *ctx, uint8_t preamble);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to ask for its MSB.
|
|
* @param ctx Xbee driver context.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_request_sn(struct di_drv_xbee_ctx *ctx);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to ask for its firmware version.
|
|
* @param ctx Xbee driver context.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_request_fw_version(struct di_drv_xbee_ctx *ctx);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to ask for the RSSI of the last frame.
|
|
* @param ctx Xbee driver context.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_current_rssi(struct di_drv_xbee_ctx *ctx);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to apply changes.
|
|
* @param ctx Xbee driver context.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_apply_changes(struct di_drv_xbee_ctx *ctx);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to write changes to flash memory.
|
|
* @param ctx Xbee driver context.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_write_changes_to_flash(struct di_drv_xbee_ctx *ctx);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to return to factory settings.
|
|
* @param ctx Xbee driver context.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_restore_factory_defaults(struct di_drv_xbee_ctx *ctx);
|
|
|
|
/*
|
|
* AT commands for remote xbee radio:
|
|
*/
|
|
|
|
/**
|
|
* Sends AT command to remote XBee radio to set the baudrate.
|
|
* @param ctx Xbee driver context.
|
|
* @param dst_addr 64 bit destination of the remote radio.
|
|
* @param baudrate enum baudrate for the UART.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_remote_set_baudrate(
|
|
struct di_drv_xbee_ctx *ctx, uint64_t dst_addr, enum di_drv_xbee_baudrate baudrate);
|
|
|
|
/**
|
|
* Sends AT command to remote XBee radio to set the stopbits for the UART.
|
|
* @param ctx Xbee driver context.
|
|
* @param dst_addr destination address of the remote radio.
|
|
* @param stopbits Number of stopbits for the UART.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_remote_set_stopbit(struct di_drv_xbee_ctx *ctx, uint64_t dst_addr, uint8_t stopbits);
|
|
|
|
/**
|
|
* Sends AT command to local XBee radio to set the sleep time.
|
|
* @param ctx Xbee driver context.
|
|
* @param dst_addr destination address of the remote radio.
|
|
* @param sleep_ms 24 bit hex sleep time in ms. if sleep coordinator, this is the sleep time of the network.
|
|
* @param wake_ms 24 bit hex wake time in ms. if sleep coordinator, this is the sleep time of the network.
|
|
* @param sleep_mode The sleepmode of the remote xbee radio.
|
|
* @param options the sleep options of the remote xbee radio.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_set_remote_sleep_settings(struct di_drv_xbee_ctx *ctx,
|
|
uint64_t dst_addr,
|
|
uint32_t sleep_ms,
|
|
uint32_t wake_ms,
|
|
enum di_drv_xbee_sleep_mode sleep_mode,
|
|
enum di_drv_xbee_sleep_options options);
|
|
|
|
/**
|
|
* Sends AT command to remote XBee radio to set the network mode.
|
|
* @param ctx Xbee driver context.
|
|
* @param dst_addr destination address of the remote radio.
|
|
* @param network_type hex network type with options.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_remote_set_network_type(
|
|
struct di_drv_xbee_ctx *ctx, uint64_t dst_addr, uint8_t network_type);
|
|
|
|
/**
|
|
* Sends AT command to remote XBee radio to set the API mode.
|
|
* @param ctx Xbee driver context.
|
|
* @param dst_addr destination address of the remote radio.
|
|
* @param mode enum of the API mode.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_remote_set_api_mode(
|
|
struct di_drv_xbee_ctx *ctx, uint64_t dst_addr, enum di_drv_xbee_api_modes mode);
|
|
|
|
/**
|
|
* Sends AT command to remote XBee radio to set the max hops.
|
|
* @param ctx Xbee driver context.
|
|
* @param dst_addr destination address of the remote radio.
|
|
* @param hops max hops in the network.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_remote_set_max_hops(struct di_drv_xbee_ctx *ctx, uint64_t dst_addr, uint8_t hops);
|
|
|
|
/**
|
|
* Sends AT command to remote XBee radio to ask for its firmware version.
|
|
* @param ctx Xbee driver context.
|
|
* @param dst_addr destination address of the remote radio.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_remote_fw_version(struct di_drv_xbee_ctx *ctx, uint64_t dst_addr);
|
|
|
|
/**
|
|
* Sends AT command to remote XBee radio to apply changes.
|
|
* @param ctx Xbee driver context.
|
|
* @param dst_addr destination address of the remote radio.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_remote_apply_changes(struct di_drv_xbee_ctx *ctx, uint64_t dst_addr);
|
|
|
|
/**
|
|
* Sends AT command to remote XBee radio to write changes to flash memory.
|
|
* @param ctx Xbee driver context.
|
|
* @param dst_addr destination address of the remote radio.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_remote_write_changes_to_flash(struct di_drv_xbee_ctx *ctx, uint64_t dst_addr);
|
|
|
|
/**
|
|
* Sends AT command to remote XBee radio to return to factory settings.
|
|
* @param ctx Xbee driver context.
|
|
* @param dst_addr destination address of the remote radio.
|
|
* @return di_errno_t Returns DNOK if successful, else an errorcode.
|
|
*/
|
|
di_errno_t di_drv_xbee_remote_restore_factory_defaults(struct di_drv_xbee_ctx *ctx, uint64_t dst_addr);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
#endif /* INCLUDE_DI_DRV_XBEE_CMD_H_ */
|