Geolocation not working on OsmAnd

Damian4 years ago

Hi, I have a device that only reports the cell tower it is connected to, so i decided to use the OsmAnd protocol with Google's Geolocation service in order to get the its location on the map.

The problem is that when the device POSTs to Traccar, the position is not saved.

Query params sent in the request:

id: "12345",
cell: "310,410,6038,56866",
valid: false,
lat: 0,
lon: 0,
hdop: 0,
altitude: 0,
speed: 0,
timestamp: 1631119460812

Logs:

...
2021-09-08 16:44:20  INFO: [d99b98a4] connected
2021-09-08 16:44:20  INFO: [d99b98a4: osmand < 192.168.112.6] HEX: 504f5354202f3f69643d31323334352663656c6c3d3331302c3431302c363033382c35363836362676616c69643d66616c7365266c61743d30266c6f6e3d302668646f703d3026616c7469747564653d302673706565643d302674696d657374616d703d3136333131313934363038313220485454502f312e310d0a4163636570743a206170706c69636174696f6e2f6a736f6e2c20746578742f706c61696e2c202a2f2a0d0a436f6e74656e742d547970653a206170706c69636174696f6e2f782d7777772d666f726d2d75726c656e636f6465640d0a557365722d4167656e743a206178696f732f302e32312e310d0a486f73743a20747261636361723a353035350d0a436f6e6e656374696f6e3a20636c6f73650d0a436f6e74656e742d4c656e6774683a20300d0a0d0a
2021-09-08 16:44:20  INFO: [d99b98a4: osmand > 192.168.112.6] HEX: 485454502f312e3120323030204f4b0d0a636f6e74656e742d6c656e6774683a20300d0a0d0a
2021-09-08 16:44:20  INFO: [d99b98a4] disconnected
...

Configuration:

....
<entry key='geolocation.enable'>true</entry>
<entry key='geolocation.processInvalidPositions'>true</entry>
<entry key='geolocation.type'>google</entry>
<entry key='geolocation.key'>xxxxxxxxxxxxxxxxxx</entry>
...

I've seen in the source code (OsmAndProtocolDecoder.java) that it should handle the cell parameter:

case "cell":
    String[] cell = value.split(",");
    if (cell.length > 4) {
        network.addCellTower(CellTower.from(
            Integer.parseInt(cell[0]), Integer.parseInt(cell[1]),
            Integer.parseInt(cell[2]), Integer.parseInt(cell[3]), Integer.parseInt(cell[4])));
    } else {
        network.addCellTower(CellTower.from(
            Integer.parseInt(cell[0]), Integer.parseInt(cell[1]),
            Integer.parseInt(cell[2]), Integer.parseInt(cell[3])));
    }
    break;

Is there something i'm missing?

Anton Tananaev4 years ago

The problem is likely that you disconnect immediately. Try keeping connection longer.

Damian4 years ago

As you said, the problem was solved by keeping the connection open.

Thank you!