GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Arduino_BLESerial/README.md at main · uutzinger/Arduino_BLESerial

Expand file tree

/

README.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
122 lines (89 loc) · 3.91 KB
/

README.md

Copy path

File metadata and controls

122 lines (89 loc) · 3.91 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

BLE Serial Library

Introduction

BLESerial allows serial communication over a BLE connection .

It implements the Nordic UART Service (NUS) as a server on a micro controller, providing commands like:

BLESerial ble;
ble.println("Hello");
n=ble.available();
ble.read(buffer,n);

It attempts to adapt for maximum throughput, low power usage or long distance communication.

The library provides a server implementation as it is designed to work with programs such as:

  • SerialUI
  • nRF connect for mobile

There are similar implementations from other authors: senseshift (lightweight and customizable) and afpineda (feature-rich NUS protocols and commands).

This implementation is a managed high-throughput BLE serial transport with adaptive link behavior and explicit reliability/streaming modes.

A throughput of more than 100k bytes/s and a latency of 10..20 ms was achieved.

Installation

Installation occurs through the Arduino library manager.

Dependencies

  • NimBLE-Arduino
  • UUtzinger_RingBuffer
  • UUtzinger_logger

BLESerial uses the shared UUtzinger_logger level but has a dedicated diagnostic output that defaults to Serial. Configure it before begin() with ble.setDiagnosticOutput(Serial1) or any application-provided Print, including a flash-file adapter. The BLESerial object itself is rejected as a diagnostic destination. Application LOG() / LOGln() calls continue to follow the global logSetOutput() destination and may intentionally target BLE.

Quick Start

Minimal example demonstrating setup, polling versus task (ESP32) mode, command parsing, and date transmission and receiving:

#include <Arduino.h>
#include "BLESerial.h"
#include "Linereader.h"

BLESerial        ble;
LineReader<128>  lr;

char line[128];
const char helpmsg[] = "Commands: ?=help, stats, echo <text>";

void setup() {
  Serial.begin(115200);
  while (!Serial) { /* wait for USB serial */ }

  // Optional: Serial is the default. Serial1 or any custom Print is accepted.
  ble.setDiagnosticOutput(Serial);

  // Security::None | JustWorks | PasskeyDisplay
  // Mode::Fast | LowPower | LongRange | Balanced
  ble.begin(BLESerial::Mode::Fast, "BLESerialDevice", BLESerial::Security::None);

  #ifdef ARDUINO_ARCH_ESP32
  ble.setPumpMode(BLESerial::PumpMode::Task); // background TX pump
  #endif

  Serial.println("BLESerial demo started.");
}

void loop() {
  if (ble.getPumpMode() == BLESerial::PumpMode::Polling) {
    ble.update();
  }

  // Parse incoming lines from BLE
  if (lr.poll(ble, line, sizeof(line))) {
    if (strcasecmp(line, "?") == 0) {
      ble.println(helpmsg);
      Serial.println(helpmsg);
    } else if (strcasecmp(line, "stats") == 0) {
      ble.printStats(); // shows on Serial port
    } else if (strncasecmp(line, "echo ", 5) == 0) {
      ble.println(line + 5);
    } else {
      ble.println("Unknown command. Type ? for help.");
    }
  }
}

Documentation

  • API Documentation
  • Operation Modes
  • Task List
  • Change Log

Example Programs

  • BLESerial_minimal (simple echo program)
  • BLESerial_demo (simple program listed above)
  • BLESerial_comprehensive (generates data for performance measurements)
  • BLESerial_text_stress (validates reliable large text output over USB and BLE; the selflog command exercises the dedicated diagnostic route)

Contributing

Urs Utzinger 2025

ChatGPT (OpenAI)

License

See LICENSE.

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.