Bluetooth BLE communication


#1

Hello, I’m looking for an up to date library to connect to a BLE device (HM-10 + Arduino) and have some simple serial communication.
Any recommendations?


#2

To answer @gustaf I’ve had luck using @joshuajnoble https://github.com/joshuajnoble/ofxBLEDevice
and modifying BLEDeviceDefines.h code.

In my case I’ve just left the following lines

#define RFDUINO_SERVICE                          "B588DCA8-1AD1-47B2-B393-A4199894538E" //my BLE id
#define RFDUINO_CHARACTERISTIC                   "FFE0" 
#define RFDUINO_RX                               "FFE1" //any number works
#define RFDUINO_TX                               "FFE1" //any number works

#define RBL_BLE_FRAMEWORK_VER                    0x0200

hope it helps
Dimitre


#3

Some more info, for people trying to connect an iPhone to an ESP32 with BLE (like me).

I’ve also used the ofxBLEDevice add-on, which was kind of mysterious to me since this is my first OF-iOS-experiment.
First I got stuck at the “startScan”-message in the console, which didn’t seem to scan that much…
In BLEDeviceManager.m I found that the startScan function looks for a specific BLE-device (/service?) using the RFDUINO_CHARACTERISTIC macro.
I think running the right sketch on the ESP32 also helps to make it visible to the iOS-app.
In ofApp.mm the didDiscoverBLEDevice-function also checks the BLE-device-name before connecting.
So using that ESP32-sketch, I set this in ofApp::setup()

    tx.UUID = @"582adc94-2eab-4735-b821-293883e26762";
    tx.shouldNotify = false;
    
    charas.push_back(tx);

    rx.UUID = @"0da69903-6d69-4810-bccc-4c56d2880188";
    rx.shouldNotify = true;

    charas.push_back(rx);

And this in BLEDeviceDefines.h

#define RFDUINO_SERVICE                          "2222" // Random
#define RFDUINO_CHARACTERISTIC                   "1b68cacd-2818-4a71-a49b-0061181c97a2"
#define RFDUINO_RX                               "2222" // Random
#define RFDUINO_TX                               "2222" // Random

edit:
Line 203 in BLEDevice.m is still looking for 2221… So commented that bit for now :stuck_out_tongue: