diff --git a/servers/tk103/coban GPRS protocol.pdf b/servers/tk103/coban GPRS protocol.pdf new file mode 100644 index 0000000..5254131 --- /dev/null +++ b/servers/tk103/coban GPRS protocol.pdf Binary files differ diff --git a/servers/tk103/gps306a_b-user manual.pdf b/servers/tk103/gps306a_b-user manual.pdf new file mode 100644 index 0000000..2f45130 --- /dev/null +++ b/servers/tk103/gps306a_b-user manual.pdf Binary files differ diff --git a/servers/tk103/readme.md b/servers/tk103/readme.md index f0e5998..2d20c36 100644 --- a/servers/tk103/readme.md +++ b/servers/tk103/readme.md @@ -1,36 +1,42 @@ -//tk102 data from Brent's device. note that data received is not always complete. +Please note that I have included 2 PDF manuals within this directory. The first, gps306a_b-user manual, is the actual manual that came with the device we were testing. The second, coban GPRS protocol, is NOT the manual for the device but it is for a very similar device. The reason I have included it is because it explains the gprs protocol and messages very well and is useful knowledge. -new connection: 24.114.27.177:23299 + +tk103 data from Brent's device. note that data received is not always complete. + +root@gps-tracker:~/gps-tracker# php tk103-server.php +new connection: 72.143.228.226:51380 total clients: 1 data: ##,imei:359710049095095,A; -data: imei:359710049095095,tracker,151006010036,,F,170036.000,A,5105.9768,N,11404.9571,W,0.00,322.56,,0,0,,,; -data: imei:359710049095095,tracker,151006010106,,F,170107.000,A,5105.9767,N,11404.9572,W,0.02,322.56,,0,0,,,; +sent LOAD to client data: 359710049095095; -data: imei:359710049095095,tracker,151006010136,,F,170136.000,A,5105.9760,N,11404.9565,W,0.01,322.56,,0,0,,,; -data: imei:359710049095095,tracker,151006010206,,F,170206.000,A,5105.9747,N,11404.9572,W,0.01,322.56,,0,0,,,; +sent ON to client +data: imei:359710049095095,tracker,151022031050,,F,191050.000,A,5105.9833,N,11404.9573,W,0.01,0.00,,0,0,,,; data: 359710049095095; -data: imei:359710049095095,tracker,151006010236,,F,170236.000,A,5105.9736,N,11404.9581,W,0.01,322.56,,0,0,,,; -data: imei:359710049095095,tracker,151006010306,,F,170306.000,A,5105.9736,N,11404.9581,W,0.00,322.56,,0,0,,,; +sent ON to client +data: imei:359710049095095,tracker,151022031150,,F,191150.000,A,5105.9832,N,11404.9571,W,0.02,0.00,,0,0,,,; data: 359710049095095; +sent ON to client +data: imei:359710049095095,tracker,151022031250,,F,191250.000,A,5105.9832,N,11404.9571,W,0.02,0.00,,0,0,,,; +data: 359710049095095; +sent ON to client +data: imei:359710049095095,tracker,151022031350,,F,191350.000,A,5105.9832,N,11404.9571,W,0.01,0.00,,0,0,,,; +data: 359710049095095; +sent ON to client +data: imei:359710049095095,tracker,151022031450,,F,191450.000,A,5105.9832,N,11404.9571,W,0.01,0.00,,0,0,,,; +data: 359710049095095; +sent ON to client +data: imei:359710049095095,tracker,151022031550,,F,191550.000,A,5105.9832,N,11404.9571,W,0.02,0.00,,0,0,,,; +data: 359710049095095; +sent ON to client +data: imei:359710049095095,tracker,151022031650,,F,191650.000,A,5105.9832,N,11404.9571,W,0.03,0.00,,0,0,,,; +data: 359710049095095; +sent ON to client +data: imei:359710049095095,tracker,151022031750,,F,191750.000,A,5105.9832,N,11404.9572,W,0.02,0.00,,0,0,,,; +data: 359710049095095; +sent ON to client +data: imei:359710049095095,tracker,151022031850,,F,191850.000,A,5105.9832,N,11404.9573,W,0.01,0.00,,0,0,,,; +data: 359710049095095; +sent ON to client +data: imei:359710049095095,tracker,151022031950,,F,191950.000,A,5105.9833,N,11404.9574,W,0.01,0.00,,0,0,,,; -// tk102 data from other device -1203292316,0031698765432,GPRMC,211657.000,A,5213.0247,N,00516.7757,E,0.00,273.30,290312,,,A*62,F,imei:123456789012345,123 -The message sent by tracker to IP address is as following: -Serial number + authorized number + GPRMC + GPS signal indicator + command + IMEI number + CRC16 checksum. -* 090723164830 = Serial #(year,month,date,hour,minute,second) -* +13616959853 = Authorized # -* GPRMC,214830.000,A,3017.2558,N,09749.4888,W,26.9,108.8,230709,,,A*61 = standard GPRMC sentences. -* F = GPS signal is full, if it indicate "L", means GPS signal is low -* Help me = It is the SOS message, and this section is blank for tracking message -* IMEI = Identifying # of the tracker -* 05 = Means you get 5 GPS fix (from 3 to 10) -* 264.5 = Altitude -* F:3.79V = Battery voltage -* 0= Means the tracker is NOT charged. 1 means the tracker is charged -* 122= The length of the GPRS string -* 13990 = Checksum -* 310 = MCC Mobile Country Code -* 01 = MNC Mobile Network Code -* 0AB0 =LAC Location areacode -* 345A = CellID \ No newline at end of file diff --git a/servers/tk103/tk102-server.php b/servers/tk103/tk102-server.php deleted file mode 100644 index 3ddb16c..0000000 --- a/servers/tk103/tk102-server.php +++ /dev/null @@ -1,68 +0,0 @@ - heartbeat requires "ON" response $response = "ON"; + echo "sent ON to client\n"; break; case 3: // ##,imei:359710049095095,A -> this requires a "LOAD" response - if (tk103_data[0] == "##") { - $response = "LOAD" + if ($tk103_data[0] == "##") { + $response = "LOAD"; + echo "sent LOAD to client\n"; } break; case 19: // imei:359710049095095,tracker,151006012336,,F,172337.000,A,5105.9792,N,11404.9599,W,0.01,322.56,,0,0,,, -> this is our gps data $imei = substr($tk103_data[0], 5); $alarm = $tk103_data[1]; $gps_time = nmea_to_mysql_time($tk103_data[2]); - $latitude = degree_to_decimal($tk103_data[8], $tk103_data[8]); - $latitude = degree_to_decimal($tk103_data[10], $tk103_data[11]); - $speed_in_knots = $tk103_data[12]; + $latitude = degree_to_decimal($tk103_data[7], $tk103_data[8]); + $longitude = degree_to_decimal($tk103_data[9], $tk103_data[10]); + $speed_in_knots = $tk103_data[11]; $speed_in_mph = 1.15078 * $speed_in_knots; - $bearing = $tk103_data[13]; + $bearing = $tk103_data[12]; - insert_location_into_db($imei, $gps_time, $latitude, $longitude, $speed_in_mph, $bearing); + insert_location_into_db($pdo, $imei, $gps_time, $latitude, $longitude, $speed_in_mph, $bearing); + if ($alarm == "help me") { $response = "**,imei:" + $imei + ",E;"; @@ -93,7 +96,7 @@ } } // end while loop -function insert_location_into_db($imei, $gps_time, $latitude, $longitude,$speed_in_mph, $bearing) { +function insert_location_into_db($pdo, $imei, $gps_time, $latitude, $longitude,$speed_in_mph, $bearing) { $params = array(':latitude' => $latitude, ':longitude' => $longitude, @@ -110,12 +113,14 @@ ':event_type' => "tk103"); // PLEASE NOTE, I am hardcoding the wordpress table prefix (wp_) until I can find a better way + $stmt = $pdo->prepare('CALL wp_save_gps_location( :latitude, :longitude, :user_name, :phone_number, - :session_id + :session_id, + :speed, :direction, :distance, :gps_time, @@ -126,7 +131,7 @@ $stmt->execute($params); $timestamp = $stmt->fetchColumn(); - echo $timestamp; + // echo "inserted into db: " . $timestamp . "\n"; } function nmea_to_mysql_time($date_time){