Problem
I got some problem in change device name.
I found that the function of ble.gap.setDeviceName(deviceName) is useless.
So I've searching for another function. And I found at this website.
And it works.
But the point is when I try to broadcast iBeacon (using the method of this website)
The device name became unchangeable.
I wondering if there is a solution allows me to mix them together.
Because I hope that it can not only broadcast iBeacon, but also have a device name in order to connect through an APP to change the data like uuid or other detail of iBeacon broadcasting data.
Code
#include "mbed.h"
#include "BLEDevice.h"
#include "iBeaconService.h"
BLEDevice ble;
const static char DEVICE_NAME[] = "TestDeviceName";
const uint8_t uuid[] = {0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4,
0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61
};
uint16_t majorNumber = 1122;
uint16_t minorNumber = 3344;
uint16_t txPower = 0xC8;
const static uint8_t AdvData[] = {0x01,0x02,0x03,0x04,0x05};
int main(void)
{
ble.init();
//If I add the line below device name become unchangeable
iBeaconService ibeacon(ble, uuid, majorNumber, minorNumber, txPower);
ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE );
ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble.accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, AdvData, sizeof(AdvData));
//This line is used to change device name
ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
ble.setAdvertisingInterval(1000);
ble.startAdvertising();
for (;;) {
ble.waitForEvent();
}
}