Use Config over BLE GATTS with require pairing enabled and allow pairing disabled

  1. My goal is: I am trying to use Config over BLE GATTS with require pairing enabled and allow pairing disabled. My goal is to allow user to pair on specific button event for a limited amount of time. but i am able to send WIFI creds over BLE without pairing.
  2. My actions are:
    my Config schema includes:
  - ["bt.enable", true]
  - ["bt.keep_enabled", true]
  - ["bt.max_paired_devices", -1]
  - ["bt.gatts.require_pairing", true]
  - ["bt.gatts.min_sec_level", 0]

and libs includes:

- origin:

- origin:

- origin:
  1. The result I see is: In above case, Mongoose OS should not allow me to use BLE services but i am able to send wifi creds without pairing to device first.
  2. My expectation & question is: Am i doing something wrong? or can someone please give me an example or a way to accomplish my goal.

Thank you in advance.

Then you have to enable and disable pairing on event handlers by calling mgos_bt_gap_set_pairing_enable(), you can ffi and call from mJS; let bindornot = ffi('bool mgos_bt_gap_set_pairing_enable(bool)');
Start with - ["bt.allow_pairing", false]
When I tried something like that, 2 years ago, I used a higher minimum security level. I don’t remember the details right now but the definition for “security level” is related to pairing being required or not. - ["bt.gatts.min_sec_level", 1]

Thank you so much for replying.

tried calling mgos_bt_gap_set_pairing_enable(true) on handler, but fails to build, shows undefined reference, can you please specify the lib to include. i tried to look in bt-common but unable to find implementation of that particular function. found definition inside esp32_bt_gap.h but even though i include it its still not building up giving error: undefined reference to mgos_bt_gap_set_pairing_enable. can you please tell me which header file to include in order to use that function?

Thank you in advance.

I bet the last one is the one:

  - origin:
  - origin:

No luck sir. still same error. Maybe I should think of something else.

OK, I checked my old code and it doesn’t build under current release 2.20, same error. You can try pinning your application to an older release, for example, my code builds under 2.19.1, or investigate further, I can’t help.

Thank you so much,I’ll try and and update here

Thank you @scaprile, it is working like a charm now, problem is some of the bt_gap function implementations are missing in 2.20.0 version. I looked into the libraries and found mgos_bt_gap_set_pairing_enable() is not implemented and some auth related functions also , by trying 2.19.1 it is working. will raise a issue in github so that devs can look over it.

That is why I told you it builds under 2.19.1 and not 2.20.
Newer versions use more recent versions of the IDF and the BT code has changed a lot in these ones. The developers did not remove those functions without purpose, the BT implementation in the IDF might be totally different and that might have been the best choice. They know what they do.
I think your best choice is to study the underlying IDF release and use those functions, since BT is only available for the ESP32 at the moment.

bt-common started to move to NimBLE here, i.e. between 2.19.1 and 2.20.0.

1 Like

Thank you @nliviu and @scaprile i’ll study IDF and NIMble for more information. Thank you again.