Scanning of beacon devices and printing their uuid on cloud

hi to everyone,
i want to scan beacon devices from the argon and show the number f beacon devices and print their uuid .

now for doing so i am first writing code for printing the total number of beacon devices near my argon and for that i have written this code.

const size_t SCAN_RESULT_MAX = 30;
BleScanResult scanResults[SCAN_RESULT_MAX];

void setup() {
}

void loop() {
    char buffer[20];
    // int a=10;
    BLE.setScanTimeout(50);
    int count = BLE.scan(scanResults, SCAN_RESULT_MAX);
    itoa(count,buffer,10);
    Particle.publish("no",buffer);
    // delay(2000);   
}

now on doing so in my console in event name
no different values are being printed like this shown https://drive.google.com/open?id=1CyuCqObf-nWeOEW4wbefGec1XKnMLUNR

now question is why are different values being printed at a time …
as BLE.scan is counting for all the number of beacons nearby the argon , so shouldn’t it print one fixed number,instead of different

Where is your BLE.on() call?
Also what beacon advertising interval are all your beacons using?
Could it be that during your 0.5 sec sometimes only one, two or none of the beacons may be advertising?

itis 5sec which is default as given in the docs …and i am using only 1 beacon device .

If that 5 seconds applies to the beacon this will account or the cases where you see 0 and 1 - as your 0.5sec scan period might catch the beacon (1) or not (0).
Furthermore, could it be that you have another 3rd party device also acting as beacon - this would account for the 2s.

5 sec is the interval for scanning the beacons by central device which is by default mentioned in the docs of REFERENCE by iot particle.
here my central device is Argon and peripheral is beacon.

but in the above program i changed that interval to 0.5 secs

one point to clear …(just to ask whether i am thinking right or not)
ble .scan() will only return the no of beacon devices which are near the argon central device???

if yes then will i get the no of bytes in advertisement data …(asking)- by the statement scanResult->advertisingData.getData(get_data, sizeof(get_data));
here scanResult is the object of the class BleScanResult
and get_data is my buffer of length 30

But you are overriding the default and that was all we knew of your tests :wink:

That depends on your definition of “near”

1 Like

https://api.particle.io/v1/devices/e00fce68153347b92d9fdedc/events?access_token=097ca55283ac62a7f3faa3c4d36ed2df8f1ab78d

see here is my terminal of consule.

and even if i try with default or by custum it is still sending different values even though i have only one beacon and both beacon and argon are placed next to each other

Then it is probably time to have a closer look at the actual advertise data the found beacons send.

do you mean scanResult->advertisingData.get(get_data, sizeof(get_data))?
If so, yes the return value of that call should return the actual count of data received (up to sizeof(get_data).

okay then by accessing the get_data buffer i should get the advertisement data…??

let me just try this then i respond back to u

Also check scanResult->address to see whether you are catching the same beacon multiple times.

spark/device/diagnostics/update-
{"device":{"network":{"signal":{"at":"Wi-Fi","strength":58,"strength_units":"%","strengthv":-71,"strengthv_units":"dBm","strengthv_type":"RSSI","quality":32.25,"quality_units":"%","qualityv":19,"qualityv_units":"dB","qualityv_type":"SNR"}},"cloud":{"connection":{"status":"connected","error":0,"attempts":1,"disconnects":7,"disconnect_reason":"error"},"coap":{"transmit":360,"retransmit":759,"unack":17,"round_trip":29724},"publish":{"rate_limited":0}},"system":{"uptime":1095,"memory":{"used":106360,"total":158488}}},"service":{"device":{"status":"ok"},"cloud":{"uptime":40,"publish":{"sent":3}},"coap":{"round_trip":null}}}
spark/device/diagnostics/update
{"service":{"device":{"status":"unreachable"},"cloud":{"uptime":19,"publish":{"sent":1}},"coap":{"round_trip":null}}}

from the past 1 hour on uploading the program from web ide this thing is coming …dont know what happened all of sudden
and in the web ide it is just showing TIME RUN OUT error

  1. my particle device is not getting flash from web ide
    when i run the diagnostics test it shows that their is one problem and
    also on signaling and ping it from the console it shows that device is not reachable by the particle cloud.
    Also it automatically gets disconnected to wifi and cloud on its own without any external activity randomy and then gets connected to both wifi and cloud .

  2. But argon keep on sending the data to the cloud as per the code which is last flashed on it and led status is cyan colour blinking …which means it is connected to cloud.

what is issue i cant figure out.

Your code is probably jamming up the cloud communication for prolonged periods.

Try Safe Mode to flash new code OTA.

It should be breathing - blinking means it’s not currently connected but tries to reconnect.

Try adding SYSTEM_THREAD(ENABLED) to your next code and see if this helps.

Even if i try to upload blink sketch that also is not getting flashed … I am here attaching a url of the video u can see that .


This is what happening randomly it randomly gets disconnected and tries to connect to net and cloud .

And this is what happening on uploading the code

beacouse of this thing i am trying to re-update the device OS from workbench
using the command FLASH APPLICATION AND DEVICE OS in command palette and putting the ARGON in DFU mode …but on doing so it here agin showing error
showing error code 2 .

now hoe to get ahead of this problem