But, using the included ibeacon library as guide, it enabled me to understand how to turn the device into ibeacon. I used Ibeacon Detector app to capture the data packets or advertising packets, and used the captured data to change the blepheripheral manufurerdata and that's it. I just turned it into ibeacon.
Here is the sample ibeacon advertising packet:
This is the manufacturerdata I used:
0x4c, 0x00, 0x02, 0x15, 0xa1, 0x96, 0xc8, 0x76, 0xde, 0x8c, 0x4c, 0x47, 0xab, 0x5a, 0xd7, 0xaf, 0xd5, 0xae, 0x71, 0x27, 0x00, 0x12, 0x00, 0x25, 0xcb, 0x5c
The breakdown is as follows:
0x4c 0x00 = Apple Company
0x02 0x15 = Ibeacon Identifier
0xa1 0x96 0xc8 0x76 0xde 0x8c 0x4c 0x47 0xab 0x5a 0xd7 0xaf 0xd5 0xae 0x71 0x27 =UUID
0x00 0x12 = Major
0x00 0x25 = Minor
0xcb 0x5c = Transmitted Power(-53dBm)
Here is the complete sketch:
#include <SPI.h>#include <BLEPeripheral.h>const char * localName = "LED On";BLEPeripheral blePeriph();void setup() {// put your setup code here, to run once:Serial.begin(115200);blePeriph.setDeviceName(localName);blePeriph.setLocalName(localName);blePeriph.setTxPower(measuredPower);const unsigned char manufacturerData[26] = {0x4c, 0x00, 0x02, 0x15, 0xa1, 0x96, 0xc8, 0x76, 0xde, 0x8c, 0x4c, 0x47, 0xab, 0x5a, 0xd7, 0xaf, 0xd5, 0xae, 0x71, 0x27, 0x00, 0x12, 0x00, 0x25, 0xcb, 0x5c};unsigned int lng = 26;blePeriph.setManufacturerData(manufacturerData, lng);blePeriph.begin();}void loop() {// put your main code here, to run repeatedly:blePeriph.poll();}