How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

ht_main1
Posts: 28
Joined: Sun Oct 06, 2019 6:08 pm

How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Postby ht_main1 » Wed May 20, 2020 8:18 am

I ran the example code for BT SPP from esp-idfv4.0 example code ? i just want to know how do i set the STATIC PIN for pairing BT ?
In the code it generate random pairing key.

Thanks
in advance

Bushi1e
Posts: 1
Joined: Wed May 20, 2020 10:50 am

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Postby Bushi1e » Wed May 20, 2020 10:52 am

To disconnect from the paired Bluetooth device, press and hold the Power/pairing button on your speaker for one prepaid gift balance.

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

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Postby chegewara » Wed May 20, 2020 12:29 pm

https://github.com/espressif/esp-idf/bl ... #L102-L108

You have also change option in menuconfig, disable Secure simple pairing (or enable).

ht_main1
Posts: 28
Joined: Sun Oct 06, 2019 6:08 pm

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Postby ht_main1 » Wed May 20, 2020 7:18 pm

chegewara wrote:
Wed May 20, 2020 12:29 pm
https://github.com/espressif/esp-idf/bl ... #L102-L108

You have also change option in menuconfig, disable Secure simple pairing (or enable).
Secure simple pairing (disabling this throws error for esp_bt_gap_set_pin )
i added the code from link as below,
is it right ?

Code: Select all

    case ESP_SPP_INIT_EVT:
        ESP_LOGI(SPP_TAG, "ESP_SPP_INIT_EVT");
        esp_bt_dev_set_device_name("bt_server");

	esp_bt_pin_type_t pin_type = ESP_BT_PIN_TYPE_FIXED;
	esp_bt_pin_code_t pin_code;
	pin_code[0] = '0';
	pin_code[1] = '0';
	pin_code[2] = '0';
	pin_code[3] = '0';
	esp_bt_gap_set_pin(pin_type, 4, pin_code);


        esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE);
        esp_spp_start_srv(sec_mask,role_slave, 0, SPP_SERVER_NAME);
        break;

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

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Postby chegewara » Thu May 21, 2020 9:03 am

I have bt classic project i finished 2 days ago and now checked to make sure. You have to disable
Secure simple pairing
to make use of static pin code.

https://github.com/espressif/esp-idf/is ... -443575348

ht_main1
Posts: 28
Joined: Sun Oct 06, 2019 6:08 pm

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Postby ht_main1 » Sat May 23, 2020 6:22 pm

chegewara wrote:
Thu May 21, 2020 9:03 am
I have bt classic project i finished 2 days ago and now checked to make sure. You have to disable
Secure simple pairing
to make use of static pin code.

https://github.com/espressif/esp-idf/is ... -443575348
Thanks that solved it, i had to manual insert following code, i was getting error on compilations,

Code: Select all

#define CONFIG_CLASSIC_BT_ENABLED 1
#define CONFIG_BT_SPP_ENABLED 1
i found from this comment https://github.com/platformio/platform ... -475671300

Thanks @chegewara you always provide right and accurate information.
Keep doing best work. Take care

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

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Postby chegewara » Sun May 24, 2020 11:16 am

ht_main1 wrote:
Sat May 23, 2020 6:22 pm

Thanks that solved it, i had to manual insert following code, i was getting error on compilations,

Code: Select all

#define CONFIG_CLASSIC_BT_ENABLED 1
#define CONFIG_BT_SPP_ENABLED 1
i found from this comment https://github.com/platformio/platform ... -475671300
Thats strange, because those flags are already there:
https://github.com/espressif/esp-idf/bl ... g.defaults

Maybe try to use idf.py defconfig.
ht_main1 wrote: Thanks @chegewara you always provide right and accurate information.
Keep doing best work. Take care
Thanks

merlinpendragonx
Posts: 1
Joined: Fri Apr 09, 2021 11:25 am

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Postby merlinpendragonx » Fri Apr 09, 2021 11:28 am

Bushi1e wrote:
Wed May 20, 2020 10:52 am
To disconnect from the paired Bluetooth device, press and hold the Power/pairing button on your speaker for one Prepaid Gift Balance
.
I'm not sure about setting a static pin, but as far as discover-ability timeout, you would edit /etc/bluetooth/main.conf and set DiscoverableTimeout = 0 and you might also want to change PairableTimeout = 0.

Who is online

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