AllWize Library
Public Member Functions | Protected Member Functions | Protected Attributes
AllWize Class Reference

#include <AllWize.h>

Inheritance diagram for AllWize:
Inheritance graph
[legend]
Collaboration diagram for AllWize:
Collaboration graph
[legend]

Public Member Functions

 AllWize (HardwareSerial *serial, uint8_t reset_gpio=GPIO_NONE, uint8_t config_gpio=GPIO_NONE)
 AllWize object constructor. More...
 
 AllWize (uint8_t rx, uint8_t tx, uint8_t reset_gpio=GPIO_NONE, uint8_t config_gpio=GPIO_NONE)
 AllWize object constructor. More...
 
void begin (uint8_t baudrate=MODEM_DEFAULT_BAUDRATE)
 Inits the module communications. More...
 
bool reset ()
 Resets the radio module. More...
 
void softReset ()
 Cleans the RX/TX line. More...
 
bool factoryReset ()
 Resets the module to factory settings. More...
 
void sleep ()
 Sets the radio module in sleep mode. More...
 
void wakeup ()
 Wakes up the radio from sleep mode. More...
 
bool ready ()
 Test whether the radio module is ready or not. More...
 
bool waitForReady (uint32_t timeout=DEFAULT_TIMEOUT)
 Waits for timeout millis for the module to be ready. More...
 
void dump (Stream &debug)
 Dumps the current memory configuration to the given stream. More...
 
bool ack ()
 Sends an ACK. More...
 
bool send (uint8_t *buffer, uint8_t len)
 Sends a byte array. More...
 
bool send (const char *buffer)
 Sends c-string. More...
 
bool available ()
 Returns true if a new message has been received and decoded This method has to be called in the main loop to monitor for incoming messages. More...
 
bool enableRX (bool enable)
 Enables or disables RF recever. More...
 
allwize_message_t read ()
 Returns latest received message. More...
 
void setControlInformation (uint8_t ci)
 Sets the control information byte. More...
 
uint8_t getControlInformation ()
 Gets the control information byte. More...
 
void master ()
 Sets the module in master mode. More...
 
void slave ()
 Sets the module in slave mode. More...
 
void repeater ()
 Sets the module in repeater mode. More...
 
void setChannel (uint8_t channel, bool persist=false)
 Sets the communications channel (for MBUS_MODE_R2 only) More...
 
void setPower (uint8_t power, bool persist=false)
 Sets the RF power. More...
 
void setDataRate (uint8_t dr)
 Sets the data rate. More...
 
void setMode (uint8_t mode, bool persist=false)
 Sets the module in one of the available MBus modes. More...
 
void setSleepMode (uint8_t mode)
 Sets the sleep mode. More...
 
void setAppendRSSI (bool value)
 Sets the RSSI mode value. More...
 
void setPreamble (uint8_t preamble)
 Sets the preamble length frame format. More...
 
void setTimeout (uint16_t ms)
 Sets the buffer timeout (also used for auto sleep modes) More...
 
void setNetworkRole (uint8_t role)
 Sets the network role. More...
 
void setLEDControl (uint8_t value)
 Sets the LED control. More...
 
void setDataInterface (uint8_t value)
 Sets the data interface for receiving packets. More...
 
void setControlField (uint8_t value, bool persist=false)
 Sets the control field value. More...
 
void setInstallMode (uint8_t mode, bool persist=false)
 Sets the module in one of the available operations modes. More...
 
void setEncryptFlag (uint8_t flag)
 Sets the encrypt flag setting. More...
 
void setDecryptFlag (uint8_t flag)
 Sets the decrypt flag setting. More...
 
void setKey (uint8_t reg, const uint8_t *key)
 Sets the default encryption key. More...
 
void setDefaultKey (const uint8_t *key)
 Sets the default encryption key. More...
 
void setAccessNumber (uint8_t value)
 Sets new/specific access number. More...
 
void setBaudRate (uint8_t baudrate)
 Sets the UART baud rate, requires reset to take effect. More...
 
uint8_t getChannel ()
 Gets the channel stored in non-volatile memory. More...
 
uint8_t getPower ()
 Gets the RF power stored in non-volatile memory. More...
 
uint8_t getDataRate ()
 Gets the data rate stored in non-volatile memory. More...
 
uint8_t getMode ()
 Gets the MBus mode stored in non-volatile memory. More...
 
uint8_t getSleepMode ()
 Gets the sleep mode stored in non-volatile memory. More...
 
uint8_t getPreamble ()
 Gets the preamble length frame format. More...
 
uint8_t getDataInterface ()
 Gets the data interface for receiving packets. More...
 
uint8_t getControlField ()
 Gets the control field value stored in non-volatile memory. More...
 
bool getAppendRSSI ()
 Gets the current RSSI mode value. More...
 
uint16_t getTimeout ()
 Gets the current buffer timeout (also used for auto sleep modes) More...
 
uint8_t getNetworkRole ()
 Gets the current network role. More...
 
uint8_t getLEDControl ()
 Gets the current LED control. More...
 
uint8_t getInstallMode ()
 Gets the install modevalue stored in non-volatile memory. More...
 
uint8_t getEncryptFlag ()
 Gets the encrypt flag setting. More...
 
uint8_t getDecryptFlag ()
 Gets the decrypt flag setting. More...
 
void getDefaultKey (uint8_t *key)
 Gets the default encryption key. More...
 
uint8_t getBaudRate ()
 Gets the UART baud rate. More...
 
uint32_t getBaudRateSpeed (uint8_t value)
 Gets the UART baud rate speed in bps. More...
 
float getRSSI ()
 Returns the RSSI of the last valid packet received TODO: values do not seem right and are not the same as in the packet. More...
 
