pyupm_xbee module

class pyupm_xbee.XBee(uart=0)[source]

Bases: object

API for the XBee modules.

ID: xbee

Name: XBee Serial Module

Category: wifi

Manufacturer: sparkfun

Connection: uart

Link:https://www.sparkfun.com/products/11215 This is a generic UART driver for use with Digi XBee modules. It was tested with the XBee S1 802.15.4 module and the XBee S6B WiFi module.

It provides basic UART support for sending and receiving data to and from the device. It is controlled by an AT or API command set.

It is connected at 9600 baud by default.

These devices are typically configured using Digi’s X-CTU windows software, however it is possible of course to configure them manually using AT commands. See the examples.

XBee Sensor image provided by SparkFun* underCC BY-NC-SA-3.0.

C++ includes: xbee.hpp

commandMode(*args)[source]

bool commandMode(std::string cmdChars=”+++”, int guardTimeMS=1000)

Attempts to enter AT Command Mode. When Idle, data sent to the device (assuming it is not in API mode) is silently transmitted to the configured destination. Running this command attempts to place the device into command mode, allowing you to send AT commands. Note, after a configurable period of inactivity, the device will exit command mode automatically (default 10 seconds).

Both the cmdChars (+++) and the Guard Time can be configured on the device to different values using AT configuration commands.

cmdChars: The command mode characters, default “+++”

guardTimeMS: The number of milliseconds to wait before and after sending the command characters. Default is 1000 (1 second).

true if successful (received an “OK”), false otherwise

dataAvailable(millis)[source]

bool dataAvailable(unsigned int millis)

Checks to see if there is data available for reading

millis: Number of milliseconds to wait; 0 means no waiting

true if there is data available for reading

readData(buffer, len)[source]

int readData(char *buffer, unsigned int len)

Reads any available data into a user-supplied buffer. Note: the call blocks until data is available for reading. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking.

buffer: Buffer to hold the data read

len: Length of the buffer

Number of bytes read

readDataStr(len)[source]

std::string readDataStr(int len)

Reads any available data and returns it in a std::string. Note: the call blocks until data is available for reading. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking.

len: Maximum length of the data to be returned

string containing the data read

setBaudRate(baud=9600)[source]

mraa::Result setBaudRate(int baud=9600)

Sets the baud rate for the device. The default is 9600.

baud: Desired baud rate

true if successful

stringCR2LF(str)[source]

string stringCR2LF(std::string str)

This is a convenience method that converts each CR () in a string to a LF ( ) and returns it. This is useful for outputting the response to an AT command for instance, which is typically CR terminated.

str: The string to convert

The converted string

writeData(buffer, len)[source]

int writeData(char *buffer, unsigned len)

Writes the data in the buffer to the device. If you are writing an AT command, be sure to terminate it with a carriage return ()

buffer: Buffer to hold the data to write

len: Length of the buffer

Number of bytes written

writeDataStr(data)[source]

int writeDataStr(std::string data)

Writes the std:string data to the device. If you are writing an AT command, be sure to terminate it with a carriage return ()

data: Buffer to write to the device

Number of bytes written

class pyupm_xbee.charArray(nelements)[source]

Bases: object

cast()[source]
static frompointer()