dung
Dependencies: BLE_API mbed nRF51822
Revision 0:45eb97275821, committed 2017-11-22
- Comitter:
- tridung141196
- Date:
- Wed Nov 22 13:48:39 2017 +0000
- Commit message:
- dung
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BLE_API.lib Wed Nov 22 13:48:39 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#65474dc93927
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 22 13:48:39 2017 +0000 @@ -0,0 +1,110 @@ +// mbed HRM1017 Eddystone +// Programed by Kazuyuki Eguchi + +#include "mbed.h" +#include "ble/BLE.h" + +BLEDevice ble; + +static const uint16_t uuid16_list[] = {0x00A0}; + +const static uint8_t beaconPayload_uid[] = { + 0x00, + 0x12, + + // UID + + 0x00, // Frame Type + 0x00, // Ranging Data + + 0x8B, // NID[0] + 0x0C, // NID[1] + 0xA7, // NID[2] + 0x50, // NID[3] + 0xE7, // NID[4] + 0xA7, // NID[5] + 0x4E, // NID[6] + 0x14, // NID[7] + 0xBD, // NID[8] + 0x99, // NID[9] + + 0x09, // BID[0] + 0x54, // BID[1] + 0x77, // BID[2] + 0xCB, // BID[3] + 0x3E, // BID[4] + 0x77, // BID[5] + 0x00, // RFU + 0x00 // RFU +}; + +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', +}; + +const static uint8_t beaconPayload_tlm[] = { + 0xaa, + 0xfe, + + // TLM + + 0x20, // Frame Type + 0x00, // Version + 0x01, // VBATT[0] + 0x00, // VBATT[1] + 0x02, // TEMP[0] + 0x00, // TEMP[1] + 0x03, // ADV[0] + 0x00, // ADV[1] + 0x00, // ADV[2] + 0x00, // ADV[3] + 0x04, // SEC_CNT[0] + 0x00, // SEC_CNT[1] + 0x00, // SEC_CNT[2] + 0x00 // SEC_CNT[3] +}; + + +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(); + } +} + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 22 13:48:39 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nRF51822.lib Wed Nov 22 13:48:39 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#c90ae1400bf2