This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to Simply process Advertising Data

Hello to everyone,

My problem/question now is about the MasterEmulator. I´m working with the nRF51822(SoftDevice) and i have my own program already working more or less like I want. The main idea is that the device will send some information in the advertising data (my own data that don´t match with any existing Service).

But i´m trying to find out to make my own program for the PCA10000 that should only be scanning for Advertising devices, and process that advertising packets ( with processing it, i mean more or less store every data that see with the time stamp in a file).

I´m taking a look in the "nRFUart" and the "HeathThermoDemo" codes for the PCA1000 dongle but, i´m not so familiar with the "app programing" and I´m not be able to make only that "simply" part of scanning and have the data to work with.

Till now I´m only able to connect to the usb-dongle like in the "hello world" example, but not so much more. Any help like some other "easy start" codes, recommendation, etc.. will be so appreciated.

Thanks, Alvaro.

  • Ok, i have been working with the HealthThermoDemo app, and i found that it is also only able to get the same information from the adv/scan packet that i make with "my little console program".

    So now i´m wondering if it is possible to get the entire packet (as it is), that i could process and take my adv.data and scanresponse.data by my self.

    thanks one more time, Alvaro.

  • Oook, one more time I´m here again, now I´m able to take the ManufacturerSpecificData (now I change my data to be there) from the advertising packet, but I have no idea of how I can take the same data from the ScanResponse packet where the other half of my info is.

    Please some clue or indication will be great.

  • Great that you've been able to get some progress on your own! Unfortunately, we don't have any more documentation on the Master Emulator API than what is already there, but combined with the example applications, I believe that you should be able to get things working.

    As for your problem with getting the Scan Responses, remember that you must set the scan type to active, or else the Master Emulator dongle won't send any Scan Requests, and hence don't get any responses. This can be done by setting the ScanType field of the BtScanParameters struct before starting scanning:

    
    BtScanParameters scanParams = new BtScanParameters();
    scanParams.ScanType = BtScanType.ActiveScanning;
    ...
    
    
  • Thanks for the comment, but till now i can´t get the data, I see that usually i get the data from the advertising packet, and sometimes take the data from the scan response packet when i read from the DeviceInfoType.ManufacturerSpecificData, so how can I take both?

    That´s my small code for testing:

       MasterEmulator master = new MasterEmulator();       
                var usbdevices = master.EnumerateUsb(UsbDeviceType.AnyMasterEmulator);
                foreach (string usbdevice in usbdevices)
                {
                    master.Open(usbdevice);
                    Console.WriteLine("Device {0} Opened.",usbdevice);
                    master.Reset();
                    Console.WriteLine("MasterEmulator Reset.");
                }
                BtScanParameters scanParameters = new BtScanParameters();
                scanParameters.ScanType = BtScanType.ActiveScanning;
                master.Run();
    
                while (true)
                {
                    try
                    {
    
                        IEnumerable<BtDevice> devices;
                        devices = master.DiscoverDevices(1, scanParameters);
                
                        foreach (BtDevice dev in devices)
                        {
                            IDictionary<DeviceInfoType, string> deviceInfo = dev.DeviceInfo;
                            
                            var servData = dev.DeviceInfo[DeviceInfoType.ManufacturerSpecificData];
    
                            Console.WriteLine("Device found... {0}", dev);
                          
                            foreach (String test in dev.DeviceInfo.Values)
                            {
                                Console.WriteLine("... {0}", test);
                            }                 
    
                            ////Console.WriteLine(deviceInfo[DeviceInfoType.ServiceData]);
    
                        }
                        Console.WriteLine("---------------------------------");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Exception in StartDeviceDiscovery {0}", ex.Message);
                    }
    

    I have put the UUID 0007 in the scandata info and the UUID 0008 in the response packet that i can know when I read one or the other. I get usually always the info from the scandata but not the response packet (that only appear sometimes).

    That´s the console output:

    http://i41.tinypic.com/xdxbhu.jpg

    ConsoleCapture.jpg

    DongleCapture3.jpg

  • Your terminology is a tad confusing, there is only an advertisement packet and a scan response packet, the latter which the scanner only receives if it does active scanning. Can you please edit your post to also include a screenshot of the Master Control Panel showing your device?

Related