You are here

Cell ID based positioning demo

Showcase, February 25, 2016 - 9:40am, 1920 views

Hi All,

Recently, I've done some research on the  topic of "Cell ID based positioning / location".

Hope my experience can help others to evaluate / implement this technology.

All the material, including Power Point presentation, demo server and Java midlet is available here

I would like to share a few code snippets for some tricky parts in the midlet:

Sending Form data in HTTP POST Request:

connection = (HttpConnection)Connector.open("http://ae.c-wm.net:3000/client_submit;" + connProfile);

//HTTP Request
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("Content-Language", "en-US");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
String msg = "sender=name&message=text";
OutputStream out = connection.openOutputStream();
out.flush();
	
// HTTP Response
if (connection.getResponseCode() == HttpConnection.HTTP_OK)
{	System.out.println("Message Sent successfully");	}

Get GPS location from EHS8 modem:

WTK library AT commands listener exits right after it sees OK in response, which is OK for most AT commands. However when you enable GPS, first you'll get an OK and then NMEA messages with location info, that you will miss, since the listener has finished it's job.

Luckily we've got JSR 179 support in our Java Library, which makes life even easier:

try  {  provider = LocationProvider.getInstance(criteria); }
catch (LocationException e) { e.printStackTrace(); }
finally {
if(null != provider) {
try {
location = provider.getLocation(-1);
}
catch (Exception e) { } System.out.println("location=" + location); }
}

Capturing Cellular Network Scan Report:

Performing Network Scan takes 2-3 minutes, by that time AT command response listener can time out. Here is how to capture it all:

 private class NetworkScanReportListener implements ATCommandResponseListener {
  public void ATResponse(String Response) {
    NetworkScanReport += Response; 
	if ( utilities.indexOf(new StringBuffer(Response), "OK", 0) != -1) NetworkScanFinished = true;
  }
}
 
private void NetworkScan()  throws IllegalStateException, IllegalArgumentException, ATCommandFailedException, InterruptedException {
  NetworkScanReport = "";
  NetworkScanFinished = false;
  System.out.print("Starting Network Scan");
  m_Cmd.send("AT^SNMON=\"INS\",2\r", new NetworkScanReportListener());
  while(!NetworkScanFinished)
  {
    Thread.sleep(2000);
    System.out.print(".");
  }
  System.out.println("Network Scan Finished");
} 

STDOUT should look like this:

Starting Network Scan......................................................Network Scan Finished

Didier Gemalto Moderator's picture
Didier Gemalto ...

Very good post! Thanks

Alopez's picture
Alopez

Hi

NICE

Regards

ALopez

Somewhere over the rainbow!!! Looking for the Oz Land!!!

antero.markkula@enkom.fi's picture
antero.markkula...

Hi,

I cannot open the http://ae.c-wm.net:3000/ to get the material.

Best Regards
Antero

Antero Markkula
Communication and Mechatronics

Enkom Active Oy – www.enkom-active.fi
Upseerinkatu 3 A, 02600 Espoo, Finland
Mobile: +358 400 411368
Office: +358 10 204 0000
Fax: +358 10 204 0010
E-mail: antero.markkula@enkom-active.fi

davidnetten's picture
davidnetten

Thank you for this! could you look at the link again, because I really would like to download the material.

Regards,

David

ASHVARTS