fulup-bzh / GeoGate

GeoGate is an opensource tracking GPS/AIS framework to implement GTS applications.
Apache License 2.0
76 stars 39 forks source link

MySqlDb backend does not store data #1

Closed albhardy closed 9 years ago

albhardy commented 9 years ago

Hi, Thanks for developing this app - I managed to install and run GeoGate using DummyBackend on Windows 2012R2. However, when using 'MySqlDb' as backend, I'm unable to get geojson data from [server]:4080/ajax/geojson.rest?format=json&key=123456789&cmd=list&group=all and MySQL database is still empty (no all_devices table)

My MySqlDb config file:

var PortBase = 4000;

var GeoGateConfig = {
    backend    : "MySqlDb",         // backend file ==> mysql-backend.js [default file]
    name       : "GpsdMySQL",     // friendly service name [default Gpsd-Track]
    inactivity : 900,             // remove device from active list after xxxs inactivity [default 600s]
    debug      : 7,               // debug level 0=none 9=everything

    "services"    :  {  debug: 4
// this controle console, you probably want it hyden behind your firewall
        , Telnet   : {info: "Telnet Console"  , adapter: "TelnetConsole" , port: PortBase +0}
        , Httpd    : {info: "Minimalist HTTPd", adapter: "HttpAjax"      , port:PortBase +80, debug:5}

// following apaters are TCP servers and wait for clients to connect
        , Gps103   : {info: "Tk102 Gps103"    , adapter: "Gps103Tk102"   , port:PortBase + 3, debug:6}

// phone applications typically some form of OpenGPRMC
        , Celltrac : {info: "CellTrac Android", adapter: "GtcGprmcDroid" , port:PortBase + 20, debug:5} // OpenGPRMC

    },

  "mysql": { // [should reflect your MySQL configuration]
hostname: "localhost",   // MySql hostname
basename: "gpsdtest",        // Basename base should exist
username: "gpsdtest",        // MySql username
password: "password"         // MySql password
    }
};

module.exports = GeoGateConfig;

This is the console screenshot - I'm able to receive GPS message from my phone (connecting to port 4020) - using iOS\GTSTracker:

image

