Enable and disable Bluetooth
Before connecting to your XBee device over Bluetooth Low Energy, you first have to enable this interface. The XBee Java Library provides two methods to enable or disable this interface:
Method | Description |
---|---|
enableBluetooth() |
Enables the Bluetooth Low Energy interface of your XBee device. |
disableBluetooth() |
Disables the Bluetooth Low Energy interface of your XBee device. |
Enable and disable the Bluetooth interface
import com.digi.xbee.api.XBeeDevice; [...] // Instantiate and open an XBee device object. XBeeDevice myXBeeDevice = new XBeeDevice("COM1", 9600); myXBeeDevice.open(); // Enable the Bluetooth interface. myXBeeDevice.enableBluetooth(); [...] // Disable the Bluetooth interface. myXBeeDevice.disableBluetooth();
These methods may fail for the following reasons:
- There is a timeout setting the IP addressing parameter, throwing a TimeoutException.
- Other errors caught as XBeeException:
- The operating mode of the device is not API or API_ESCAPE, throwing an InvalidOperatingModeException.
- The response of the command is not valid, throwing an ATCommandException.
- There is an error writing to the XBee interface, throwing a generic XBeeException.