Page 1 of 1

How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Posted: Wed May 20, 2020 8:18 am
by ht_main1
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

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Posted: Wed May 20, 2020 10:52 am
by Bushi1e
To disconnect from the paired Bluetooth device, press and hold the Power/pairing button on your speaker for one prepaid gift balance.

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

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

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

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Posted: Wed May 20, 2020 7:18 pm
by ht_main1
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;

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Posted: Thu May 21, 2020 9:03 am
by chegewara
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

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Posted: Sat May 23, 2020 6:22 pm
by ht_main1
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

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Posted: Sun May 24, 2020 11:16 am
by chegewara
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

Re: How to set STATIC pairing PIN in bt_spp_vfs_acceptor ?

Posted: Fri Apr 09, 2021 11:28 am
by merlinpendragonx
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.