8 years, 9 months ago.

can I send digital data though GAP service? IF yes how to include the device?

#include "mbed.h"
#include "BLEDevice.h"

// BLE object
BLEDevice ble;
DigitalIn sensor(P0_5)
// Optional: Device Name, add for human read-ability
const static char     DEVICE_NAME[]        = "Flowmeter Tom_field"; // Optional: device name

// You have up to 26 bytes of advertising data to use.
const static uint8_t AdvData[] = {0x01,0x02,0x03,0x04,0x05};   // example of hex data
//const static uint8_t AdvData[] = {"ChangeThisData"};         // example of character data
static uint8_t analog_enabled = 0;
static uint8_t old_state = 0;
// Optional: Restart advertising when phone app disconnects
void disconnectionCallback(Gap::Handle_t handle, Gap::DisconnectionReason_t reason)
{
    ble.startAdvertising();
}

Question relating to:

This example program shows how to set up a GAP advertising packet to broadcast data from the device out to anyone who may be listening. BLE, custom GAP, GAP, GAP Demo, GAP Example

Also the code gives errors.

posted by jayendra mishra 23 Jul 2015

1 Answer

8 years, 9 months ago.

The GAP service is a standard service with read-only characteristics: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.generic_access.xml

Some of its characteristics can be updated using methods offered by BLE_API, but it's not a good idea to overload standard characteristics to send application-specific digital data.

Accepted Answer

so what is the best process to send a digital data from a sensor. I actually want to calculate the frequency of and send it to the cellphone.

posted by jayendra mishra 24 Jul 2015