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.

Parents
  • Hi James

    The nRF Sniffer is documented here. In particular you can refer to the chapter caller nRF Sniffer Usage.

    The dongle needs to be programmed with the hex file included in the sniffer download, most likely it has the wrong firmware. This will be described in the documentation I linked to above. 

    The sniffer does provide a Python interface, and you can find it documented in the Sniffer API Guide document included in the doc folder of the sniffer download. 

    Best regards
    Torbjørn

  • Torbjørn,

                The instruction for installation is very hard to follow and leads to a dead end.

    First your link takes me to nRF Sniffer usage. The index on the side “Installing the nRF Sniffer starts off as if it is already installed. Very confusing!!

    Another is the SnifferAPI.

    I cannot find it anywhere.

    Since I took too long to try and get this working, I have other priorities, But will circle back to try and get this to work.

    Due to my time allocation for this project is short.

    Please give me some dummy proof steps to get this working.

     

     

    I see a bunch of python code under the nrf_sniffer_for_bluetooth_le_4.1.1 directory I downloaded, but I don’t know which one I need for my application.

     

    Greatly appreciate it.

     

    James DeLorenzo

  • With some modifications to Device.py I was able to have the return value in hex for the MAC address.

    However, the scan results does not show the extended advertising. Is there a configuration of some sort to return extended advertising?

  • FYI: Your release_notes.txt states that in version 4.0.0 added support for Extended Advertising. I need to know how to implement it on the dongle AND get it on the PC. I'm using the example.py you suggested to try and figure it out. so far, I'm still stuck.

  • Hi James

    The scan(..) function have an argument called findAux which is set to False by default. I believe this argument needs to be set True in order to pick up extended advertisement packets. 

    Could you try to start scanning with this argument set and see if it works better? 

    In order to do so just call the scan function like this:

    mySniffer.scan(findAux=True)

    Best regards
    Torbjørn

  • This did not change the output. I want to be sure we are on the same page.

    I'm calling example.py from the command line.

    Within this file, the call to mySniffer.scan(findAux=True) now looks like this.

    The output did not change form before I made the change.

  • Also, I noticed that within the file Types.py there are constants. Referring to the ones that start with ADV_TYPE_xxx. I see that there is one named ADV_TYPE_ADV_EXT_IND that I thought would work.  However I did  a search for ADV_TYPE and could not find where these constants are being used.

Reply Children
  • Could I add one more request about example.py? Testing would go much faster if it can print out only certain MAC address that starts with an address from a list of MAC addresses.

    Example: print out D2:72:7B:D6 (remaining digits I don't care). I'll need about 6 MAC address to look for with different prefixes.

  • Before I forget, once the dongle finds and prints the device name and MAC address, I also need the data of the extended advertising.

    Thanks.

    Jim D

  • I haven't gotten an answer in 2 days, this is very important that I try to get this working in the next few days. A coworker has started to look into this and is searching for a way to accomplish this task. If he succeeds that means all the dongles we brought from you will go back for a return and will implement his method.

  • Hi Jim

    Sorry for the slow response. To be honest we don't get a lot of questions about these python bindings, and I have to learn as I go here Wink

    To verify your issue I tried to modify example.py myself, and I added some code to count not only the number of packets (like in the original file) but also the type of packet received. 

    Essentially you can get the advertising type of every packet by referencing packet.blePacket.advType, and I made an array to keep count of how many packets I received by type:

    # 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

    When running this script at first I didn't see any packets in index 7 (ADV_TYPE_ADV_EXT_IND), like expected. Then I flashed an nRF52DK with the periodic_adv sample from the nRF Connect SDK, and to my surprise I could now see the counter increase:

    In other words it seems to me like extended advertise packets are enabled by default. 

    Then my follow up question would be whether or not you are sure that there is actually something nearby sending extended advertise packets? 

    Do you have some other means of checking this, such as a smart phone with extended advertising support running the nRF Connect for Mobile app?

    Regarding specific requests to example.py, keep in mind that this file is just meant as a starting point. It is up to you to implement the functionality you need based on your project requirements. 

    Please find my modified script attached below:

    # 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()
    
        # 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
        
    setup()
    if mySniffer is not None:
        loop()
    

    Best regards
    Torbjørn

  • Thanks for the response. Yes, I have a smart phone that shows the extended advertising along with all the data it is advertising. The closest I got was with Wireshark and there is an Extended advertising section but none of the data matched the phone's.. I will look at the code mod you sent and experiment. Thanks.

Related