Connecting to other Bluetooth module
Besides than scanning functions, the Bluetooth API contains some functions to open a transparent connection to other Bluetooth module.
CreateConnection (MAC)
This function is used to open a transparent connection with other Bluetooth module using the Serial Port Profile. The MAC address of the remote Bluetooth device must be specified.
SendData (data)
This function sends data directly to other Bluetooth module using a previously created connection.
RemoveConnection()
This function removes a transparent connection with other Bluetooth module.
In the Waspmote Development section you can find a complete example about using these functions:
https://development.libelium.com/bt-pro-10-creating-a-transparent-connection/
Pairing with devices
If the user wants to connect one device with security, both devices have to be paired before. A pin code can be used also to avoid man-in-the-middle intrusions. There are three functions to manage paired devices saved by the Bluetooth module.
Pair(macAddress, pincode)
This function pairs the Bluetooth module with the specified Bluetooth device. If the pin code is not specified, default code will be "123456".
IsPaired(deviceMac)
This function is used to check if a device is already paired.
removePairedDevices()
This function removes all paired devices from the list.
In the Waspmote Development section you can find a complete example about using these functions:
https://development.libelium.com/bt-pro-12-pairing-example/
Using WaspFrame class to create sensor data frames
WaspFrame is a class that allows the user to create data frames with a specified format. It is a very useful tool to build the packet in the same way as other Waspmote examples. It is recommended to read the Waspmote Programming Guide available here:
http://www.libelium.com/development/waspmote/documentation/programming
Last updated