GPS Listener

mc5 years ago

Hi,

I want to use the Traccar as GSP listener only. I changed the lines as below in order to use MySQL instead H2 database. I changed the lines as below based on Open GTS example:

Removed all event.* entries from the config
Changed web.enable value to false
Modified database connection properties (replaced [DATABASE], [USER], [PASSWORD] with correct values):

<entry key='database.driver'>com.mysql.jdbc.Driver</entry>
<entry key='database.url'>jdbc:mysql://localhost/[DATABASE]?allowMultiQueries=true</entry>
<entry key='database.user'>[USER]</entry>
<entry key='database.password'>[PASSWORD]</entry>

So far all is OK. My problem starting from next step, which is only need insert GPS data coming from device into MySQL database. No need to read or no need to make any other use with GPS listener data.

<entry key='database.insertPosition'>
    START TRANSACTION;
        UPDATE Device SET lastValidLatitude = :latitude, lastValidLongitude = :longitude, lastGPSTimestamp = UNIX_TIMESTAMP(:fixTime), lastUpdateTime = UNIX_TIMESTAMP(NOW()) WHERE imeiNumber = SUBSTRING(CAST(:deviceId AS CHAR(32)), 2);
        SELECT @accountID := accountID, @deviceID := deviceID FROM Device WHERE imeiNumber = SUBSTRING(CAST(:deviceId AS CHAR(32)), 2);
        INSERT INTO EventData (accountID, deviceID, timestamp, statusCode, latitude, longitude, speedKPH, heading, altitude, rawData, creationTime, address)
        VALUES (@accountID, @deviceID, UNIX_TIMESTAMP(:fixTime), 0, :latitude, :longitude, :speed * 1.852, :course, :altitude, '', UNIX_TIMESTAMP(NOW()), :address);
    COMMIT;
</entry>

But my database have different structure :

Time (device)
Time (server)
Lat
Lon
Altitude
Angel
Speed (km)
<last field is all rest data as is separated by $ separator character.>

Where I am making the error which no data saved in data base?
Thank you.

mc5 years ago

BTW each data saved into separately record for each device own file in database by name device_<device id> and each record have fields as listed above