Nimble BLE GATT write returns status 0x103 (259)

rnplus
Posts: 1
Joined: Fri Dec 18, 2015 1:55 pm

Nimble BLE GATT write returns status 0x103 (259)

Postby rnplus » Sun Sep 07, 2025 2:00 pm

Hello! I'm trying to communicate with a BLE thermal printer from an ESP32.

I am trying to do what this Python script does on a PC: https://github.com/rbaron/catprinter/bl ... ter/ble.py

My attempt at porting this to ESP32 can be found here: https://github.com/renzenicolai/catprin ... ain.c#L943

The main Python script generates an array of command bytes to send, ble.py then sends these commands by writing mtu - 3 bytes (in this case 20 bytes) sized chunks.

In the ESP32 code the "write_data" array is the command data generated by the Python script.

Like the Python script the ESP32 firmware first scans for devices and then connects to the first device found which exposes the correct service UUID. It then subscribes to the RX characteristic.

This part works: opening and closing the paper tray of the printer does indeed produce a notification which is correctly received by the ESP32.

Writing command data does not work, when writing to the device using ble_gattc_write_flat the error->status in the callback is set to 259 (0x103), which I think indicates a permissions issue.

This question is purely about the low-level BLE communication, not the contents of the command data. The first message written already results in the error code and the printer does not execute the commands.


What is the difference between how the Python script sets up the connection and how the ESP32 sets up the connection? I do not see what is done differently.

Do I need to do extra steps in order to be able to write to a device?

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot], Craig_2026, Google [Bot] and 2 guests