The active location store: holds the phone's coordinates and owns the appmessage coords channel. More...
#include "io/stores/location_store.h"#include "io/stores/store_persist.h"#include <stdio.h>#include <string.h>#include "io/appmessage/appmessage.h"#include "wire/coords.h"#include "text/cstring_fit.h"Data Structures | |
| struct | [struct].s_state |
Functions | |
| static void | persist_save (void) |
| Stash the coords so a relaunch can restore them. | |
| static void | copy_pair (char *out_lat, char *out_lon, const char *lat, const char *lon) |
| Copy a pair of coordinates into two fields the size of the state's, reading a missing one as empty. | |
| static void | set (const char *lat, const char *lon) |
| Save the latest coordinates, and tell whoever is listening when they changed. It is the coords channel handler, since its signature matches. | |
| void | location_store_subscribe (void(*cb)(void)) |
| Hand it the function to call when the coordinates change (the screen redraw). | |
| void | location_store_init (LocationConfig cfg, const LocationSeed *seed) |
| Start the store with its rules. Pass seed = NULL for normal use. | |
| const char * | location_store_lat (void) |
| The latitude string, or empty if we have not got one yet. | |
| const char * | location_store_lon (void) |
| The longitude string, or empty if we have not got one yet. | |
Variables | |
| static uint32_t | s_persist_key |
| Where the last good fix is kept, handed in by the face. | |
| static struct | s_state |
| The last fix, laid out as the blob that gets persisted. | |
| static void(*) | s_cb (void) |
| Called whenever the coords change, so the face can redraw. | |
| static uint32_t | s_saved_sum |
| Sum of the reading last written, so a reply that changes nothing is not written again. | |
| static bool | s_live |
| True on a live face, so the cache is worth reading and writing. | |
The active location store: holds the phone's coordinates and owns the appmessage coords channel.
|
static |
Copy a pair of coordinates into two fields the size of the state's, reading a missing one as empty.
| out_lat | Where the latitude goes, sizeof(s_state.lat) long. |
| out_lon | Where the longitude goes, sizeof(s_state.lon) long. |
| lat | Latitude string, or NULL. |
| lon | Longitude string, or NULL. |
|
static |
Stash the coords so a relaunch can restore them.
Only a live face writes, and only a real fix, so a dropped one can't stomp the last good location.
|
static |
Save the latest coordinates, and tell whoever is listening when they changed. It is the coords channel handler, since its signature matches.
| lat | Latitude string, empty when unavailable. |
| lon | Longitude string, empty when unavailable. |
|
static |
Where the last good fix is kept, handed in by the face.
A relaunch, such as coming back from the timeline, shows the coords straight away rather than blanking to "--". The face picks the slot, so it is the one place that knows which keys it has already spent.