Cod - Classic Bluetooth

KHOAPHAM
Posts: 12
Joined: Wed Jan 19, 2022 3:03 am

Cod - Classic Bluetooth

Postby KHOAPHAM » Sat Mar 26, 2022 2:20 pm

Dear,
I have a query. What does ":" mean? And how can I assign value for each member of struct? I'm trying to set class of device for my Classic Bluetooth Application. But I'm stucked here. Can anyone help me. Thanks in advance.

Code: Select all

typedef struct {
    uint32_t      reserved_2: 2;                    /*!< undefined */
    uint32_t      minor: 6;                         /*!< minor class */
    uint32_t      major: 5;                         /*!< major class */
    uint32_t      service: 11;                      /*!< service class */
    uint32_t      reserved_8: 8;                    /*!< undefined */
} esp_bt_cod_t;

ESP_Sprite
Posts: 9746
Joined: Thu Nov 26, 2015 4:08 am

Re: Cod - Classic Bluetooth

Postby ESP_Sprite » Sun Mar 27, 2022 12:57 am

https://www.tutorialspoint.com/cprogram ... fields.htm

You can use them as if they were a regular member of a struct.

KHOAPHAM
Posts: 12
Joined: Wed Jan 19, 2022 3:03 am

Re: Cod - Classic Bluetooth

Postby KHOAPHAM » Sun Mar 27, 2022 9:53 am

Thank you, but I could not set minor and major. The code is below. Is it correct?

Code: Select all

esp_bt_cod_t cod;
        cod.reserved_2 = 0;
		cod.minor = 0b00001;
		cod.major = 0b00010;
		cod.reserved_8 = 0;
		cod.service = 0;
        ret = esp_bt_gap_set_cod(cod,ESP_BT_INIT_COD);

ESP_Sprite
Posts: 9746
Joined: Thu Nov 26, 2015 4:08 am

Re: Cod - Classic Bluetooth

Postby ESP_Sprite » Mon Mar 28, 2022 1:05 am

That should work on the struct side of things, but I'm not sure if Xtensa-GCC (or any other GCC aside from the AVR one, for that matter) understands binary numbers. Suggest you try e.g. 0x2 instead of 0b00010.

KHOAPHAM
Posts: 12
Joined: Wed Jan 19, 2022 3:03 am

Re: Cod - Classic Bluetooth

Postby KHOAPHAM » Mon Mar 28, 2022 3:08 am

It doesn't work..
Attachments
Screenshot 2022-03-28 100655.png
Screenshot 2022-03-28 100655.png (38.85 KiB) Viewed 2886 times

KHOAPHAM
Posts: 12
Joined: Wed Jan 19, 2022 3:03 am

Re: Cod - Classic Bluetooth

Postby KHOAPHAM » Mon Mar 28, 2022 3:21 am

I solved it. I put the code before setting device name and gap scan mode. It worked now. Thanks alot for your help.

Who is online

Users browsing this forum: No registered users and 111 guests