Reduced user facing output of random characters by moving to more use of logging library.

Moved version responses to CodiFunctions to be more inline with other functionality
This commit is contained in:
Adam Boardman 2020-12-18 16:29:14 +00:00
parent 7b53c5e705
commit 5ef2d5c294
9 changed files with 440 additions and 407 deletions

View file

@ -1,6 +1,9 @@
import sqlite3 import sqlite3
import CodiStatus import CodiStatus
import getpass import getpass
import logging
log = logging.getLogger('codi')
def contactNameForNumber(number): def contactNameForNumber(number):
for c in CodiStatus.Contacts: for c in CodiStatus.Contacts:
@ -47,4 +50,4 @@ def refreshContacts():
c.close() c.close()
conn.close() conn.close()
except Exception as e: except Exception as e:
print('Exception:', e) log.error("Exception: %r", e)

View file

@ -1,6 +1,7 @@
from datetime import datetime from datetime import datetime
import time import time
import os import os
import logging
import DBusServer import DBusServer
from gi.repository import GLib from gi.repository import GLib
import CodiStatus import CodiStatus
@ -11,6 +12,27 @@ import sqlite3
import getpass import getpass
tapHistory = False tapHistory = False
codi_version = None
resources_version = None
protocol_major = None
protocol_minor = None
log = logging.getLogger('codi')
def get_codi_version():
global codi_version
return codi_version
def get_resources_version():
global resources_version
return resources_version
def get_protocol_major():
global protocol_major
return protocol_major
def get_protocol_minor():
global protocol_minor
return protocol_minor
def datetime_from_utc_to_local(utc_datetime): def datetime_from_utc_to_local(utc_datetime):
now_timestamp = time.time() now_timestamp = time.time()
@ -88,20 +110,20 @@ def ActionCall(action, sim, line, numtype, msisdn, contact, contact_id):
'", "self", "' + \ '", "self", "' + \
datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.000Z') + \ datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.000Z') + \
'", 0, 4, 0, "' + msisdn + '")' '", 0, 4, 0, "' + msisdn + '")'
# print(statement) # log.info(statement)
c.execute(statement) c.execute(statement)
conn.commit() conn.commit()
c.close() c.close()
conn.close() conn.close()
except Exception as e: except Exception as e:
print('Exception:', e) log.error("Exception: %r", e)
if action == 14: if action == 14:
# print(dir(DBusServer.ril0['org.ofono.VoiceCallManager'])) # log.info(dir(DBusServer.ril0['org.ofono.VoiceCallManager']))
DBusServer.ril0['org.ofono.VoiceCallManager'].SwapCalls() DBusServer.ril0['org.ofono.VoiceCallManager'].SwapCalls()
# print(dir(CodiStatus.CallInfo.currentCall)) # log.info(dir(CodiStatus.CallInfo.currentCall))
except Exception as e: except Exception as e:
print(e) log.error(e)
@ -109,7 +131,7 @@ def SetCallMuteStatus(status):
try: try:
DBusServer.ril0['org.ofono.CallVolume'].SetProperty('Muted', GLib.Variant(value=status, format_string='b')) DBusServer.ril0['org.ofono.CallVolume'].SetProperty('Muted', GLib.Variant(value=status, format_string='b'))
except Exception as e: except Exception as e:
print(e) log.error(e)
def SendDTMF(sim, line, asciinum, palyit): def SendDTMF(sim, line, asciinum, palyit):
@ -126,7 +148,7 @@ def SendDTMF(sim, line, asciinum, palyit):
elif asciinum == 35: elif asciinum == 35:
DBusServer.ril0['org.ofono.VoiceCallManager'].SendTones('#') DBusServer.ril0['org.ofono.VoiceCallManager'].SendTones('#')
except Exception as e: except Exception as e:
print(e) log.error(e)
def SetCallOutput(status): def SetCallOutput(status):
try: try:
@ -135,7 +157,7 @@ def SetCallOutput(status):
elif status == 1: elif status == 1:
os.system('pactl set-sink-port 1 "output-speaker"') os.system('pactl set-sink-port 1 "output-speaker"')
except Exception as e: except Exception as e:
print(e) log.error(e)
def Restart(restartMode): def Restart(restartMode):
try: try:
@ -152,11 +174,23 @@ def Restart(restartMode):
mtkCmd.SetCoDiStatus(3, 3, 3) mtkCmd.SetCoDiStatus(3, 3, 3)
os.system('qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout 0 1 -1') os.system('qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout 0 1 -1')
except Exception as e: except Exception as e:
print(e) log.error(e)
# def SetVolumeLevel(status, stream): def CoDiFlashVersionInfo(version):
# # Not working global codi_version
# os.system('pactl set-sink-volume sink.primary') global resources_version
parts = version.split(b':')
if parts[0] == b'CODI' and len(parts[3]) > 0:
codi_version = parts[1].decode("utf-8")
resources_version = parts[2].decode("utf-8")
def ProtocolVersionInfo(majorVer, minVer):
global protocol_major
global protocol_minor
protocol_major = majorVer
protocol_minor = minVer
def CoDiOFF(par1, par2): def CoDiOFF(par1, par2):
if CodiStatus.CallInfo.state == 'disconnected': if CodiStatus.CallInfo.state == 'disconnected':
@ -173,7 +207,7 @@ def GetCallHistory(index):
c = conn.cursor() c = conn.cursor()
totalCdr = c.execute('select count(*) from voice_events').fetchall()[0][0] totalCdr = c.execute('select count(*) from voice_events').fetchall()[0][0]
except Exception as e: except Exception as e:
print('Exception:', e) log.error("Exception: %r", e)
totalCdr = 0 totalCdr = 0
try: try:
@ -189,13 +223,13 @@ def GetCallHistory(index):
try: try:
dt = datetime.strptime(history[i][4][0:19], '%Y-%m-%dT%H:%M:%S') dt = datetime.strptime(history[i][4][0:19], '%Y-%m-%dT%H:%M:%S')
dt = datetime_from_utc_to_local(dt) dt = datetime_from_utc_to_local(dt)
# print(history[i]) # log.info(history[i])
# print(i, totalCdr, batchSize, history[i][1], history[i][1], dt.day, dt.month, dt.year, dt.hour, dt.minute, dt.second, 0, state) # log.info(i, totalCdr, batchSize, history[i][1], history[i][1], dt.day, dt.month, dt.year, dt.hour, dt.minute, dt.second, 0, state)
mtkCmd.CallHistoryInfo(i, totalCdr, batchSize, Addressbook.contactNameForNumber(history[i][1]), history[i][1], dt.day, dt.month, dt.year, dt.hour, dt.minute, dt.second, 0, state) mtkCmd.CallHistoryInfo(i, totalCdr, batchSize, Addressbook.contactNameForNumber(history[i][1]), history[i][1], dt.day, dt.month, dt.year, dt.hour, dt.minute, dt.second, 0, state)
except Exception as e: except Exception as e:
print('Exception:', e) log.error("Exception: %r", e)
except Exception as e: except Exception as e:
print('Exception:', e) log.error("Exception: %r", e)
c.close() c.close()
conn.close() conn.close()
@ -234,7 +268,7 @@ def MouseInfo(mode, x_coord, y_coord):
# return # return
if x_coord < -200 or x_coord > 200 or y_coord < -200 or y_coord > 200: if x_coord < -200 or x_coord > 200 or y_coord < -200 or y_coord > 200:
print('Discarding...') log.info('Discarding...')
return return
mx = 0 mx = 0

View file

@ -1,3 +1,4 @@
import logging
import DBusServer import DBusServer
import CodiStatus import CodiStatus
import codi_mtk_generated_functions as mtkCmd import codi_mtk_generated_functions as mtkCmd
@ -6,6 +7,8 @@ import LEDManager
import subprocess import subprocess
import Addressbook import Addressbook
log = logging.getLogger('codi')
def init(): def init():
global CallInfo global CallInfo
global DeviceInfo global DeviceInfo
@ -14,14 +17,14 @@ def init():
def volumeButtonPressed(sender, name, value): def volumeButtonPressed(sender, name, value):
print('<=', sender, name, value) log.info('<= %r %r %r', sender, name, value)
if name == 'decrease_volume': if name == 'decrease_volume':
if CallInfo.state == 'incoming': if CallInfo.state == 'incoming':
try: try:
CallInfo.currentCall.Answer() CallInfo.currentCall.Answer()
except Exception as e: except Exception as e:
print(e) log.error(e)
else: else:
mtkCmd.KeyPressInfo(25, value, 0) mtkCmd.KeyPressInfo(25, value, 0)
if name == 'increase_volume': if name == 'increase_volume':
@ -29,12 +32,12 @@ def volumeButtonPressed(sender, name, value):
try: try:
CallInfo.currentCall.Hangup() CallInfo.currentCall.Hangup()
except Exception as e: except Exception as e:
print(e) log.error(e)
else: else:
mtkCmd.KeyPressInfo(24, value, 0) mtkCmd.KeyPressInfo(24, value, 0)
def propertiesChanged(sender, property, data): def propertiesChanged(sender, property, data):
print('<=', sender, property, data) log.info('<= %r %r %r', sender, property, data)
if 'LidIsClosed' in property.keys(): if 'LidIsClosed' in property.keys():
value = property['LidIsClosed'] value = property['LidIsClosed']
DeviceInfo.lidClosed = value DeviceInfo.lidClosed = value
@ -56,11 +59,11 @@ def propertiesChanged(sender, property, data):
LEDManager.ledsCharging(DBusServer.power.State == 1) LEDManager.ledsCharging(DBusServer.power.State == 1)
def networkPropertiesChanged(properties): def networkPropertiesChanged(properties):
print('<=', properties) log.info('<= %r', properties)
mtkCmd.WiFiStatusInfo(int(DBusServer.network.WirelessEnabled), 100) mtkCmd.WiFiStatusInfo(int(DBusServer.network.WirelessEnabled), 100)
def propertyChanged(property, value): def propertyChanged(property, value):
print('<=', property, value) log.info('<=', property, value)
# TODO: This does NOT work for some reason! # TODO: This does NOT work for some reason!
if property == 'Muted': if property == 'Muted':
mtkCmd.CallMuteStatusInfo(1) mtkCmd.CallMuteStatusInfo(1)
@ -79,7 +82,7 @@ def propertyChanged(property, value):
def callStatusChanged(sender, data=None): def callStatusChanged(sender, data=None):
print('<=', sender, data) log.info('<=', sender, data)
if data: if data:
CallInfo.currentCall = DBusServer.bus.get('org.ofono', sender) CallInfo.currentCall = DBusServer.bus.get('org.ofono', sender)
CallInfo.currentCall.onPropertyChanged = propertyChanged CallInfo.currentCall.onPropertyChanged = propertyChanged

View file

@ -2,8 +2,10 @@ import serial
import struct import struct
import threading import threading
import time import time
import logging
import codi_st32_generated_functions as st32Cmd import codi_st32_generated_functions as st32Cmd
log = logging.getLogger('codi')
isRunning = True isRunning = True
socket = None socket = None
thread = None thread = None
@ -18,7 +20,7 @@ def init():
thread = threading.Thread(target=readFromSerial) thread = threading.Thread(target=readFromSerial)
thread.start() thread.start()
except Exception as e: except Exception as e:
print(e) log.error(e)
def stop(): def stop():
global isRunning global isRunning
@ -32,7 +34,7 @@ def stop():
thread.join(4) thread.join(4)
def getSocket(): def get_socket():
global socket global socket
global isRunning global isRunning
global thread global thread
@ -52,7 +54,7 @@ def readFromSerial():
global isRunning global isRunning
msgHeader = bytes.fromhex('58 21 58 21') msgHeader = bytes.fromhex('58 21 58 21')
print('[115200]Listening...') log.info('[115200]Listening...')
while isRunning: while isRunning:
header = socket.read_until(msgHeader, size=300) header = socket.read_until(msgHeader, size=300)
# print('[115200]Found header', header) # print('[115200]Found header', header)
@ -66,7 +68,7 @@ def readFromSerial():
st32Cmd.readMessage(msg) st32Cmd.readMessage(msg)
else: else:
if isRunning: if isRunning:
print('[115200]Message length wrong, ignoring msg') log.error('[115200]Message length wrong, ignoring msg')
def sendCommand(cmd): def sendCommand(cmd):
@ -78,19 +80,19 @@ def sendCommand(cmd):
socket.write(cmd) socket.write(cmd)
lock.release() lock.release()
except Exception as e: except Exception as e:
print(e) log.error(e)
def uploadReadFromSerial(): def uploadReadFromSerial():
global socket global socket
global isRunning global isRunning
print('[230400]Listening...') log.info('[230400]Listening...')
while isRunning: while isRunning:
uploadResponse = socket.read() uploadResponse = socket.read()
if socket.in_waiting > 0: if socket.in_waiting > 0:
uploadResponse += socket.read(socket.in_waiting) uploadResponse += socket.read(socket.in_waiting)
print('[230400]Response', uploadResponse) log.debug('[230400]Response %r', uploadResponse)
def switchToUploadMode(): def switchToUploadMode():
@ -113,7 +115,7 @@ def switchToUploadMode():
isRunning = True isRunning = True
thread.start() thread.start()
except Exception as e: except Exception as e:
print(e) log.error(e)
def switchToCmdMode(): def switchToCmdMode():
@ -136,5 +138,5 @@ def switchToCmdMode():
isRunning = True isRunning = True
thread.start() thread.start()
except Exception as e: except Exception as e:
print(e) log.error(e)

View file

@ -13,14 +13,14 @@ def stm32_hardware_reset():
time.sleep(4) time.sleep(4)
def stm32_into_download_mode(prepare="0"): def stm32_out_of_download_mode():
print("STM32_DL_FW", prepare) print("Out of download mode")
with open('/proc/AEON_STM32_DL_FW', 'w') as f: with open('/proc/AEON_STM32_DL_FW', 'w') as f:
f.write(prepare) f.write("0")
lock = "/tmp/.codi.lock" lock = "/tmp/.codi.lock"
killed = lock_file.check_and_kill(lock) killed = lock_file.check_and_kill(lock)
lock_file.lock(lock) lock_file.lock(lock)
stm32_hardware_reset() stm32_hardware_reset()
stm32_into_download_mode() stm32_out_of_download_mode()

View file

@ -3,6 +3,7 @@ import argparse
import sys import sys
import time import time
from datetime import datetime from datetime import datetime
import logging
from gi.repository import GLib from gi.repository import GLib
import DBusServer import DBusServer

View file

@ -10,6 +10,9 @@ from xmodem import YMODEM
import codi_st32_generated_functions as st32Cmd import codi_st32_generated_functions as st32Cmd
import SerialPortManager import SerialPortManager
import lock_file import lock_file
import CodiFunctions as cf
log = logging.getLogger('codiUpdate')
ospi_url = None ospi_url = None
resources_url = None resources_url = None
@ -51,7 +54,6 @@ def check_new_fota_versions_available():
sendMessage(st32Cmd.CMD_MTK_GET_CODI_FLASH_VERSION) sendMessage(st32Cmd.CMD_MTK_GET_CODI_FLASH_VERSION)
sendMessage(st32Cmd.CMD_MTK_GET_PROTOCOL_VERSION) sendMessage(st32Cmd.CMD_MTK_GET_PROTOCOL_VERSION)
# download available versions - http://fota.planetcom.co.uk/stm32flash/cosmo_stm32_firmware_versions.txt # download available versions - http://fota.planetcom.co.uk/stm32flash/cosmo_stm32_firmware_versions.txt
base_url = None
newest_version = None newest_version = None
for line in urllib.request.urlopen("http://fota.planetcom.co.uk/stm32flash/cosmo_stm32_firmware_versions.txt"): for line in urllib.request.urlopen("http://fota.planetcom.co.uk/stm32flash/cosmo_stm32_firmware_versions.txt"):
firmware_line = line.decode('utf-8') firmware_line = line.decode('utf-8')
@ -70,45 +72,44 @@ def check_new_fota_versions_available():
resources_checksum = firmware_parts[7] resources_checksum = firmware_parts[7]
time.sleep(2) # Wait for CODI to reply time.sleep(2) # Wait for CODI to reply
print("CODI versions:", st32Cmd.get_codi_version(), st32Cmd.get_resources_version(), st32Cmd.get_protocol_major(), print("Current CODI versions:", cf.get_codi_version(), cf.get_resources_version(), cf.get_protocol_major(),
st32Cmd.get_protocol_minor()) cf.get_protocol_minor())
print("NewestVersion:", newest_version) print("Newest Server Version:", newest_version)
# print("BaseUrl:",base_url)
# print("OspiUrl:",base_url+'/'+ospi_url)
# print("ResourcesUrl:",base_url+'/'+resources_url)
if st32Cmd.get_codi_version() is not None and st32Cmd.get_resources_version() is not None: if cf.get_codi_version() is not None and cf.get_resources_version() is not None:
print(LooseVersion(newest_version) > LooseVersion(st32Cmd.get_codi_version().replace('V', '')), print(LooseVersion(newest_version) > LooseVersion(cf.get_codi_version().replace('V', '')),
LooseVersion(newest_version) > LooseVersion(st32Cmd.get_resources_version().replace('R', ''))) LooseVersion(newest_version) > LooseVersion(cf.get_resources_version().replace('R', '')))
return LooseVersion(newest_version) > LooseVersion(st32Cmd.get_codi_version().replace('V', '')) or \ return LooseVersion(newest_version) > LooseVersion(cf.get_codi_version().replace('V', '')) or \
LooseVersion(newest_version) > LooseVersion(st32Cmd.get_resources_version().replace('R', '')) LooseVersion(newest_version) > LooseVersion(cf.get_resources_version().replace('R', ''))
else: else:
return False return False
def stm32_hardware_reset(): def stm32_hardware_reset():
print("Reset STM32 1") print("Resetting CoDi")
with open('/proc/AEON_RESET_STM32', 'w') as f: with open('/proc/AEON_RESET_STM32', 'w') as f:
f.write("1") f.write("1")
time.sleep(1) time.sleep(1)
print("Reset STM32 0")
with open('/proc/AEON_RESET_STM32', 'w') as f: with open('/proc/AEON_RESET_STM32', 'w') as f:
f.write("0") f.write("0")
time.sleep(4) time.sleep(4)
print("Reset complete")
def stm32_into_download_mode(prepare="0"): def stm32_into_download_mode(prepare):
print("STM32_DL_FW", prepare) print("Into download mode, prepare:", prepare)
with open('/proc/AEON_STM32_DL_FW', 'w') as f: with open('/proc/AEON_STM32_DL_FW', 'w') as f:
f.write(prepare) if prepare:
f.write("1")
else:
f.write("0")
ser = None ser = None
def print_progress_bar (iteration, error_count, total): def print_progress_bar (iteration, error_count, total):
errors = "E:" + str(error_count) errors = "E:" + str(error_count)
length = int(os.popen('stty size', 'r').read().split()[1]) - len(errors) - 11 length = int(os.popen('stty size', 'r').read().split()[1]) - len(errors) - 11
percent = ("{0:.1f}").format(100 * (iteration / float(total))) percent = "{0:.1f}".format(100 * (iteration / float(total)))
filled_length = int(length * iteration // total) filled_length = int(length * iteration // total)
bar = '' * filled_length + '-' * (length - filled_length) bar = '' * filled_length + '-' * (length - filled_length)
print(f'\r |{bar}| {percent}% {errors}', end = "\r") print(f'\r |{bar}| {percent}% {errors}', end = "\r")
@ -124,28 +125,32 @@ def send_file(file):
print("Switch to upload") print("Switch to upload")
SerialPortManager.switchToUploadMode() SerialPortManager.switchToUploadMode()
time.sleep(1) time.sleep(1)
stm32_into_download_mode("1") stm32_into_download_mode(True)
time.sleep(4) time.sleep(4)
print("Sending 140 '0d oa' session 5 - requesting reset") log.info("Sending 140 '0d oa' session 5 - requesting reset")
sendMessage(140, [writeUint8(0x0d), writeUint8(0x0a)], '00 00 00 05') sendMessage(140, [writeUint8(0x0d), writeUint8(0x0a)], '00 00 00 05')
time.sleep(2) time.sleep(2)
stm32_hardware_reset() stm32_hardware_reset()
stm32_into_download_mode() stm32_into_download_mode(False)
print("Send Command 1") print("Send Command 1")
SerialPortManager.sendCommand(writeString("1")) SerialPortManager.sendCommand(writeString("1"))
time.sleep(1) time.sleep(1)
ser = SerialPortManager.getSocket() ser = SerialPortManager.get_socket()
modem = YMODEM(ser) modem = YMODEM(ser)
print("Sending", file) print("Sending", file)
print("Expect a few errors at 0% as the CoDi is erasing the flash, ~3 fw, ~15 res")
file_sent = False
try: try:
print("\r\nSend completed:", modem.send(file, callback=callback)) file_sent = modem.send(file, callback=callback)
print("\r\nSend completed:", file_sent)
except Exception as e: except Exception as e:
print("Exception", e) log.error(e)
SerialPortManager.switchToCmdMode() SerialPortManager.switchToCmdMode()
print("Finished") print("Finished")
return file_sent
parser = optparse.OptionParser(usage='%prog [filename]') parser = optparse.OptionParser(usage='%prog [filename]')
@ -163,22 +168,31 @@ killed = lock_file.check_and_kill(lock)
lock_file.lock(lock) lock_file.lock(lock)
SerialPortManager.init() SerialPortManager.init()
fileSent = False
if len(args) > 0: if len(args) > 0:
send_file(args[0]) fileSent = send_file(args[0])
if check_new_fota_versions_available():
print("")
print("Newer version available")
print("Please flash resources first")
print("R:",resources_url)
print("M:",ospi_url)
elif st32Cmd.get_codi_version() is not None:
print("Your all up to date - no new firmware")
else: else:
print("CODI Error getting existing version") print("")
versionAvailable = check_new_fota_versions_available()
if versionAvailable:
print("Newer version available, please download and flash as desired, suggest resources first")
print("R:",resources_url)
print("F:",ospi_url)
else:
if cf.get_codi_version() is None:
print("CODI Error getting existing version, a reset might help or a reflash may be needed")
if ospi_url is not None:
print("Server versions available")
print("R:",resources_url)
print("F:",ospi_url)
else:
print("Your all up to date - no new firmware")
print("Note firmware version numbers are early in the binary so a partial flash may still show as up to date")
SerialPortManager.stop() SerialPortManager.stop()
#if killed: if killed:
print("")
print("Please logout & in again to restart the CoDi server once you've done all needed flashing")
# print("Restarting codi server") # print("Restarting codi server")
# os.system("/usr/lib/codi/codiServer.py & disown") # os.system("/usr/lib/codi/codiServer.py & disown")

View file

@ -1,5 +1,6 @@
import struct import struct
import SerialPortManager import SerialPortManager
import logging
def writeUint8(p): def writeUint8(p):
return struct.pack(">B", p) return struct.pack(">B", p)
@ -175,230 +176,232 @@ CMD_SYNC_SYS_SLEEP_STATUS = 143
CMD_SYNC_RIGHT_USB_OTG_STATUS = 144 CMD_SYNC_RIGHT_USB_OTG_STATUS = 144
CMD_ST_ENTRY_DEEP_SLEEP_STATUS = 145 CMD_ST_ENTRY_DEEP_SLEEP_STATUS = 145
log = logging.getLogger('codi')
def GetFlashVersion(): def GetFlashVersion():
print("-> GetFlashVersion") log.info("-> GetFlashVersion")
sendMessage(CMD_MTK_GET_CODI_FLASH_VERSION) sendMessage(CMD_MTK_GET_CODI_FLASH_VERSION)
def DateTimeInfo(day, month, year, hour, minute, second, tz): def DateTimeInfo(day, month, year, hour, minute, second, tz):
print("-> DateTimeInfo") log.info("-> DateTimeInfo")
sendMessage(CMD_MTK_INFO_DATETIME, [writeUint32(day), writeUint32(month), writeUint32(year), writeUint32(hour), writeUint32(minute), writeUint32(second), writeUint32(tz)]) sendMessage(CMD_MTK_INFO_DATETIME, [writeUint32(day), writeUint32(month), writeUint32(year), writeUint32(hour), writeUint32(minute), writeUint32(second), writeUint32(tz)])
def LocationStatusInfo(status): def LocationStatusInfo(status):
print("-> LocationStatusInfo") log.info("-> LocationStatusInfo")
sendMessage(CMD_MTK_INFO_LOCATION_STATUS, [writeUint16(status)]) sendMessage(CMD_MTK_INFO_LOCATION_STATUS, [writeUint16(status)])
def TorchStatusInfo(status): def TorchStatusInfo(status):
print("-> TorchStatusInfo") log.info("-> TorchStatusInfo")
sendMessage(CMD_MTK_INFO_TORCH_STATUS, [writeUint16(status)]) sendMessage(CMD_MTK_INFO_TORCH_STATUS, [writeUint16(status)])
def CoverStatusInfo(status): def CoverStatusInfo(status):
print("-> CoverStatusInfo") log.info("-> CoverStatusInfo")
sendMessage(CMD_MTK_INFO_COVER_STATUS, [writeUint16(status)]) sendMessage(CMD_MTK_INFO_COVER_STATUS, [writeUint16(status)])
def WiFiStatusInfo(status, signalval): def WiFiStatusInfo(status, signalval):
print("-> WiFiStatusInfo") log.info("-> WiFiStatusInfo")
sendMessage(CMD_MTK_INFO_WIFI_STATUS, [writeUint16(status), writeUint32(signalval)]) sendMessage(CMD_MTK_INFO_WIFI_STATUS, [writeUint16(status), writeUint32(signalval)])
def BTStatusInfo(status): def BTStatusInfo(status):
print("-> BTStatusInfo") log.info("-> BTStatusInfo")
sendMessage(CMD_MTK_INFO_BT_STATUS, [writeUint16(status)]) sendMessage(CMD_MTK_INFO_BT_STATUS, [writeUint16(status)])
def BatterySaverStatusInfo(status): def BatterySaverStatusInfo(status):
print("-> BatterySaverStatusInfo") log.info("-> BatterySaverStatusInfo")
sendMessage(CMD_MTK_INFO_BATTERY_SAVER_STATUS, [writeUint16(status)]) sendMessage(CMD_MTK_INFO_BATTERY_SAVER_STATUS, [writeUint16(status)])
def FlightModeStatusInfo(status): def FlightModeStatusInfo(status):
print("-> FlightModeStatusInfo") log.info("-> FlightModeStatusInfo")
sendMessage(CMD_MTK_INFO_FLIGHT_MODE_STATUS, [writeUint16(status)]) sendMessage(CMD_MTK_INFO_FLIGHT_MODE_STATUS, [writeUint16(status)])
def HotspotStatusInfo(status): def HotspotStatusInfo(status):
print("-> HotspotStatusInfo") log.info("-> HotspotStatusInfo")
sendMessage(CMD_MTK_INFO_HOTSPOT_STATUS, [writeUint16(status)]) sendMessage(CMD_MTK_INFO_HOTSPOT_STATUS, [writeUint16(status)])
def MobileDataStatusInfo(status): def MobileDataStatusInfo(status):
print("-> MobileDataStatusInfo") log.info("-> MobileDataStatusInfo")
sendMessage(CMD_MTK_INFO_MOBILE_DATA_STATUS, [writeUint16(status)]) sendMessage(CMD_MTK_INFO_MOBILE_DATA_STATUS, [writeUint16(status)])
def DoNotDisturbStatusInfo(status): def DoNotDisturbStatusInfo(status):
print("-> DoNotDisturbStatusInfo") log.info("-> DoNotDisturbStatusInfo")
sendMessage(CMD_MTK_INFO_DND_STATUS, [writeUint16(status)]) sendMessage(CMD_MTK_INFO_DND_STATUS, [writeUint16(status)])
def VolumeLevelInfo(status, stream): def VolumeLevelInfo(status, stream):
print("-> VolumeLevelInfo") log.info("-> VolumeLevelInfo")
sendMessage(CMD_MTK_INFO_VOLUME_LEVEL, [writeUint16(status), writeUint16(stream)]) sendMessage(CMD_MTK_INFO_VOLUME_LEVEL, [writeUint16(status), writeUint16(stream)])
def BatteryLevelInfo(status): def BatteryLevelInfo(status):
print("-> BatteryLevelInfo") log.info("-> BatteryLevelInfo")
sendMessage(CMD_MTK_INFO_BATTERY_LEVEL, [writeUint16(status)]) sendMessage(CMD_MTK_INFO_BATTERY_LEVEL, [writeUint16(status)])
def SetCoDiStatus(mode, screen, data1): def SetCoDiStatus(mode, screen, data1):
print("-> SetCoDiStatus") log.info("-> SetCoDiStatus")
sendMessage(CMD_MTK_SET_CODI_STATUS, [writeUint32(mode), writeUint32(screen), writeUint32(data1)]) sendMessage(CMD_MTK_SET_CODI_STATUS, [writeUint32(mode), writeUint32(screen), writeUint32(data1)])
def LockStatusInfo(locked, method, strdata): def LockStatusInfo(locked, method, strdata):
print("-> LockStatusInfo") log.info("-> LockStatusInfo")
sendMessage(CMD_MTK_INFO_LOCK_STATUS, [writeUint16(locked), writeUint32(method), writeString(strdata)]) sendMessage(CMD_MTK_INFO_LOCK_STATUS, [writeUint16(locked), writeUint32(method), writeString(strdata)])
def CallMuteStatusInfo(status): def CallMuteStatusInfo(status):
print("-> CallMuteStatusInfo") log.info("-> CallMuteStatusInfo")
sendMessage(CMD_MTK_INFO_CALL_MUTE_STATUS, [writeUint32(status)]) sendMessage(CMD_MTK_INFO_CALL_MUTE_STATUS, [writeUint32(status)])
def CallOutputInfo(output): def CallOutputInfo(output):
print("-> CallOutputInfo") log.info("-> CallOutputInfo")
sendMessage(CMD_MTK_INFO_CALL_OUTPUT, [writeUint32(output)]) sendMessage(CMD_MTK_INFO_CALL_OUTPUT, [writeUint32(output)])
def CallOutputOptionsInfo(output_options): def CallOutputOptionsInfo(output_options):
print("-> CallOutputOptionsInfo") log.info("-> CallOutputOptionsInfo")
sendMessage(CMD_MTK_INFO_CALL_OUTPUT_OPTIONS, [writeUint32(output_options)]) sendMessage(CMD_MTK_INFO_CALL_OUTPUT_OPTIONS, [writeUint32(output_options)])
def CameraStatusInfo(status): def CameraStatusInfo(status):
print("-> CameraStatusInfo") log.info("-> CameraStatusInfo")
sendMessage(CMD_MTK_INFO_CAMERA_STATUS, [writeUint32(status)]) sendMessage(CMD_MTK_INFO_CAMERA_STATUS, [writeUint32(status)])
def CameraSettingsInfo(parameter, value): def CameraSettingsInfo(parameter, value):
print("-> CameraSettingsInfo") log.info("-> CameraSettingsInfo")
sendMessage(CMD_MTK_INFO_CAMERA_SETTINGS, [writeUint32(parameter), writeUint32(value)]) sendMessage(CMD_MTK_INFO_CAMERA_SETTINGS, [writeUint32(parameter), writeUint32(value)])
def VideoStatusInfo(status): def VideoStatusInfo(status):
print("-> VideoStatusInfo") log.info("-> VideoStatusInfo")
sendMessage(CMD_MTK_INFO_VIDEO_STATUS, [writeUint32(status)]) sendMessage(CMD_MTK_INFO_VIDEO_STATUS, [writeUint32(status)])
def VideoSettingsInfo(parameter, value): def VideoSettingsInfo(parameter, value):
print("-> VideoSettingsInfo") log.info("-> VideoSettingsInfo")
sendMessage(CMD_MTK_INFO_VIDEO_SETTINGS, [writeUint32(parameter), writeUint32(value)]) sendMessage(CMD_MTK_INFO_VIDEO_SETTINGS, [writeUint32(parameter), writeUint32(value)])
def CoverLightSensorInfo(value): def CoverLightSensorInfo(value):
print("-> CoverLightSensorInfo") log.info("-> CoverLightSensorInfo")
sendMessage(CMD_MTK_INFO_COVER_LIGHT_SENSOR, [writeUint32(value)]) sendMessage(CMD_MTK_INFO_COVER_LIGHT_SENSOR, [writeUint32(value)])
def LoadLanguageResource(langid, resname, resdata, forcereload): def LoadLanguageResource(langid, resname, resdata, forcereload):
print("-> LoadLanguageResource") log.info("-> LoadLanguageResource")
sendMessage(CMD_MTK_LOAD_LANGUAGE_RESOURCE, [writeString(langid), writeString(resname), writeBlob(resdata), writeUint32(forcereload)]) sendMessage(CMD_MTK_LOAD_LANGUAGE_RESOURCE, [writeString(langid), writeString(resname), writeBlob(resdata), writeUint32(forcereload)])
def GetCurrentLanguage(): def GetCurrentLanguage():
print("-> GetCurrentLanguage") log.info("-> GetCurrentLanguage")
sendMessage(CMD_MTK_GET_CURRENT_LANGUAGE) sendMessage(CMD_MTK_GET_CURRENT_LANGUAGE)
def SetCurrentLanguage(langid): def SetCurrentLanguage(langid):
print("-> SetCurrentLanguage") log.info("-> SetCurrentLanguage")
sendMessage(CMD_MTK_SET_CURRENT_LANGUAGE, [writeString(langid)]) sendMessage(CMD_MTK_SET_CURRENT_LANGUAGE, [writeString(langid)])
def ShowMedia(typestr, resname, seconds, speed, aftermode): def ShowMedia(typestr, resname, seconds, speed, aftermode):
print("-> ShowMedia") log.info("-> ShowMedia")
sendMessage(CMD_MTK_SHOW_MEDIA, [writeString(typestr), writeString(resname), writeUint32(seconds), writeUint32(speed), writeUint32(aftermode)]) sendMessage(CMD_MTK_SHOW_MEDIA, [writeString(typestr), writeString(resname), writeUint32(seconds), writeUint32(speed), writeUint32(aftermode)])
def StopMedia(typestr, resname, aftermode): def StopMedia(typestr, resname, aftermode):
print("-> StopMedia") log.info("-> StopMedia")
sendMessage(CMD_MTK_STOP_MEDIA, [writeString(typestr), writeString(resname), writeUint32(aftermode)]) sendMessage(CMD_MTK_STOP_MEDIA, [writeString(typestr), writeString(resname), writeUint32(aftermode)])
def LoadMedia(typestr, resname, resdata, loadmode): def LoadMedia(typestr, resname, resdata, loadmode):
print("-> LoadMedia") log.info("-> LoadMedia")
sendMessage(CMD_MTK_LOAD_MEDIA, [writeString(typestr), writeString(resname), writeBlob(resdata), writeUint32(loadmode)]) sendMessage(CMD_MTK_LOAD_MEDIA, [writeString(typestr), writeString(resname), writeBlob(resdata), writeUint32(loadmode)])
def UnloadMedia(typestr, resname): def UnloadMedia(typestr, resname):
print("-> UnloadMedia") log.info("-> UnloadMedia")
sendMessage(CMD_MTK_UNLOAD_MEDIA, [writeString(typestr), writeString(resname)]) sendMessage(CMD_MTK_UNLOAD_MEDIA, [writeString(typestr), writeString(resname)])
def HasMedia(typestr, resname): def HasMedia(typestr, resname):
print("-> HasMedia") log.info("-> HasMedia")
sendMessage(CMD_MTK_HAS_MEDIA, [writeString(typestr), writeString(resname)]) sendMessage(CMD_MTK_HAS_MEDIA, [writeString(typestr), writeString(resname)])
def ShowAlert(alertmode, alertype, alerticondata, typestr, resname, seconds, speed, aftermode, option1, option2): def ShowAlert(alertmode, alertype, alerticondata, typestr, resname, seconds, speed, aftermode, option1, option2):
print("-> ShowAlert") log.info("-> ShowAlert")
sendMessage(CMD_MTK_SHOW_ALERT, [writeUint32(alertmode), writeUint32(alertype), writeBlob(alerticondata), writeString(typestr), writeString(resname), writeUint32(seconds), writeUint32(speed), writeUint32(aftermode), writeUTF8String(option1), writeUTF8String(option2)]) sendMessage(CMD_MTK_SHOW_ALERT, [writeUint32(alertmode), writeUint32(alertype), writeBlob(alerticondata), writeString(typestr), writeString(resname), writeUint32(seconds), writeUint32(speed), writeUint32(aftermode), writeUTF8String(option1), writeUTF8String(option2)])
def StopAlert(aftermode): def StopAlert(aftermode):
print("-> StopAlert") log.info("-> StopAlert")
sendMessage(CMD_MTK_STOP_ALERT, [writeUint32(aftermode)]) sendMessage(CMD_MTK_STOP_ALERT, [writeUint32(aftermode)])
def OrientationInfo(value): def OrientationInfo(value):
print("-> OrientationInfo") log.info("-> OrientationInfo")
sendMessage(CMD_MTK_ORIENTATION_INFO, [writeUint32(value)]) sendMessage(CMD_MTK_ORIENTATION_INFO, [writeUint32(value)])
def ActionCoDiHome(screenoff): def ActionCoDiHome(screenoff):
print("-> ActionCoDiHome") log.info("-> ActionCoDiHome")
sendMessage(CMD_MTK_ACTION_CODI_HOME, [writeUint32(screenoff)]) sendMessage(CMD_MTK_ACTION_CODI_HOME, [writeUint32(screenoff)])
def NextAlarmInfo(appid, daystring, timestr): def NextAlarmInfo(appid, daystring, timestr):
print("-> NextAlarmInfo") log.info("-> NextAlarmInfo")
sendMessage(CMD_MTK_INFO_NEXT_ALARM, [writeUint32(appid), writeString(daystring), writeString(timestr)]) sendMessage(CMD_MTK_INFO_NEXT_ALARM, [writeUint32(appid), writeString(daystring), writeString(timestr)])
def ShowBatteryLevel(percentage, showforseconds): def ShowBatteryLevel(percentage, showforseconds):
print("-> ShowBatteryLevel") log.info("-> ShowBatteryLevel")
sendMessage(CMD_MTK_SHOW_BATTERY_LEVEL, [writeUint32(percentage), writeUint32(showforseconds)]) sendMessage(CMD_MTK_SHOW_BATTERY_LEVEL, [writeUint32(percentage), writeUint32(showforseconds)])
def ContactInfo(contactid, totalcontacts, batchsize, contactname, msisdn): def ContactInfo(contactid, totalcontacts, batchsize, contactname, msisdn):
print("-> ContactInfo") log.info("-> ContactInfo")
sendMessage(CMD_MTK_CONTACT_INFO, [writeString(contactid), writeUint32(totalcontacts), writeUint32(batchsize), writeUTF8String(contactname), writeString(msisdn)]) sendMessage(CMD_MTK_CONTACT_INFO, [writeString(contactid), writeUint32(totalcontacts), writeUint32(batchsize), writeUTF8String(contactname), writeString(msisdn)])
def CallHistoryInfo(cdrid, totalcdr, batchsize, contactname, msisdn, day, month, year, hour, minute, second, tz, state): def CallHistoryInfo(cdrid, totalcdr, batchsize, contactname, msisdn, day, month, year, hour, minute, second, tz, state):
print("-> CallHistoryInfo") log.info("-> CallHistoryInfo")
sendMessage(CMD_MTK_CALL_HISTORY_INFO, [writeUint32(cdrid), writeUint32(totalcdr), writeUint32(batchsize), writeUTF8String(contactname), writeString(msisdn), writeUint32(day), writeUint32(month), writeUint32(year), writeUint32(hour), writeUint32(minute), writeUint32(second), writeUint32(tz), writeUint32(state)]) sendMessage(CMD_MTK_CALL_HISTORY_INFO, [writeUint32(cdrid), writeUint32(totalcdr), writeUint32(batchsize), writeUTF8String(contactname), writeString(msisdn), writeUint32(day), writeUint32(month), writeUint32(year), writeUint32(hour), writeUint32(minute), writeUint32(second), writeUint32(tz), writeUint32(state)])
def NotificationInfo(notid, action, appname, shortinfo, longinfo, day, month, year, hour, minute, second, tz, replyactions, replyaction1, replyaction2, replyaction3): def NotificationInfo(notid, action, appname, shortinfo, longinfo, day, month, year, hour, minute, second, tz, replyactions, replyaction1, replyaction2, replyaction3):
print("-> NotificationInfo") log.info("-> NotificationInfo")
sendMessage(CMD_MTK_NOTIFICATION_INFO, [writeUint32(notid), writeUint32(action), writeUTF8String(appname), writeUTF8String(shortinfo), writeUTF8String(longinfo), writeUint32(day), writeUint32(month), writeUint32(year), writeUint32(hour), writeUint32(minute), writeUint32(second), writeUint32(tz), writeUint32(replyactions), writeUTF8String(replyaction1), writeUTF8String(replyaction2), writeUTF8String(replyaction3)]) sendMessage(CMD_MTK_NOTIFICATION_INFO, [writeUint32(notid), writeUint32(action), writeUTF8String(appname), writeUTF8String(shortinfo), writeUTF8String(longinfo), writeUint32(day), writeUint32(month), writeUint32(year), writeUint32(hour), writeUint32(minute), writeUint32(second), writeUint32(tz), writeUint32(replyactions), writeUTF8String(replyaction1), writeUTF8String(replyaction2), writeUTF8String(replyaction3)])
def PlayerInfo(appname, artist, album, track, offset, length, state, imageadr): def PlayerInfo(appname, artist, album, track, offset, length, state, imageadr):
print("-> PlayerInfo") log.info("-> PlayerInfo")
sendMessage(CMD_MTK_PLAYER_INFO, [writeUTF8String(appname), writeUTF8String(artist), writeUTF8String(album), writeUTF8String(track), writeUint32(offset), writeUint32(length), writeUint32(state), writeBlob(imageadr)]) sendMessage(CMD_MTK_PLAYER_INFO, [writeUTF8String(appname), writeUTF8String(artist), writeUTF8String(album), writeUTF8String(track), writeUint32(offset), writeUint32(length), writeUint32(state), writeBlob(imageadr)])
def CallInfo(modem, action, contactid, contactname, msisdn, hasicon): def CallInfo(modem, action, contactid, contactname, msisdn, hasicon):
print("-> CallInfo") log.info("-> CallInfo")
sendMessage(CMD_MTK_CALL_INFO, [writeUint32(modem), writeUint32(action), writeString(contactid), writeUTF8String(contactname), writeString(msisdn), writeUint32(hasicon)]) sendMessage(CMD_MTK_CALL_INFO, [writeUint32(modem), writeUint32(action), writeString(contactid), writeUTF8String(contactname), writeString(msisdn), writeUint32(hasicon)])
def LEDisonModeInfo(value): def LEDisonModeInfo(value):
print("-> LEDisonModeInfo") log.info("-> LEDisonModeInfo")
sendMessage(CMD_MTK_LEDISON_MODE_INFO, [writeUint32(value)]) sendMessage(CMD_MTK_LEDISON_MODE_INFO, [writeUint32(value)])
def LEDisonPatternInfo(animid, animname, animationdata): def LEDisonPatternInfo(animid, animname, animationdata):
print("-> LEDisonPatternInfo") log.info("-> LEDisonPatternInfo")
sendMessage(CMD_MTK_LEDISON_PATTERN_INFO, [writeUint32(animid), writeUTF8String(animname), writeBlob(animationdata)]) sendMessage(CMD_MTK_LEDISON_PATTERN_INFO, [writeUint32(animid), writeUTF8String(animname), writeBlob(animationdata)])
def ContactIconInfo(contactid, contactname, msisdn, icondata): def ContactIconInfo(contactid, contactname, msisdn, icondata):
print("-> ContactIconInfo") log.info("-> ContactIconInfo")
sendMessage(CMD_MTK_CONTACT_ICON_INFO, [writeString(contactid), writeUTF8String(contactname), writeString(msisdn), writeBlob(icondata)]) sendMessage(CMD_MTK_CONTACT_ICON_INFO, [writeString(contactid), writeUTF8String(contactname), writeString(msisdn), writeBlob(icondata)])
def ModemSignalInfo(sim1, sim2, sim2type): def ModemSignalInfo(sim1, sim2, sim2type):
print("-> ModemSignalInfo") log.info("-> ModemSignalInfo")
sendMessage(CMD_MTK_MODEM_SIGNAL_INFO, [writeUint32(sim1), writeUint32(sim2), writeUint32(sim2type)]) sendMessage(CMD_MTK_MODEM_SIGNAL_INFO, [writeUint32(sim1), writeUint32(sim2), writeUint32(sim2type)])
def WeatherInfo(weatherstate, temp, scale, additionaltext): def WeatherInfo(weatherstate, temp, scale, additionaltext):
print("-> WeatherInfo") log.info("-> WeatherInfo")
sendMessage(CMD_MTK_WEATHER_INFO, [writeUint32(weatherstate), writeUint32(temp), writeString(scale), writeString(additionaltext)]) sendMessage(CMD_MTK_WEATHER_INFO, [writeUint32(weatherstate), writeUint32(temp), writeString(scale), writeString(additionaltext)])
def ExtraCommand(data1, data2, str1, str2): def ExtraCommand(data1, data2, str1, str2):
print("-> ExtraCommand") log.info("-> ExtraCommand")
sendMessage(CMD_MTK_EXTRA_COMMAND, [writeUint32(data1), writeUint32(data2), writeString(str1), writeString(str2)]) sendMessage(CMD_MTK_EXTRA_COMMAND, [writeUint32(data1), writeUint32(data2), writeString(str1), writeString(str2)])
def DateTimeFormat(dateformat, timeformat): def DateTimeFormat(dateformat, timeformat):
print("-> DateTimeFormat") log.info("-> DateTimeFormat")
sendMessage(CMD_MTK_DATE_TIME_FORMAT_INFO, [writeString(dateformat), writeUint32(timeformat)]) sendMessage(CMD_MTK_DATE_TIME_FORMAT_INFO, [writeString(dateformat), writeUint32(timeformat)])
def AlbumArtInfo(albumartpng): def AlbumArtInfo(albumartpng):
print("-> AlbumArtInfo") log.info("-> AlbumArtInfo")
sendMessage(CMD_MTK_ALBUM_ART_INFO, [writeBlob(albumartpng)]) sendMessage(CMD_MTK_ALBUM_ART_INFO, [writeBlob(albumartpng)])
def CameraFrameImage(width, height, png): def CameraFrameImage(width, height, png):
print("-> CameraFrameImage") log.info("-> CameraFrameImage")
sendMessage(CMD_MTK_CAMERA_FRAME_IMG, [writeUint16(width), writeUint16(height), writeBlob(png)]) sendMessage(CMD_MTK_CAMERA_FRAME_IMG, [writeUint16(width), writeUint16(height), writeBlob(png)])
def KeyPressInfo(keycode, mode, modifiers): def KeyPressInfo(keycode, mode, modifiers):
print("-> KeyPressInfo") log.info("-> KeyPressInfo")
sendMessage(CMD_MTK_KEY_PRESS_INFO, [writeUint16(keycode), writeUint16(mode), writeUint16(modifiers)]) sendMessage(CMD_MTK_KEY_PRESS_INFO, [writeUint16(keycode), writeUint16(mode), writeUint16(modifiers)])
def VoiceRecorderSettingsInfo(parameter, value): def VoiceRecorderSettingsInfo(parameter, value):
print("-> VoiceRecorderSettingsInfo") log.info("-> VoiceRecorderSettingsInfo")
sendMessage(CMD_MTK_INFO_VOICE_RECODER_SETTINGS, [writeUint32(parameter), writeUint32(value)]) sendMessage(CMD_MTK_INFO_VOICE_RECODER_SETTINGS, [writeUint32(parameter), writeUint32(value)])
def VoiceRecorderStatusInfo(status): def VoiceRecorderStatusInfo(status):
print("-> VoiceRecorderStatusInfo") log.info("-> VoiceRecorderStatusInfo")
sendMessage(CMD_MTK_INFO_VOICE_RECORDER_STATUS, [writeUint32(status)]) sendMessage(CMD_MTK_INFO_VOICE_RECORDER_STATUS, [writeUint32(status)])
def MTKDataChangeAlert(type, data1): def MTKDataChangeAlert(type, data1):
print("-> MTKDataChangeAlert") log.info("-> MTKDataChangeAlert")
sendMessage(CMD_MTK_DATA_CHANGE_ALERT, [writeUint32(type), writeUint32(data1)]) sendMessage(CMD_MTK_DATA_CHANGE_ALERT, [writeUint32(type), writeUint32(data1)])
def SetMouse(onOff, absoluteOrRelative): def SetMouse(onOff, absoluteOrRelative):
print("-> SetMouse") log.info("-> SetMouse")
sendMessage(146, [writeUint8(onOff), writeUint8(absoluteOrRelative)]) sendMessage(146, [writeUint8(onOff), writeUint8(absoluteOrRelative)])

File diff suppressed because it is too large Load diff