vo dung / Mbed 2 deprecated eddystone_URL

Dependencies:   mbed

Dependents:   ibeacon

Fork of BLE_WallbotBLE_Challenge by JKSoft

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #include "BLEDevice.h"
00004 
00005 BLEDevice  ble;
00006 
00007 void bleUploadUrl()
00008 {
00009     static const uint16_t uuid16_list[]        = {0xFEAA};
00010     const static uint8_t beaconPayload_url[] = {
00011         0xaa,0xfe,
00012         // URL
00013         0x10, // Frame Type
00014         0x20, // Ranging Data
00015         0x01, // URL Scheme (https:// = 0x02)
00016         'e','s','p','3','2','.','v','n'};
00017                                                 
00018     ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED|GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
00019  
00020     ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
00021  
00022     ble.accumulateAdvertisingPayload(GapAdvertisingData::SERVICE_DATA,beaconPayload_url, sizeof(beaconPayload_url));
00023  
00024     ble.setAdvertisingType (GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
00025     
00026     ble.setAdvertisingInterval (160);
00027     
00028     ble.setTxPower(200);
00029     
00030     ble.startAdvertising();
00031     
00032 }
00033 
00034 int main(void)
00035 {
00036     ble.init();
00037     
00038     bleUploadUrl();
00039     
00040     while(true) {
00041         ble.waitForEvent();
00042     }
00043 }