diff --git a/src/gps/UBloxGPS.cpp b/src/gps/UBloxGPS.cpp index 30b6a579..70fc91ec 100644 --- a/src/gps/UBloxGPS.cpp +++ b/src/gps/UBloxGPS.cpp @@ -225,6 +225,10 @@ bool UBloxGPS::lookForLocation() int32_t tmp_lon = ublox.getLongitude(0); int32_t tmp_alt_msl = ublox.getAltitudeMSL(0); int32_t tmp_alt_hae = ublox.getAltitude(0); + int32_t max_dop = PDOP_INVALID; + if (radioConfig.preferences.gps_max_dop) + max_dop = radioConfig.preferences.gps_max_dop * 100; // scaling + // Note: heading is only currently implmented in the ublox for the 8m chipset - therefore // don't read it here - it will generate an ignored getPVT command on the 6ms // heading = ublox.getHeading(0); @@ -248,16 +252,25 @@ bool UBloxGPS::lookForLocation() // FIXME - NULL ISLAND is a real location on Earth! foundLocation = (tmp_lat != 0) && (tmp_lon != 0) && (tmp_lat <= 900000000) && (tmp_lat >= -900000000) && - (tmp_dop < PDOP_INVALID); + (tmp_dop < max_dop); // only if entire dataset is valid, update globals from temp vars if (foundLocation) { p.location_source = Position_LocSource_LOCSRC_GPS_INTERNAL; p.longitude_i = tmp_lon; p.latitude_i = tmp_lat; - p.altitude = tmp_alt_msl / 1000; - p.altitude_hae = tmp_alt_hae / 1000; - p.alt_geoid_sep = (tmp_alt_hae - tmp_alt_msl) / 1000; + if (fixType > 2) { + // if fix is 2d, ignore altitude data + p.altitude = tmp_alt_msl / 1000; + p.altitude_hae = tmp_alt_hae / 1000; + p.alt_geoid_sep = (tmp_alt_hae - tmp_alt_msl) / 1000; + } else { +#ifdef GPS_EXTRAVERBOSE + DEBUG_MSG("no altitude data (fixType=%d)\n", fixType); +#endif + // clean up old values in case it's a 3d-2d fix transition + p.altitude = p.altitude_hae = p.alt_geoid_sep = 0; + } p.pos_timestamp = tmp_ts; p.PDOP = tmp_dop; p.fix_type = fixType; @@ -277,7 +290,10 @@ bool UBloxGPS::lookForLocation() bool UBloxGPS::hasLock() { - return (fixType >= 3 && fixType <= 4); + if (radioConfig.preferences.gps_accept_2d) + return (fixType >= 2 && fixType <= 4); + else + return (fixType >= 3 && fixType <= 4); } bool UBloxGPS::whileIdle() diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index c6c30969..a1cc1f41 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -79,7 +79,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 407 +#define AdminMessage_size 417 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h index 6c97720b..6b6c7406 100644 --- a/src/mesh/generated/deviceonly.pb.h +++ b/src/mesh/generated/deviceonly.pb.h @@ -125,7 +125,7 @@ extern const pb_msgdesc_t ChannelFile_msg; /* Maximum encoded size of messages (where known) */ #define LegacyRadioConfig_size 4 #define LegacyRadioConfig_LegacyPreferences_size 2 -#define DeviceState_size 10054 +#define DeviceState_size 9000 #define ChannelFile_size 832 #ifdef __cplusplus diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index e464cf61..44013196 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -33,6 +33,24 @@ typedef enum _HardwareModel { HardwareModel_DIY_V1 = 39 } HardwareModel; +typedef enum _Team { + Team_CLEAR = 0, + Team_CYAN = 1, + Team_WHITE = 2, + Team_YELLOW = 3, + Team_ORANGE = 4, + Team_MAGENTA = 5, + Team_RED = 6, + Team_MAROON = 7, + Team_PURPLE = 8, + Team_DARK_BLUE = 9, + Team_BLUE = 10, + Team_TEAL = 11, + Team_GREEN = 12, + Team_DARK_GREEN = 13, + Team_BROWN = 14 +} Team; + typedef enum _Constants { Constants_Unused = 0, Constants_DATA_PAYLOAD_LEN = 237 @@ -158,11 +176,6 @@ typedef struct _Position { uint32_t fix_type; uint32_t sats_in_view; uint32_t sensor_id; - uint32_t heading; - int32_t roll; - int32_t pitch; - uint32_t air_speed; - uint32_t ground_distance_cm; uint32_t pos_next_update; uint32_t pos_seq_number; } Position; @@ -184,6 +197,7 @@ typedef struct _User { pb_byte_t macaddr[6]; HardwareModel hw_model; bool is_licensed; + Team team; } User; typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t; @@ -253,6 +267,10 @@ typedef struct _ToRadio { #define _HardwareModel_MAX HardwareModel_DIY_V1 #define _HardwareModel_ARRAYSIZE ((HardwareModel)(HardwareModel_DIY_V1+1)) +#define _Team_MIN Team_CLEAR +#define _Team_MAX Team_BROWN +#define _Team_ARRAYSIZE ((Team)(Team_BROWN+1)) + #define _Constants_MIN Constants_Unused #define _Constants_MAX Constants_DATA_PAYLOAD_LEN #define _Constants_ARRAYSIZE ((Constants)(Constants_DATA_PAYLOAD_LEN+1)) @@ -287,8 +305,8 @@ extern "C" { #endif /* Initializer values for message structs */ -#define Position_init_default {0, 0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -#define User_init_default {"", "", "", {0}, _HardwareModel_MIN, 0} +#define Position_init_default {0, 0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define User_init_default {"", "", "", {0}, _HardwareModel_MIN, 0, _Team_MIN} #define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define Routing_init_default {0, {RouteDiscovery_init_default}} #define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0} @@ -299,8 +317,8 @@ extern "C" { #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} #define ToRadio_init_default {0, {MeshPacket_init_default}} #define ToRadio_PeerInfo_init_default {0, 0} -#define Position_init_zero {0, 0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -#define User_init_zero {"", "", "", {0}, _HardwareModel_MIN, 0} +#define Position_init_zero {0, 0, 0, 0, 0, _Position_LocSource_MIN, _Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define User_init_zero {"", "", "", {0}, _HardwareModel_MIN, 0, _Team_MIN} #define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} #define Routing_init_zero {0, {RouteDiscovery_init_zero}} #define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0} @@ -357,11 +375,6 @@ extern "C" { #define Position_fix_type_tag 23 #define Position_sats_in_view_tag 24 #define Position_sensor_id_tag 25 -#define Position_heading_tag 30 -#define Position_roll_tag 31 -#define Position_pitch_tag 32 -#define Position_air_speed_tag 33 -#define Position_ground_distance_cm_tag 34 #define Position_pos_next_update_tag 40 #define Position_pos_seq_number_tag 41 #define RouteDiscovery_route_tag 2 @@ -373,6 +386,7 @@ extern "C" { #define User_macaddr_tag 4 #define User_hw_model_tag 6 #define User_is_licensed_tag 7 +#define User_team_tag 8 #define MeshPacket_from_tag 1 #define MeshPacket_to_tag 2 #define MeshPacket_channel_tag 3 @@ -428,11 +442,6 @@ X(a, STATIC, SINGULAR, UINT32, fix_quality, 22) \ X(a, STATIC, SINGULAR, UINT32, fix_type, 23) \ X(a, STATIC, SINGULAR, UINT32, sats_in_view, 24) \ X(a, STATIC, SINGULAR, UINT32, sensor_id, 25) \ -X(a, STATIC, SINGULAR, UINT32, heading, 30) \ -X(a, STATIC, SINGULAR, SINT32, roll, 31) \ -X(a, STATIC, SINGULAR, SINT32, pitch, 32) \ -X(a, STATIC, SINGULAR, UINT32, air_speed, 33) \ -X(a, STATIC, SINGULAR, UINT32, ground_distance_cm, 34) \ X(a, STATIC, SINGULAR, UINT32, pos_next_update, 40) \ X(a, STATIC, SINGULAR, UINT32, pos_seq_number, 41) #define Position_CALLBACK NULL @@ -444,7 +453,8 @@ X(a, STATIC, SINGULAR, STRING, long_name, 2) \ X(a, STATIC, SINGULAR, STRING, short_name, 3) \ X(a, STATIC, SINGULAR, FIXED_LENGTH_BYTES, macaddr, 4) \ X(a, STATIC, SINGULAR, UENUM, hw_model, 6) \ -X(a, STATIC, SINGULAR, BOOL, is_licensed, 7) +X(a, STATIC, SINGULAR, BOOL, is_licensed, 7) \ +X(a, STATIC, SINGULAR, UENUM, team, 8) #define User_CALLBACK NULL #define User_DEFAULT NULL @@ -584,13 +594,13 @@ extern const pb_msgdesc_t ToRadio_PeerInfo_msg; #define ToRadio_PeerInfo_fields &ToRadio_PeerInfo_msg /* Maximum encoded size of messages (where known) */ -#define Position_size 188 -#define User_size 76 +#define Position_size 153 +#define User_size 78 #define RouteDiscovery_size 40 #define Routing_size 42 #define Data_size 260 #define MeshPacket_size 309 -#define NodeInfo_size 285 +#define NodeInfo_size 252 #define MyNodeInfo_size 101 #define LogRecord_size 81 #define FromRadio_size 318 diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index ee7b2aeb..e30ea3f8 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -113,6 +113,8 @@ typedef struct _RadioConfig_UserPreferences { char mqtt_server[32]; bool mqtt_disabled; GpsCoordinateFormat gps_format; + bool gps_accept_2d; + uint32_t gps_max_dop; bool factory_reset; bool debug_log_enabled; pb_size_t ignore_incoming_count; @@ -177,8 +179,8 @@ typedef struct _RadioConfig { #define _PositionFlags_ARRAYSIZE ((PositionFlags)(PositionFlags_POS_TIMESTAMP+1)) #define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11+1)) +#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20 +#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20+1)) #ifdef __cplusplus @@ -187,9 +189,9 @@ extern "C" { /* Initializer values for message structs */ #define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default} -#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0} +#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0} #define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero} -#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0} +#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0} /* Field tags (for use in manual encoding/decoding) */ #define RadioConfig_UserPreferences_position_broadcast_secs_tag 1 @@ -219,6 +221,8 @@ extern "C" { #define RadioConfig_UserPreferences_mqtt_server_tag 42 #define RadioConfig_UserPreferences_mqtt_disabled_tag 43 #define RadioConfig_UserPreferences_gps_format_tag 44 +#define RadioConfig_UserPreferences_gps_accept_2d_tag 45 +#define RadioConfig_UserPreferences_gps_max_dop_tag 46 #define RadioConfig_UserPreferences_factory_reset_tag 100 #define RadioConfig_UserPreferences_debug_log_enabled_tag 101 #define RadioConfig_UserPreferences_ignore_incoming_tag 103 @@ -285,6 +289,8 @@ X(a, STATIC, SINGULAR, FLOAT, frequency_offset, 41) \ X(a, STATIC, SINGULAR, STRING, mqtt_server, 42) \ X(a, STATIC, SINGULAR, BOOL, mqtt_disabled, 43) \ X(a, STATIC, SINGULAR, UENUM, gps_format, 44) \ +X(a, STATIC, SINGULAR, BOOL, gps_accept_2d, 45) \ +X(a, STATIC, SINGULAR, UINT32, gps_max_dop, 46) \ X(a, STATIC, SINGULAR, BOOL, factory_reset, 100) \ X(a, STATIC, SINGULAR, BOOL, debug_log_enabled, 101) \ X(a, STATIC, REPEATED, UINT32, ignore_incoming, 103) \ @@ -325,8 +331,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg; #define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg /* Maximum encoded size of messages (where known) */ -#define RadioConfig_size 404 -#define RadioConfig_UserPreferences_size 401 +#define RadioConfig_size 414 +#define RadioConfig_UserPreferences_size 411 #ifdef __cplusplus } /* extern "C" */