uint8_t getTemperature ()
 Returns the internal temperature of the module. More...
 
uint16_t getVoltage ()
 Returns the internal voltage of the module. More...
 
String getMID ()
 Returns the Manufacturer ID. More...
 
bool setMID (uint16_t mid)
 Sets the Manufacturer ID. More...
 
String getUID ()
 Returns the Unique ID string. More...
 
bool setUID (uint32_t uid)
 Saved the UID into the module memory. More...
 
uint8_t getVersion ()
 Returns the device version from non-volatile memory. More...
 
void setVersion (uint8_t version)
 Sets the device version. More...
 
uint8_t getDevice ()
 Returns the device type from non-volatile memory. More...
 
void setDevice (uint8_t type)
 Sets the device type. More...
 
String getPartNumber ()
 Returns the module part number. More...
 
String getRequiredHardwareVersion ()
 Returns the minimum required hardware version to run the current firmware. More...
 
String getFirmwareVersion ()
 Returns the module firmware revision. More...
 
String getSerialNumber ()
 Returns the module serial number. More...
 
double getFrequency (uint8_t channel)
 Returns the frequency for the given channel. More...
 
uint16_t getDataRateSpeed (uint8_t dr)
 Returns the speed for te given datarate. More...
 
uint8_t getModuleType ()
 Returns the module type. More...
 
String getModuleTypeName ()
 Returns the module type. More...
 
bool setWizeControl (uint8_t wize_control)
 Sets the wize control field in the transpoprt layer. More...
 
void setWizeOperatorId (uint16_t wize_operator_id)
 Sets the wize operator ID field in the transpoprt layer. More...
 
void setWizeApplication (uint8_t wize_application)
 Sets the wize applicaton field in the transpoprt layer. More...
 
void setCounter (uint16_t counter)
 Sets the wize couonter field in the transpoprt layer. More...
 
uint16_t getCounter ()
 Gets the current wize counter. More...
 

Protected Member Functions

void _init ()
 
uint8_t _getAddress (uint8_t slot)
 Return the physical memory address for the given slot. More...
 
bool _setConfig (bool value)
 Sets or unsets config mode. More...
 
int8_t _sendCommand (uint8_t command, uint8_t *data, uint8_t len)
 Sends a command with the given data. More...
 
int8_t _sendCommand (uint8_t command, uint8_t data)
 Sends a command with the given data. More...
 
int8_t _sendCommand (uint8_t command)
 Sends a command with no data. More...
 
bool _cacheMemory (uint8_t *buffer)
 Reads and caches the module memory. More...
 
uint8_t _getMemory (uint8_t address)
 Returns the contents of memory address. More...
 
uint8_t _getMemory (uint8_t address, uint8_t *buffer, uint8_t len)
 Returns the contents of consecutive memory addresses. More...
 
bool _setMemory (uint8_t address, uint8_t data)
 Sets non-volatile memory contents starting from given address. More...
 
bool _setMemory (uint8_t address, uint8_t *data, uint8_t len)
 Sets non-volatile memory contents starting from given address. More...
 
bool _setSlot (uint8_t slot, uint8_t data)
 Sets non-volatile memory contents starting from given address. More...
 
bool _setSlot (uint8_t slot, uint8_t *data, uint8_t len)
 Sets non-volatile memory contents starting from given address. More...
 
uint8_t _getSlot (uint8_t slot)
 Returns the contents of single-byte memory slot. More...
 
uint8_t _getSlot (uint8_t slot, uint8_t *buffer, uint8_t len)
 Returns the contents of consecutive memory addresses. More...
 
String _getSlotAsHexString (uint8_t slot, uint8_t len)
 Returns the contents of the memory from a certain address as an HEX String. More...
 
String _getSlotAsString (uint8_t slot, uint8_t len)
 Returns the contents of the memory from a certain address as a String object. More...
 
void _readModel ()
 Searches for the module model. More...
 
bool _decode ()
 Decodes the current RX buffer contents. More...
 
void _flush ()
 Flushes the serial line to the module. More...
 
void _resetSerial ()
 Resets the serial object. More...
 
uint8_t _send (uint8_t *buffer, uint8_t len)
 Sends a binary buffer to the module UART. Returns the number of bytes actually sent. More...
 
uint8_t _send (uint8_t ch)
 Sends a single byte to the module UART. Returns the number of bytes actually sent. More...
 
int8_t _receive ()
 Listens to incoming data from the module until timeout or END_OF_RESPONSE. More...
 
int8_t _sendAndReceive (uint8_t *buffer, uint8_t len)
 Sends a binary buffer and waits for response. Returns the number of bytes received and stored in the internal _buffer. More...
 
int8_t _sendAndReceive (uint8_t ch)
 Sends a byte and waits for response. Returns the number of bytes received and stored in the internal _buffer. More...
 
int _timedRead ()
 Reads a byte from the stream with a timeout. More...
 
int _readBytes (char *buffer, uint16_t len)
 Reads the stream buffer up to a number of bytes. More...
 
int _readBytesUntil (char terminator, char *buffer, uint16_t len)
 Reads the stream buffer up to a certain char or times out. More...
 
void _hex2bin (char *hex, uint8_t *bin, uint8_t len)
 Converts a hex c-string to a binary buffer. More...
 
void _bin2hex (uint8_t *bin, char *hex, uint8_t len)
 Converts a binary buffer to an hex c-string. More...
 
void _niceDelay (uint32_t ms)
 Does a non-blocking delay. More...
 

Protected Attributes

int8_t _rx = -1
 
int8_t _tx = -1
 
Stream * _stream = NULL
 
