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

Minimal BLE GAP example (FreeRTOS). More...

#include <cassert>
#include <cstdint>
#include <cstdio>
#include "advertisement_data.hpp"
#include "../common/gap_event_handler.hpp"
#include "ble.hpp"
#include "freertos_task.hpp"
#include "gap.hpp"
#include "onboard_led.hpp"
#include "pico/stdlib.h"
#include "platform.hpp"
Include dependency graph for main_ble_gap.cpp:

Functions

static void on_turn_on ()
 Callback executed when the BLE stack is fully initialized.
 
void ble_app_task (void *params)
 FreeRTOS task that owns BLE initialization and periodic updates.
 
int main ()
 Program entry point.
 

Variables

static c7222::OnBoardLEDonboard_led = nullptr
 On-board LED used as a heartbeat while advertising.
 
static c7222::Platformplatform = nullptr
 Platform abstraction (initializes CYW43/BTstack).
 
static GapEventHandler gap_event_handler
 Common GAP event handler used for logging.
 

Detailed Description

Minimal BLE GAP example (FreeRTOS).

This example focuses purely on GAP functionality: setting up advertising, registering a GAP event handler, and periodically updating manufacturer data.

Dependencies:

Function Documentation

◆ ble_app_task()

void ble_app_task ( void *  params)

FreeRTOS task that owns BLE initialization and periodic updates.

Initializes the BLE stack, registers the stack-on callback, then periodically refreshes manufacturer data while advertising is enabled. The LED toggles as a heartbeat to confirm the task is running.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( void  )

Program entry point.

Here is the call graph for this function:

◆ on_turn_on()

static void on_turn_on ( )
static

Callback executed when the BLE stack is fully initialized.

Steps:

  • Attach a GAP event handler for logging.
  • Configure flags and device name.
  • Add a manufacturer-specific payload.
  • Start advertising with a fixed interval range.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ gap_event_handler

GapEventHandler gap_event_handler
static

Common GAP event handler used for logging.

◆ onboard_led

c7222::OnBoardLED* onboard_led = nullptr
static

On-board LED used as a heartbeat while advertising.

◆ platform

c7222::Platform* platform = nullptr
static

Platform abstraction (initializes CYW43/BTstack).