This is MySQL (I've created the DB and User)

image

and this is the browser screenshot:

image

Using Dummy Backend, I successfully get:

image

I'm not sure whether it is caused by the server or the mobile app config. Any idea how I can resolve this? (I have used gpsdtracking with flatfile backend before, it is also unable to record location data sent by GTSTracker).

Thanks in advance!

albhardy commented 9 years ago

Additional info

When I enable RemGps : {info: "Gps Over Tcp" , adapter: "NmeaTcpFeed" , hostname: "geotobe.org" , remport:4001, timeout:60, mmsi:123456789, mindist:500}

The console reported missing SQL table:

image

I can't really figure out when CheckTablesExits is executed to create those tables.

fulup-bzh commented 9 years ago

Thank you for this very detail report.

Look like the mistake come from a non existing MySQL tables. You do not seem to use control console, accessible through telnet port 4000 with your config. I know that M$ users are not used to "telnet" but the command should work out of the box on any M$ box try "telnet localhost 4000" then "help".

For MySql first make sure that your server is configured with MySQL backend [note that you may only have one active backend for a given server]. If you get GPS input with DummyBackend you should be able to store your positions in MySQL. They is no difference in the acquisition in between Dummy and MySQL backend. If it works with one, it should work with the other one.

With MySql backend. Connect on telnet console and enter 'db init' this should create your table in MySQL. You can then check with mysql shell command line: mysql --user=xxx --password=xxx basename show tables; select * from all_devices; exit;

Acquisition cannot work if MySql table do not exist. Be aware than with MySql you need to create the device before server start storing data, when by default DummyBackend accept data from any device. To register your device in table, enter in telnet control console: "db create IMEI My Device Name"

Conclusion: with MySql backend on. Connect with telnet control console and try telnet localhost 4000 [or what ever port you've configure] help [you should get all available commands] db init [should create table in mysql] db create 123456789 My Device Name [add IMEI=123456 in device table] dev all [list all connected devices] dev list [list all login devices] dev info 123456 [list last info from IMEI=123456]

Note if you create device entry after device was connected on the server, you should force its login reconnection with "dev logout 123456" or GPS data will not be store in MySQL until it deconnects/reconnects.

albhardy commented 9 years ago

Thanks for the reply. I made some progress here. I did db init and db create 123456789 geotobe geotobemodel geotobedevice

image

I managed to capture location received from RemGps : {info: "Gps Over Tcp" , adapter: "NmeaTcpFeed" , hostname: "geotobe.org" , remport:4001, timeout:60, mmsi:123456789, mindist:500}

image

However, when I tried both db create ve1 test01 xxmodel abcd and db create test01 ve1 test01model test01device for my iOS GTSTracker, my database is still empty and dev all only shows devid/mmsi 123456789 from nmeatcp adapter

My iOS GTSTracker setting as following:

image

GGServer console displays following data received from nmeatcp and GtcGprmcDroid:

image

My service config for port 4020 is `Celltrac : {info: "CellTrac Android", adapter: "GtcGprmcDroid" , port:PortBase + 20, debug:5}'.

Did I use the correct Device ID? I've also attempted to look into GtcGprmcDroid-adapter - not sure if there's any authentication issue that prevent the connection. I haven't really figure out auth part of the adapter. Thanks again.

fulup-bzh commented 9 years ago

I do not understand your "db create ve1 test01 xxmodel abcd" . Your 1st screenshot shows that you created a device with EMEI=123456789 which I suppose is the fake EMEI you choose for your phone. DB create command only accept EMEI and a name for the device, it does not care about model, or anything else. Any device create by 'db create" should be visible in your database device table. Note that as I already use EMEI=123456789 for RemGps simulator, you should take something different, or remove RemGps from your config.

On the last screen I can see that device EMEI=123456789 do not move enough to push data in DB. Now I do not understand the %d look like the system fail to compute the distance. As you do not use CellTrack we may have some differences in data packet format. Could you increase debug level only on celltrack adapter to 9 this will trace input packet before and after decoding.

Bitat that they is no authentication in adapter. You can check your device EMEI before creating the device with "dev all" command. When you have found your tracker EMEI you can create your device with "db create". As soon your device is creating in devices tables, then its gps data should enter in base.

PS; could you use console dump and not graphic its much easier to read.

albhardy commented 9 years ago

Yes, I used your sample EMEI=123456789 for RemGps simulator just to verify mysql records incoming data as reference. My problem is on the iPhone side. dev all command does not show my iphone device ID and it only shows your original RemGps simulator.

Meanwhile I see following incoming message on the console window (I've set debug:9):

-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:199 [Path=/gprmc/Data [len=1
1] Query={"acct":"test01","dev":"ve1","gprmc":"$GPRMC,170040.00,A,120.1211942967
81,N,10242.0223333356026,E,0,-1,210115,,,*3C"}]

Since it shows dev:ve1 I experimented with both ve1 and test01 since they are available in the app settings window.

I've tried db create using my phone IMEI (3XXXXXXXXXXXXX9) but unsuccessful. I'm curious here as the app and ggserver console indicate they are able to send and receive data, but yet the device is not recognized in "dev list" and "dev all".

image

Anyway, I installed OpenGTS Tracker Lite - this app has device ID and I managed to see the in dev all.

image

This is the returned value

-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:199 [Path=/gprmc/Data [len=1
1] Query={"id":"123456789012345","altitude":"54.615295","hacc":"30.000000","code
":"0xF020","gprmc":"$GPRMC,162834.10,A,0120.1303,N,10342.0337,E,00.00,000.00,210
115,0,0,A*66"}]

MySQL Table gpsdtest.t_123456789012345; is still null though. What I really want actually to get http geojson values from my phone location so that I can display it on my map (much like your demo app).

fulup-bzh commented 9 years ago

If you don't see your packet, it's probably because gps packets are turn down before they are decoded. Even when a device is not declare as soon as it provides valid data it should visible with "dev all".

Your debug level for GrcGrrmcDroid is still to low to understand what is happening, did you increase apapter debug to 9, it was at 5 on your original config.

If you check adapter file: GrcGrrmcDroid method ProcessData you should enter in default case from switch (query.cmd). You have two debugs line there [level 5 and 7] I would be please to get a copy of what they say. Add few console.log or this.Debug make sure that your packet are processed.

An alternative would be your packet to turn down because device did not log. This append around line 230 of the same file, but if you have create the device they is no reason to be locked at that point.

Conclusion: make sure that you pass all checks and have your packet send to NMEA decoder. Looking at the packet you posted, it should work. Unfortunately for you I did the test with CellTrack on Android and it looks like the iPhone have some specificities.

albhardy commented 9 years ago

This is what I got:

-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:199 [Path=/gprmc/Data [len=1
1] Query={"id":"123456789012345","altitude":"29.689575","hacc":"10.000000","code
":"0xF020","gprmc":"$GPRMC,182146.41,A,0120.1535,N,10342.0309,E,00.00,000.00,210
115,0,0,A*6a"}]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:200 [DEBUGGER ProcessData: q
uestion: [object Object] query=[object Object]]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:201 [DEBUGGER ProcessData: q
uestion.pathname: /gprmc/Data request.url=/gprmc/Data?id=123456789012345&altitud
e=29.689575&hacc=10.000000&code=0xF020&gprmc=$GPRMC,182146.41,A,0120.1535,N,1034
2.0309,E,00.00,000.00,210115,0,0,A*6a]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:202 [DEBUGGER ProcessData: q
uery.g: undefined ]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:203 [DEBUGGER ProcessData: q
uery.d=undefined]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:231 [DEBUGGER  :Device: [obj
ect Object] ]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:232 [DEBUGGER  :query.cmd: u
ndefined ]
-7- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:261 [--> NMEA Lat:undefined
Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150121]
-2- _HttpClient.js/GpsdHttpClient.ProcessData:169 [Notice: [httpclient//GtcFree:
123456789012345] Unknown command=[undefined] Ignored]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:269 [DEBUGGER FOR Lvl 5 data
.valid:true GPRMC invalid nmeadata=$GPRMC,182146.41,A,0120.1535,N,10342.0309,E,0
0.00,000.00,210115,0,0,A*6a]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:270 [DEBUGGER FOR Lvl 7 NMEA
 Lat:undefined Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150121]
fulup-bzh commented 9 years ago

I suppose that Debug from line 200 to 232 where added by you, unfortunately you try to print a non existing variable which does not help much :)

Line 253 is interesting. It shows that while your NMEA data are tagged as OK, the result of the NmeaDecode is not valid.

Could you add a console.log ("**" + query.gprmc) just before the NmeaDecode to make sure of the data you're sending to NMEA decode. this should print the data your phone send to NMEA decode.

albhardy commented 9 years ago

This is data using OpenGTS Tracker Lite

-6- MySqlDb-backend.js/BackendStorage.LoginDev:245 [Login MySQL device:httpclien
t//GtcFree:123456789012345 devid=123456789012345]

-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:199 [Path=/gprmc/Data [len=1
1] Query={"id":"123456789012345","altitude":"29.689575","hacc":"10.000000","code
":"0xF020","gprmc":"$GPRMC,182816.26,A,4916.45,N,10342.0309,E,00.00,000.00,210
115,0,0,A*67"}]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:200 [DEBUGGER ProcessData: q
uestion: [object Object] query=[object Object]]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:201 [DEBUGGER ProcessData: q
uestion.pathname: /gprmc/Data request.url=/gprmc/Data?id=123456789012345&altitud
e=29.689575&hacc=10.000000&code=0xF020&gprmc=$GPRMC,182816.26,A,4916.45,N,1034
2.0309,E,00.00,000.00,210115,0,0,A*67]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:202 [DEBUGGER ProcessData: q
uery.g: undefined ]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:203 [DEBUGGER ProcessData: q
uery.d=undefined]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:231 [DEBUGGER  :Device: [obj
ect Object] ]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:232 [DEBUGGER  :query.cmd: u
ndefined ]
-7- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:261 [--> NMEA Lat:undefined
Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150122]
-2- _HttpClient.js/GpsdHttpClient.ProcessData:169 [Notice: [httpclient//GtcFree:
123456789012345] Unknown command=[undefined] Ignored]
******$GPRMC,182816.26,A,4916.45,N,10342.0309,E,00.00,000.00,210115,0,0,A*67
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:270 [DEBUGGER FOR Lvl 5 data
.valid:true GPRMC invalid nmeadata=$GPRMC,182816.26,A,4916.45,N,10342.0309,E,0
0.00,000.00,210115,0,0,A*67]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:271 [DEBUGGER FOR Lvl 7 NMEA
 Lat:undefined Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150122]

This is the data using GTSTracker (it does not get into the console.log)

-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:199 [Path=/gprmc/Data [len=1
1] Query={"acct":"test01","dev":"ve1","gprmc":"$GPRMC,005737.00,A,120.1660281606
77,N,10342.0192940963636,E,0,-1,220115,,,*35"}]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:200 [DEBUGGER ProcessData: q
uestion: [object Object] query=[object Object]]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:201 [DEBUGGER ProcessData: q
uestion.pathname: /gprmc/Data request.url=/gprmc/Data?acct=test01&dev=ve1&gprmc=
$GPRMC,005737.00,A,120.166028160677,N,10342.0192940963636,E,0,-1,220115,,,*35]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:202 [DEBUGGER ProcessData: q
uery.g: undefined ]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:203 [DEBUGGER ProcessData: q
uery.d=undefined]

Thus I added additional console log in the beginning, this is the result for OpenGTS Tracker:


-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:199 [Path=/gprmc/Data [len=1
1] Query={"id":"123456789012345","altitude":"43.977329","hacc":"65.000000","code
":"0xF020","gprmc":"$GPRMC,005716.55,A,4916.45,N,10350.8960,E,00.00,000.00,220
115,0,0,A*6d"}]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:200 [DEBUGGER ProcessData: q
uestion: [object Object] query=[object Object]]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:201 [DEBUGGER ProcessData: q
uestion.pathname: /gprmc/Data request.url=/gprmc/Data?id=123456789012345&altitud
e=43.977329&hacc=65.000000&code=0xF020&gprmc=$GPRMC,005716.55,A,4916.45,N,1035
0.8960,E,00.00,000.00,220115,0,0,A*6d]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:202 [DEBUGGER ProcessData: q
uery.g: undefined ]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:203 [DEBUGGER ProcessData: q
uery.d=undefined]
****** query ******
{ id: '123456789012345',
  altitude: '43.977329',
  hacc: '65.000000',
  code: '0xF020',
  gprmc: '$GPRMC,005716.55,A,4916.45,N,10350.8960,E,00.00,000.00,220115,0,0,A*
6d' }
****** question [pathname:/gprmc/Data]******
{ protocol: null,
  slashes: null,
  auth: null,
  host: null,
  port: null,
  hostname: null,
  hash: null,
  search: '?id=123456789012345&altitude=43.977329&hacc=65.000000&code=0xF020&gpr
mc=$GPRMC,005716.55,A,4916.45,N,10350.8960,E,00.00,000.00,220115,0,0,A*6d',
  query:
   { id: '123456789012345',
     altitude: '43.977329',
     hacc: '65.000000',
     code: '0xF020',
     gprmc: '$GPRMC,005716.55,A,4916.45,N,10350.8960,E,00.00,000.00,220115,0,0
,A*6d' },
  pathname: '/gprmc/Data',
  path: '/gprmc/Data?id=123456789012345&altitude=43.977329&hacc=65.000000&code=0
xF020&gprmc=$GPRMC,005716.55,A,4916.45,N,10350.8960,E,00.00,000.00,220115,0,0,
A*6d',
  href: '/gprmc/Data?id=123456789012345&altitude=43.977329&hacc=65.000000&code=0
xF020&gprmc=$GPRMC,005716.55,A,4916.45,N,10350.8960,E,00.00,000.00,220115,0,0,
A*6d' }
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:239 [DEBUGGER  :Device: [obj
ect Object] ]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:240 [DEBUGGER  :query.cmd: u
ndefined ]
-7- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:269 [--> NMEA Lat:undefined
Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150122]
-2- _HttpClient.js/GpsdHttpClient.ProcessData:169 [Notice: [httpclient//GtcFree:
123456789012345] Unknown command=[undefined] Ignored]
******$GPRMC,005716.55,A,4916.45,N,10350.8960,E,00.00,000.00,220115,0,0,A*6d
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:278 [DEBUGGER FOR Lvl 5 data
.valid:true GPRMC invalid nmeadata=$GPRMC,005716.55,A,4916.45,N,10350.8960,E,0
0.00,000.00,220115,0,0,A*6d]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:279 [DEBUGGER FOR Lvl 7 NMEA
 Lat:undefined Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150122]

and GTSTracker


-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:199 [Path=/gprmc/Data [len=1
1] Query={"acct":"test01","dev":"ve1","gprmc":"$GPRMC,012044.00,V,4916.45
53,N,10350.8916732966119,E,0,-1,220115,,,*27"}]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:200 [DEBUGGER ProcessData: q
uestion: [object Object] query=[object Object]]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:201 [DEBUGGER ProcessData: q
uestion.pathname: /gprmc/Data request.url=/gprmc/Data?acct=test01&dev=ve1&gprmc=
$GPRMC,012044.00,V,4916.4553,N,10350.8916732966119,E,0,-1,220115,,,*27]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:202 [DEBUGGER ProcessData: q
uery.g: undefined ]
-9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:203 [DEBUGGER ProcessData: q
uery.d=undefined]
****** query ******
{ acct: 'test01',
  dev: 've1',
  gprmc: '$GPRMC,012044.00,V,4916.4553,N,10350.8916732966119,E,0,-1,22011
5,,,*27' }
****** question [pathname:/gprmc/Data]******
{ protocol: null,
  slashes: null,
  auth: null,
  host: null,
  port: null,
  hostname: null,
  hash: null,
  search: '?acct=test01&dev=ve1&gprmc=$GPRMC,012044.00,V,4916.4553,N,1035
0.8916732966119,E,0,-1,220115,,,*27',
  query:
   { acct: 'test01',
     dev: 've1',
     gprmc: '$GPRMC,012044.00,V,4916.4553,N,10350.8916732966119,E,0,-1,22
0115,,,*27' },
  pathname: '/gprmc/Data',
  path: '/gprmc/Data?acct=test01&dev=ve1&gprmc=$GPRMC,012044.00,V,4916.45
53,N,10350.8916732966119,E,0,-1,220115,,,*27',
  href: '/gprmc/Data?acct=test01&dev=ve1&gprmc=$GPRMC,012044.00,V,4916.45
53,N,10350.8916732966119,E,0,-1,220115,,,*27' }

Both apps seem to have different approach in implementing gprmc - not sure which one has more accurate implementation. I'm open to your advice.

fulup-bzh commented 9 years ago

The error looks to be in NmeaDecoder *****_$GPRMC,182816.26,A,4916.45,N,10342.0309,E,00.00,000.00,210115,0,0,A_67 -9- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:270 [DEBUGGER FOR Lvl 5 data .valid:true GPRMC invalid nmeadata=$GPRMC,182816.26,A,4916.45,N,10342.0309,E,0

Looks like NmeaDecoder does not like your input. I will try to check than later today. But is should be easy to fix the decoder to support your format.

fulup-bzh commented 9 years ago

I'm lost in your test, I tested $GPRMC,182816.26,A,4916.45,N,10342.0309,E,00.00,000.00,210115,0,0,A*67 which seams to be your GPRMC message and it is accepted by NmeaDecoder.

Now looking at your track I find out in your 1st post Query={"acct":"test01","dev":"ve1","gprmc":"$GPRMC,170040.00,A,120.1211942967 81,N,10242.0223333356026,E,0,-1,210115,,,*3C"}

If this is the message you send, it is normal that they are refused as you have no 'ID' in your packet. In this case your packet are ejected at line if (query.id === undefined). You should then replace all query.id with query.acct and make sure that you have a valid EMEI configure and not "test01"

albhardy commented 9 years ago

I'm not quite sure how I can change the packet since it is sent by GerGTS Tracker (I installed the app since it was listed in GtcGprmcDroid-adapter.js for iphone). From the app description (also found in http://sourceforge.net/p/opengts/discussion/579834/thread/1853f307/) it said that I need to install gprmc.war and configure following:

# -- GPRMC properties
#gprmc.logName=gprmc
#gprmc.defaultAccountID=gprmcx
#gprmc.minimumSpeedKPH=5.0
#gprmc.simulateGeozones=true
gprmc.parm.account=acct
gprmc.parm.device=dev
#gprmc.parm.auth=pass
#gprmc.parm.status=code
#gprmc.parm.gprmc=gprmc
gprmc.response.ok=GPSOK
gprmc.response.error=GPSERROR

Thus, I suppose account ID is defined on the server side rather than as part of the packet. The other app (OpenGTS Tracker - with dev id 123456789012345) seems more promising as its packet was captured by dev all though also was not saved in the Db.

fulup-bzh commented 9 years ago

All those trackers/phone-app diverge on one point or an other. You should not care about protocol details. Choose the application you like and stick to it. When this is done, send me the exact packet your application uses. There is a debug level-4 in GtcGprmcDroid-adapter.js that should provide this information. When this will be known we only have to adapt the driver to support that phone application, which probably will only be one to two lines to change.

albhardy commented 9 years ago

This is the exact package:

-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:199 [Path=/gprmc/Data [len=1
1] Query={"id":"123456789012345","altitude":"43.977329","hacc":"65.000000","code
":"0xF020","gprmc":"$GPRMC,010341.06,A,0123.4340,N,10350.8960,E,00.00,000.00,220
115,0,0,A*69"}]
fulup-bzh commented 9 years ago

Could you please point your tracker on http://breizhme.net:5005 this port is currently forwarded to my desktop. I will check your packet, this might be easier than long mail exchanges.

Note: I push a version on git that include more debug on DroidAdapter and fix a minimal distance issue on httpclient. That minimal distance could issue be the source of your problem. You may clone again GeoGate to check if you still have the issue.

fulup-bzh commented 9 years ago

Ok I see your packet coming, I'll check what happen

fulup-bzh commented 9 years ago

Your packet transmission stopped but I think I had enough to understand the issue. Look like your device was not correctly create in base, I also fixed few debug issues on my side, but I doubt this could be the source of the problem.

Nevertheless update your GeoGate with git or npm and restart your local server.

Syntax for device creation: db create 123456789012345 +1xxxxxxxx Albhardy iPhone

capture du 2015-01-22 16 40 43

You can see on the picture after creating your device I got your position. Because your phone is not moving I only validated one position. But as soon as your move of more than 200m it should start update your base. You can move this limit down to zero for test.

Debug; in the new commit I added Level-4 debugs in DroidAdapter to notify when the device is not logged, and when adapter receives packet with no id:EMEI in the query.

Note: I nevertheless have a remaining bug on my side that I do not have time to investigate now. ForceLogout function does not work correctly for HTTP trackers. After creating your device if you see it in "dev all" and not in "dev list" restart your server. I need to investigate force logout on http tracker class, as I may have something wrong in my logic.

fulup-bzh commented 9 years ago

Pushed on GIT and NPM the fix for force logout. Hopefully everything should work. Let me know the outcome.

albhardy commented 9 years ago

Thanks for bearing with me. This time dev list shows that my device is active. The db search is still empty.

image

My console log:

-5- MySqlDb-backend.js/null:54 [MySQL Connect Done [mysql:root@localhost/gpsdtes
t]]
-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:193 [Path=/gprmc/Data [len=1
1] Query={"id":"123456789012345","altitude":"36.616333","hacc":"10.000000","code
":"0xF020","gprmc":"$GPRMC,151801.40,A,0120.1811,N,10342.0200,E,00.00,000.00,220
115,0,0,A*6f"}]
-6- MySqlDb-backend.js/BackendStorage.LoginDev:245 [Login MySQL device:httpclien
t//GtcFree:123456789012345 devid=123456789012345]
-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:231 [Device not login: EMEI=
123456789012345]
-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:193 [Path=/gprmc/Data [len=1
1] Query={"id":"123456789012345","altitude":"36.616333","hacc":"10.000000","code
":"0xF020","gprmc":"$GPRMC,151831.40,A,0120.1811,N,10342.0200,E,00.00,000.00,220
115,0,0,A*6c"}]
-7- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:249 [--> NMEA Lat:undefined
Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150122]
-2- _HttpClient.js/GpsdHttpClient.ProcessData:170 [Notice: [httpclient//GtcFree:
123456789012345] Unknown command=[undefined] Ignored]
-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:193 [Path=/gprmc/Data [len=1
1] Query={"id":"123456789012345","altitude":"36.616333","hacc":"10.000000","code
":"0xF020","gprmc":"$GPRMC,151831.40,A,0120.1811,N,10342.0200,E,00.00,000.00,220
115,0,0,A*6c"}]
-7- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:249 [--> NMEA Lat:undefined
Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150122]
-2- _HttpClient.js/GpsdHttpClient.ProcessData:170 [Notice: [httpclient//GtcFree:
123456789012345] Unknown command=[undefined] Ignored]
-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:193 [Path=/gprmc/Data [len=1
1] Query={"id":"123456789012345","altitude":"36.616333","hacc":"10.000000","code
":"0xF020","gprmc":"$GPRMC,151831.40,A,0120.1811,N,10342.0200,E,00.00,000.00,220
115,0,0,A*6c"}]
-7- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:249 [--> NMEA Lat:undefined
Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150122]
-2- _HttpClient.js/GpsdHttpClient.ProcessData:170 [Notice: [httpclient//GtcFree:
123456789012345] Unknown command=[undefined] Ignored]
-4- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:193 [Path=/gprmc/Data [len=1
1] Query={"id":"123456789012345","altitude":"36.616333","hacc":"10.000000","code
":"0xF020","gprmc":"$GPRMC,151831.40,A,0120.1811,N,10342.0200,E,00.00,000.00,220
115,0,0,A*6c"}]
-7- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:249 [--> NMEA Lat:undefined
Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150122]
-2- _HttpClient.js/GpsdHttpClient.ProcessData:170 [Notice: [httpclient//GtcFree:
123456789012345] Unknown command=[undefined] Ignored]

If the above log is more or less expected, I'll try out if the issue is caused by mysql config...

fulup-bzh commented 9 years ago

Look like we're pretty close of the solution. May we have something wrong in your installation ? Your "gprmc" packets are fine, but when you send them to NmeaDecode the result is wrong !!! As you can see on the trace you've got the error 'NaN [Not A Number]" when they return from NmeaDecode.

Query={"id":"123456789012345","altitude":"36.616333","hacc":"10.000000","code
":"0xF020","gprmc":"$GPRMC,151831.40,A,0120.1811,N,10342.0200,E,00.00,000.00,220
115,0,0,A*6c"}]
-7- GtcGprmcDroid-adapter.js/DevAdapter.ProcessData:249 [--> NMEA Lat:undefined
Lon:undefined Sog:NaN Cog:NaN Alt:NaN Date:150122]

Your packet pass NmeaDecode test on my Linux machine. Could you try on yours. Search in node module encoder/test/FeedSample/GprmcSample.nmea add one of your GPRMC packet at the end and run encoder/test/NmeaEncodeDecodeTest.js you should see your packet at the end of previous test with lat/lon decoded.

$GPRMC,151831.40,A,0120.1811,N,10342.0200,E,00.00,000.00,220
115,0,0,A*6c"

At this point we need to make sure that Decoder works on your machine. I use Linux and at this point a portability issue is still possible. Before moving forward I need to make sure that NmeaDecoder is working for you.

Note: before doing all those test, could you clean up your config. I know you tried the old GeoTracking version, and mixing both would not be a good idea.

albhardy commented 9 years ago

The encoding seems working (I installed ggencoder and run the test) - I need to make sure there is a line break after the last row, otherwise it does not get processed.

image

fulup-bzh commented 9 years ago

Good news this mean we do not have a nasty portability issue. The next step introduce some debug in NmeaDecode. Warning not the sandalone version you installed for testing decoder, the version that was installed with ggserver.

You need to find function NmeaDecode (inputpaquet) should be in "node_modules/ggserver/node_modules/ggencoder/lib/GG-NmeaDecode.js". Line 44 you will find case "$GPRMC" and right before the end of Decoding method a line with 'try {this.NormalizeData();} catch(err) {}' replace this line with 'this.NormalizeData();' I'm almost sure that we have an error in NormalizeData that is hidden with the try, if we move it out, you should have an abort with an error message.

albhardy commented 9 years ago

I've replaced the code

image

But I don't really see the error message

image

fulup-bzh commented 9 years ago

This is NmeaDecodeTest, try with your iPhone app and GGserver. Add a console.log ('****') to be sure that you're using the code you modified.

albhardy commented 9 years ago

as following - no error message

image

fulup-bzh commented 9 years ago

I was expecting Normalize function to fail. The only remaining option it to trace why NmeaDecode fails to return a valid decoded object.

Could you addd few 'console.log' in NmeaDecode to understand the error

 case "$GPRMC":  // position with speed and eventually no altitude
            // $GPRMC,225446.00,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68

  console.log ("**** NMEA="+ this.nmea);

            this.cmd= 2;  // Tracker
            this.mssi=0;
            if (this.nmea[2] !== 'A') {
                this.valid=false;
                return;
            }
            this.time = this.nmea[1];
            this.lat  =[this.nmea[3], this.nmea[4]];

console.log ("*** this.lat=" + this.lat + " this.nmea[3]=" + this.nmea[3] + "  this.nmea[4]=" +  this.nmea[4]);

            this.lon  =[this.nmea[5], this.nmea[6]];
            this.sog  = parseFloat (this.nmea[7] || 0);

console.log ("*** this.sog=" + this.sog + " this.nmea[7]=" + this.nmea[7]);

            this.cog  = parseFloat (this.nmea[8] || 0);
            this.day  = this.nmea[9];
            this.alt  = parseFloat (this.nmea[10] || 0);
            break;

     ......
   console.log ("Before Norm this.lat = " + this.lat + " this.lon="  this.lon + " this.sog=" + this.sog);
        this.NormalizeData();
     console.log ("After Norm this.lat = " + this.lat + " this.lon="  this.lon + " this.sog=" + this.sog);
albhardy commented 9 years ago

This is the result

image

image

Also no luck using getting CelltracGTS Free on Android on MySQL. I use following Server URL: `http://[ipaddress]:4020/gprmc/Data?

fulup-bzh commented 9 years ago

As you can see NmeaDecode works fine and process your packet. Your Lon/Lat are correctly decoded. It data are valid at the end of NormalizeData we should retrieve them. We are loosing NmeaData in between the call the new NmeaDecode(query.gprmc); and its return !!!

In GprmcDroidAdapter line 36, I see something wrong that could create this issue. Line 36 should be NmeaDecode = require('ggencoder').NmeaDecode; Currently it is pointing on NmeaEncode. I'm running in dev environment also it does not impact me but I could impact you. What I nevertheless do not understand is how such an error does not scratch completely the application.

For Android it is normal that is does not work. The error come from the interaction in between GGencoder and GGserver, any device using NMEA should fail.

albhardy commented 9 years ago

Awesome - That's the code! I managed to get data from both iOS and Android (UsingGPSTrackerGTS) . Thanks so much - really appreciate your help solving my problem - Will explore further :D

fulup-bzh commented 9 years ago

Good new, I pushed the correction on GitHub and NPN. Could you upload your config with a fresh installation. It would assert that I did the right correction in master distribution. Unfortunately this error is not visible in my context, and it would nice if you could double check that new master is ok for you.

Note on this error hunting: I still do not understand how with such an error you could enter in NmeaDecode method !!!! You should learn to use node source debugger. With a step-by-step in DroidAdapter, we would have find the error in 5mn :) Stepping in NmeaDecode method the debugger would have shown you that you ended up in NmeaEncode method. Source debugger is a must have feature it you want to debug anything quickly.

Hope you'll be have fun using GeoGate. Now that your Adapter works, you can start really playing with the other functions.

albhardy commented 9 years ago

Sorry for the late reply - was occupied with other issues. The updated master works (to certain extent) - It stored the first 1-2 locations, but it no longer stores data when I reconnect my mobile app. Currently I'm exploring your GGSimulator to pump the location data instead. Hopefully I can understand how things work and isolate the issue better :)

fulup-bzh commented 9 years ago

By checking the log you should find the issue. With a phone they is no notion of reconnect, each packet creates a new connection [HTTP is stateless]. And if you correctly stores 1st position, they is not reason for not storing next ones. On the other hand if your packet is denied then you should see in log [typically moved less than xxx meters]

Do not forget that when your phone does not move, you do not store data in DB. GG Simulator push data in the system in AIS or NMEA mode, it may help to understand how the system works. You can run your own simulator or pull data from mine online.