How to receive a byte array via BLE???

phantomBlurrr
Posts: 19
Joined: Mon Jun 10, 2019 4:01 pm

How to receive a byte array via BLE???

Postby phantomBlurrr » 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!

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

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

Postby Ritesh » Sat Jun 22, 2019 10:52 am

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.
Regards,
Ritesh Prajapati

chegewara
Posts: 2230
Joined: Wed Jun 14, 2017 9:00 pm

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

Postby chegewara » 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.

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

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

Postby Ritesh » Mon Jun 24, 2019 8:33 am

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.
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: Bing [Bot] and 126 guests