This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to create your own ble service?

I want to graduate from hacking my own data through the heart-rate-service (hrs). None of these seem to fulfill my requirements. Is there a document or template from which I can build my custom service? I really just want to send up a batch of timestamped sensor readings.

#define MAX_BLE_PAYLOAD_SIZE  20

typedef struct my_sample_s {
  uint16_t my_value;
  uint16_t elapsed_ms; // or some kind of relative time since last sync or connection
} my_sample_t;

typedef struct my_message_s {
  //my_sample_t samples[MAX_BLE_PAYLOAD_SIZE / sizeof(my_sample_t)];
  my_sample_t samples[5];
} my_message_t;

my_message_t my_message; 

How can I just send(my_message)?

  • Hi,

    Take a look at these previous questions:

    How do I create a service and How to use Vendor-specific UUID.

    When creating a non-adopted service, you have to use 128-bit UUID values instead of the 16-bit variants you are used to see. Then you would follow the outline of a normal, simple service like the battery service and pipe the incoming events to your service. To be able to send data, you can either have a notifiable characteristic, have the peer enable notifications, and then start sending data - OR - you can have service that allows data to be written to on the peer side and use write requests/commands or long writes to push your data.

Related