diff --git a/dish_grpc_sqlite.py b/dish_grpc_sqlite.py index 9fe529e..5505edc 100644 --- a/dish_grpc_sqlite.py +++ b/dish_grpc_sqlite.py @@ -46,7 +46,7 @@ import time import dish_common import starlink_grpc -SCHEMA_VERSION = 3 +SCHEMA_VERSION = 4 class Terminated(Exception): @@ -208,8 +208,10 @@ def ensure_schema(opts, conn, context): def create_tables(conn, context, suffix): tables = {} - name_groups = starlink_grpc.status_field_names(context=context) - type_groups = starlink_grpc.status_field_types(context=context) + name_groups = (starlink_grpc.status_field_names(context=context) + + (starlink_grpc.location_field_names(),)) + type_groups = (starlink_grpc.status_field_types(context=context) + + (starlink_grpc.location_field_types(),)) tables["status"] = zip(name_groups, type_groups) name_groups = starlink_grpc.history_stats_field_names() diff --git a/dish_grpc_text.py b/dish_grpc_text.py index 68a5222..db735b6 100644 --- a/dish_grpc_text.py +++ b/dish_grpc_text.py @@ -128,18 +128,21 @@ def print_header(opts, print_file): header.append(name) if opts.status_mode: - context = starlink_grpc.ChannelContext(target=opts.target) - try: - name_groups = starlink_grpc.status_field_names(context=context) - except starlink_grpc.GrpcError as e: - dish_common.conn_error(opts, "Failure reflecting status field names: %s", str(e)) - return 1 - if "status" in opts.mode: - header_add(name_groups[0]) - if "obstruction_detail" in opts.mode: - header_add(name_groups[1]) - if "alert_detail" in opts.mode: - header_add(name_groups[2]) + if opts.pure_status_mode: + context = starlink_grpc.ChannelContext(target=opts.target) + try: + name_groups = starlink_grpc.status_field_names(context=context) + except starlink_grpc.GrpcError as e: + dish_common.conn_error(opts, "Failure reflecting status field names: %s", str(e)) + return 1 + if "status" in opts.mode: + header_add(name_groups[0]) + if "obstruction_detail" in opts.mode: + header_add(name_groups[1]) + if "alert_detail" in opts.mode: + header_add(name_groups[2]) + if "location" in opts.mode: + header_add(starlink_grpc.location_field_names()) if opts.bulk_mode: general, bulk = starlink_grpc.history_bulk_field_names() @@ -153,10 +156,10 @@ def print_header(opts, print_file): header_add(ping) if "ping_run_length" in opts.mode: header_add(runlen) - if "ping_loaded_latency" in opts.mode: - header_add(loaded) if "ping_latency" in opts.mode: header_add(latency) + if "ping_loaded_latency" in opts.mode: + header_add(loaded) if "usage" in opts.mode: header_add(usage) diff --git a/starlink_grpc.py b/starlink_grpc.py index 371e341..893ce68 100644 --- a/starlink_grpc.py +++ b/starlink_grpc.py @@ -776,6 +776,26 @@ def status_data( }, alerts +def location_field_names(): + """Return the field names of the location data. + + Returns: + A list with location data field names. + """ + return _field_names(LocationDict) + + +def location_field_types(): + """Return the field types of the location data. + + Return the type classes for each field. + + Returns: + A list with location data field types. + """ + return _field_types(LocationDict) + + def get_location(context: Optional[ChannelContext] = None): """Fetch location data and return it in grpc structure format.