cannot talk to dongle after connect

I connect to the nRF52840-MDK dongle thru the Serial Terminal (nRF52 Connectivity) it found the comm port and set the baudrate automatically. However, the terminal window constantly fills up the screen with ~/ characters. it repeats every 1 second. What I would like is detailed instructions on how to configure this dongle to be a BT 5 sniffer and read the Extended Advertising for any BT device near the dongle. It would also be helpful to filter the devices seen. Eventually I like to use Python to filter the choices and obtain the advertises data where I can parse the data received. I'm using Windows 10 pro.

Thanks.

  • I was experimenting with your code modification. I'm trying to figure out how to print out the packets that are Extended advertising only along with the data. Can you help?

  • When you said you flashed an nRF52DK with the periodic_adv sample from the nRF Connect SDK.

    Is that the same as the nrf_sniffer_for_bluetooth_le_v4.1.1.uf2 file?

    If not can you point me to where it is exactly? because the website is very hard to follow.

  • Hi Jim

    You can find the installation instructions for the nRF Connect SDK here.

    Most of our customers use this SDK to develop their code for our chipsets, but if I understand you correctly you are not planning any projects with one of the nRF devices? 

    You are just using our dongles in order to use the sniffer?

    JimmyD said:
    I'm trying to figure out how to print out the packets that are Extended advertising only along with the data. Can you help?

    I will set aside some time later today to look into this. If you have any progress before that please let me know, so we don't end up doing double work Wink

    Best regards
    Torbjørn

  • Hi again

    I played around with this some more, and realized that not all the packets sent by the periodic_adv board was received. It seems my earlier advice about setting findAux=True was necessary after all. 

    Fixing this I updated the script to print out all the data, available in the packetList field of the packet. I also print out the name and the flags, and filter on the RSSI and the advertising type to ensure I only print packets for an extended advertiser in close proximity. 

    Please find my modified script here:

    # Copyright (c) Nordic Semiconductor ASA
    # All rights reserved.
    #
    # Redistribution and use in source and binary forms, with or without modification,
    # are permitted provided that the following conditions are met:
    #
    # 1. Redistributions of source code must retain the above copyright notice, this
    #    list of conditions and the following disclaimer.
    #
    # 2. Redistributions in binary form, except as embedded into a Nordic
    #    Semiconductor ASA integrated circuit in a product or a software update for
    #    such product, must reproduce the above copyright notice, this list of
    #    conditions and the following disclaimer in the documentation and/or other
    #    materials provided with the distribution.
    #
    # 3. Neither the name of Nordic Semiconductor ASA nor the names of its
    #    contributors may be used to endorse or promote products derived from this
    #    software without specific prior written permission.
    #
    # 4. This software, with or without modification, must only be used with a
    #    Nordic Semiconductor ASA integrated circuit.
    #
    # 5. Any software provided in binary form under this license must not be reverse
    #    engineered, decompiled, modified and/or disassembled.
    #
    # THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
    # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    # OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
    # DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
    # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
    # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
    import time
    from SnifferAPI import Sniffer, UART
    
    nPackets = 0
    nPacketsByType = [0,0,0,0,0,0,0,0]
    mySniffer = None
    
    def setup():
        global mySniffer
        
        # Find connected sniffers
        ports = UART.find_sniffer()
        
        if len(ports) > 0:
            # Initialize the sniffer on the first COM port found with baudrate 1000000.
            # If you are using an old firmware version <= 2.0.0, simply remove the baudrate parameter here.
            mySniffer = Sniffer.Sniffer(portnum=ports[0], baudrate=1000000)
        
        else:
            print("No sniffers found!")
            return
        
        # Start the sniffer module. This call is mandatory.
        mySniffer.start()
        # Scan for new advertisers
        mySniffer.scan(findAux=True)
    
        # Wait to allow the sniffer to discover device mySniffer.
        #time.sleep(5)
        # Retrieve list of discovered devicemySniffer.
        #d = mySniffer.getDevices()
        # Find device with name "Example".
        #dev = d.find('Example')
        
        #if dev is not None:
            # Follow (sniff) device "Example". This call sends a REQ_FOLLOW command over UART.
        #    mySniffer.follow(dev)
        #else:
        #    print("Could not find device")
    
    def loop():
        # Enter main loop
        nLoops = 0
        while True:
            time.sleep(0.1)
            # Get (pop) unprocessed BLE packets.
            packets = mySniffer.getPackets()
            
            processPackets(packets) # function defined below
            
            nLoops += 1
            
            # print diagnostics every so often
            if nLoops % 20 == 0:
                #print(mySniffer.getDevices())
                print("inConnection", mySniffer.inConnection)
                print("currentConnectRequest", mySniffer.currentConnectRequest)
                print("packetsInLastConnection", mySniffer.packetsInLastConnection)
                print("nPackets", nPackets)
                print("packet by type", nPacketsByType)
                print()
            
    # Takes list of packets
    def processPackets(packets):
        for packet in packets:
            # packet is of type Packet
            # packet.blePacket is of type BlePacket
            global nPackets
            if packet.OK:
                # Counts number of packets which are not malformed.
                nPackets += 1
                nPacketsByType[packet.blePacket.advType] += 1
                #if packet.blePacket.advType == 7:
                if packet.RSSI > -30 and packet.blePacket.advType == 7:
                    print(packet.flags, " ", packet.blePacket.name, "-", packet.getList())
    
    setup()
    if mySniffer is not None:
        loop()
    

    The output when the advertiser is close should be something like this:

    1   "" - [32, 0, 3, 76, 166, 2, 10, 1, 37, 21, 0, 0, 91, 129, 195, 208, 214, 190, 137, 142, 71, 13, 12, 25, 157, 155, 66, 48, 47, 61, 117, 10, 73, 37, 32, 138, 61, 24]
    1   "" - [32, 0, 3, 77, 166, 2, 10, 1, 38, 22, 0, 0, 147, 130, 195, 208, 214, 190, 137, 142, 71, 13, 12, 25, 157, 155, 66, 48, 47, 61, 117, 10, 73, 27, 32, 66, 120, 194]
    1   "" - [32, 0, 3, 78, 166, 2, 10, 1, 39, 22, 0, 0, 203, 131, 195, 208, 214, 190, 137, 142, 71, 13, 12, 25, 157, 155, 66, 48, 47, 61, 117, 10, 73, 17, 32, 141, 22, 24]
    17   "Test Periodic Advertising" - [68, 0, 3, 79, 166, 2, 10, 17, 9, 22, 0, 0, 206, 133, 195, 208, 214, 190, 137, 142, 7, 49, 21, 40, 117, 10, 113, 13, 192, 3, 255, 255, 255, 255, 191, 7, 101, 9, 38, 147, 65, 240, 14, 7, 26, 9, 84, 101, 115, 116, 32, 80, 101, 114, 105, 111, 100, 105, 99, 32, 65, 100, 118, 101, 114, 116, 105, 115, 105, 110, 103, 112, 184, 51]
    1   "" - [32, 0, 3, 110, 166, 2, 10, 1, 37, 21, 0, 0, 223, 46, 197, 208, 214, 190, 137, 142, 71, 13, 12, 25, 157, 155, 66, 48, 47, 61, 117, 10, 64, 37, 32, 86, 175, 0]
    1   "" - [32, 0, 3, 111, 166, 2, 10, 1, 38, 22, 0, 0, 23, 48, 197, 208, 214, 190, 137, 142, 71, 13, 12, 25, 157, 155, 66, 48, 47, 61, 117, 10, 64, 27, 32, 158, 234, 218]
    1   "" - [32, 0, 3, 112, 166, 2, 10, 1, 39, 23, 0, 0, 79, 49, 197, 208, 214, 190, 137, 142, 71, 13, 12, 25, 157, 155, 66, 48, 47, 61, 117, 10, 64, 17, 32, 81, 132, 0]
    17   "Test Periodic Advertising" - [68, 0, 3, 113, 166, 2, 10, 17, 0, 22, 0, 0, 82, 51, 197, 208, 214, 190, 137, 142, 7, 49, 21, 40, 117, 10, 137, 47, 192, 3, 255, 255, 255, 255, 191, 7, 101, 9, 38, 147, 65, 240, 15, 7, 26, 9, 84, 101, 115, 116, 32, 80, 101, 114, 105, 111, 100, 105, 99, 32, 65, 100, 118, 101, 114, 116, 105, 115, 105, 110, 103, 94, 111, 136]
    1   "" - [32, 0, 3, 140, 166, 2, 10, 1, 39, 22, 0, 0, 18, 200, 198, 208, 214, 190, 137, 142, 71, 13, 12, 25, 157, 155, 66, 48, 47, 61, 117, 10, 83, 17, 32, 184, 113, 192]
    17   "Test Periodic Advertising" - [68, 0, 3, 141, 166, 2, 10, 17, 19, 23, 0, 0, 21, 202, 198, 208, 214, 190, 137, 142, 7, 49, 21, 40, 117, 10, 46, 46, 192, 3, 255, 255, 255, 255, 191, 7, 101, 9, 38, 147, 65, 240, 15, 7, 26, 9, 84, 101, 115, 116, 32, 80, 101, 114, 105, 111, 100, 105, 99, 32, 65, 100, 118, 101, 114, 116, 105, 115, 105, 110, 103, 136, 25, 63]
    1   "" - [32, 0, 3, 169, 166, 2, 10, 1, 37, 21, 0, 0, 135, 114, 200, 208, 214, 190, 137, 142, 71, 13, 12, 25, 157, 155, 66, 48, 47, 61, 117, 10, 73, 37, 32, 138, 61, 24]
    1   "" - [32, 0, 3, 170, 166, 2, 10, 1, 38, 22, 0, 0, 191, 115, 200, 208, 214, 190, 137, 142, 71, 13, 12, 25, 157, 155, 66, 48, 47, 61, 117, 10, 73, 27, 32, 66, 120, 194]
    1   "" - [32, 0, 3, 171, 166, 2, 10, 1, 39, 22, 0, 0, 247, 116, 200, 208, 214, 190, 137, 142, 71, 13, 12, 25, 157, 155, 66, 48, 47, 61, 117, 10, 73, 17, 32, 141, 22, 24]
    17   "Test Periodic Advertising" - [68, 0, 3, 172, 166, 2, 10, 17, 9, 22, 0, 0, 250, 118, 200, 208, 214, 190, 137, 142, 7, 49, 21, 40, 117, 10, 192, 44, 192, 3, 255, 255, 255, 255, 191, 7, 101, 9, 38, 147, 65, 240, 15, 7, 26, 9, 84, 101, 115, 116, 32, 80, 101, 114, 105, 111, 100, 105, 99, 32, 65, 100, 118, 101, 114, 116, 105, 115, 105, 110, 103, 9, 156, 219]

    Best regards
    Torbjørn

  • my output is not the same. the loaded FW is nrf_sniffer_for_bluetooth_lev4.1.1.ut2. if this is incorrect please let me know specific what I should load.

    my output is...

    I ran your example_count_by_type_v2.py unmodified and got above. I never saw the characters "Test Periodic Advertising"

Related