class BLEUARTServer
BLEUARTServer class is a BLE UART server, which can be connected to by a BLE UART client and communicate with it.
Micropython Example:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from bleuart import * 9import time 10 11 12label0 = None 13ble_periph = None 14 15 16data = None 17 18 19def setup(): 20 global label0, ble_periph, data 21 22 M5.begin() 23 Widgets.fillScreen(0x222222) 24 label0 = Widgets.Label("Text", 20, 31, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18) 25 26 ble_periph = BLEUARTServer(name="ble-uart") 27 28 29def loop(): 30 global label0, ble_periph, data 31 M5.update() 32 if (ble_periph.any()) > 0: 33 data = ble_periph.read() 34 label0.setText(str(data)) 35 ble_periph.write(data) 36 else: 37 time.sleep_ms(100) 38 39 40if __name__ == "__main__": 41 try: 42 setup() 43 while True: 44 loop() 45 except (Exception, KeyboardInterrupt) as e: 46 try: 47 from utility import print_error_msg 48 49 print_error_msg(e) 50 except ImportError: 51 print("please update to latest firmware")
UIFLOW2 Example:
cores3_bleuart_server_example.m5f2
Constructors
Methods
- BLEUARTServer.irq()
The irq of the ble uart server.
- BLEUARTServer.any() int
Check if there is any data in the receive buffer.
- Returns:
The number of bytes in the receive buffer.
UIFLOW2:

- BLEUARTServer.read(sz=None) bytes
Read data from the receive buffer.
- Parameters:
sz (int) – The number of bytes to read. If not specified, read all data.
- Returns:
The data read from the receive buffer.
UIFLOW2:




- BLEUARTServer.write(data: bytes)
Write data to the ble uart server.
- Parameters:
data (bytes) – The data to write.
UIFLOW2:






- BLEUARTServer.close()
Close the ble uart server.
UIFLOW2:

- BLEUARTServer.deinit()
Deinitialize the ble uart server.
UIFLOW2:


