MTU Negotiation Seeed Xiao nRF52840 Sense and Javascritp GUI

Hi!
I am sending a packet of data larger than 20 bytes to my laptop and I am reading them with JS GUI.
The problem is that I need to negotiate the MTU size because my GUI is reading only the first 20 bytes of the string.

Anyone is familiar with this problem?

The following link provides an example of extending MTU.

\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.8\libraries\Bluefruit52Lib\examples\Peripheral\throughput

1 Like

Thank you for your response!

I noticed that when I view the string on my iPhone using the “Bluefruitconnection” app, I can see the entire string. However, when I try to read the string from the JavaScript GUI, I can only see 20 bytes. Could this issue be related to the Seeed Xiao, Chrome, or perhaps windows11 ?

Have you had any experience connecting the Seeed Xiao to a Chrome webpage before? I apologize for the basic questions; I’m relatively new to this and still trying to navigate my way through.

My interest is exclusively in XIAO-to-XIAO communication.
I have no experience connecting to Chrome and unfortunately cannot help you.

1 Like

Hi there,
I would make the suggestion , you load up NRF connect for desktops and run the BLE program it allows one to experiment with most of the connection properties on the fly. If your code is correct and connection is configured properly it will be reflected in the Setting.
like this.


I changed it to 200 as a test, it acknowledged the change at the bottom. open the device and see how it works.

You can change the PHY also I can up it to 2M as well.

Value is updated in the connection, Try that and see what you get!.
HTH
GL :slight_smile: PJ :v:
The test code is the Server example under the ESP32C6 BLE folder.

/*
    Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleServer.cpp
    Ported to Arduino ESP32 by Evandro Copercini
    updates by chegewara
*/

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>

// See the following for generating UUIDs:
// https://www.uuidgenerator.net/

#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"

void setup() {
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

  BLEDevice::init("Xiao ESP32C6");
  BLEServer *pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );

  pCharacteristic->setValue("Hello World SEEED");
  pService->start();
  // BLEAdvertising *pAdvertising = pServer->getAdvertising();  // this still is working for backward compatibility
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(true);
  pAdvertising->setMinPreferred(0x06);  // functions that help with iPhone connections issue
  pAdvertising->setMinPreferred(0x12);
  BLEDevice::startAdvertising();
  Serial.println("Characteristic defined! Now you can read it in your phone!");
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
}

Serial output …

Starting BLE work!
controller lib commit: [77d09ce]
Characteristic defined! Now you can read it in your phone!
1 Like

Thanks for the answers. I still have a hard time doing MTU negotiation; I also tried Python, but nothing…

Since you guys are experts in seeed xiao to seeed xiao connection. do you think it would be possible to send data from a seeed xiao nrf52840 (peripheral) to another seeed xiao nrf52840 (central), exploiting the fact that in that case, maybe I have more BLE bandwidth because I would be able to do MTU negotiation ? if yes, how can I make the seeed xiao nrf52840 scan for other active devices and link to my peripheral? Because then I would pass the data to my JS GUI through the serial port.

to conclude:

  1. in a BLE xiao-xiao (nrf52840 sense - nrf52840 sense ) connection can I pass packet of ~130 byte?
  2. in a ble xiao-xiao connection what code I should upload to the central?

thanks for the help. :slight_smile:

Here a simple scheme:

[Seeed xiao nRF52840] ==>BLE5.0==>[Seeed xiao nRF52840] ==> serial port ==> [GUI]
|
{Sensors}


This is what I was thinking. Because chunking is too slow for the data analysis that I need to do, I would go to 12 Hz to 3 Hz of data with chunking. So I need to send those data all together.

This topic may be helpful.

“XIAO nRF52840, Efficiently Uploads Peripheral On-Board Flash ROM Data to Central”

1 Like

There are examples of code to establish a connection? so I can start building up my code from them.

Please see the zip file in post 1/5.
It has the code for Peripheral and Central.

A simple example of the connection is attached.
POST_nRF52_XIAO_SimpleConnection.zip (4.9 KB)

1 Like

msfujino!

I was able to connect two boards thanks to you.

I still have a little problem; before modifying the code, I wanted to test if I would have been able to send the data, so from the peripheral, I sent “hello world” to the central.

Would you give a look at the functions? It should be clear, maybe I am missing something stupid. The connection is fine but when I am sending HEllo world the central is not receiving I think

codes.zip (3.7 KB)

the connection is automatic and the string is sent periodically

Delete the following to send “Hello World”.
You can check it with applications such as “LightBlue” and “BLE Hero”.

PERIPHERAL_CODE_XIAO.ino:65

//  dataCharacteristic.setFixedLen(DATA_NUM);
1 Like

Thanks eventually I managed to connect the 2 boards and stream the data !!!