Page 1 of 1

How to receive a byte array via BLE???

Posted: Fri Jun 21, 2019 7:29 pm
by phantomBlurrr
Hello,
I am working on a project in which I want to do some operations over BLE with a gatt client (smart phone). At some point in operation, the ESP can be sent a string from the android app and then the ESP will do some operations using that string. I am wondering if anyone knows a good method to do this task? I am having trouble converting from uint8_t* (which is the type that the gatt write event brings in the characteristic value) to a string variable. I do not want to use Blufi, Arduino, nor Kolban c++ since I want to learn how to do it using esp-idf.

So how can one take a value from BLE characteristic write event and put it into a string variable in order to perform operations?

My code is pretty much the gatt server + gatt security server + service table examples all mashed together.
Any help is appreciated!

Re: How to receive a byte array via BLE???

Posted: Sat Jun 22, 2019 10:52 am
by Ritesh
phantomBlurrr wrote:
Fri Jun 21, 2019 7:29 pm
Hello,
I am working on a project in which I want to do some operations over BLE with a gatt client (smart phone). At some point in operation, the ESP can be sent a string from the android app and then the ESP will do some operations using that string. I am wondering if anyone knows a good method to do this task? I am having trouble converting from uint8_t* (which is the type that the gatt write event brings in the characteristic value) to a string variable. I do not want to use Blufi, Arduino, nor Kolban c++ since I want to learn how to do it using esp-idf.

So how can one take a value from BLE characteristic write event and put it into a string variable in order to perform operations?

My code is pretty much the gatt server + gatt security server + service table examples all mashed together.
Any help is appreciated!
Hello,

Good Question.

Would you please let me know that which ESP32 IDF you are using for your development purpose?

Also Did you try with examples provided into ESP32 IDF itself as per your requirements? if yes then which specific issue you are facing at that time?

it will be good if you can share your example with clear requirements so that we can helpful to you for that.

Re: How to receive a byte array via BLE???

Posted: Sun Jun 23, 2019 6:38 pm
by chegewara
Thru ble you can send packets of bytes, its up to you what those bytes represent.
If you send array of bytes it will be just packet of bytes for ble application, but in your code you can cast it to array or even structure.

Look here:

esp_ble_gattc_write_char_descr(esp_gatt_if_tgattc_if, uint16_t conn_id, uint16_t handle, uint16_t value_len, uint8_t *value, esp_gatt_write_type_twrite_type, esp_gatt_auth_req_tauth_req)

If you have uint8_t array[20] you will pass &array[0] as value and value_len = 20.

Re: How to receive a byte array via BLE???

Posted: Mon Jun 24, 2019 8:33 am
by Ritesh
chegewara wrote:
Sun Jun 23, 2019 6:38 pm
Thru ble you can send packets of bytes, its up to you what those bytes represent.
If you send array of bytes it will be just packet of bytes for ble application, but in your code you can cast it to array or even structure.

Look here:

esp_ble_gattc_write_char_descr(esp_gatt_if_tgattc_if, uint16_t conn_id, uint16_t handle, uint16_t value_len, uint8_t *value, esp_gatt_write_type_twrite_type, esp_gatt_auth_req_tauth_req)

If you have uint8_t array[20] you will pass &array[0] as value and value_len = 20.
Yeah. Something like that.