Bluetooth Interface¶
In operation as a CAN-Bluetooth Interface, CAN data is transmitted wirelessly to other Bluetooth-capable devices such as PCs, smartphones, or tablets.
Supported Bluetooth Protocols¶
| Protocol | Supported |
|---|---|
| SPP | ✅ |
| HID | ✅ |
| PAN | ❌ |
CAN-CAN-Bluetooth Bridge¶
In operation as a CAN-CAN-Bluetooth Bridge, CAN data is transmitted wirelessly between two CANlink® wireless 4000 devices via a Bluetooth connection.
The CAN-CAN-Bluetooth Bridge acts as a substitute for CAN cables, e.g. in drag chains or remote control units.
Configuring a Bluetooth Bridge¶
SERVER
-
Disable Wi-Fi
Write0(Disable) to0x3008:0x02 [Wlan Enable] -
Disable BLE
Write0(Disable) to0x3008:0x09 [BLE Enable] -
Enable Bluetooth
Write1(Enable) to0x3008:0x03 [Bluetooth Enable] -
Enable Server
Write2(Server Enabled) to0x3010:0x15 [EEP Connection Direction Configuration/Server or Client1] -
Enable Bluetooth SPP
Write2(SPP) to0x3010:0x16 [EEP Connect Type 1] -
Make Discoverable
Write1(Enabled) to0x3002:0x01 [Discoverable] -
Read and save the MAC address for Client access
Read0x3007:0x01 [Bluetooth Mac Address (Bluetooth Address)] -
Optionally set a PIN for secure access by a Client device
- Write PIN into
0x3002:0x06 [BT Classic Pin Code].
The maximum length of the PIN code is 15 bytes. - Also set
0x3002:0x07 [BT Classic Enforce Pin Code]to1(Enable).
- Write PIN into
CLIENT
-
Disable Wi-Fi
Write0(Disable) to0x3008:0x02 [Wlan Enable] -
Disable BLE
Write0(Disable) to0x3008:0x09 [BLE Enable] -
Enable Bluetooth
Write1(Enable) to0x3008:0x03 [Bluetooth Enable] -
Enable Client
Write3(Client Enabled) to0x3010:0x15 [EEP Connection Direction Configuration/Server or Client1] -
Enable Bluetooth SPP
Write2(SPP) to0x3010:0x16 [EEP Connect Type 1] -
Set Server MAC address
Write the value read in step (7) in the Server directions to0x3010:0x1A [EEP Bluetooth SP MAC Address 1].- This is a 12-character ASCII field, that represents a 6-byte Hexadecimal MAC Address.
For example84BA20096D04 - (This is not case-sensitive).
- This is a 12-character ASCII field, that represents a 6-byte Hexadecimal MAC Address.
-
Optionally configure the PIN
- Write the appropriate PIN into
0x3002:0x06 [BT Classic Pin Code].
- Write the appropriate PIN into
Using Bluetooth PIN¶
A Personal Identification Number (PIN) may be used on a Bluetooth connection to offer some authentication security.
The PIN is set on the Bluetooth Server device, and the Client requesting connection must supply that same PIN in order to have the request accepted.
The maximum length of the PIN code is 15 characters.
This should be read in conjunction with the general Bluetooth guidance.
Note
Once a Client has 'paired' to a Server, it will always be allowed reconnection.
This means that if a Client that successfully used a PIN to connect, then the PIN on the Server was changed - the Client will still connect.
To prevent this, the user must clear all previously paired devices from the Server.
Write 0x64616F6C to 0x1011:0x66 [Delete BT Classic paired devices] to reset all paired Bluetooth classic devices.
See List Currently Paired Devices for more information.
After this, if the Server has the PIN enabled, all Clients must also have that same PIN to connect.
Enabling Bluetooth PIN¶
On the Server device
-
Set
0x3002:0x06 [BT Classic Pin Code]to the desired value. -
Set
0x3002:0x07 [BT Classic Enforce Pin Code]to1(Enable).
On the Client device
- Set
0x3002:0x06 [BT Classic Pin Code]to the *same value as on the Server for the same object.
If the Server is configured as above, it will request a PIN from any Client attempting connection.
Only if the PIN matches, does the connection proceed.
Disabling Bluetooth PIN¶
On the Server device, set 0x3002:0x07 [BT Classic Enforce Pin Code] to 0 (Disable).
This means any Client will be allowed to connect.
Warning
For security reasons, do not disable the PIN on the Server device.
If disabled, any BT Client will be able to connect!
Disabling the PIN might be acceptable only when other measures ensure that no unauthorized personnel or device can come within connection-distance from the Server device.
For example, when the Server device is located in an area with physical restrictions.
Bluetooth Paired Devices¶
The CANlink® wireless 4000 offers a local Bluetooth connection in order to connect to another CANlink® wireless 4000 device (in ‘Bridge’ mode), or another device such as a mobile phone or PC (in ‘Gateway’ mode) to transfer CAN data.
In order to establish a secure connection between two devices, there are several steps which all combine to form the Bluetooth “Pairing” process.
To pair devices, refer to Enabling Bluetooth PIN
-
Discovery
One device (the initiator) searches for nearby Bluetooth devices. This is what the CANlink® wireless 4000 does when configured as a Client. The other device (the responder) makes itself discoverable. The CANlink® wireless 4000 Server has this responsibility. -
Initiation
The initiator sends a pairing request to the responder. This request includes information like the device name and type. -
Authentication
Both devices exchange a unique code, often called a PIN or passkey. This step ensures that the devices are authorized to connect with each other. -
Bonding
Once the devices are authenticated, they create a bond. This involves storing the pairing information so that they can reconnect automatically in the future without repeating the pairing process. -
Connection
After bonding, the devices establish a secure connection. They can now communicate and exchange data over the Bluetooth link. -
Communication
With the connection established, the devices can now transfer data, such as audio, files, or other types of information.
In step four, the newly paired device is added to an internal list in the CANlink® wireless 4000.
This simplifies subsequent pairing - but has one drawback: If the Bluetooth PIN code on the Server is changed, a device that has already paired may still connect with the old, invalid PIN.
In order to prevent this happening, the user may check all paired devices, and remove them from this internal list, in the following manner:
List currently paired devices¶
The user can read 0x3002:0x09 [BT Classic list of paired devices] to see all currently paired devices.
The object returned is a JSON structure that will look similar to this example.
Currently paired Bluetooth devices:
{
"version": "1.0.0",
"bt_classic_paired_devices": [
{
"mac": "040D8435110E"
},
{
"mac": "3003C86A6904"
}
]
}
Remove all paired devices¶
When 0x64616F6C is written to 0x1011:0x66 [Delete BT Classic paired devices], the deletion of all devices in the paired list is triggered.
To check, the 0x3002:0x09 [BT Classic list of paired devices] object can be read, and will return:
No currently paired Bluetooth devices:
{
"version": "1.0.0",
"bt_classic_paired_devices": [
]
}
If no devices are in this list, then the Client device must supply the correct PIN for successful connection if 0x3002:0x07 [BT Classic Enforce Pin Code] is enabled in the Server device.