MQTT - GPS Bricklet

This is the description of the MQTT API bindings for the GPS Bricklet. General information and technical specifications for the GPS Bricklet are summarized in its hardware description.

An installation guide for the MQTT API bindings is part of their general description.

Examples

The example code below is Public Domain (CC0 1.0).

Simple

Download (example-simple.txt)

1
2
3
4
5
6
# Change XYZ to the UID of your GPS Bricklet

setup:
    # Get current coordinates
    subscribe to tinkerforge/response/gps_bricklet/XYZ/get_coordinates
    publish '' to tinkerforge/request/gps_bricklet/XYZ/get_coordinates

Callback

Download (example-callback.txt)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Change XYZ to the UID of your GPS Bricklet

setup:
    # Handle incoming coordinates callbacks
    subscribe to tinkerforge/callback/gps_bricklet/XYZ/coordinates
    publish '{"register": true}' to tinkerforge/register/gps_bricklet/XYZ/coordinates # Register coordinates callback

    # Set period for coordinates callback to 1s (1000ms)
    # Note: The coordinates callback is only called every second
    #       if the coordinates has changed since the last call!
    publish '{"period": 1000}' to tinkerforge/request/gps_bricklet/XYZ/set_coordinates_callback_period

API

All published payloads to and from the MQTT bindings are in JSON format.

If an error occures, the bindings publish a JSON object containing the error message as member _ERROR. It is published on the corresponding response topic: .../response/... for .../request/... and .../callback/... for .../register/....

Basic Functions

request/gps_bricklet/<UID>/get_coordinates
Request:
  • empty payload
Response:
  • latitude – Type: int, Unit: 1/1000000 °, Range: [0 to 90000000]
  • ns – Type: char, Range: ["N", "S"]
  • longitude – Type: int, Unit: 1/1000000 °, Range: [0 to 180000000]
  • ew – Type: char, Range: ["E", "W"]
  • pdop – Type: int, Unit: 1/100, Range: [0 to 216 - 1]
  • hdop – Type: int, Unit: 1/100, Range: [0 to 216 - 1]
  • vdop – Type: int, Unit: 1/100, Range: [0 to 216 - 1]
  • epe – Type: int, Unit: 1 cm, Range: [0 to 216 - 1]

Returns the GPS coordinates. Latitude and longitude are given in the DD.dddddd° format, the value 57123468 means 57.123468°. The parameter ns and ew are the cardinal directions for latitude and longitude. Possible values for ns and ew are 'N', 'S', 'E' and 'W' (north, south, east and west).

PDOP, HDOP and VDOP are the dilution of precision (DOP) values. They specify the additional multiplicative effect of GPS satellite geometry on GPS precision. See here for more information.

EPE is the "Estimated Position Error". This is not the absolute maximum error, it is the error with a specific confidence. See here for more information.

This data is only valid if there is currently a fix as indicated by request/gps_bricklet/<UID>/get_status.

request/gps_bricklet/<UID>/get_status
Request:
  • empty payload
Response:
  • fix – Type: int, Range: See symbols
  • satellites_view – Type: int, Range: [0 to 255]
  • satellites_used – Type: int, Range: [0 to 255]

Returns the current fix status, the number of satellites that are in view and the number of satellites that are currently used.

Possible fix status values can be:

Value Description
1 No Fix, request/gps_bricklet/<UID>/get_coordinates, request/gps_bricklet/<UID>/get_altitude and request/gps_bricklet/<UID>/get_motion return invalid data
2 2D Fix, only request/gps_bricklet/<UID>/get_coordinates and request/gps_bricklet/<UID>/get_motion return valid data
3 3D Fix, request/gps_bricklet/<UID>/get_coordinates, request/gps_bricklet/<UID>/get_altitude and request/gps_bricklet/<UID>/get_motion return valid data

There is also a blue LED on the Bricklet that indicates the fix status.

The following symbols are available for this function:

For fix:

  • "no_fix" = 1
  • "2d_fix" = 2
  • "3d_fix" = 3