HardwareSerial * _hw_serial = NULL
 
SoftwareSerial * _sw_serial = NULL
 
uint8_t _reset_gpio = GPIO_NONE
 
uint8_t _config_gpio = GPIO_NONE
 
bool _config = false
 
uint32_t _timeout = DEFAULT_TIMEOUT
 
uint32_t _baudrate = 19200
 
uint8_t _ci = CI_APP_RESPONSE_UP_SHORT
 
uint8_t _mbus_mode = 0xFF
 
uint8_t _data_interface = 0xFF
 
bool _append_rssi = false
 
uint8_t _access_number = 0
 
uint8_t _module = MODULE_UNKNOWN
 
bool _ready = false
 
uint8_t _memory [0x100] = {0xFF}
 
String _model
 
String _hw
 
String _fw
 
uint8_t _wize_control = 0x00
 
uint16_t _wize_operator_id = 0
 
uint8_t _wize_application = 0
 
uint16_t _counter = 0
 
allwize_message_t _message
 
uint8_t _buffer [RX_BUFFER_SIZE]
 
uint8_t _pointer = 0
 

Detailed Description

Definition at line 91 of file AllWize.h.

Constructor & Destructor Documentation

◆ AllWize() [1/2]

AllWize::AllWize ( HardwareSerial *  serial,
uint8_t  reset_gpio = GPIO_NONE,
uint8_t  config_gpio = GPIO_NONE 
)

AllWize object constructor.

Parameters
serialHardwareSerial object to communicate with the module
reset_gpioGPIO connected to the module RESET pin
config_gpioGPIO connected to the module CONFIG pin

Definition at line 40 of file AllWize.cpp.

Here is the call graph for this function:

◆ AllWize() [2/2]

AllWize::AllWize ( uint8_t  rx,
uint8_t  tx,
uint8_t  reset_gpio = GPIO_NONE,
uint8_t  config_gpio = GPIO_NONE 
)

AllWize object constructor.

Parameters
rxGPIO for RX
txGPIO for TX
reset_gpioGPIO connected to the module RESET pin
config_gpioGPIO connected to the module CONFIG pin

Definition at line 63 of file AllWize.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ _bin2hex()

void AllWize::_bin2hex ( uint8_t *  bin,
char *  hex,
uint8_t  len 
)
protected

Converts a binary buffer to an hex c-string.

Parameters
binBuffer to read the values from
hexC-string to store the hex values
lenLength of the input buffer

Definition at line 1855 of file AllWize.cpp.

Here is the caller graph for this function:

◆ _cacheMemory()

bool AllWize::_cacheMemory ( uint8_t *  buffer)
protected

Reads and caches the module memory.

Parameters
bufferBuffer with at least 256 positions to hold memory
Returns
True if successfully read

Definition at line 1249 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _decode()

bool AllWize::_decode ( )
protected

Decodes the current RX buffer contents.

Returns
Whether the contents are a valid packet

Message format depending current configuration

Data interface | 0 | 1 | 3 | 4 | 8 | C |

0. Start byte (0x68) | | | | * | | * |

  1. Length (1-byte) | * | * | * | * | * | * | length of sections 2 to 7
  2. Control field (1-byte) | * | | | * | * | * |
  3. Header (8-bytes) | * | | | * | * | * | manID (2 bytes) + address (6 bytes)
  4. Control info (1-byte) | * | * | * | * | * | * |
  5. App data (n-bytes) | * | * | * | * | * | * |
  6. RSSI (1-byte) | - | - | - | - | - | - |
  7. CRC (2-bytes) | | | | | * | * |
  8. Stop byte (0x16) | | | | * | | * |

Note:

  • Data Interface defaults to 0x04 for this version and RSSI enabled
  • Modes 0x01 and 0x03 not working in MBUS_MODE_OSP
  • Modes 0x01 and 0x03 should be the same, but 0x03 does ACK
  • Section 6 (RSSI) present always and only if RSSI_MODE == 1
  • Section 2 (C) and 3 (HEADER) not present in MBUS_MODE_OSP

Definition at line 1542 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _flush()

void AllWize::_flush ( )
protected

Flushes the serial line to the module.

Definition at line 1679 of file AllWize.cpp.

Here is the caller graph for this function:

◆ _getAddress()

uint8_t AllWize::_getAddress ( uint8_t  slot)
protected

Return the physical memory address for the given slot.

Parameters
slotMemory slot
Returns
An address, 0xFF if not found or non existant

Definition at line 1419 of file AllWize.cpp.

Here is the caller graph for this function:

◆ _getMemory() [1/2]

uint8_t AllWize::_getMemory ( uint8_t  address)
protected

Returns the contents of memory address.

Parameters
addressMemory address
Returns
Contents

Definition at line 1336 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _getMemory() [2/2]

uint8_t AllWize::_getMemory ( uint8_t  address,
uint8_t *  buffer,
uint8_t  len 
)
protected

Returns the contents of consecutive memory addresses.

Parameters
addressStarting memory address
bufferBuffer with at least 'len' position to store data to
lenNumber of positions to read
Returns
Number of positions actually read

Definition at line 1310 of file AllWize.cpp.

Here is the call graph for this function:

◆ _getSlot() [1/2]

uint8_t AllWize::_getSlot ( uint8_t  slot)
protected

Returns the contents of single-byte memory slot.

Parameters
slotMemory slot
Returns
Contents of the slot, 0 if error

Definition at line 1473 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _getSlot() [2/2]

uint8_t AllWize::_getSlot ( uint8_t  slot,
uint8_t *  buffer,
uint8_t  len 
)
protected

Returns the contents of consecutive memory addresses.

