Communicate two microcontrollers via BLE

Hello,

I'm using a nRF52 DK to test BLE communication with another microcontroller. What I need to test is the nRF52 pairing with another brand microcontroller, send a data stream and close the connection.

Could you please tell me which example from the Bluetooth samples list I can use for starting?

Thanks for your attention.

Regards,

Parents
  • Hello ,

    Thank you very much. I've reviewed this example and it is supposed to connect with the first device with an strong signal. Is there a way to force the board to connect with the device with a given MAC address?

  • Yes, I got this:

    @anep:~/.config/wireshark/extcap$  ./nrf_sniffer_ble.sh --extcap-interfaces
    extcap {version=4.1.1}{display=nRF Sniffer for Bluetooth LE}{help=https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Sniffer-for-Bluetooth-LE}
    control {number=0}{type=selector}{display=Device}{tooltip=Device list}
    control {number=1}{type=selector}{display=Key}{tooltip=}
    control {number=2}{type=string}{display=Value}{tooltip=6 digit passkey or 16 or 32 bytes encryption key in hexadecimal starting with '0x', big endian format.If the entered key is shorter than 16 or 32 bytes, it will be zero-padded in front'}{validation=\b^(([0-9]{6})|(0x[0-9a-fA-F]{1,64})|([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2}) (public|random))$\b}
    control {number=3}{type=string}{display=Adv Hop}{default=37,38,39}{tooltip=Advertising channel hop sequence. Change the order in which the sniffer switches advertising channels. Valid channels are 37, 38 and 39 separated by comma.}{validation=^\s*((37|38|39)\s*,\s*){0,2}(37|38|39){1}\s*$}{required=true}
    control {number=7}{type=button}{display=Clear}{tooltop=Clear or remove device from Device list}
    control {number=4}{type=button}{role=help}{display=Help}{tooltip=Access user guide (launches browser)}
    control {number=5}{type=button}{role=restore}{display=Defaults}{tooltip=Resets the user interface and clears the log file}
    control {number=6}{type=button}{role=logger}{display=Log}{tooltip=Log per interface}
    value {control=0}{value= }{display=All advertising devices}{default=true}
    value {control=0}{value=[00,00,00,00,00,00,0]}{display=Follow IRK}
    value {control=1}{value=0}{display=Legacy Passkey}{default=true}
    value {control=1}{value=1}{display=Legacy OOB data}
    value {control=1}{value=2}{display=Legacy LTK}
    value {control=1}{value=3}{display=SC LTK}
    value {control=1}{value=4}{display=SC Private Key}
    value {control=1}{value=5}{display=IRK}
    value {control=1}{value=6}{display=Add LE address}
    value {control=1}{value=7}{display=Follow LE address}
    

    I have also ran the 'chmod +x nrf_sniffer_ble.sh' command.

  • Thanks. This shows that the DK is programmed correctly and that the communication works.

    Please check the WS log files for errors as suggested in the Troubleshooting chapter.

  • The DK is supposed to be the ports /dev/ttyACM0 and /dev/ttyACM1

    24-May-2023 12:26:33 (+0200) INFO: --------------------------------------------------------
    24-May-2023 12:26:33 (+0200) INFO: Software version: 4.1.1
    24-May-2023 12:26:33 (+0200) INFO: Started PID 10113
    24-May-2023 12:26:33 (+0200) INFO: Namespace(capture=False, extcap_interfaces=True, extcap_interface=None, extcap_dlts=False, extcap_config=False, extcap_capture_filter=None, fifo=None, extcap_control_in=None, extcap_control_out=None, extcap_version='3.4', device='', baudrate=None, only_advertising=False, only_legacy_advertising=False, scan_follow_rsp=False, scan_follow_aux=False, coded=False)
    24-May-2023 12:26:33 (+0200) INFO: Opening serial port /dev/ttyUSB0
    24-May-2023 12:26:33 (+0200) ERROR: Error opening UART [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0'
    Traceback (most recent call last):
      File "/home/msurca/.local/lib/python3.9/site-packages/serial/serialposix.py", line 322, in open
        self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
    PermissionError: [Errno 13] Permission denied: '/dev/ttyUSB0'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/msurca/.config/wireshark/extcap/SnifferAPI/Packet.py", line 74, in __init__
        self.uart = UART.Uart(portnum, baudrate)
      File "/home/msurca/.config/wireshark/extcap/SnifferAPI/UART.py", line 124, in __init__
        self.ser = serial.Serial(
      File "/home/msurca/.local/lib/python3.9/site-packages/serial/serialutil.py", line 244, in __init__
        self.open()
      File "/home/msurca/.local/lib/python3.9/site-packages/serial/serialposix.py", line 325, in open
        raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
    serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0'
    24-May-2023 12:26:33 (+0200) INFO: Opening serial port None
    24-May-2023 12:26:33 (+0200) INFO: Opening serial port /dev/ttyUSB0
    24-May-2023 12:26:33 (+0200) ERROR: Error opening UART [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0'
    Traceback (most recent call last):
      File "/home/msurca/.local/lib/python3.9/site-packages/serial/serialposix.py", line 322, in open
        self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
    PermissionError: [Errno 13] Permission denied: '/dev/ttyUSB0'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/msurca/.config/wireshark/extcap/SnifferAPI/Packet.py", line 74, in __init__
        self.uart = UART.Uart(portnum, baudrate)
      File "/home/msurca/.config/wireshark/extcap/SnifferAPI/UART.py", line 124, in __init__
        self.ser = serial.Serial(
      File "/home/msurca/.local/lib/python3.9/site-packages/serial/serialutil.py", line 244, in __init__
        self.open()
      File "/home/msurca/.local/lib/python3.9/site-packages/serial/serialposix.py", line 325, in open
        raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
    serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0'
    24-May-2023 12:26:33 (+0200) INFO: Opening serial port None
    24-May-2023 12:26:33 (+0200) INFO: Opening serial port /dev/ttyACM1
    24-May-2023 12:26:33 (+0200) INFO: closing UART
    24-May-2023 12:26:34 (+0200) INFO: Opening serial port /dev/ttyACM1
    24-May-2023 12:26:34 (+0200) INFO: closing UART
    24-May-2023 12:26:34 (+0200) INFO: Opening serial port /dev/ttyACM0
    24-May-2023 12:26:34 (+0200) INFO: closing UART
    24-May-2023 12:26:34 (+0200) INFO: Opening serial port /dev/ttyACM0
    24-May-2023 12:26:34 (+0200) INFO: closing UART
    24-May-2023 12:26:35 (+0200) INFO: Exiting PID 10113

    When I ran the ' ./nrf_sniffer_ble.sh --extcap-interfaces' command I see that the interfaces are not shown after 'extcap':

    @anep:~/.config/wireshark/extcap$  ./nrf_sniffer_ble.sh --extcap-interfaces
    extcap {version=4.1.1}{display=nRF Sniffer for Bluetooth LE}{help=https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Sniffer-for-Bluetooth-LE}
    control {number=0}{type=selector}{display=Device}{tooltip=Device list}
    control {number=1}{type=selector}{display=Key}{tooltip=}
    control {number=2}{type=string}{display=Value}{tooltip=6 digit passkey or 16 or 32 bytes encryption key in hexadecimal starting with '0x', big endian format.If the entered key is shorter than 16 or 32 bytes, it will be zero-padded in front'}{validation=\b^(([0-9]{6})|(0x[0-9a-fA-F]{1,64})|([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2}) (public|random))$\b}
    control {number=3}{type=string}{display=Adv Hop}{default=37,38,39}{tooltip=Advertising channel hop sequence. Change the order in which the sniffer switches advertising channels. Valid channels are 37, 38 and 39 separated by comma.}{validation=^\s*((37|38|39)\s*,\s*){0,2}(37|38|39){1}\s*$}{required=true}
    control {number=7}{type=button}{display=Clear}{tooltop=Clear or remove device from Device list}
    control {number=4}{type=button}{role=help}{display=Help}{tooltip=Access user guide (launches browser)}
    control {number=5}{type=button}{role=restore}{display=Defaults}{tooltip=Resets the user interface and clears the log file}
    control {number=6}{type=button}{role=logger}{display=Log}{tooltip=Log per interface}
    value {control=0}{value= }{display=All advertising devices}{default=true}
    value {control=0}{value=[00,00,00,00,00,00,0]}{display=Follow IRK}
    value {control=1}{value=0}{display=Legacy Passkey}{default=true}
    value {control=1}{value=1}{display=Legacy OOB data}
    value {control=1}{value=2}{display=Legacy LTK}
    value {control=1}{value=3}{display=SC LTK}
    value {control=1}{value=4}{display=SC Private Key}
    value {control=1}{value=5}{display=IRK}
    value {control=1}{value=6}{display=Add LE address}
    value {control=1}{value=7}{display=Follow LE address}

  • Do you have the new 52 DK with the nRF5340 interface MCU (board version 3.0.0)?If so, do you have another Nordic Dongle or DK you can use?

    The nRF5340 interface MCU has bug in the VCOM bridge implementation that prevents the WS plugin from communicating with it.

  • I have the nRF52DK PCA10040 3.0.0. Is this the one you talk about?

Reply Children
Related