Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
main.cpp
- Committer:
- hux
- Date:
- 2016-12-11
- Revision:
- 27:09ec26511db8
- Parent:
- 26:ab05e85743a9
- Child:
- 28:114eaad388c1
File content as of revision 27:09ec26511db8:
// T04_Advertising: Tutorial for demonstration of simple advertising
// Program has been tested on NUCLEO-L76RG
#include <mbed.h>
#include "bricks.h"
// Add a device name for human readability
const static char DEVICE_NAME[] = "Stupid Board";
// You have up to 26 bytes of advertising data to use.
// Hex data example: {0x01,0x02,0x03,0x04,0x05}
// Char data example: {"ChangeThisData"}
const static uint8_t AdvData[] = {0x01,0x02,0x03,0x04,0x05};
//==============================================================================
// Some Callbacks
//==============================================================================
void onDisconnect(Blob &blob) // Disconnection Callback
{
blob.start(); // start advertising
blink(ADVERTISE); // indicate advertising
}
void onError(Blob &blob) // Error Reporting Callback
{
(void) blob; // Avoid compiler warnings
blink(FAULT); // indicate advertising
}
void onSetup(Blob &blob) // Immediately After Initializing BLE
{
blob.device(DEVICE_NAME); // setup device name
blob.data(AdvData,sizeof(AdvData));
blob.name("T05 Advertise"); // add name to device
blob.onDisconnect(onDisconnect); // setup disconnection callback
blob.mode("C:ng"); // no BR/EDR, general discoverable (UDSN)
blob.start(100); // start advertising @ 100 msec interval
blink(ADVERTISE);
}
int main(void)
{
blink(IDLE); // idle blinking - everything is OK!
Blob blob;
blob.init(onSetup,onError); // init BLE base layer, always do first
while (true) // Infinite loop waiting for BLE events */
{
blob.sleep(); // low power waiting for BLE events
}
}
