Setup Appearance GAP characteristic (0x2A01) in BLE

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Setup Appearance GAP characteristic (0x2A01) in BLE

Postby davdav » Wed Mar 21, 2018 2:32 pm

Hi,
I'm trying to understand how to setup the Appearance charateristic in GAP BLE (in particular as REMOTE_GENERIC).

Here:

https://github.com/nkolban/esp32-snippets/issues/88

They seems to have fixed for ESP32-Arduino (mayb @chegewara and @kolban can help).

Here:

https://github.com/espressif/esp-idf/issues/1042

it is stated that it will available in v3.1.

I'm using ESP-IDF and I really don't know how to change it even if in

https://github.com/espressif/esp-idf/bl ... ap.c#L2664

it seems to be present something related to appearance characteristic.


How can I do it without nee to wait for v3.1?

Thanks

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

Re: Setup Appearance GAP characteristic (0x2A01) in BLE

Postby chegewara » Wed Mar 21, 2018 4:58 pm

Hi.
When you creating ble server you have to prepare advertising data which is structure of type:
http://esp-idf.readthedocs.io/en/latest ... adv_data_t

In this structure you have field:
http://esp-idf.readthedocs.io/en/latest ... ppearanceE

which should be uint16_t (maybe its just typo in documentation).
Now you have to pass to this field hex value according to this table (this table is very ugly now, it used to be nicer)
https://www.bluetooth.com/specification ... arance.xml

Here you have few values that can passed for different HID devices:
https://github.com/nkolban/esp32-snippe ... .h#L20-L28

Or you can count it this way:
- value get from column 1 (category)
- left shift this value by 6 bits
- add value from sub-category column

This should have solve issue.

PS value will be decimal, not hex
PS2 for Generic Remote Control its: 6<<6 + 0 = 384

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

Re: Setup Appearance GAP characteristic (0x2A01) in BLE

Postby chegewara » Thu Mar 22, 2018 8:07 am

Just for test purpose i changed value in gatt_server example from esp-idf repo like this and it works:

Code: Select all

static esp_ble_adv_data_t adv_data = {
    .set_scan_rsp = false,
    .include_name = true,
    .include_txpower = true,
    .min_interval = 0x20,
    .max_interval = 0x40,
    .appearance = 962,      <--- ICON VALUE CHANGED
    .manufacturer_len = 0, 
    .p_manufacturer_data =  NULL, 
    .service_data_len = 0,
    .p_service_data = NULL,
    .service_uuid_len = 32,
    .p_service_uuid = adv_service_uuid128,
    .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Re: Setup Appearance GAP characteristic (0x2A01) in BLE

Postby davdav » Thu Mar 22, 2018 8:22 am

Thanks @chegewara for suggestion.

What I miss to say in my first post was that I'm using raw data in order to emulate an eddystone UID beacon.
Therefore, I'm not using "esp_ble_adv_data_t" structure where "appearance" element is defined.

I currently setup two arrays for advertize and scan response in this way:

Code: Select all

//Eddystone UID advertize
static  uint8_t eddystone_adv_data[31] = {
	0x02, 0x01, 0x06, //3
	0x03, 0x03, 0xAA, 0xFE, //4
	0x17, 0x16, 0xAA, 0xFE, 0x00, // 5
	0x00, //1
    0xe5, 0xf8, 0xf4, 0x9b, 0xf5, 0x61, 0xfc, 0x61, 0xf6, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //16
    0x00, 0x00 //2
};

static uint8_t eddystone_scan_rsp_data[] = {
        // device name
        0x06, 0x09, 'A', 'v', 'i', 'o', 'r',
        //Appearance
        0x03, 0x19, 0x80, 0x01, //384 = generic remote control
	//flags
        0x02, 0x01, 0x06,
        //tx power
        0x02, 0x0a, 0xdb
};
In scan_rsp_data I put the appearance "tag" (0x19) as reported in

https://www.bluetooth.com/specification ... ss-profile

The problem was that I setup in little-endian while it needs to be setup in big-endian. 384 = 0x0180 -> "0x80, 0x01"

So now it works and nRF Connect is able to scan and find the correct appearance (see image 1).

However, I'm testing GATTS_server_table_demo and when I connect the APP to the device, in the Generic Access section the Appearance value is not found (while Device Name is found probably because in the program it setup with "esp_ble_gap_set_device_name" function).


So probably my question should be: how to setup appearance in Generic Access section of GATT SERVER?

Thanks
Attachments
image2.png
image2.png (55.23 KiB) Viewed 9496 times
image1.png
image1.png (60.56 KiB) Viewed 9496 times

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

Re: Setup Appearance GAP characteristic (0x2A01) in BLE

Postby chegewara » Thu Mar 22, 2018 9:51 am

Here is the problem. We were able to set appearance only for advertising. I did some reaserch but i could not find any API that let you setup value for characteristic 0x2A01 (appearance). There is two options:
- its a bug and appearance characteristic value is not set even if its set for advertising,
- we are missing some API.

My suggestion is to open issue on github then you will get answer faster than here.
Sorry but i cant help you more with this issue.

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Re: Setup Appearance GAP characteristic (0x2A01) in BLE

Postby davdav » Thu Mar 22, 2018 3:00 pm

OK @chegewara, you gave me a lot of help.

I will open an issue on github referencing this thread. Hopefully they could give a solution.

Thanks

muradjabir
Posts: 1
Joined: Wed Mar 13, 2024 7:27 pm

Re: Setup Appearance GAP characteristic (0x2A01) in BLE

Postby muradjabir » Wed Mar 13, 2024 7:29 pm

This can now be set using esp_ble_gap_config_local_icon() on both Arduino and the IDF.

Who is online

Users browsing this forum: Baidu [Spider] and 89 guests