1 year, 5 months ago.

How to update the URL payload of a BLE Eddystone advertisement in runtime

Hello,

I am new to the BLE code and I am not being able to update the URL payload of a BLE Eddystone advertisement in runtime.

I am trying to use the eddystoneServicePtr pointer and the setURLData() method but I don't get the expected update in the advertisement.

Can someone please help me with this?

include the mbed library with this snippet

int main(void)
{
    pc.printf("INFO: Loop initializing - main thread running.\n");
    
    buttonA.rise(&flagA);
    buttonB.rise(&flagB);
    
    BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE);
    ble.init(bleInitComplete);

    /* SpinWait for initialization to complete. This is necessary because the
     * BLE object is used in the main loop below. */
    while (ble.hasInitialized()  == false) { /* spin loop */ }
    
    while (true) {
        if (triggerA) {
            pc.printf("INFO: TriggerA sensed.\n");
            
            /* Do blocking calls or whatever hardware-specific action is
             * necessary to poll the sensor. */
            wait(1);
            
            /* Set Score */
            scoreA = scoreA + 1;
            
            /* Update advertisement */
            /* ... */
            eddyServicePtr->setURLData(current_match_url);
            
            triggerA = false;
            alivenessLED = false;
        }
        
        if (triggerB) {
            pc.printf("INFO: TriggerB sensed.\n");   
            
            /* Do blocking calls or whatever hardware-specific action is
             * necessary to poll the sensor. */
            wait(1);
            
            /* Set Score */
            scoreB = scoreB + 1;
            
            /* Update advertisement */
            /* ... */
            eddyServicePtr->setURLData(current_match_url);
            
            triggerB = false;
            alivenessLED = false;
        }
        
        ble.waitForEvent(); /* this will return upon any system event (such as an interrupt or a ticker wakeup) */
    }
}
Comment on this question
Be the first to answer this question.

You need to log in to post a question