request/gps_bricklet/<UID>/get_altitude
Request:
  • empty payload
Response:
  • altitude – Type: int, Unit: 1 cm, Range: [-231 to 231 - 1]
  • geoidal_separation – Type: int, Unit: 1 cm, Range: [-231 to 231 - 1]

Returns the current altitude and corresponding geoidal separation.

This data is only valid if there is currently a fix as indicated by request/gps_bricklet/<UID>/get_status.

request/gps_bricklet/<UID>/get_motion
Request:
  • empty payload
Response:
  • course – Type: int, Unit: 1/100 °, Range: [0 to 36000]
  • speed – Type: int, Unit: 1/100 km/h, Range: [0 to 232 - 1]

Returns the current course and speed. A course of 0° means the Bricklet is traveling north bound and 90° means it is traveling east bound.

Please note that this only returns useful values if an actual movement is present.

This data is only valid if there is currently a fix as indicated by request/gps_bricklet/<UID>/get_status.

request/gps_bricklet/<UID>/get_date_time
Request:
  • empty payload
Response:
  • date – Type: int, Range: [10100 to 311299]
  • time – Type: int, Range: [0 to 235959999]

Returns the current date and time. The date is given in the format ddmmyy and the time is given in the format hhmmss.sss. For example, 140713 means 14.07.13 as date and 195923568 means 19:59:23.568 as time.

Advanced Functions

request/gps_bricklet/<UID>/restart
Request:
  • restart_type – Type: int, Range: See symbols
Response:
  • no response

Restarts the GPS Bricklet, the following restart types are available:

