Get the FREE Ultimate OpenClaw Setup Guide →

connectivity-ble

npx machina-cli add skill beriberikix/zephyr-agent-skills/connectivity-ble --openclaw
Files (1)
SKILL.md
2.1 KB

Zephyr Connectivity: BLE

Implement robust, low-power Bluetooth Low Energy applications using Zephyr's industry-standard BLE stack.

Core Workflows

1. BLE Fundamentals

Set up advertising, define GATT services, and manage connections.

  • Reference: ble_fundamentals.md
  • Key Tools: BT_GATT_SERVICE_DEFINE, bt_le_adv_start, BT_CONN_CB_DEFINE.

2. Send-When-Idle Pattern

Optimize radio usage by bundling data and transmitting only during idle periods.

  • Reference: send_when_idle.md
  • Key Tools: k_work_delayable, Workqueues, SMF integration.

3. Power Optimization

Fine-tune intervals and connection parameters for maximum battery life.

Quick Start (Advertising)

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
#include <zephyr/bluetooth/bluetooth.h>

void start_simple_adv(void) {
    bt_enable(NULL);
    bt_le_adv_start(BT_LE_ADV_CONN_NAME, NULL, 0, NULL, 0);
}

Professional Patterns (Wireless Design)

  • Aggressive Latency: Increase peripheral latency to allow the radio to stay off longer during quiet periods.
  • Decoupled Messaging: Use Zbus to feed data into the BLE module, keeping the radio logic separate from the application logic.
  • Idle Bundling: Use the "Send-When-Idle" pattern specifically to reduce the number of wake-ups for the radio controller.

Resources

  • References:
    • ble_fundamentals.md: GATT, GAP, and connection basics.
    • send_when_idle.md: Implementing the idle-bundle pattern.
    • power_optimization.md: Parameter tuning and power-saving Kconfigs.

Source

git clone https://github.com/beriberikix/zephyr-agent-skills/blob/main/skills/connectivity-ble/SKILL.mdView on GitHub

Overview

Enable robust, low-power BLE apps on Zephyr’s BLE stack. This skill covers GATT services and characteristics, GAP advertising, connection parameters, power optimization, and the Send-When-Idle design pattern to minimize radio activity.

How This Skill Works

Leverage Zephyr’s BLE APIs to define GATT services (BT_GATT_SERVICE_DEFINE), start advertising (bt_le_adv_start), and manage connections (BT_CONN_CB_DEFINE). Optimize radio usage by tuning connection parameters, advertising intervals, and PHY settings, and implement the Send-When-Idle pattern with k_work_delayable, workqueues, and SMF integration for idle bundling.

When to Use It

  • When adding BLE connectivity to a Zephyr-based device
  • When battery life is a top priority for wireless devices
  • When implementing custom GATT profiles beyond standard services
  • When you want to reduce radio wakeups with idle bundling
  • When decoupling application logic from BLE radio using Zbus

Quick Start

  1. Step 1: Enable BLE in Kconfig: CONFIG_BT=y and CONFIG_BT_PERIPHERAL=y
  2. Step 2: Initialize BLE and start advertising using bt_enable(NULL); bt_le_adv_start(BT_LE_ADV_CONN_NAME, NULL, 0, NULL, 0);
  3. Step 3: Implement GATT services, configure power-optimization params, and test idle-bundling patterns

Best Practices

  • Use BT_GATT_SERVICE_DEFINE to declare GATT services and characteristics
  • Apply the Send-When-Idle pattern to bundle data and reduce wake-ups
  • Tune bt_le_conn_param, advertising intervals, and PHY for best power vs. performance
  • Choose appropriate PHY and monitor current consumption under real conditions
  • Keep radio logic separate from app logic with decoupled messaging (e.g., Zbus)

Example Use Cases

  • Wearable device implementing custom GATT services for health data
  • Environmental sensor node using idle bundling to extend battery life
  • Smart home button with efficient peripheral advertising and low latency
  • Industrial BLE node with optimized connection parameters for long duty cycles
  • BLE gateway that feeds data to the radio module via Zbus

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers