def main(self):
        App.main(self)

        # Autodiscover device if necessary
        if self.options.addr == None:
            self.log.info("Bluetooth address not specified. Searching for matching device...")
            devs = btLink.discover()
            if len(devs) == 0:
                self.log.error("No devices found")
                sys.exit(1)
            else:
                self.log.info("Using device: %s - %s" % (devs[0][0], devs[0][1]))
                self.options.addr = devs[0][0]

        with btLink.btLink(self.options.addr) as S:
            S.enter_bootloader()
            S.send_ihex(self.options.filename)
            S.exit_bootloader()
            S.set_time()
 def pb_tgl_connect_click(self):
     
     if((settings.BT_LINK == None) or (settings.BT_LINK.connected == False)):
         # Connect
         
         if(gui_btLink.check_bt_addr()):
             
             if(settings.BT_LINK == None):
                 settings.BT_LINK = btLink.btLink(settings.S_DATA.bt_addr)
             
             try:
                 settings.BT_LINK.open()
             except:
                 print("BT connect error")
                 settings.BT_LINK = None
                 return
             
             self.pb_tgl_connect.configure(text="Disconnect")
     else:
         # Disconnect
         settings.BT_LINK.close()
         
         self.pb_tgl_connect.configure(text="Connect")