parameters: (self)
docstring: Check for new fw and update or pass
docstring_summary: Check for new fw and update or pass
docstring_tokens: Check for new fw and update or pass
function: async def _ota(self):
          """Check for new fw and update or pass"""
          device_name = self.msg['name']
          device_chip = self.msg['chip']
          device_version = self.msg['version']
          fw_version = ''
          fw_name = ''
          fw_device = ''
  
          for filename in listdir(fw_path):
              fw_info = filename.split("-")
              fw_device = fw_info[0]
              if fw_device == device_name:
                  fw_version = fw_info[1]
                  fw_name = filename
                  break
  
          if not fw_version:
              Logger.info("Client(%s): No fw found!", device_name)
              msg = '{"type": "ota", "value":"ok"}'
              await self.websocket.send(msg)
              return
  
          if not version_checker(device_name, device_version, fw_version):
              return
  
          fw_file = join_pth(fw_path, fw_name)
          if device_chip == 'esp8266' and not fw_file.endswith('.gz'):
              # We can compress fw to make it smaller for upload
              fw_cpress = fw_file
              fw_file = fw_cpress + ".gz"
              cpress = f"gzip -9 {fw_cpress}"
              cstate = shell(cpress)
              if cstate:
                  Logger.error("Cannot compress firmware: %s", fw_name)
                  return
  
          # Get size of fw
          size = Path(fw_file).stat().st_size
  
          # Request ota mode
          msg = '{"type": "ota", "value":"go", "size":' + str(size) + '}'
          await self.websocket.send(msg)
  
          # send file by chunks trough websocket
          await binary_send(self.websocket, fw_file)
function_tokens: async def _ota ( self ) : device_name = self . msg [ 'name' ] device_chip = self . msg [ 'chip' ] device_version = self . msg [ 'version' ] fw_version = '' fw_name = '' fw_device = '' for filename in listdir ( fw_path ) : fw_info = filename . split ( "-" ) fw_device = fw_info [ 0 ] if fw_device == device_name : fw_version = fw_info [ 1 ] fw_name = filename break if not fw_version : Logger . info ( "Client(%s): No fw found!" , device_name ) msg = '{"type": "ota", "value":"ok"}' await self . websocket . send ( msg ) return if not version_checker ( device_name , device_version , fw_version ) : return fw_file = join_pth ( fw_path , fw_name ) if device_chip == 'esp8266' and not fw_file . endswith ( '.gz' ) : # We can compress fw to make it smaller for upload fw_cpress = fw_file fw_file = fw_cpress + ".gz" cpress = f"gzip -9 {fw_cpress}" cstate = shell ( cpress ) if cstate : Logger . error ( "Cannot compress firmware: %s" , fw_name ) return # Get size of fw size = Path ( fw_file ) . stat ( ) . st_size # Request ota mode msg = '{"type": "ota", "value":"go", "size":' + str ( size ) + '}' await self . websocket . send ( msg ) # send file by chunks trough websocket await binary_send ( self . websocket , fw_file )