ELEC-C7222
Libraries for ELEC C7222 Course Work
Loading...
Searching...
No Matches
main_ble_custom_service_rw.cpp File Reference

BLE example showing a minimal custom service with READ + WRITE characteristics. More...

#include <cassert>
#include <cstdint>
#include <cstdio>
#include <vector>
#include "../common/gap_event_handler.hpp"
#include "../common/characteristic_event_handler.hpp"
#include "advertisement_data.hpp"
#include "attribute_server.hpp"
#include "ble.hpp"
#include "characteristic.hpp"
#include "freertos_task.hpp"
#include "gap.hpp"
#include "platform.hpp"
#include "app_profile.h"
Include dependency graph for main_ble_custom_service_rw.cpp:

Functions

int main ()
 Program entry point for the custom service RW example.
 

Detailed Description

BLE example showing a minimal custom service with READ + WRITE characteristics.

This example demonstrates how to implement a custom service using:

  • a .gatt profile (compiled into app_profile.h)
  • AttributeServer to locate services/characteristics by UUID
  • Characteristic::EventHandler to react to reads and writes

GATT layout

Service UUID: 0xFFE0

  • PublicValue (UUID 0xFFE1): READ (dynamic)
  • WriteValue (UUID 0xFFE2): WRITE / WRITE_WITHOUT_RESPONSE (dynamic)

How to test (nRF Connect / LightBlue)

1) Connect to "c7222-rw-demo" 2) Read "PublicValue" -> returns the current value 3) Write any bytes to "WriteValue" 4) Read "PublicValue" again -> it becomes whatever you wrote

Function Documentation

◆ main()

int main ( void  )

Program entry point for the custom service RW example.

Creates the BLE task and starts the FreeRTOS scheduler.

Here is the call graph for this function: