@ -110,36 +110,52 @@ def gps_enabled() -> bool:
raise Exception ( " failed to execute QGPS mmcli command " ) from exc
raise Exception ( " failed to execute QGPS mmcli command " ) from exc
def download_and_inject_assistance ( ) :
def download_and_inject_assistance ( ) :
assist_data_file = ' /tmp/xtra3grc.bin '
assist_data_file = ' /tmp/xtra3grc.bin '
assistance_url = ' http://xtrapath3.izatcloud.net/xtra3grc.bin '
assistance_url = ' http://xtrapath3.izatcloud.net/xtra3grc.bin '
try :
try :
c = pycurl . Curl ( )
# download assistance
c . setopt ( c . URL , assistance_url )
try :
c . setopt ( c . NOBODY , 1 )
c . setopt ( pycurl . CONNECTTIMEOUT , 2 )
c . perform ( )
c . close ( )
bytes_n = c . getinfo ( c . CONTENT_LENGTH_DOWNLOAD )
if bytes_n > 1e5 :
cloudlog . exception ( " Qcom assistance data larger than expected " )
return
with open ( assist_data_file , " wb " ) as fp :
c = pycurl . Curl ( )
c = pycurl . Curl ( )
c . setopt ( pycurl . URL , assistance_url )
c . setopt ( c . URL , assistance_url )
c . setopt ( pycurl . CONNECTTIMEOUT , 5 )
c . setopt ( c . NOBODY , 1 )
c . setopt ( pycurl . CONNECTTIMEOUT , 2 )
c . setopt ( pycurl . WRITEDATA , fp )
c . perform ( )
c . perform ( )
bytes_n = c . getinfo ( c . CONTENT_LENGTH_DOWNLOAD )
c . close ( )
c . close ( )
except pycurl . error as e :
if bytes_n > 1e5 :
cloudlog . exception ( f ' Failed to download assistance file with error: { e } ' )
cloudlog . error ( " Qcom assistance data larger than expected " )
if os . path . isfile ( assist_data_file ) :
return
with open ( assist_data_file , ' wb ' ) as fp :
c = pycurl . Curl ( )
c . setopt ( pycurl . URL , assistance_url )
c . setopt ( pycurl . CONNECTTIMEOUT , 5 )
c . setopt ( pycurl . WRITEDATA , fp )
c . perform ( )
c . close ( )
except pycurl . error :
cloudlog . exception ( " Failed to download assistance file " )
return
# inject into module
try :
try :
subprocess . check_call ( f " mmcli -m any --timeout 30 --location-inject-assistance-data= { assist_data_file } " , shell = True )
cmd = f " mmcli -m any --timeout 30 --location-inject-assistance-data= { assist_data_file } "
except subprocess . CalledProcessError :
subprocess . check_output ( cmd , stderr = subprocess . PIPE , shell = True )
cloudlog . exception ( " rawgps.mmcli_command_failed " )
cloudlog . info ( " successfully loaded assistance data " )
if os . path . isfile ( assist_data_file ) :
except subprocess . CalledProcessError as e :
os . remove ( assist_data_file )
cloudlog . event (
" rawgps.assistance_loading_failed " ,
error = True ,
cmd = e . cmd ,
output = e . output ,
returncode = e . returncode
)
finally :
if os . path . exists ( assist_data_file ) :
os . remove ( assist_data_file )
def setup_quectel ( diag : ModemDiag ) :
def setup_quectel ( diag : ModemDiag ) :
# enable OEMDRE in the NV
# enable OEMDRE in the NV