Parameters
slotMemory slot
bufferBuffer with at least 'len' position to store data to
lenNumber of positions to read
Returns
Number of positions actually read

Definition at line 1461 of file AllWize.cpp.

Here is the call graph for this function:

◆ _getSlotAsHexString()

String AllWize::_getSlotAsHexString ( uint8_t  slot,
uint8_t  len 
)
protected

Returns the contents of the memory from a certain address as an HEX String.

Parameters
slotMemory slot
lenNumber of bytes to read
Returns
Result (empty string if error)

Definition at line 1486 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _getSlotAsString()

String AllWize::_getSlotAsString ( uint8_t  slot,
uint8_t  len 
)
protected

Returns the contents of the memory from a certain address as a String object.

Parameters
slotMemory slot
lenNumber of bytes to read
Returns
Result (empty string if error)

Definition at line 1503 of file AllWize.cpp.

Here is the call graph for this function:

◆ _hex2bin()

void AllWize::_hex2bin ( char *  hex,
uint8_t *  bin,
uint8_t  len 
)
protected

Converts a hex c-string to a binary buffer.

Parameters
hexC-string with the hex values
binBuffer to store the converted values in
lenLength of the hex c-string

Definition at line 1842 of file AllWize.cpp.

◆ _init()

void AllWize::_init ( )
protected

Definition at line 75 of file AllWize.cpp.

Here is the caller graph for this function:

◆ _niceDelay()

void AllWize::_niceDelay ( uint32_t  ms)
protected

Does a non-blocking delay.

Parameters
msmilliseconds to delay

Definition at line 1866 of file AllWize.cpp.

Here is the caller graph for this function:

◆ _readBytes()

int AllWize::_readBytes ( char *  data,
uint16_t  len 
)
protected

Reads the stream buffer up to a number of bytes.

Parameters
dataBuffer to store the values to
lenMax number of bytes to read
Returns
Number of bytes read or -1 if timed out

Definition at line 1794 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readBytesUntil()

int AllWize::_readBytesUntil ( char  terminator,
char *  data,
uint16_t  len 
)
protected

Reads the stream buffer up to a certain char or times out.

Parameters
terminatorTerminating char
dataBuffer to store the values to
lenMax number of bytes to read
Returns
Number of bytes read or -1 if timed out

Definition at line 1818 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _readModel()

void AllWize::_readModel ( )
protected

Searches for the module model.

Definition at line 1264 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _receive()

int8_t AllWize::_receive ( )
protected

Listens to incoming data from the module until timeout or END_OF_RESPONSE.

Returns
Number of bytes received and stored in the internal _buffer.

Definition at line 1726 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _resetSerial()

void AllWize::_resetSerial ( )
protected

Resets the serial object.

Definition at line 120 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _send() [1/2]

uint8_t AllWize::_send ( uint8_t *  buffer,
uint8_t  len 
)
protected

Sends a binary buffer to the module UART. Returns the number of bytes actually sent.

Parameters
bufferBinary data to send
lenLength of the binary data
Returns
Number of bytes actually sent

Definition at line 1713 of file AllWize.cpp.

Here is the caller graph for this function:

◆ _send() [2/2]

uint8_t AllWize::_send ( uint8_t  ch)
protected

Sends a single byte to the module UART. Returns the number of bytes actually sent.

Parameters
chByte to send
Returns
Number of bytes actually sent

Definition at line 1695 of file AllWize.cpp.

◆ _sendAndReceive() [1/2]

int8_t AllWize::_sendAndReceive ( uint8_t *  buffer,
uint8_t  len 
)
protected

Sends a binary buffer and waits for response. Returns the number of bytes received and stored in the internal _buffer.

Parameters
bufferBinary data to send
lenLength of the binary data
Returns
Number of bytes received, -1 if timed out or error sending

Definition at line 1737 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _sendAndReceive() [2/2]

int8_t AllWize::_sendAndReceive ( uint8_t  ch)
protected

Sends a byte and waits for response. Returns the number of bytes received and stored in the internal _buffer.

Parameters
chByte to send (-1 if timed out)
Returns
Number of bytes received, -1 if timed out or error sending

Definition at line 1748 of file AllWize.cpp.

Here is the call graph for this function:

◆ _sendCommand() [1/3]

int8_t AllWize::_sendCommand ( uint8_t  command,
uint8_t *  data,
uint8_t  len 
)
protected

Sends a command with the given data.

Parameters
commandCommand key
dataBinary data to send
lenLength of the binary data

Definition at line 1200 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _sendCommand() [2/3]

int8_t AllWize::_sendCommand ( uint8_t  command,
uint8_t  data 
)
protected

Sends a command with the given data.

Parameters
commandCommand key
dataSingle byte
Returns
Number of bytes received, -1 if timed out or error sending

Definition at line 1217 of file AllWize.cpp.

Here is the call graph for this function:

◆ _sendCommand() [3/3]

int8_t AllWize::_sendCommand ( uint8_t  command)
protected

Sends a command with no data.

Parameters
commandCommand key
Returns
Number of bytes received, -1 if timed out or error sending

Definition at line 1233 of file AllWize.cpp.

Here is the call graph for this function:

◆ _setConfig()

bool AllWize::_setConfig ( bool  value)
protected

Sets or unsets config mode.

Parameters
valueTrue to enter config mode
Returns
True if in config mode

Definition at line 1171 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _setMemory() [1/2]

bool AllWize::_setMemory ( uint8_t  address,
uint8_t  data 
)
protected

Sets non-volatile memory contents starting from given address.

Parameters
addressMemory address
dataSingle byte to store at given address
Returns
True if the data was successfully saved

