1 year, 6 months ago.

How to save the information of a beacon and send it on the next payload?


I have as my final objective in a project of the university to create a system of indoor location where I have to transmit my signal beacon (data) and if this signal interacts with another beacon transmit my signal plus the beacon that interacted, ie transmit my data plus the data of another person in the same signal.

I can send my data and receive data from another beacon. my problem is being in saving the data received and sending it along with mine at the next signal sent.

#include <events/mbed_events.h>
#include "mbed.h"
#include "ble/BLE.h"

char beacons[]= {};

static EventQueue eventQueue(/* event count */ 16 * EVENTS_EVENT_SIZE);

DigitalOut led1(LED1, 1);

 * The Beacon payload (encapsulated within the MSD advertising data structure)
 * has the following composition:
 * 128-Bit UUID = E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61
 * Major/Minor  = 0000 / 0000
 * Tx Power     = C8 -

const uint8_t beaconPayload[] = {
    0x4C, 0x00, // Company identifier code (0x004C == Apple)
    0x02,       // ID
    0x15,       // length of the remaining payload
    0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4, // location UUID
    0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61,
    0x00, 0x00, // the major value to differentiate a location
    0x00, 0x00, // the minor value to differentiate a location
    0xC8        // 2's complement of the Tx power (-56dB)
void periodicCallback(void)
    led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */

 * This function is called every time we scan an advertisement.
void advertisementCallback(const Gap::AdvertisementCallbackParams_t *params)

    for(int i=0; i<params->advertisingDataLen; i++) {
        printf("%02x.", params->advertisingData[i]);

void onBleInitError(BLE &ble, ble_error_t error)
    /* Initialization error handling should go here */

void bleInitComplete(BLE::InitializationCompleteCallbackContext *params)
    BLE&        ble   = params->ble;
    ble_error_t error = params->error;

    if (error != BLE_ERROR_NONE) {
        onBleInitError(ble, error);

    if (ble.getInstanceID() != BLE::DEFAULT_INSTANCE) {

    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
    ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, beaconPayload, sizeof(beaconPayload));

    ble.gap().setAdvertisingInterval(1600); /* 1s; in multiples of 0.625ms. */

    ble.gap().setScanParams(1800 /* scan interval */, 1500 /* scan window */);


void scheduleBleEventsProcessing(BLE::OnEventsToProcessCallbackContext* context)
    BLE &ble = BLE::Instance();
    eventQueue.call(Callback<void()>(&ble, &BLE::processEvents));

int main()
    eventQueue.call_every(500, periodicCallback);

    BLE &ble = BLE::Instance();


    return 0;

Hello Leandro,

I am not sure where you are having trouble. Are you getting errors or do you think this is an application error?

Regards, - Earl, team Mbed

posted by Earl Manning 28 Aug 2018
Be the first to answer this question.