Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sdk:scripts:gps-monitor [2015/05/05 15:04]
sdk:scripts:gps-monitor [2015/05/05 15:04] (current)
Line 1: Line 1:
 +====== SDK Script gps-monitor.are ======
 +<code c gps-monitor.are>​
 +/* DESC: A script for activating WLAN as soon as GPS position (lat,lon) is within a specified range.
 + * Copyright (C) 2012 NetModule AG, Switzerland
 + */
 +
 +LAT_MAX = 47.377892;
 +LAT_MIN = 47.377897;
 +
 +LON_MAX = 8.540053;
 +LON_MIN = 8.540057;
 +
 +while(1) {
 +    status = nb_status("​gnss"​);​
 +    lat = struct_get(status,​ "​GNSS1_LATITUDE"​);​
 +    lon = struct_get(status,​ "​GNSS1_LONGITUDE"​);​
 +
 +    if (lat != "​n/​a"​ && lon != "​n/​a"​) {
 +        printf("​lat is %s, lon is %s\n", lat, lon);
 +        if (lat >= LAT_MIN && lat <= LAT_MAX &&
 +            lon >= LON_MIN && lon <= LON_MAX) {
 +
 +            printf("​Activating WLAN\n"​);​
 +            nb_config_set("​wlan.0.status=1"​);​
 +        } else {
 +            printf("​De-activating WLAN\n"​);​
 +            nb_config_set("​wlan.0.status=0"​);​
 +        }
 +    } else {
 +        printf("​no GPS coordinates yet\n"​);​
 +    }
 +    sleep(10);
 +}
 +
 +exit(0);
 +
 +</​code>​