Connecting to Pebble watch using Arduino - bluetooth

I am curently looking to find out wheter it is possible to Bluetooth connect an arduino or similar micro controller to the pebble watch using the RN-42 Sparkfun RN-42 adapter
I currently am having difficulty connecting to the pebble, as the board just times out.
Thanks

The RN-42 can, using bluetooth. The following will get you paired, and the watch MAY accept a ping:
SF,1 //factory reset
SP,9999 //takes care of the pairing code
SM,6 //pairing
SA,4
SY,0000 //power
SW,0640 //sniff mode
R,1 //reset so settings are saved/active and pebble should ask to connect
To pass app messages you need to pass some information to the watch, see http://dexwatch.blogspot.com/2015/12/more-on-pebble.html for the full details.

Related

Setup password on a Bluez BLE beacon

I am running a BLE beacon in bluez5.52 on a linux machine(ubuntu 14.04) using the default gatt-service and the beacon using the btmgmt provided in the tools folder. Following are the commands I run to setup the beacon:
Terminal 1:
./gatt-service
Terminal 2
sudo ./btmgmt
add-adv -u 180d -u 180f -d 080954657374204C45 1
I am easily able to connect and disconnect with the beacon using BLE scanner app in android.
What I would like to do is setup a password for the beacon so that I am the only one who can connect to it. So far I have been unable to find any resources online that could help set that up. I have a decent understanding of the btmgmt and gatt-service code. I am looking for direction on what part of bluez code to look for to set up the password protection. Any leads, pseudo-code or partial code would help a lot.
Emil already mentioned pairing and bonding in the comments. This would definetly serve your purpose as you would be able to control who could connect to your peripheral.
A BLE characteristic can ask a connected device to authenticate before reading or writing which would result in a 'insufficient authentication error' if the device is not paired to your peripheral. A Android app is able to handle this error by displaying a pairing popup depending on the used pairing method.
So it is possible to have characteristics without security right next to one's that require pairing.
In case you still want to implement something like your mentioned password safety you should look into a 'authorized read'.
A characteristic which requires authorization first receives a read request and you can allow or deny it based on your own requirements. That means you can authorize yourself by sending a password to one characteristic and afterwards allow a read request on another characteristic. This would be even easier if you only accept one connection at a time.

Connecting to Web Bluetooth

