Module: xbee

Module supporting XBee radios.

  • $$Id$$
  • Edward A. Lee


(inner) defaultXBeeOptions

The default options for connections over XBee radio.



(static) hostSerialPorts()

Return an array of serial port names or null if none are found.


An array of port names.

(static) supportedReceiveTypes()

Return an array of the types supported by the current host for the receiveType option.


(static) supportedSendTypes()

Return an array of the types supported by the current host for the sendType option.


(static) XBee(portName, options)

Construct an XBee object, initialize it with the specified options. It is an event emitter that emits the following events:

  • 'data': Emitted when new data arrives on the radio.

    The options argument is a JSON object that can include:

  • receiveType: See below.

  • sendType: See below.
  • baudRate: The baud rate to communicate with the radio. This defaults to 9600.

The send and receive types can be any of those returned by supportedReceiveTypes() and supportedSendTypes(), respectively. If both ends of the socket are known to be JavaScript clients, then you should use the 'number' data type for numeric data. If one end or the other is not JavaScript, then you can use more specified types such as 'float' or 'int', if they are supported by the host. In all cases, received numeric data will be converted to JavaScript 'number' when emitted. For sent data, this will try to convert a JavaScript number to the specified type. The type 'number' is equivalent to 'double'.

When type conversions are needed, e.g. when you send a double with sendType set to int, or an int with sendType set to byte, then a "primitive narrowing conversion" will be applied, as specified here: .

For numeric types, you can also send an array with a single call to this.send(). The elements of the array will be sent in sequence all at once, and may be received in one batch. If both ends have rawBytes set to false (specifying message framing), then these elements will be emitted at the receiving end all at once in a single array. Otherwise, they will be emitted one at a time.

For strings, you can also send an array of strings in a single call, but these will be simply be concatenated and received as a single string.

Name Type Description

The name of the port to open.


The options.


If the port is in use or initializing the port fails.


An XBee interface.