Definition at line 1354 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _setMemory() [2/2]

bool AllWize::_setMemory ( uint8_t  address,
uint8_t *  data,
uint8_t  len 
)
protected

Sets non-volatile memory contents starting from given address.

Parameters
addressMemory address
dataBinary data to store
lenLength of the binary data
Returns
True if the data was successfully saved

Definition at line 1384 of file AllWize.cpp.

Here is the call graph for this function:

◆ _setSlot() [1/2]

bool AllWize::_setSlot ( uint8_t  slot,
uint8_t  data 
)
protected

Sets non-volatile memory contents starting from given address.

Parameters
slotMemory slot
dataSingle byte to store at given address
Returns
True if the data was successfully saved

Definition at line 1447 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _setSlot() [2/2]

bool AllWize::_setSlot ( uint8_t  slot,
uint8_t *  data,
uint8_t  len 
)
protected

Sets non-volatile memory contents starting from given address.

Parameters
slotMemory slot
dataBinary data to store
lenLength of the binary data
Returns
True if the data was successfully saved

Definition at line 1434 of file AllWize.cpp.

Here is the call graph for this function:

◆ _timedRead()

int AllWize::_timedRead ( )
protected

Reads a byte from the stream with a timeout.

Returns
Read char or -1 if timed out

Definition at line 1758 of file AllWize.cpp.

Here is the caller graph for this function:

◆ ack()

bool AllWize::ack ( )

Sends an ACK.

Returns
Returns true if message has been correctly sent

Definition at line 432 of file AllWize.cpp.

Here is the call graph for this function:

◆ available()

bool AllWize::available ( )

Returns true if a new message has been received and decoded This method has to be called in the main loop to monitor for incoming messages.

Returns
Whether a new message is available

Definition at line 458 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin()

void AllWize::begin ( uint8_t  baudrate = MODEM_DEFAULT_BAUDRATE)

Inits the module communications.

Definition at line 91 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump()

void AllWize::dump ( Stream &  debug)

Dumps the current memory configuration to the given stream.

Parameters
debugData stream to dump the data to

Definition at line 307 of file AllWize.cpp.

Here is the call graph for this function:

◆ enableRX()

bool AllWize::enableRX ( bool  enable)

Enables or disables RF recever.

Parameters
enableTrue to enable, false to disable
Returns
Returns true if successfully set

Definition at line 443 of file AllWize.cpp.

Here is the call graph for this function:

◆ factoryReset()

bool AllWize::factoryReset ( )

Resets the module to factory settings.

Returns
Factory reset successfully issued

Definition at line 212 of file AllWize.cpp.

Here is the call graph for this function:

◆ getAppendRSSI()

bool AllWize::getAppendRSSI ( )

Gets the current RSSI mode value.

Returns
True if RSSI value will be appended to received data

Definition at line 714 of file AllWize.cpp.

Here is the caller graph for this function:

◆ getBaudRate()

uint8_t AllWize::getBaudRate ( )

Gets the UART baud rate.

Returns
Value (1 byte)

Definition at line 935 of file AllWize.cpp.

Here is the call graph for this function:

◆ getBaudRateSpeed()

uint32_t AllWize::getBaudRateSpeed ( uint8_t  value)

Gets the UART baud rate speed in bps.

Parameters
valueBaudrate code
Returns
UART speed

Definition at line 944 of file AllWize.cpp.

◆ getChannel()

uint8_t AllWize::getChannel ( )

Gets the channel stored in non-volatile memory.

Returns
Channel (1 byte)

Definition at line 591 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getControlField()

uint8_t AllWize::getControlField ( )

Gets the control field value stored in non-volatile memory.

Returns
Control field value (1 byte)

Definition at line 823 of file AllWize.cpp.

Here is the call graph for this function:

◆ getControlInformation()

uint8_t AllWize::getControlInformation ( )

Gets the control information byte.

Returns
CI byte value

Definition at line 567 of file AllWize.cpp.

◆ getCounter()

uint16_t AllWize::getCounter ( )

Gets the current wize counter.

Returns
Counter

Definition at line 547 of file AllWize.cpp.

◆ getDataInterface()

uint8_t AllWize::getDataInterface ( )

Gets the data interface for receiving packets.

Returns
Value (1 byte)

Definition at line 803 of file AllWize.cpp.

Here is the caller graph for this function:

◆ getDataRate()

uint8_t AllWize::getDataRate ( )

Gets the data rate stored in non-volatile memory.

Returns
Current data rate (1 byte)

Definition at line 646 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDataRateSpeed()

uint16_t AllWize::getDataRateSpeed ( uint8_t  dr)

Returns the speed for te given datarate.

Parameters
drDatarate
Returns
Speed in bps

Definition at line 1153 of file AllWize.cpp.

Here is the caller graph for this function:

◆ getDecryptFlag()

uint8_t AllWize::getDecryptFlag ( )

Gets the decrypt flag setting.

Returns
Decrypt flag

Definition at line 879 of file AllWize.cpp.

Here is the call graph for this function:

◆ getDefaultKey()

void AllWize::getDefaultKey ( uint8_t *  key)

Gets the default encryption key.

Parameters
keyA binary buffer to store the key (16 bytes)

Definition at line 908 of file AllWize.cpp.

Here is the call graph for this function:

◆ getDevice()

uint8_t AllWize::getDevice ( )

Returns the device type from non-volatile memory.

Returns
Device

Definition at line 1057 of file AllWize.cpp.

Here is the call graph for this function:

◆ getEncryptFlag()

uint8_t AllWize::getEncryptFlag ( )

Gets the encrypt flag setting.

Returns
Encrypt flag

