Few changes and a build test for GAP advertising changes
This commit is contained in:
parent
00af476bcf
commit
94142f321f
3 changed files with 37 additions and 23 deletions
|
@ -111,6 +111,10 @@ ble_error_t GapAdvertisingData::addAppearance(Appearance appearance)
|
|||
@para
|
||||
\ref LE_GENERAL_DISCOVERABLE - The peripheral is
|
||||
permanently discoverable
|
||||
|
||||
@para
|
||||
\ref BREDR_NOT_SUPPORTED - This peripheral is a
|
||||
Bluetooth Low Energy only device (no EDR support)
|
||||
|
||||
@returns ble_error_t
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
@para
|
||||
For convenience sake, all appropriate AD types have been encapsulated
|
||||
into an enum at \ref DataType.
|
||||
into \ref DataType.
|
||||
|
||||
@para
|
||||
Before the AD Types and their payload (if any) can be inserted into
|
||||
|
@ -38,29 +38,20 @@
|
|||
- Record length (1 byte)
|
||||
- AD Type (1 byte)
|
||||
- AD payload (optional, only present if record length > 1)
|
||||
|
||||
|
||||
@para
|
||||
When multiple AD records are present, the individual records are
|
||||
appended one after the other, up to the maximum payload length of 31
|
||||
bytes, as can be seen in the example payload below.
|
||||
This class takes care of properly formatting the payload, performs
|
||||
some basic checks on the payload length, and tries to avoid common
|
||||
errors like adding an exclusive AD field twice in the Advertising
|
||||
or Scan Response payload.
|
||||
|
||||
@section Sample Raw Advertising Payload
|
||||
@section EXAMPLE
|
||||
|
||||
// Two record payload containing BLE_GAP_ADV_DATATYPE_FLAGS (0x01) and
|
||||
// BLE_GAP_ADV_DATATYPE_COMPLETE_LOCAL_NAME (0x09) fields
|
||||
02 01 01 0A 09 50 65 64 6F 6D 65 74 65 72
|
||||
|
||||
// Record 1 (FLAGS)
|
||||
02 01 01
|
||||
02 = record length (2 bytes)
|
||||
01 = BLE_GAP_ADV_DATATYPE_FLAGS
|
||||
01 = BLE_GAP_ADV_FLAGS_LE_LIMITED_DISCOVERABLE
|
||||
@code
|
||||
|
||||
// Record 2 (COMPLETE LOCAL NAME)
|
||||
0A 09 50 65 64 6F 6D 65 74 65 72
|
||||
0A = record length (10 bytes)
|
||||
09 = BLE_GAP_ADV_DATATYPE_COMPLETE_LOCAL_NAME
|
||||
50 65 64 6F 6D 65 74 65 72 = "Pedometer"
|
||||
// ToDo
|
||||
|
||||
@endcode
|
||||
*/
|
||||
/**************************************************************************/
|
||||
class GapAdvertisingData
|
||||
|
|
25
main.cpp
25
main.cpp
|
@ -29,12 +29,31 @@ GattCharacteristic thermType ( 0x2A1D, 1, 1, BLE_GATT_CHAR_PROPERTIES_READ )
|
|||
GattCharacteristic thermInterval ( 0x2A21, 2, 2, BLE_GATT_CHAR_PROPERTIES_READ );
|
||||
|
||||
/* Notify = device (server) sends data when it changes */
|
||||
/* Indicate = device (server) sends data when it changes and client confirms reception */
|
||||
|
||||
/* Indicate = device (server) sends data when it changes and client confirms reception */
|
||||
|
||||
/* GAP Advertising Example (iBeacon) */
|
||||
GapAdvertisingParams advParams ( GapAdvertisingParams::NON_CONNECTABLE );
|
||||
GapAdvertisingData advData;
|
||||
|
||||
uint8_t iBeaconPayload[25] = { 0x4C, 0x00, 0x02, 0x15, 0xE2, 0x0A, 0x39, 0xF4, 0x73, 0xF5, 0x4B, 0xC4, 0xA1, 0x2F, 0x17, 0xD1, 0xAD, 0x07, 0xA9, 0x61, 0x00, 0x00, 0x00, 0x00, 0xC8 };
|
||||
|
||||
void startBeacon(void)
|
||||
{
|
||||
/* iBeacon includes the FLAG and MSD fields */
|
||||
advData.addFlags(GapAdvertisingData::BREDR_NOT_SUPPORTED);
|
||||
advData.addData(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, iBeaconPayload, 25);
|
||||
|
||||
wait(2);
|
||||
radio.reset();
|
||||
radio.setAdvertising(advParams, advData);
|
||||
radio.start();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
wait(2);
|
||||
radio.test();
|
||||
// radio.test();
|
||||
startBeacon();
|
||||
while(1);
|
||||
|
||||
/* Add the battery level characteristic to the battery service */
|
||||
|
|
Loading…
Reference in a new issue