Optimize Bluetooth LE L2CAP throughput between Linux running bluer l2cat and iOS - bluetooth-lowenergy

In transferring a raw stream of data over Bluetooth LE L2CAP between Linux and iOS, I get a throughput of approx. 9 kilobyte payload per sec. I expected to be able to transfer approx. 25 kB/s.
How can I investigate and/or optimize on the transfer rate?
Client Details
The L2CAP client is an iPhone 13 Pro running iOS 16 using the "CBL2CAPChannel-Demo" app over PSM 0x95.
It is essentially using Apple's open2LCAPChannel(_ PSM:) method in CBPeripheral.
As far as I see, Apple offers no configuration options for changing connection intervals, MTUs or anything like that. It all seems to be automatic.
Server Details
The L2CAP server is a Linux computer running Linux 5.10 using the bluez Bluetooth stack.
The test program is the command l2cat from Rust's bluer-tools.
I have used btmon to examine the exchanged packets, and they seem to be generally either 188 or 243 bytes in length.
Per Apple's recommendation, I have tried setting the connection interval min/max to 15 like so:
echo 15 > /sys/kernel/debug/bluetooth/hci0/conn_min_interval
echo 15 > /sys/kernel/debug/bluetooth/hci0/conn_max_interval
It did not have any effect on throughput.
How can I tell whether the Bluetooth module is using the 1Mbps PHY or the 2Mbps PHY?
I have tested the server on two seperate types of hardware:
Raspberry Pi CM4 with its built-in Bluetooth module and an external antennae
i.MX 8M Mini computer with an Intel WiFi 6 AX200 module and an external antennae
Note: It was tested with two different types of external antennae, and it was verified that the antennaes were connected properly.

Related

Winsock2 SOCK_RAW vs NPCap

I am building a CNC controller which has 1Gbps Ethernet interface for communction with a Desktop Windows. Right now I am using NPCap to implement a custom protocol to communicate between Windows and a CNC microcontroller for a high-performance link with low latency.
Problem: NPCAP is extremely slow. I benchmarked both the microcontroller firmware and NPCap. My microcontroller can easily go up to 700 Mbps in transmit and receive. But NPCap is giving me only 1 mbps transmit and 56 kbps receive. Is it that NPCAP itself is slow, or am I doing something wrong?
I see that Microsoft Winsock also allows some limited capabilities for RAW Ethernet. As of now, I haven't been able to get Winsock to work on my Windows application in SOCK_RAW mode. But before I go down the rabbit hole of using Winsock in RAW or give up and try to make my own network driver, I want to know if Winsock transfer speeds in SOCK_RAW are better than NPCap or are they similarly limited?

Raspberryy pi 3 BLE Devices

I am new to android.I have Raspberry pi 3 device.I can connect mobile device to Raspberry pi 3 over classic Bluetooth.now i am confused about Raspberry how to connect mobile device to Raspberry over bluetooth low energy.we can connect BLE device to android device and get Characteristics and can write Characteristics.now i want to do same thing in Raspberry pi 3 like (heart rate monitor,MI band 2)
Do it using a program
You can do it programmatically using DBus Calls. DBus is an interprocess Communication method used in linux. You can use DBus bindings for different languages such as python or C to make the DBus calls and do the operations.
A few links to help you get started :
DBus tutorial - https://dbus.freedesktop.org/doc/dbus-tutorial.html
BLE DBus API - https://elinux.org/images/3/32/Doing_Bluetooth_Low_Energy_on_Linux.pdf
Using Gatttool from terminal
Gatttool is a terminal tool just like hcitool. You can use the following commands to get the thing working:
hcitool lescan Gives you the list of nearby Low Energy Devices
gatttool -b mac_adress_of_le_device -I gives you an interactive session with the mentioned LE device
From the interactive session give connect to connect to the device
primary to get the primary services.
From this result, you can use the handle values to get the list of characteristics of a specific service. characteristics handle
To get the value of a characteristic use char-read-hnd handle
To get the characteristic descriptor, use char-desc handle
to write to a characteristic char-write-req handle value
Hope This helps!

Using HM-10 as an iBeacon scanner, I see only a maximum of 6 iBeacons

I have made an iBeacon scanner using the HM-10, where there may be as many as 20-30 iBeacons within range.
I connect an HM-10 (firmware V540) to my MacBook Air's USB port using the OSEPP FTDI USB-to-serial converter and a USB-mini USB cable.
Using the Arduino or CoolTerm app, I send the following AT commands:
AT+ROLE1
AT+IMME1
AT+RESET
AT+DISI?
This produces a scan of only 6 iBeacons, when I have present in the room about 30 iBeacons (all made using the HM-10 or by Kontakt).
Is this a limit in the scan firmware, or am I missing some other command?
We sent an email to the company about this, in English and Chinese. They responded with the advice to upgrade the firmware to V544. We did this, and now the device found 25 iBeacons on the last scan. You can also vary the scan time from 1-9 seconds.

Communicating with serial device over multi-drop bus

I'm new to serial communication. For a project I have to develop software for a vending machine. The vending machine basically consists of a host computer (a windows xp machine) and various peripherals. One of those peripherals is a coin acceptor. According to the documentation of the vending machine, the host computer communicates with the coin acceptor using the serial port. The only documentation I have is this document called "Multi-Drop Bus / Internal Communication Protocol" (the version I have can be found here: http://www.coin-acceptor.com.cn/Upload/EditorFiles/technicalfile/Mdb_version_4-2.pdf).
According to the docs it seems I have to create a serial port connection using a baud rate of 9600, 1 start bit, 1 stop bit, 1 mode bit and 8 data bits (page 29 in the linked document). The vending machine docs state that the coin acceptor is on COM port 6. I tried to create a connection like this using HyperTerminal and Putty. My first question is:
How do I properly create a connection to a device that supports this MDB 'protocol'? Putty and HyperTerminal don't allow me to set a "mode bit". I didn't find anything about the flow control and parity bit in the document. Can this be done using Putty or HyperTerminal? Or do I need some other tool to communicate over MDB?
My second question is about how to send a command to the device. I looked through the commands and saw a RESET command. According to the document, upon receiving the RESET command the device should reset itself and respond with an ACK. According to pages 33 and 63 of the document, if I want to send the RESET command to the coin acceptor, I can send the HEX value 08H over the serial line. Page 33 states that the coin changer listens to commands sent to addresses 08H until 10H (if I'm interpreting the document correctly, that is). Page 63 states that the RESET command is 08H with no data bytes. So can I just type "08H" into Putty and hit "enter" to send this command to the device? Or how can I send this command to the device over the serial line? Is this even the right approach or am I looking in the completely wrong place? The vending machine docs only contain this document for the coin acceptor. Thank you for the help!
Kind regards
Chris

Serial input ok but output queue fails

I'm using Python 2.7, pySerial under windows 7.
I have 8 devices, they are connected to my PC via Virtual COM port (Silicon Labs CP210x USB to UART Bridge), I'm testing them With multiprocessing all 8 COM ports are open and each time i'm sending command to one unit only, there is no MultiThreading.
The problem is that after X time (it could be 10 minutes or 5 hours), the output Queue of the serial ports fails to send me responses. it's not a specific port each time it's a different port (it can be several ports)
It's importent to say, the device gets my command and do it. the fail is to get the response, The device i'm testing is OK for sure.
I am sniffing the port with Serial monitor, all the commands send OK and the device makes them, only it doesn't respond.
Any idea's ?
There could be n number of reasons:
Buffers might be full
Com Port is not working or might be
And finally the device is malfunctioning..
Check out these things might be it will help you.

Resources