Definition at line 863 of file AllWize.cpp.

Here is the call graph for this function:

◆ getFirmwareVersion()

String AllWize::getFirmwareVersion ( )

Returns the module firmware revision.

Returns
4-byte hex string with the FW version

Definition at line 1089 of file AllWize.cpp.

◆ getFrequency()

double AllWize::getFrequency ( uint8_t  channel)

Returns the frequency for the given channel.

Parameters
channelChannel
Returns
Frequency (float) in MHz for the given channel

Definition at line 1128 of file AllWize.cpp.

Here is the caller graph for this function:

◆ getInstallMode()

uint8_t AllWize::getInstallMode ( )

Gets the install modevalue stored in non-volatile memory.

Returns
Install mode value (1 byte)

Definition at line 845 of file AllWize.cpp.

Here is the call graph for this function:

◆ getLEDControl()

uint8_t AllWize::getLEDControl ( )

Gets the current LED control.

Returns
LED control value

Definition at line 784 of file AllWize.cpp.

Here is the call graph for this function:

◆ getMID()

String AllWize::getMID ( )

Returns the Manufacturer ID.

Returns
Manufacturer ID

Definition at line 1001 of file AllWize.cpp.

Here is the call graph for this function:

◆ getMode()

uint8_t AllWize::getMode ( )

Gets the MBus mode stored in non-volatile memory.

Returns
MBus mode (1 byte)

Definition at line 677 of file AllWize.cpp.

Here is the caller graph for this function:

◆ getModuleType()

uint8_t AllWize::getModuleType ( )

Returns the module type.

Returns
One of MODULE_UNKNOWN, MODULE_MBUS4, MODULE_OSP and MODULE_WIZE

Definition at line 1105 of file AllWize.cpp.

◆ getModuleTypeName()

String AllWize::getModuleTypeName ( )

Returns the module type.

Returns
One of MODULE_UNKNOWN, MODULE_MBUS4, MODULE_OSP and MODULE_WIZE

Definition at line 1113 of file AllWize.cpp.

◆ getNetworkRole()

uint8_t AllWize::getNetworkRole ( )

Gets the current network role.

Returns
Network role

Definition at line 767 of file AllWize.cpp.

Here is the call graph for this function:

◆ getPartNumber()

String AllWize::getPartNumber ( )

Returns the module part number.

Returns
12-byte hex string with the part number

Definition at line 1073 of file AllWize.cpp.

Here is the caller graph for this function:

◆ getPower()

uint8_t AllWize::getPower ( )

Gets the RF power stored in non-volatile memory.

Returns
RF power (1 byte)

Definition at line 613 of file AllWize.cpp.

Here is the call graph for this function:

◆ getPreamble()

uint8_t AllWize::getPreamble ( )

Gets the preamble length frame format.

Returns
Preamble length format (1 byte)

Definition at line 732 of file AllWize.cpp.

Here is the call graph for this function:

◆ getRequiredHardwareVersion()

String AllWize::getRequiredHardwareVersion ( )

Returns the minimum required hardware version to run the current firmware.

Returns
4-byte hex string with the HW version

Definition at line 1081 of file AllWize.cpp.

◆ getRSSI()

float AllWize::getRSSI ( )

Returns the RSSI of the last valid packet received TODO: values do not seem right and are not the same as in the packet.

Returns
RSSI in dBm

Definition at line 958 of file AllWize.cpp.

Here is the call graph for this function:

◆ getSerialNumber()

String AllWize::getSerialNumber ( )

Returns the module serial number.

Returns
8-byte hex string with the serial number

Definition at line 1097 of file AllWize.cpp.

Here is the call graph for this function:

◆ getSleepMode()

uint8_t AllWize::getSleepMode ( )

Gets the sleep mode stored in non-volatile memory.

Returns
Sleep mode (1 byte)

Definition at line 693 of file AllWize.cpp.

Here is the call graph for this function:

◆ getTemperature()

uint8_t AllWize::getTemperature ( )

Returns the internal temperature of the module.

Returns
Temperature in Celsius

Definition at line 968 of file AllWize.cpp.

Here is the call graph for this function:

◆ getTimeout()

uint16_t AllWize::getTimeout ( )

Gets the current buffer timeout (also used for auto sleep modes)

Returns
Timeout setting in millis

Definition at line 750 of file AllWize.cpp.

Here is the call graph for this function:

◆ getUID()

String AllWize::getUID ( )

Returns the Unique ID string.

Returns
4-byte hex string with the unique ID

Definition at line 1020 of file AllWize.cpp.

Here is the call graph for this function:

◆ getVersion()

uint8_t AllWize::getVersion ( )

Returns the device version from non-volatile memory.

Returns
Version

Definition at line 1041 of file AllWize.cpp.

Here is the call graph for this function:

◆ getVoltage()

uint16_t AllWize::getVoltage ( )

Returns the internal voltage of the module.

Returns
Voltage in mV

Definition at line 985 of file AllWize.cpp.

Here is the call graph for this function:

◆ master()

void AllWize::master ( )

Sets the module in master mode.

Definition at line 234 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

allwize_message_t AllWize::read ( )

Returns latest received message.

Returns
New message

Definition at line 504 of file AllWize.cpp.

Here is the caller graph for this function:

◆ ready()

bool AllWize::ready ( )

Test whether the radio module is ready or not.

Definition at line 285 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ repeater()

void AllWize::repeater ( )

Sets the module in repeater mode.

Definition at line 260 of file AllWize.cpp.

Here is the call graph for this function:

◆ reset()

bool AllWize::reset ( )

Resets the radio module.

Returns
Reset successfully issued

Definition at line 162 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send() [1/2]

