diff --git a/modules/config.py b/modules/config.py index 1f550483..535aa7f9 100644 --- a/modules/config.py +++ b/modules/config.py @@ -1065,6 +1065,54 @@ def hardware_wifi_bt(self, status): exec_cmd( ["sudo", "sed", "-i", f"$a{disable}", BOOT_FILE], False ) + # UART configuration will change if we disable bluetooth + # https://www.raspberrypi.com/documentation/computers/configuration.html#primary-and-secondary-uart + if status: + exec_cmd( + [ + "sudo", + "sed", + "-i", + "-e", + 's/^\#DEVICES\="\/dev\/ttyS0"/DEVICES\="\/dev\/ttyS0"/', + "/etc/default/gpsd", + ], + False, + ) + exec_cmd( + [ + "sudo", + "sed", + "-i", + "-e", + 's/^DEVICES\="\/dev\/ttyAMA0"/\#DEVICES\="\/dev\/ttyAMA0"/', + "/etc/default/gpsd", + ], + False, + ) + else: + exec_cmd( + [ + "sudo", + "sed", + "-i", + "-e", + 's/^DEVICES\="\/dev\/ttyS0"/\#DEVICES\="\/dev\/ttyS0"/', + "/etc/default/gpsd", + ], + False, + ) + exec_cmd( + [ + "sudo", + "sed", + "-i", + "-e", + 's/^\#DEVICES\="\/dev\/ttyAMA0"/DEVICES\="\/dev\/ttyAMA0"/', + "/etc/default/gpsd", + ], + False, + ) def get_wifi_bt_status(self): if not self.G_IS_RASPI: @@ -1073,9 +1121,11 @@ def get_wifi_bt_status(self): status = {"wlan": False, "bluetooth": False} try: # json option requires raspbian buster - raw_status = exec_cmd_return_value(["sudo", "rfkill", "--json"], cmd_print=False) + raw_status = exec_cmd_return_value( + ["sudo", "rfkill", "--json"], cmd_print=False + ) json_status = json.loads(raw_status) - # "": Raspberry Pi OS, "rfkilldevices": + # "": Raspberry Pi OS, "rfkilldevices": self.parse_wifi_bt_json(json_status, status, ["", "rfkilldevices"]) except Exception as e: app_logger.warning(f"Exception occurred trying to get wifi/bt status: {e}") @@ -1103,7 +1153,7 @@ def onoff_wifi_bt(self, key=None): onoff_cmd = { "Wifi": { True: ["sudo", "rfkill", "block", "wifi"], - False: ["sudo"", rfkill", "unblock", "wifi"], + False: ["sudo", "rfkill", "unblock", "wifi"], }, "Bluetooth": { True: ["sudo", "rfkill", "block", "bluetooth"], diff --git a/modules/logger_core.py b/modules/logger_core.py index ed616a32..73d6a4df 100644 --- a/modules/logger_core.py +++ b/modules/logger_core.py @@ -265,8 +265,8 @@ def init_db(self): res = self.cur.fetchone() replace_flg = False if ( - res is not None - and len(res) >= 5 + res is not None + and len(res) >= 5 and res[4].replace(" ", "") != self.create_table_sql.replace(" ", "") ): log_db_moved = self.config.G_LOG_DB + "-old_layout" @@ -897,8 +897,8 @@ def update_track(self, timestamp): shutil.copy(self.config.G_LOG_DB, db_file) query = ( - 'SELECT distance,position_lat,position_long FROM BIKECOMPUTER_LOG ' - + 'WHERE position_lat is not null AND position_long is not null ' + "SELECT distance,position_lat,position_long FROM BIKECOMPUTER_LOG " + + "WHERE position_lat is not null AND position_long is not null " + 'and typeof(position_lat) = "real" and typeof(position_long) = "real"' ) if timestamp is not None: diff --git a/modules/pyqt/menu/pyqt_system_menu_widget.py b/modules/pyqt/menu/pyqt_system_menu_widget.py index 07e03f1d..d62920a7 100644 --- a/modules/pyqt/menu/pyqt_system_menu_widget.py +++ b/modules/pyqt/menu/pyqt_system_menu_widget.py @@ -153,7 +153,7 @@ def preprocess(self): def debug_log(self): self.change_page("Debug Log", preprocess=True) - + def set_log_level_to_debug(self, change=True): # assume the initial log level is INFO. # Future support for multiple log levels. @@ -164,9 +164,7 @@ def set_log_level_to_debug(self, change=True): else: app_logger.setLevel(level=logging.DEBUG) self.is_log_lebel_debug = True - self.buttons["Debug Level Log"].change_toggle( - self.is_log_lebel_debug - ) + self.buttons["Debug Level Log"].change_toggle(self.is_log_lebel_debug) class BluetoothTetheringListWidget(ListWidget): diff --git a/scripts/comment_out.sh b/scripts/comment_out.sh deleted file mode 100755 index 62e46cc5..00000000 --- a/scripts/comment_out.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -sudo sed -i -e "s/^\#DEVICES\=\"\/dev\/ttyS0\"/DEVICES\=\"\/dev\/ttyS0\"/" /etc/default/gpsd -sudo sed -i -e "s/^DEVICES\=\"\/dev\/ttyAMA0\"/\#DEVICES\=\"\/dev\/ttyAMA0\"/" /etc/default/gpsd diff --git a/scripts/uncomment.sh b/scripts/uncomment.sh deleted file mode 100755 index 18474317..00000000 --- a/scripts/uncomment.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -sudo sed -i -e "s/^DEVICES\=\"\/dev\/ttyS0\"/\#DEVICES\=\"\/dev\/ttyS0\"/" /etc/default/gpsd -sudo sed -i -e "s/^\#DEVICES\=\"\/dev\/ttyAMA0\"/DEVICES\=\"\/dev\/ttyAMA0\"/" /etc/default/gpsd