Page 1 of 1

Adding characteristic results in GATT_ERROR 133

Posted: Fri Feb 28, 2025 12:27 am
by ccut93
I am trying to make a simpler to use interface for BLE with esp-idf. I have run into an issue that I have been messing with for the last 6 hours. I am able to advertise and create a service, but when I try to add a characteristic, the callback comes with status 133 (general failure). Also, I am able to see the service advertised, but when I try to view the service by connect in nRF Connect, it doesnt show the service

Code is hosted at https://github.com/shadowdash1901/idf_ble_simple

This is the output

Code: Select all

I (491) main_task: Calling app_main()
I (505) BTDM_INIT: BT controller compile version [f7360be]
I (507) BTDM_INIT: Bluetooth MAC: d4:d4:da:0f:cc:2e
I (510) phy_init: phy_version 4840,02e0d70,Sep  2 2024,19:39:07
I (902) gatts_simple: GATT server register, status 0, app_id 0, gatts_if 3
I (908) gatts_simple: Raw Adv Data Complete
I (913) gatts_simple: RAW adv rsp data complete
I (927) gatts_simple: Advertising start successfully
I (928) gatts_simple: Service UUID df0b4f24-cb71-4ec0-b43e-7f6fc3a3440f
I (929) gatts_simple: Service create, status 0, service_handle 40
I (934) gatts_simple: Char uuid: 2b6513d4-5453-4d15-af7f-98788ffe9e51
I (940) gatts_simple: Adding characteristic srv_hdl:40 perm:17 prop:26
I (946) gatts_simple: Characteristic add, status 133, attr_handle 0 service_handle 40
I (953) main: Hello World!
I (956) main_task: Returned from app_main()

Re: Adding characteristic results in GATT_ERROR 133

Posted: Tue Mar 04, 2025 6:51 pm
by ccut93
I have found the problem in my code. In esp_ble_gatts_create_service(), I specified one handle. This is apparently incorrect. The service was created, but when I tried to add a characteristic, the service didn't have any handles available to give for it, so the add_char() failed. I have determined that each characteristic consumes 2 handles, so you have to know how many characteristics you are going to create, and call create_service() with a corresponding number.