Skip to content

Commit 52bb4ce

Browse files
committed
Added setInterval function
1 parent c8589c4 commit 52bb4ce

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

API.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Supported security is None, JustWorks and PasskeyDisplay.
1313
* available() / readAvailable() – Bytes currently buffered in RX ring.
1414
* read() / read(dst, n) – Pop one / up to n bytes from RX ring.
1515
* peek() / peek(dst, n) – Inspect one / up to n bytes without consuming.
16-
* write(b) / write(buf, n) – Non-blocking enqueue to TX ring (may be partial if flow control blocks).
16+
* write(b) / write(buf, n) – Non-blocking enqueue to TX ring (may be partial if flow control blocks). Returns actual number of bytes written.
1717
* write(const char*) / print(str) / println(str) – Convenience text output (println adds CRLF).
1818
* printf(fmt, ...) – Formatted print into TX ring (truncates at local buffer size).
1919
* writeTimeout(buf, n, timeoutMs) – Attempt to enqueue up to n bytes within timeout; cooperatively waits for buffer space/unlock; decoupled from in-flight notifies (pop-based staging).
20-
* writeReady() – True if a client is subscribed and producer lock is not asserted; intentionally ignores in-flight notifies under pop-based staging.
20+
* writeReady() – True if a client is subscribed and producer lock is not asserted.
2121
* writeAvailable() – Remaining free space in TX ring (capacity - used).
2222

2323
### Pumping / Scheduling
@@ -58,15 +58,13 @@ Supported security is None, JustWorks and PasskeyDisplay.
5858
* getTxCapacity() / getRxCapacity() – Total ring capacities.
5959
* getTxFree() / getRxFree() – Remaining free space in TX / RX rings.
6060
* getTxDrops() / getRxDrops() – Dropped bytes due to buffer saturation.
61-
* getLkgEscalateCount() – Number of pacing escalations.
62-
* getEappCount() – Application error occurrences.
6361
* getLowWaterMark() / getHighWaterMark() – Current low/high water marks used for TX flow control.
6462

6563
### Flow Control Concepts
6664

6765
* Tx state machine – Internal: transmission advances through Waiting → Staging → Pending → Recovering/Discarding based on notify outcomes
6866
* txLocked – Internal: producer lock engaged (high-water limit reached; unlocks at low-water).
69-
Use writeReady() or check return value of write()/writeTimeout() instead of inspecting internals.
67+
Use writeReady() before writing and check if all data was successfully written.
7068

7169
### Implemented Setters
7270

@@ -75,6 +73,8 @@ Supported security is None, JustWorks and PasskeyDisplay.
7573
* getPumpMode() – Current pump mode
7674
* setPumpMode(Polling|Task) – Polling, or ESP32 task mode which runs a background FreeRTOS TX pump
7775
* setPower() – sets power level for Advertising, Scanning or Connection
76+
* setInterval(interval) – sets transmission interval in microseconds, auto adjusted during runtime
77+
* getInterval() – current pacing interval (µs)
7878

7979
### Implemented Status Queries
8080

@@ -84,7 +84,6 @@ Supported security is None, JustWorks and PasskeyDisplay.
8484
* getMode() – Fast, LongRange, LowPower, or Balanced
8585
* getBytesRx() / getBytesTx() – total bytes received/sent
8686
* getRxDrops() / getTxDrops() – dropped bytes
87-
* getInterval() – current pacing interval (µs)
8887
* getLkgInterval() / getMinInterval() – current LKG and minimum intervals (µs)
8988
* getRSSI() – smoothed RSSI
9089
* getMac() – device MAC address

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=BLE Serial - NUS
2-
version=1.1.1
2+
version=1.1.2
33
author=Urs Utzinger
44
maintainer=Urs Utzinger
55
sentence=Library creating a Nordic UART Service on a BLE device. Server mode.

src/BLESerial.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern "C" {
5757
/* Constants */
5858
/******************************************************************************************************/
5959

60-
#define BLE_SERIAL_VERSION_STRING "BLE Serial Library v1.1.1"
60+
#define BLE_SERIAL_VERSION_STRING "BLE Serial Library v1.1.2"
6161
#define BLE_SERIAL_APPEARANCE 0x0540 // Generic Sensor
6262

6363
// Log levels: ascending by verbosity for comparisons like (logLevel >= LEVEL)
@@ -336,6 +336,8 @@ class BLESerial : public Stream {
336336
#else
337337
void setPumpMode(PumpMode m) { pumpMode = PumpMode::Polling; } // no Task on non-ESP32
338338
#endif
339+
void setInterval(uint32_t us) {sendIntervalUs = us; }
340+
// set desired send interval in microseconds, auto adjusted through probing during runtime
339341

340342
// ----------------------------------------------------------------------------------------------
341343
// Logging / diagnostics

0 commit comments

Comments
 (0)