Value Description
0 Hot start (use all available data in the NV store)
1 Warm start (don't use ephemeris at restart)
2 Cold start (don't use time, position, almanacs and ephemeris at restart)
3 Factory reset (clear all system/user configurations at restart)

The following symbols are available for this function:

For restart_type:

  • "hot_start" = 0
  • "warm_start" = 1
  • "cold_start" = 2
  • "factory_reset" = 3
request/gps_bricklet/<UID>/get_identity
Request:
  • empty payload
Response:
  • uid – Type: string, Length: up to 8
  • connected_uid – Type: string, Length: up to 8
  • position – Type: char, Range: ["a" to "h", "z"]
  • hardware_version – Type: [int, ...], Length: 3
    • 0: major – Type: int, Range: [0 to 255]
    • 1: minor – Type: int, Range: [0 to 255]
    • 2: revision – Type: int, Range: [0 to 255]
  • firmware_version – Type: [int, ...], Length: 3
    • 0: major – Type: int, Range: [0 to 255]
    • 1: minor – Type: int, Range: [0 to 255]
    • 2: revision – Type: int, Range: [0 to 255]
  • device_identifier – Type: int, Range: [0 to 216 - 1]
  • _display_name – Type: string

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an Isolator Bricklet is always at position 'z'.

The device identifier numbers can be found here. If symbolic output is not disabled, the device identifier is mapped to the corresponding name in the format used in topics.

The display name contains the GPS's name in a human readable form.

Callback Configuration Functions

request/gps_bricklet/<UID>/set_coordinates_callback_period
Request:
  • period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0
Response:
  • no response

Sets the period with which the register/gps_bricklet/<UID>/coordinates callback is triggered periodically. A value of 0 turns the callback off.

The register/gps_bricklet/<UID>/coordinates callback is only triggered if the coordinates changed since the last triggering.

request/gps_bricklet/<UID>/get_coordinates_callback_period
Request:
  • empty payload
Response:
  • period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0

Returns the period as set by request/gps_bricklet/<UID>/set_coordinates_callback_period.

request/gps_bricklet/<UID>/set_status_callback_period
Request:
  • period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0
Response:
  • no response

Sets the period with which the register/gps_bricklet/<UID>/status callback is triggered periodically. A value of 0 turns the callback off.

The register/gps_bricklet/<UID>/status callback is only triggered if the status changed since the last triggering.

request/gps_bricklet/<UID>/get_status_callback_period
Request:
  • empty payload
Response:
  • period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0

Returns the period as set by request/gps_bricklet/<UID>/set_status_callback_period.

request/gps_bricklet/<UID>/set_altitude_callback_period
Request:
  • period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0
Response:
  • no response

Sets the period with which the register/gps_bricklet/<UID>/altitude callback is triggered periodically. A value of 0 turns the callback off.

The register/gps_bricklet/<UID>/altitude callback is only triggered if the altitude changed since the last triggering.

request/gps_bricklet/<UID>/get_altitude_callback_period
Request:
  • empty payload
Response:
  • period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0

Returns the period as set by request/gps_bricklet/<UID>/set_altitude_callback_period.

request/gps_bricklet/<UID>/set_motion_callback_period
Request:
  • period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0
Response:
  • no response

Sets the period with which the register/gps_bricklet/<UID>/motion callback is triggered periodically. A value of 0 turns the callback off.

The register/gps_bricklet/<UID>/motion callback is only triggered if the motion changed since the last triggering.

request/gps_bricklet/<UID>/get_motion_callback_period
Request:
  • empty payload
Response:
  • period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0

Returns the period as set by request/gps_bricklet/<UID>/set_motion_callback_period.

request/gps_bricklet/<UID>/set_date_time_callback_period
Request:
  • period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0
Response:
  • no response

Sets the period with which the register/gps_bricklet/<UID>/date_time callback is triggered periodically. A value of 0 turns the callback off.

The register/gps_bricklet/<UID>/date_time callback is only triggered if the date or time changed since the last triggering.

request/gps_bricklet/<UID>/get_date_time_callback_period
Request:
  • empty payload
Response:
  • period – Type: int, Unit: 1 ms, Range: [0 to 232 - 1], Default: 0

Returns the period as set by request/gps_bricklet/<UID>/set_date_time_callback_period.

Callbacks

Callbacks can be registered to receive time critical or recurring data from the device. The registration is done with the corresponding .../register/... topic and an optional suffix. This suffix can be used to deregister the callback later.

Note

Using callbacks for recurring events is always preferred compared to using getters. It will use less USB bandwidth and the latency will be a lot better, since there is no round trip time.

register/gps_bricklet/<UID>/coordinates
Register Request:
  • register – Type: bool
Callback Response:
  • latitude – Type: int, Unit: 1/1000000 °, Range: [0 to 90000000]
  • ns – Type: char, Range: ["N", "S"]
  • longitude – Type: int, Unit: 1/1000000 °, Range: [0 to 180000000]
  • ew – Type: char, Range: ["E", "W"]
  • pdop – Type: int, Unit: 1/100, Range: [0 to 216 - 1]
  • hdop – Type: int, Unit: 1/100, Range: [0 to 216 - 1]
  • vdop – Type: int, Unit: 1/100, Range: [0 to 216 - 1]
  • epe – Type: int, Unit: 1 cm, Range: [0 to 216 - 1]

A callback can be registered for this event by publishing to the .../register/gps_bricklet/<UID>/coordinates[/<SUFFIX>] topic with the payload "true". An added callback can be removed by publishing to the same topic with the payload "false". To support multiple (de)registrations, e.g. for message filtering, an optional suffix can be used.

If the callback is triggered, a message with it's payload is published under the corresponding .../callback/gps_bricklet/<UID>/coordinates[/<SUFFIX>] topic for each registered suffix.

This callback is triggered periodically with the period that is set by request/gps_bricklet/<UID>/set_coordinates_callback_period. The parameters are the same as for request/gps_bricklet/<UID>/get_coordinates.

The register/gps_bricklet/<UID>/coordinates callback is only triggered if the coordinates changed since the last triggering and if there is currently a fix as indicated by request/gps_bricklet/<UID>/get_status.

register/gps_bricklet/<UID>/status
Register Request:
  • register – Type: bool
Callback Response:
  • fix – Type: int, Range: See symbols
  • satellites_view – Type: int, Range: [0 to 255]
  • satellites_used – Type: int, Range: [0 to 255]

A callback can be registered for this event by publishing to the .../register/gps_bricklet/<UID>/status[/<SUFFIX>] topic with the payload "true". An added callback can be removed by publishing to the same topic with the payload "false". To support multiple (de)registrations, e.g. for message filtering, an optional suffix can be used.

If the callback is triggered, a message with it's payload is published under the corresponding .../callback/gps_bricklet/<UID>/status[/<SUFFIX>] topic for each registered suffix.

This callback is triggered periodically with the period that is set by request/gps_bricklet/<UID>/set_status_callback_period. The parameters are the same as for request/gps_bricklet/<UID>/get_status.

The register/gps_bricklet/<UID>/status callback is only triggered if the status changed since the last triggering.

The following symbols are available for this function:

For fix:

  • "no_fix" = 1
  • "2d_fix" = 2
  • "3d_fix" = 3
register/gps_bricklet/<UID>/altitude
Register Request:
  • register – Type: bool
Callback Response:
  • altitude – Type: int, Unit: 1 cm, Range: [-231 to 231 - 1]
  • geoidal_separation – Type: int, Unit: 1 cm, Range: [-231 to 231 - 1]

A callback can be registered for this event by publishing to the .../register/gps_bricklet/<UID>/altitude[/<SUFFIX>] topic with the payload "true". An added callback can be removed by publishing to the same topic with the payload "false". To support multiple (de)registrations, e.g. for message filtering, an optional suffix can be used.

If the callback is triggered, a message with it's payload is published under the corresponding .../callback/gps_bricklet/<UID>/altitude[/<SUFFIX>] topic for each registered suffix.

This callback is triggered periodically with the period that is set by request/gps_bricklet/<UID>/set_altitude_callback_period. The parameters are the same as for request/gps_bricklet/<UID>/get_altitude.

The register/gps_bricklet/<UID>/altitude callback is only triggered if the altitude changed since the last triggering and if there is currently a fix as indicated by request/gps_bricklet/<UID>/get_status.

register/gps_bricklet/<UID>/motion
Register Request:
  • register – Type: bool
Callback Response:
  • course – Type: int, Unit: 1/100 °, Range: [0 to 36000]
  • speed – Type: int, Unit: 1/100 km/h, Range: [0 to 232 - 1]

A callback can be registered for this event by publishing to the .../register/gps_bricklet/<UID>/motion[/<SUFFIX>] topic with the payload "true". An added callback can be removed by publishing to the same topic with the payload "false". To support multiple (de)registrations, e.g. for message filtering, an optional suffix can be used.

If the callback is triggered, a message with it's payload is published under the corresponding .../callback/gps_bricklet/<UID>/motion[/<SUFFIX>] topic for each registered suffix.

This callback is triggered periodically with the period that is set by request/gps_bricklet/<UID>/set_motion_callback_period. The parameters are the same as for request/gps_bricklet/<UID>/get_motion.

The register/gps_bricklet/<UID>/motion callback is only triggered if the motion changed since the last triggering and if there is currently a fix as indicated by request/gps_bricklet/<UID>/get_status.

register/gps_bricklet/<UID>/date_time
Register Request:
  • register – Type: bool
Callback Response:
  • date – Type: int, Range: [10100 to 311299]
  • time – Type: int, Range: [0 to 235959999]

A callback can be registered for this event by publishing to the .../register/gps_bricklet/<UID>/date_time[/<SUFFIX>] topic with the payload "true". An added callback can be removed by publishing to the same topic with the payload "false". To support multiple (de)registrations, e.g. for message filtering, an optional suffix can be used.

If the callback is triggered, a message with it's payload is published under the corresponding .../callback/gps_bricklet/<UID>/date_time[/<SUFFIX>] topic for each registered suffix.

This callback is triggered periodically with the period that is set by request/gps_bricklet/<UID>/set_date_time_callback_period. The parameters are the same as for request/gps_bricklet/<UID>/get_date_time.

The register/gps_bricklet/<UID>/date_time callback is only triggered if the date or time changed since the last triggering.