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 — GitHub - uutzinger/Arduino_BLESerial: Nordic UART Service, a serial interfaced over BLE

BranchesTags
Open more actions menu

Latest commit

 

History

17 Commits
17 Commits

Folders and files

NameName
Last commit message
Last commit date
.vscode
.vscode
 
 
assets
assets
 
 
examples
examples
 
 
src
src
 
 
tools
tools
 
 
.gitignore
.gitignore
 
 
API.md
API.md
 
 
CHANGELOG.md
CHANGELOG.md
 
 
License.txt
License.txt
 
 
Operation_Modes.md
Operation_Modes.md
 
 
README.md
README.md
 
 
TaskList.md
TaskList.md
 
 
keywords.txt
keywords.txt
 
 
library.properties
library.properties
 
 

Repository files navigation

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.

About

Nordic UART Service, a serial interfaced over BLE

Resources

Readme
MIT license
Activity

Stars

3 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — 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.