18
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

mbed HRM1017 をつかって、Eddystone対応のビーコンを作ってみる

Last updated at Posted at 2015-07-16

昨日、GoogleからオープンプラットフォームのBeacon技術であるeddystoneが発表された。
mbedを使ってEddystone対応のビーコンを作ってみた。

プロジェクトの構成はこんな感じ
150716-0001.png

です。

殻となるmain.cppは

main.cpp
// mbed HRM1017 Eddystone
// Programed by Kazuyuki Eguchi

#include "mbed.h"
#include "BLE.h"

BLEDevice ble;

static const uint16_t uuid16_list[]        = {0xFEAA};
                                              
const static uint8_t beaconPayload_uid[] = {
    0xaa,
    0xfe,
    
    // UID

    0x00, // Frame Type
    0x00, // Ranging Data
    
    0x01, // NID[0]
    0x02, // NID[1]
    0x03, // NID[2]
    0x04, // NID[3]
    0x05, // NID[4]
    0x06, // NID[5]
    0x07, // NID[6]
    0x08, // NID[7]
    0x09, // NID[8]
    0x0A, // NID[9]
    
    0x11, // BID[0] 
    0x22, // BID[1]
    0x33, // BID[2]
    0x44, // BID[3]
    0x55, // BID[4]
    0x66, // BID[5]
    0x00, // RFU
    0x00  // RFU
};

const static uint8_t beaconPayload_url[] = {
    0xaa,
    0xfe,

    // URL
    
    0x10, // Frame Type
    0x00, // Ranging Data
    0x02, // URL Scheme (http:// = 0x02)
    
    'e',
    'g',
    'u',
    'c',
    'h',
    'i',
    '.',
    'j',
    'p'
};

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();

    for (;;) {
        ble.waitForEvent();
    }
}
18
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?