Your Bluetooth device needs to be paired with your gateway device so that the gateway device can send data from your Bluetooth device to Oracle IoT Cloud Service. Your gateway device will automatically register the Bluetooth device by sending the Bluetooth device’s endpoint information to the Oracle IoT Cloud Service server.
Attach a Bluetooth USB dongle to the gateway device.
Login to your gateway device, open a command prompt, and then run this command to confirm that BlueZ software stack version 4.98 or later is installed on your gateway device:
hcitool | grep ver
The output whould be similar to the following:hcitool - HCI Tool ver 4.101
Run this command to list the Bluetooth devices currently paired with the gateway:
Note:If you receive the following message after running that last command, use the next step to modify the udev rules to allow non-root users to access Bluetooth services:
bt-device: bluez service is not found Did you forget to run bluetoothd?
(Optional) Modify the udev rules to allow non-root users access to Bluetooth.
As the root user or using the
sudocommand, create a
sudo touch /etc/udev/rules.d/bluetooth.rules
Determine the path to the Bluetooth adapter in your system’s
/sysfolder using the
find /sys -name bluetooth
You should see something like the following/sys/devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2:1.0/bluetooth
Add the following line to the
bluetooth.rulesfile, using the path found in the previous step for the DEVPATH property entry. You also need to append /hci[0-9]* to the DEVPATH value.
ACTION=="add", SUBSYTEM=="bluetooth", KERNEL="hci[0-9]*" DEVPATH="/sys/devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2:1.0/bluetooth/hci[0-9]*, RUN+="/bin/sh -c 'cd /sys%p; chown :bluetooth export unexport; chmod g+w export unexport'"
Add the user to the bluetooth group, which should be already present in the system.
(Optional) Add bluetooth group, if needed.
sudo groupadd bluetooth
Add user to to the bluetooth group using the following:
sudo usermod —aG bluetooth <username>
Reboot your gateway device.
(Optional) If the Bluetooth device is already showing as paired with the device gateway but you are having problems connecting to the device, remove the pairing information.
sudo bt-device -r BT_ADDR
where BT_ADDR is a colon-separated value. For example, for a Nonin Pulse Oximeter device, it would be similar to
Determine the device’s Bluetooth address by using the hcitool scan command, as illustrated below.
hcitool scan Scanning ... 40:A6:Z8:T7:795:8C bt-device0 40:X6:D9:G8:58:A8 bt-devoce1 40:R6:E9:N9:19:0G bt-device2
To pair the Bluetooth device, turn it off and turn it back on to place it back in discovery mode. For example, for the Nonin Pulse Oximeter, take out its batteries to turn it off and reinsert its batteries in the device to turn it back on and pair it.
Set the Bluetooth device aside and type the following command quickly (the pairing period expires in a short period).
sudo bt-device -c <BT_ADDR>
where <BT_ADDR> is a colon separated value. For example, for a Nonin Pulse Oximeter device with a pairing information of
00:1C:05:00:B7:E4, you would type the following:
sudo bt-device —c 00:1C:05:00:B7:E4
You would then see something similar to the following:
Connecting to: 00:1C:05:00:b7:e34 Agent registered
Device: Nonin_Medical_Inc._577981 (00:1C:05:00:B7:E4)
When prompted for the PIN code, locate it on the device or in the device’s user manual, and type it at the prompt. In the following example, 567890 is the sample PIN code.:
Enter PIN code: 567890
Verify that the Bluetooth device is paired with the gateway device:
sudo bt-device —l
The output displayed would be similar to the following:
Added devices:Nonin_Medical_Inc._577981 (00:1C:05:00:B7:E4)