logo elektroda
logo elektroda
X
logo elektroda

ESP 32 WROOM Arduino how to acquire bluetooth client address right after pairing.

coshiz 759 4
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19565433
    coshiz
    Level 11  
    Good afternoon,
    I would like your help please. I need to read the bluetooth client address right after pairing.
    I've been looking around the web for a while and found this code (I'm posting below the problem description).
    Does anyone maybe know the command (second line) to implement the conditional instruction right after pairing. At the moment
    manages to read the bluetooth mac address but only after opening a terminal e.g. on a smartphone and the pairing itself has no effect.
    Thanks in advance for your help.

    void callback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) {

    if (event == ESP_SPP_SRV_OPEN_EVT){

    Serial.println("Client Connected has address:");

    for (int i = 0; i < 6; i++) {

    Serial.printf("X", param->srv_open.rem_bda );

    if (i < 5) {
    Serial.print(":");
    }

    }
    }
    }
    source: https://techtutorialsx.com/2018/12/11/esp32-arduino-serial-over-bluetooth-get-client-address/
    Do you have a problem with Arduino? Ask question. Visit our forum Arduino.
  • ADVERTISEMENT
  • #2 19566025
    khoam
    Level 42  
    The client address is in param->srv_open.rem_bda and just in this example is displayed in the serial port monitor, but it does not need to be.

    coshiz wrote:
    Does anyone know perhaps a command (second line) to implement a conditional instruction right after pairing.
    .
    I don't really understand. Which conditional are you referring to specifically?
  • ADVERTISEMENT
  • #3 19567586
    coshiz
    Level 11  
    Thank you for your reply.
    Indeed I did not specify the exact problem.
    Indeed the address is displayed in the serial port monitor and this works fine.
    The problem is that it is only displayed when I run a terminal on a device attached to the ESP32 via Bluetooth. I happen to be running a free program from the Play Store "Arduino Bluetooth Controller" for this purpose.
    The point is that I don't need to run additional applications, but just after pairing, the address of the client is displayed in the terminal.
    I suspect that instead of ESP_SPP_SRV_OPEN_EVT command you need to use something like ESP_SPP_INIT_EVT for example, but it doesn't work for me.
    Greetings
    Coshiz
  • ADVERTISEMENT
  • #4 19567738
    khoam
    Level 42  
    Maybe ESP_SPP_DISCOVERY_COMP_EVT ?
  • #5 19567849
    coshiz
    Level 11  
    Unfortunately it does not work.
    It compiles successfully but does not enter the conditional instruction at this command.
    I am also looking all the time and if I find it I will of course post the answer.
    Thanks again for your help.
    Greetings
    Coshiz
ADVERTISEMENT