first commit

Dependencies:   mbed

Dependents:   ibeacon

Fork of BLE_WallbotBLE_Challenge by JKSoft

main.cpp

Committer:
tridung141196
Date:
2017-11-23
Revision:
4:2386637c9c7c
Parent:
3:ef465ae893a3
Child:
5:984cc7e96073

File content as of revision 4:2386637c9c7c:

#include "mbed.h"
#include "BLEDevice.h"

BLEDevice  ble;
static const uint16_t uuid16_list[]        = {0x00A0};
const static uint8_t beaconPayload_url[] = {
    0xaa,
    0xfe,
 
    // URL
 
    0x10, // Frame Type
    0x20, // Ranging Data
    0x02, // URL Scheme (http:// = 0x02)
 
    'i',
    'o',
    't',
    'm',
    'a',
    'k',
    'e',
    'r',
    '.',
    'v',
    'n',
};
int main(void)
{
    ble.init();
    ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED|GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
 
    ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
 
    //ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA,beaconPayload_uid, sizeof(beaconPayload_uid));
    ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA,beaconPayload_url, sizeof(beaconPayload_url));
    //ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA,beaconPayload_tlm, sizeof(beaconPayload_tlm));
 
    ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
 
    ble.setAdvertisingInterval(160);
    
    ble.startAdvertising();
 
    while(true) {
        ble.waitForEvent();
    }
}