I'm trying to connect a bluetooth device (ESP32, peripheral) with Web Bluetooth (central). I send an addvertising packet and I can see the device on the web page, but I fail to connect to it. My code for the ESP32 looks like this: (MicroPython)
ble.gap_advertise(interval_us=100, adv_data=bytearray(b'\x02\x01\x06\x06\x08\x45\x53\x50\x33\x32\x11\x07\x26\x6c\x34\x7f\xb2\x38\x61\x82\xbe\x4d\x1d\x64\xf1\xf7\x93\x16\x02\x19\x80'),resp_data=None, connectable=True)
In Web Bluetooth (JavaScript) I just request a device and try to connect to the gatt.
Can anyone help me out?
Thanks in advance!
The JavaScript does work with another bluetooth peripheral. (RN4678)
And in JavaScript I can find the peripheral (ESP32) after filtering, but I can't connect to it.
JavaScirpt:
server = await device.gatt.connect()
The code stops at that point.
MicroPython:
The GATT is defined using:
ble.gatts.register.services()
I'm trying to use my own service, not a SIG defined one. So I advertise b'(x...') which contains the flags, the service and the device name. And it works with the nRF Connect App. I can send and recive data. But it doesn't work with the bluetooth enabled web browser.
Thanks for your help!

Unable to connect Arduin Uno with inbuilt wifi to internet

(https://i.stack.imgur.com/9Vx5t.jpg)
This is the board that I'm using Arduino Uno with inbuilt wifi. I'm unable to connect it to my wifi network
I tried doing what is mentioned in the link
https://www.trojanc.co.za/2017/11/05/arduino-uno-wifi-network-setup/
But the webpage won't open
Then I also tried uploading the code mentioned in below link to ESP8266 by pushing on 5th ,6th,and 7th dip switch
https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/readme.html
But it still does not connect to the internet
On the terminal it shows
Hard resetting via rts pin
Nothing is visible on serial monitor or arduino IDE
Thanks in advance
There are some switch to control connection between USB, Atmega and ESP8266/Wifi
pin 1 and 2 on : Atmega connect to ESP8266 there is not connection to USB/Computer
pin 3 and 4 on : USB/Computer connect to Atmega, so you can upload a skecth
pin 5 and 6 on : USB/Computer connect to ESP8266/Wifi
make sure you have been setup this switch correctly depend on your need.

Android Things on RaspberryPi3 and HC-05 Bluetooth Classic

I am using Android Things preview 6 image on Raspberry Pi3. Now I have application that can connect to HC-05 when running on Android Phone but same application not able to connect to HC-05 when it is running on Raspberry Pi3 with Android Things.
I can see HC-05 is classic bluetooth device and Wondering as Android things not give popup to enter passkey is making the problem to connect the HC-05 or is there something I am missing
I am getting below error
ConnectThread run: IO Exceptionjava.io.IOException: read failed, socket might closed or timeout, read ret: -1
D/BluetoothSocket: close() this: android.bluetooth.BluetoothSocket#ea69040, channel: -1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream#e5f1b79, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream#173c0bemSocket: android.net.LocalSocket#3f7251f impl:android.net.LocalSocketImpl#284706c fd:java.io.FileDescriptor#c2cf635, mSocketState: INIT
D/BluetoothSocket: close() this: android.bluetooth.BluetoothSocket#4272aca, channel: -1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream#5f2f43b, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream#f7e2758mSocket: android.net.LocalSocket#ec3c0b1 impl:android.net.LocalSocketImpl#7f52996 fd:java.io.FileDescriptor#6129917, mSocketState: INIT
The problem with my HC-05 that it needs pin to pair with Android Things App and as Android Things dont have luxury of user interface we have to set the pin programmatically through app
After few mints of searching I found answer of how to set pairing pin through program from this post programmatically-pairing-with-a-ble-device-on-android-4-4 and it is working perfectly for me. no need to change anything in my app accept added broadcast receiver
Thanks

Initiate connection from Arduino to remote device

I am trying to achieve that my arduino-built device connects automatically to a device after it is switched on. The board is an Arduino Mini Pro and the bluetooth module is the Bluetooth Mate Silver (RN42). The devices are already paired, the bluetooth module is in slave mode, the remote device (in this case a normal laptop) is discoverable. I am using the SoftwareSerial library provided with the Arduino software.
Here is my setup:
void setup()
{
Serial.begin(9600); // Begin the serial monitor at 9600bps
// bluetooth
// set baud rate to 9600
bluetooth.begin(9600);
// start command mode
bluetooth.print("$$$");
// reply delay
delay(100);
// set to slave mode
bluetooth.println("SM,0");
// reply delay
delay(100);
// set device pin to 0403
bluetooth.println("SP,0403");
// reply delay
delay(100);
// connect to pixelsense
bluetooth.println("C," + remoteMAC); // remoteMAC is a string with the mac address
// reply delay
delay(2500);
// leave command mode
bluetooth.println("---");
// reply delay
delay(100);
}
I read the command set of the RN42 and I think the commands are correct. I can connect to Arduino via bluetooth but the other direction isn't working. I also tried using the master mode or storing the remote mac in the flash instead of using a string. From the documentation it should be possible to initiate connections from the RN42, but I haven't quite found out how this works in details. Can anyone provide any help to solve my issue?
EDIT: The device does not seem to enter command mode at all. At least the flash lights don't indicate that. Is there anything wrong with the commands so that the command mode cannot be accessed?
After nearly a week, I came across a solution. Actually it seems to be important that there is any program that accepts a bluetooth connection. I tried it the whole time with the Windows 7 Bluetooth dialog menu entry "Receive a file" but that did not work. So I used a third party program that listens for incoming connections and that actually worked. Basically everything I did was fine except for the missing connection listener.
Sometimes if I upload new code to the Arduino there is the problem that the connection cannot be established. This can be solved by removing and readding the bluetooth device.
The code for the RN42 Bluetooth Client above works. The library SoftwareSerial provided with the Arduino software is used.
I think you may need to put some delay after bluetooth.begin(9600), to let set its baudrate and then issue print command.
You can enter into the command mode only in 60s after the module is powered on. You can see if the timer is still counting using the status LED(if it blink 2 per second). Sorry for my bad english.
On startup the RN-42 needs 500ms before it can enter command mode try 'delay(500);' before 'bluetooth.begin(115200);' and that should get you there. Also CTS should be tied low
as can be seen on page 45 of the document found at the link below.
https://cdn.sparkfun.com/assets/1/e/e/5/d/5217b297757b7fd3748b4567.pdf
PG 45
"3.3 INTERFACING TO A MICROPROCESSOR
Roving Networks Bluetooth devices can connect to 3.3-V (only) microprocessors using
the UART interface. When interfacing with a microprocessor, use the following guidelines:
• The Bluetooth device power, ground, RX, and TX signals must be connected and
CTS should be held low or tied to RTS.
• The Bluetooth device can go into command mode 500 ms after booting.
• The microprocessor should send $$$ with no carriage return or line feed to enter
command mode.
3.3.0.1 HOW DO I KNOW THE MODULE IS READY FOR COMMAND MODE?
500 ms after rebooting, the module is ready for command mode. You send $$$with no
carriage return.
3.3.0.2 WHICH HARD SIGNALS SHOULD I CONNECT?
You should connect power, ground, RX, and TX. CTS should be low or you can connect
or tie it to RTS."

Resources