RTL8722DM Mini BLE using min and max

Hello, im using this board connected with max30102 sensor to send data via ble.
Im struggling with it because the example works for creating ble but min and max value doesn’t change.

This is the code example for ibeacon:


#include "BLEDevice.h"
#include "BLEBeacon.h"

iBeacon beacon;
//altBeacon beacon;

// See the following for generating UUIDs:
// https://www.uuidgenerator.net/
#define UUID "00112233-4455-6677-8899-AABBCCDDEEFF"


void setup() {
    // For all possible BLE manufacturer IDs, refer to:
    // www.bluetooth.com/specifications/assigned-numbers/company-identifiers/
    beacon.setManufacturerId(0x004C); // MfgId (0x004C: Apple Inc)
    beacon.setRSSI(0xBF);             // rssi: (0xBF: -65 dBm)
    beacon.setMajor(0x007B);          // 123
    beacon.setMinor(0x01C8);          // 456
    beacon.setUUID(UUID);

    BLE.init();
    BLE.configAdvert()->setAdvType(GAP_ADTYPE_ADV_NONCONN_IND);
    BLE.configAdvert()->setAdvData(beacon.getAdvData(), beacon.advDataSize);
    BLE.configAdvert()->setScanRspData(beacon.getScanRsp(), beacon.scanRspSize);
    BLE.beginPeripheral();
}

void loop() {
    delay(1000);
}

beacon.setMajor(0x007B); in this case it displays 123 but if i have my Hear Rate value in a varibale ‘hr’ and do
beacon.setMajor(hr); it shows 0

Im a begginer into this and seems that i can’t solve this. Anyone can help me with this?

Hi @portblock

The beacon advertisement data is fixed once BLE.beginPeripheral is called. If you wish to change it, you can try

// Stop BLE advertising first
BLE.end();

// Change beacon values
beacon.setMajor(hr);

// Update BLE with new beacon advertisement data
BLE.configAdvert()->setAdvData(beacon.getAdvData(), beacon.advDataSize);
BLE.configAdvert()->setScanRspData(beacon.getScanRsp(), beacon.scanRspSize);

// Restart BLE advertising
BLE.beginPeripheral();

basically this code needs to repeat every time you wish to update the value

1 Like