Electron Cellular Locate Test App

Did something change between 0.6.0 and 0.6.2 on the Electron that governs the rate at which the callback function is called?

I have code that issues a CGED=5 command and I used to be able to collect the entire response with one callback run. Now the callback seems to be running too quickly, and I am missing some characters as well.

For instance, in v.0.6.0, the entire response to this command would have been placed in the buffer, where I could parse the entire thing at once. Now in 0.6.2, _cbLOCATE is called before the entire response is placed in the buffer. Is there a way to wait for the complete response from the AT command before calling the callback function?

Cellular.command(_cbLOCATE, &loc, timeout_ms, "AT+CGED=5\r\n")

I think it might have something to do with this change: https://github.com/spark/firmware/pull/1140

This problem was fairly straightforward to solve, once I understood what was happening. Since the callback function was being called more often, I simply needed to collect all of the responses and then wait for the TYPE_OK response in order to act upon it.

Something like this in the callback function:

if (type == TYPE_UNKNOWN) {
   Add contents of buffer to a string
   WAIT
}

if (type == TYPE_OK) {
   Act on the contents of the string
}

Hi @BDub!

Any news for an official API for this? Iā€™ve been testing the Google Maps beta integration, but seems that itā€™s always only polling the active cell tower (Iā€™ve also had issues with a lot of 404 responses from the API, but thatā€™s another issue) and Iā€™m looking for other options.

Iā€™m working with an Electron Asset Tracker kit (got the SARA-U270-00S) and itā€™s not entirely clear to me if the +CGED=5 command is working or not on this chipset?

Any general recommendations for the best options for the most accurate cell location are most welcome :slight_smile:

Hello @BDub,
Iā€™m running through some testing of this and I have the location code working, but it only seems to work if you call it when connected via the serial port. I modified the code to also have a function that could be called from the particle cloud to tell the electron to call the location code. I then put the results in a particle variable that I can get. The issue is that the location call will fire using the particle function, but it always returns 0 for lat and lng as well as a date of 1/1/2014. If I connect using the serial port and call the location code it returns fine with valid values. The next interesting thing is that subsequent calls using the particle function return just fine then. At that point I figured, okā€¦call the location code once in the loop, but even that returns nothing.

Any thoughts on why the serial connection would work differently?

Thanks,
Dave

Iā€™m having issues incorporating this into my own code. It appears this method doesnā€™t work in multi-thread mode; however, other pieces of my code really do need it. Are you able to identify any parts of your code that may conflict with multi-thread mode?

Hmm, I donā€™t think there is anything intrinsic to this code that would make it incompatible with multi-threaded mode. Maybe the cellular callbacks?

I would encourage you to try the google map integration / location library, to see if that performs better with the system_thread enabled:

https://docs.particle.io/tutorials/integrations/google-maps/

Thanks,
David

I noticed it still fetches the celltower information correctly in multi_thread mode. Itā€™s receiving the location thatā€™s an issue.

I found your code and I using it within the next sketch :

#include "CellLocate.h"

CellLocate cl;
    
void setup() {
    Serial.begin(9600);
}

void loop() {
  uint8_t tries = 0;

    while (!cl.completed() &&  tries++ < 10) {
      if (cl.get_response()) {
        cl.display();
        cl.googleMaps();
     } else {
        Serial.printlnf("Failed to locate position, did not get valid response, try %d", tries);
        if (tries < 50) delay(100);
      }
    }    
} 

It is the proper way to use it ? I canā€™t get it working.

Thanks

What exactly does, and doesn't, it do, and how did you come to the conclusion it doesn't work (as in, what did you try?)

It just print :

Failed to locate position, did not get valid response, try 1
Failed to locate position, did not get valid response, try 2
Failed to locate position, did not get valid response, try 3

ā€¦ and so ā€¦

I tried also the code this code, which is basically the same but not OOP, and works.

Perhaps Iā€™m using the library the wrong way.

Hi everyone,

Iā€™m attempting to run the test app, cell-locate.cpp.

Iā€™m not getting any response. I am running an electron v7.0, are others able to run the program with this firmware? I also tried backdating to v6.4 and also saw no response after flashing.

It will complie just as Iā€™ve downlowded it as a .cpp file, but it looks strange to me its not an ā€œ.inoā€ file like Iā€™m used to seeing.

Is cell-locate.cpp a standalone application? Or is it supposed to be added to a main .ino file?

Thanks!

Solved, I had not read the directions clearly.

After you open you Serial Monitor program of choice you must type ā€œLā€ to initiate the Cell-Locate feature.

I was just waiting for something to happen. :joy_cat: Whoopsā€¦

Hereā€™s a photo for others in case you are intimidated, and forget what to do.

1 Like

How close is it to your real location?

My accuracy varied.

Hi RWB,

I was pretty happy with the performance. It seemed to find my location quite well.

I only have tested in a single location though.

In practice I am thinking of combining this with the cell tower gps location feature as a double check.

1 Like

Has anyone had any luck getting this to work on an E Series module?

The original app posted should work on 2G/3G/pentaband E Series modules, but I personally have really started liking our Google Maps Integration better :slight_smile:

https://docs.particle.io/tutorials/integrations/google-maps

Neither of these work on LTE E Series modules yetā€¦ some updating is required to get the data necessary. Anyone looking into that by any chance?

Thanks BDub. I should have been more specific. Was talking about the LTE module specifically.
I started a new thread on this.
https://community.particle.io/t/gsm-location-info-on-lte-e-series/

Would love to know if anyone has started tinkering with it. It looks like celllocate commands simply arenā€™t available in the current SARA R4 firmware.

I am admittedly a noobie to particle, but have successfully compiled and flashed simple sketches to my brandnew Electron, and been able to get event data on my iPhone event log on single cell tower LAC info from example sketches.

I have been UNsuccessful getting this present app to run. I send an ā€œLā€ from my serial monitor, and have waited minutes without seeing any data from the Electron. I would be grateful for some hints as to what Iā€™m doing wrong.

Thanks in advance!

John

Which serial monitor are you using? You canā€™t use particle serial monitor as itā€™s only a monitor from the device and canā€™t be used to send data to it. So you canā€™t use it to trigger the L command in the Electron Cell Locate test app.

Iā€™m not using the particle serial monitor; I was using the OS X Terminal app, and have also tried using CoolTerm. No joy.