bool AllWize::send ( uint8_t *  buffer,
uint8_t  len 
)

Sends a byte array.

Parameters
bufferByte array with the application payload
lenLength of the payload
Returns
Returns true if message has been correctly sent

Definition at line 366 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send() [2/2]

bool AllWize::send ( const char *  buffer)

Sends c-string.

Parameters
bufferC-string with the application payload
Returns
Returns true if message has been correctly sent

Definition at line 424 of file AllWize.cpp.

Here is the call graph for this function:

◆ setAccessNumber()

void AllWize::setAccessNumber ( uint8_t  value)

Sets new/specific access number.

Parameters
valueNew access number

Definition at line 916 of file AllWize.cpp.

Here is the call graph for this function:

◆ setAppendRSSI()

void AllWize::setAppendRSSI ( bool  value)

Sets the RSSI mode value.

Parameters
valueSet to true to append RSSI value to received data

Definition at line 701 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBaudRate()

void AllWize::setBaudRate ( uint8_t  value)

Sets the UART baud rate, requires reset to take effect.

Parameters
valueValue from 1 to 11

Definition at line 924 of file AllWize.cpp.

Here is the call graph for this function:

◆ setChannel()

void AllWize::setChannel ( uint8_t  channel,
bool  persist = false 
)

Sets the communications channel (for MBUS_MODE_R2 only)

Parameters
channelChannel number
persistPersist the changes in non-volatile memory (defaults to False)

Definition at line 576 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setControlField()

void AllWize::setControlField ( uint8_t  value,
bool  persist = false 
)

Sets the control field value.

Parameters
valueControl field
persistPersist the changes in non-volatile memory (defaults to False)

Definition at line 812 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setControlInformation()

void AllWize::setControlInformation ( uint8_t  ci)

Sets the control information byte.

Parameters
ciCI byte value

Definition at line 559 of file AllWize.cpp.

◆ setCounter()

void AllWize::setCounter ( uint16_t  counter)

Sets the wize couonter field in the transpoprt layer.

Parameters
counterWize counter

Definition at line 539 of file AllWize.cpp.

◆ setDataInterface()

void AllWize::setDataInterface ( uint8_t  value)

Sets the data interface for receiving packets.

Parameters
valueValue from 0x00 to 0x0C

Definition at line 792 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDataRate()

void AllWize::setDataRate ( uint8_t  dr)

Sets the data rate.

Parameters
drValue in [1, 2, 3, 4, 5]

Definition at line 621 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDecryptFlag()

void AllWize::setDecryptFlag ( uint8_t  flag)

Sets the decrypt flag setting.

Parameters
flagDecrypt flag

Definition at line 871 of file AllWize.cpp.

Here is the call graph for this function:

◆ setDefaultKey()

void AllWize::setDefaultKey ( const uint8_t *  key)

Sets the default encryption key.

Parameters
keyA 16-byte encryption key as binary array

Definition at line 900 of file AllWize.cpp.

Here is the call graph for this function:

◆ setDevice()

void AllWize::setDevice ( uint8_t  type)

Sets the device type.

Parameters
typeDevice type

Definition at line 1065 of file AllWize.cpp.

Here is the call graph for this function:

◆ setEncryptFlag()

void AllWize::setEncryptFlag ( uint8_t  flag)

Sets the encrypt flag setting.

Parameters
flagEncrypt flag

Definition at line 853 of file AllWize.cpp.

Here is the call graph for this function:

◆ setInstallMode()

void AllWize::setInstallMode ( uint8_t  mode,
bool  persist = false 
)

Sets the module in one of the available operations modes.

Parameters
modeOperation mode
persistPersist the changes in non-volatile memory (defaults to False)

Definition at line 832 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setKey()

void AllWize::setKey ( uint8_t  reg,
const uint8_t *  key 
)

Sets the default encryption key.

Parameters
regRegister number (1-64)
keyA 16-byte encryption key as binary array

Definition at line 888 of file AllWize.cpp.

Here is the call graph for this function:

◆ setLEDControl()

void AllWize::setLEDControl ( uint8_t  value)

Sets the LED control.

Parameters
valueLED control value

Definition at line 775 of file AllWize.cpp.

Here is the call graph for this function:

◆ setMID()

bool AllWize::setMID ( uint16_t  mid)

Sets the Manufacturer ID.

Parameters
midMID to save

Definition at line 1009 of file AllWize.cpp.

Here is the call graph for this function:

◆ setMode()

void AllWize::setMode ( uint8_t  mode,
bool  persist = false 
)

Sets the module in one of the available MBus modes.

Parameters
modeMBus mode (MBUS_MODE_*)
persistPersist the changes in non-volatile memory (defaults to False)

Definition at line 655 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setNetworkRole()

void AllWize::setNetworkRole ( uint8_t  role)

Sets the network role.

Parameters
roleNetwork role (NETWORK_ROLE_*)

Definition at line 759 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPower()

void AllWize::setPower ( uint8_t  power,
bool  persist = false 
)

Sets the RF power.

Parameters
powerValue from 1 to 5
persistPersist the changes in non-volatile memory (defaults to False)

Definition at line 600 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPreamble()

void AllWize::setPreamble ( uint8_t  preamble)

Sets the preamble length frame format.

Parameters
preamble0 or 2

Definition at line 722 of file AllWize.cpp.

Here is the call graph for this function:

◆ setSleepMode()

void AllWize::setSleepMode ( uint8_t  mode)

Sets the sleep mode.

Parameters
modeOne of SLEEP_MODE_*

Definition at line 685 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTimeout()

void AllWize::setTimeout ( uint16_t  ms)

Sets the buffer timeout (also used for auto sleep modes)

Parameters
msTimeout value in milliseconds

Definition at line 740 of file AllWize.cpp.

Here is the call graph for this function:

◆ setUID()

bool AllWize::setUID ( uint32_t  uid)

Saved the UID into the module memory.

Parameters
uidUID to save

Definition at line 1028 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVersion()

void AllWize::setVersion ( uint8_t  version)

Sets the device version.

Parameters
versionDevice version

Definition at line 1049 of file AllWize.cpp.

Here is the call graph for this function:

◆ setWizeApplication()

void AllWize::setWizeApplication ( uint8_t  wize_application)

Sets the wize applicaton field in the transpoprt layer.

Parameters
wize_applicationWize Application

Definition at line 531 of file AllWize.cpp.

Here is the caller graph for this function:

◆ setWizeControl()

bool AllWize::setWizeControl ( uint8_t  wize_control)

Sets the wize control field in the transpoprt layer.

Parameters
wize_controlWize Control (defined the key to be used)
Returns
True is correctly set

Definition at line 513 of file AllWize.cpp.

◆ setWizeOperatorId()

void AllWize::setWizeOperatorId ( uint16_t  wize_operator_id)

Sets the wize operator ID field in the transpoprt layer.

Parameters
wize_operator_idWize Operator ID

Definition at line 523 of file AllWize.cpp.

◆ slave()

void AllWize::slave ( )

Sets the module in slave mode.

Definition at line 249 of file AllWize.cpp.

Here is the call graph for this function:

◆ sleep()

void AllWize::sleep ( )

Sets the radio module in sleep mode.

Definition at line 268 of file AllWize.cpp.

Here is the call graph for this function:

◆ softReset()

void AllWize::softReset ( )

Cleans the RX/TX line.

Definition at line 197 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waitForReady()

bool AllWize::waitForReady ( uint32_t  timeout = DEFAULT_TIMEOUT)

Waits for timeout millis for the module to be ready.

Definition at line 294 of file AllWize.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wakeup()

void AllWize::wakeup ( )

Wakes up the radio from sleep mode.

Definition at line 276 of file AllWize.cpp.

Here is the call graph for this function:

Field Documentation

◆ _access_number

uint8_t AllWize::_access_number = 0
protected

Definition at line 262 of file AllWize.h.

◆ _append_rssi

bool AllWize::_append_rssi = false
protected

Definition at line 261 of file AllWize.h.

◆ _baudrate

uint32_t AllWize::_baudrate = 19200
protected

Definition at line 256 of file AllWize.h.

◆ _buffer

uint8_t AllWize::_buffer[RX_BUFFER_SIZE]
protected

Definition at line 283 of file AllWize.h.

◆ _ci

uint8_t AllWize::_ci = CI_APP_RESPONSE_UP_SHORT
protected

Definition at line 258 of file AllWize.h.

◆ _config

bool AllWize::_config = false
protected

Definition at line 254 of file AllWize.h.

◆ _config_gpio

uint8_t AllWize::_config_gpio = GPIO_NONE
protected

Definition at line 253 of file AllWize.h.

◆ _counter

uint16_t AllWize::_counter = 0
protected

Definition at line 279 of file AllWize.h.

◆ _data_interface

uint8_t AllWize::_data_interface = 0xFF
protected

Definition at line 260 of file AllWize.h.

◆ _fw

String AllWize::_fw
protected

Definition at line 273 of file AllWize.h.

◆ _hw

String AllWize::_hw
protected

Definition at line 272 of file AllWize.h.

◆ _hw_serial

HardwareSerial* AllWize::_hw_serial = NULL
protected

Definition at line 243 of file AllWize.h.

◆ _mbus_mode

uint8_t AllWize::_mbus_mode = 0xFF
protected

Definition at line 259 of file AllWize.h.

◆ _memory

uint8_t AllWize::_memory[0x100] = {0xFF}
protected

Definition at line 268 of file AllWize.h.

◆ _message

allwize_message_t AllWize::_message
protected

Definition at line 282 of file AllWize.h.

◆ _model

String AllWize::_model
protected

Definition at line 271 of file AllWize.h.

◆ _module

uint8_t AllWize::_module = MODULE_UNKNOWN
protected

Definition at line 263 of file AllWize.h.

◆ _pointer

uint8_t AllWize::_pointer = 0
protected

Definition at line 284 of file AllWize.h.

◆ _ready

bool AllWize::_ready = false
protected

Definition at line 267 of file AllWize.h.

◆ _reset_gpio

uint8_t AllWize::_reset_gpio = GPIO_NONE
protected

Definition at line 252 of file AllWize.h.

◆ _rx

int8_t AllWize::_rx = -1
protected

Definition at line 239 of file AllWize.h.

◆ _stream

Stream* AllWize::_stream = NULL
protected

Definition at line 242 of file AllWize.h.

◆ _sw_serial

SoftwareSerial* AllWize::_sw_serial = NULL
protected

Definition at line 249 of file AllWize.h.

◆ _timeout

uint32_t AllWize::_timeout = DEFAULT_TIMEOUT
protected

Definition at line 255 of file AllWize.h.

◆ _tx

int8_t AllWize::_tx = -1
protected

Definition at line 240 of file AllWize.h.

◆ _wize_application

uint8_t AllWize::_wize_application = 0
protected

Definition at line 278 of file AllWize.h.

◆ _wize_control

uint8_t AllWize::_wize_control = 0x00
protected

Definition at line 276 of file AllWize.h.

◆ _wize_operator_id

uint16_t AllWize::_wize_operator_id = 0
protected

Definition at line 277 of file AllWize.h.


The documentation for this class was generated from the following files: