diff --git a/codi-app/Addressbook.py b/codi-app/Addressbook.py index 837f978..67cf7d5 100644 --- a/codi-app/Addressbook.py +++ b/codi-app/Addressbook.py @@ -1,6 +1,9 @@ import sqlite3 import CodiStatus import getpass +import logging + +log = logging.getLogger('codi') def contactNameForNumber(number): for c in CodiStatus.Contacts: @@ -47,4 +50,4 @@ def refreshContacts(): c.close() conn.close() except Exception as e: - print('Exception:', e) + log.error("Exception: %r", e) diff --git a/codi-app/CodiFunctions.py b/codi-app/CodiFunctions.py index a62371d..cc28079 100644 --- a/codi-app/CodiFunctions.py +++ b/codi-app/CodiFunctions.py @@ -1,6 +1,7 @@ from datetime import datetime import time import os +import logging import DBusServer from gi.repository import GLib import CodiStatus @@ -11,6 +12,27 @@ import sqlite3 import getpass 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): now_timestamp = time.time() @@ -88,20 +110,20 @@ def ActionCall(action, sim, line, numtype, msisdn, contact, contact_id): '", "self", "' + \ datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.000Z') + \ '", 0, 4, 0, "' + msisdn + '")' - # print(statement) + # log.info(statement) c.execute(statement) conn.commit() c.close() conn.close() except Exception as e: - print('Exception:', e) + log.error("Exception: %r", e) if action == 14: - # print(dir(DBusServer.ril0['org.ofono.VoiceCallManager'])) + # log.info(dir(DBusServer.ril0['org.ofono.VoiceCallManager'])) DBusServer.ril0['org.ofono.VoiceCallManager'].SwapCalls() - # print(dir(CodiStatus.CallInfo.currentCall)) + # log.info(dir(CodiStatus.CallInfo.currentCall)) except Exception as e: - print(e) + log.error(e) @@ -109,7 +131,7 @@ def SetCallMuteStatus(status): try: DBusServer.ril0['org.ofono.CallVolume'].SetProperty('Muted', GLib.Variant(value=status, format_string='b')) except Exception as e: - print(e) + log.error(e) def SendDTMF(sim, line, asciinum, palyit): @@ -126,7 +148,7 @@ def SendDTMF(sim, line, asciinum, palyit): elif asciinum == 35: DBusServer.ril0['org.ofono.VoiceCallManager'].SendTones('#') except Exception as e: - print(e) + log.error(e) def SetCallOutput(status): try: @@ -135,7 +157,7 @@ def SetCallOutput(status): elif status == 1: os.system('pactl set-sink-port 1 "output-speaker"') except Exception as e: - print(e) + log.error(e) def Restart(restartMode): try: @@ -152,11 +174,23 @@ def Restart(restartMode): mtkCmd.SetCoDiStatus(3, 3, 3) os.system('qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout 0 1 -1') except Exception as e: - print(e) + log.error(e) -# def SetVolumeLevel(status, stream): -# # Not working -# os.system('pactl set-sink-volume sink.primary') +def CoDiFlashVersionInfo(version): + global codi_version + 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): if CodiStatus.CallInfo.state == 'disconnected': @@ -173,7 +207,7 @@ def GetCallHistory(index): c = conn.cursor() totalCdr = c.execute('select count(*) from voice_events').fetchall()[0][0] except Exception as e: - print('Exception:', e) + log.error("Exception: %r", e) totalCdr = 0 try: @@ -189,13 +223,13 @@ def GetCallHistory(index): try: dt = datetime.strptime(history[i][4][0:19], '%Y-%m-%dT%H:%M:%S') dt = datetime_from_utc_to_local(dt) - # print(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(history[i]) + # 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) except Exception as e: - print('Exception:', e) + log.error("Exception: %r", e) except Exception as e: - print('Exception:', e) + log.error("Exception: %r", e) c.close() conn.close() @@ -234,7 +268,7 @@ def MouseInfo(mode, x_coord, y_coord): # return if x_coord < -200 or x_coord > 200 or y_coord < -200 or y_coord > 200: - print('Discarding...') + log.info('Discarding...') return mx = 0 diff --git a/codi-app/PropertyManager.py b/codi-app/PropertyManager.py index d1aa9f2..f01da59 100644 --- a/codi-app/PropertyManager.py +++ b/codi-app/PropertyManager.py @@ -1,3 +1,4 @@ +import logging import DBusServer import CodiStatus import codi_mtk_generated_functions as mtkCmd @@ -6,6 +7,8 @@ import LEDManager import subprocess import Addressbook +log = logging.getLogger('codi') + def init(): global CallInfo global DeviceInfo @@ -14,14 +17,14 @@ def init(): def volumeButtonPressed(sender, name, value): - print('<=', sender, name, value) + log.info('<= %r %r %r', sender, name, value) if name == 'decrease_volume': if CallInfo.state == 'incoming': try: CallInfo.currentCall.Answer() except Exception as e: - print(e) + log.error(e) else: mtkCmd.KeyPressInfo(25, value, 0) if name == 'increase_volume': @@ -29,12 +32,12 @@ def volumeButtonPressed(sender, name, value): try: CallInfo.currentCall.Hangup() except Exception as e: - print(e) + log.error(e) else: mtkCmd.KeyPressInfo(24, value, 0) def propertiesChanged(sender, property, data): - print('<=', sender, property, data) + log.info('<= %r %r %r', sender, property, data) if 'LidIsClosed' in property.keys(): value = property['LidIsClosed'] DeviceInfo.lidClosed = value @@ -56,11 +59,11 @@ def propertiesChanged(sender, property, data): LEDManager.ledsCharging(DBusServer.power.State == 1) def networkPropertiesChanged(properties): - print('<=', properties) + log.info('<= %r', properties) mtkCmd.WiFiStatusInfo(int(DBusServer.network.WirelessEnabled), 100) def propertyChanged(property, value): - print('<=', property, value) + log.info('<=', property, value) # TODO: This does NOT work for some reason! if property == 'Muted': mtkCmd.CallMuteStatusInfo(1) @@ -79,7 +82,7 @@ def propertyChanged(property, value): def callStatusChanged(sender, data=None): - print('<=', sender, data) + log.info('<=', sender, data) if data: CallInfo.currentCall = DBusServer.bus.get('org.ofono', sender) CallInfo.currentCall.onPropertyChanged = propertyChanged diff --git a/codi-app/SerialPortManager.py b/codi-app/SerialPortManager.py index 22f362d..b7d7017 100644 --- a/codi-app/SerialPortManager.py +++ b/codi-app/SerialPortManager.py @@ -2,8 +2,10 @@ import serial import struct import threading import time +import logging import codi_st32_generated_functions as st32Cmd +log = logging.getLogger('codi') isRunning = True socket = None thread = None @@ -18,7 +20,7 @@ def init(): thread = threading.Thread(target=readFromSerial) thread.start() except Exception as e: - print(e) + log.error(e) def stop(): global isRunning @@ -32,7 +34,7 @@ def stop(): thread.join(4) -def getSocket(): +def get_socket(): global socket global isRunning global thread @@ -52,7 +54,7 @@ def readFromSerial(): global isRunning msgHeader = bytes.fromhex('58 21 58 21') - print('[115200]Listening...') + log.info('[115200]Listening...') while isRunning: header = socket.read_until(msgHeader, size=300) # print('[115200]Found header', header) @@ -66,7 +68,7 @@ def readFromSerial(): st32Cmd.readMessage(msg) else: if isRunning: - print('[115200]Message length wrong, ignoring msg') + log.error('[115200]Message length wrong, ignoring msg') def sendCommand(cmd): @@ -78,19 +80,19 @@ def sendCommand(cmd): socket.write(cmd) lock.release() except Exception as e: - print(e) + log.error(e) def uploadReadFromSerial(): global socket global isRunning - print('[230400]Listening...') + log.info('[230400]Listening...') while isRunning: uploadResponse = socket.read() if socket.in_waiting > 0: uploadResponse += socket.read(socket.in_waiting) - print('[230400]Response', uploadResponse) + log.debug('[230400]Response %r', uploadResponse) def switchToUploadMode(): @@ -113,7 +115,7 @@ def switchToUploadMode(): isRunning = True thread.start() except Exception as e: - print(e) + log.error(e) def switchToCmdMode(): @@ -136,5 +138,5 @@ def switchToCmdMode(): isRunning = True thread.start() except Exception as e: - print(e) + log.error(e) diff --git a/codi-app/codiReset.py b/codi-app/codiReset.py index dce2b52..11308b4 100755 --- a/codi-app/codiReset.py +++ b/codi-app/codiReset.py @@ -13,14 +13,14 @@ def stm32_hardware_reset(): time.sleep(4) -def stm32_into_download_mode(prepare="0"): - print("STM32_DL_FW", prepare) +def stm32_out_of_download_mode(): + print("Out of download mode") with open('/proc/AEON_STM32_DL_FW', 'w') as f: - f.write(prepare) + f.write("0") lock = "/tmp/.codi.lock" killed = lock_file.check_and_kill(lock) lock_file.lock(lock) stm32_hardware_reset() -stm32_into_download_mode() +stm32_out_of_download_mode() diff --git a/codi-app/codiServer.py b/codi-app/codiServer.py index 700a6a6..88a9494 100755 --- a/codi-app/codiServer.py +++ b/codi-app/codiServer.py @@ -3,6 +3,7 @@ import argparse import sys import time from datetime import datetime +import logging from gi.repository import GLib import DBusServer diff --git a/codi-app/codiUpdate.py b/codi-app/codiUpdate.py index a7e4efd..62a070b 100755 --- a/codi-app/codiUpdate.py +++ b/codi-app/codiUpdate.py @@ -10,6 +10,9 @@ from xmodem import YMODEM import codi_st32_generated_functions as st32Cmd import SerialPortManager import lock_file +import CodiFunctions as cf + +log = logging.getLogger('codiUpdate') ospi_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_PROTOCOL_VERSION) # download available versions - http://fota.planetcom.co.uk/stm32flash/cosmo_stm32_firmware_versions.txt - base_url = None newest_version = None for line in urllib.request.urlopen("http://fota.planetcom.co.uk/stm32flash/cosmo_stm32_firmware_versions.txt"): firmware_line = line.decode('utf-8') @@ -70,45 +72,44 @@ def check_new_fota_versions_available(): resources_checksum = firmware_parts[7] time.sleep(2) # Wait for CODI to reply - print("CODI versions:", st32Cmd.get_codi_version(), st32Cmd.get_resources_version(), st32Cmd.get_protocol_major(), - st32Cmd.get_protocol_minor()) - print("NewestVersion:", newest_version) - # print("BaseUrl:",base_url) - # print("OspiUrl:",base_url+'/'+ospi_url) - # print("ResourcesUrl:",base_url+'/'+resources_url) + print("Current CODI versions:", cf.get_codi_version(), cf.get_resources_version(), cf.get_protocol_major(), + cf.get_protocol_minor()) + print("Newest Server Version:", newest_version) - if st32Cmd.get_codi_version() is not None and st32Cmd.get_resources_version() is not None: - print(LooseVersion(newest_version) > LooseVersion(st32Cmd.get_codi_version().replace('V', '')), - LooseVersion(newest_version) > LooseVersion(st32Cmd.get_resources_version().replace('R', ''))) - return LooseVersion(newest_version) > LooseVersion(st32Cmd.get_codi_version().replace('V', '')) or \ - LooseVersion(newest_version) > LooseVersion(st32Cmd.get_resources_version().replace('R', '')) + if cf.get_codi_version() is not None and cf.get_resources_version() is not None: + print(LooseVersion(newest_version) > LooseVersion(cf.get_codi_version().replace('V', '')), + LooseVersion(newest_version) > LooseVersion(cf.get_resources_version().replace('R', ''))) + return LooseVersion(newest_version) > LooseVersion(cf.get_codi_version().replace('V', '')) or \ + LooseVersion(newest_version) > LooseVersion(cf.get_resources_version().replace('R', '')) else: return False def stm32_hardware_reset(): - print("Reset STM32 1") + print("Resetting CoDi") with open('/proc/AEON_RESET_STM32', 'w') as f: f.write("1") time.sleep(1) - print("Reset STM32 0") with open('/proc/AEON_RESET_STM32', 'w') as f: f.write("0") time.sleep(4) + print("Reset complete") -def stm32_into_download_mode(prepare="0"): - print("STM32_DL_FW", prepare) +def stm32_into_download_mode(prepare): + print("Into download mode, prepare:", prepare) with open('/proc/AEON_STM32_DL_FW', 'w') as f: - f.write(prepare) - + if prepare: + f.write("1") + else: + f.write("0") ser = None def print_progress_bar (iteration, error_count, total): errors = "E:" + str(error_count) 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) bar = '█' * filled_length + '-' * (length - filled_length) print(f'\r |{bar}| {percent}% {errors}', end = "\r") @@ -124,28 +125,32 @@ def send_file(file): print("Switch to upload") SerialPortManager.switchToUploadMode() time.sleep(1) - stm32_into_download_mode("1") + stm32_into_download_mode(True) 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') time.sleep(2) stm32_hardware_reset() - stm32_into_download_mode() + stm32_into_download_mode(False) print("Send Command 1") SerialPortManager.sendCommand(writeString("1")) time.sleep(1) - ser = SerialPortManager.getSocket() + ser = SerialPortManager.get_socket() modem = YMODEM(ser) 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: - 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: - print("Exception", e) + log.error(e) SerialPortManager.switchToCmdMode() print("Finished") + return file_sent parser = optparse.OptionParser(usage='%prog [filename]') @@ -163,22 +168,31 @@ killed = lock_file.check_and_kill(lock) lock_file.lock(lock) SerialPortManager.init() +fileSent = False if len(args) > 0: - 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") + fileSent = send_file(args[0]) 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() -#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") # os.system("/usr/lib/codi/codiServer.py & disown") diff --git a/codi-app/codi_mtk_generated_functions.py b/codi-app/codi_mtk_generated_functions.py index 59caf6d..cdde725 100644 --- a/codi-app/codi_mtk_generated_functions.py +++ b/codi-app/codi_mtk_generated_functions.py @@ -1,5 +1,6 @@ import struct import SerialPortManager +import logging def writeUint8(p): return struct.pack(">B", p) @@ -175,230 +176,232 @@ CMD_SYNC_SYS_SLEEP_STATUS = 143 CMD_SYNC_RIGHT_USB_OTG_STATUS = 144 CMD_ST_ENTRY_DEEP_SLEEP_STATUS = 145 +log = logging.getLogger('codi') + def GetFlashVersion(): - print("-> GetFlashVersion") + log.info("-> GetFlashVersion") sendMessage(CMD_MTK_GET_CODI_FLASH_VERSION) 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)]) def LocationStatusInfo(status): - print("-> LocationStatusInfo") + log.info("-> LocationStatusInfo") sendMessage(CMD_MTK_INFO_LOCATION_STATUS, [writeUint16(status)]) def TorchStatusInfo(status): - print("-> TorchStatusInfo") + log.info("-> TorchStatusInfo") sendMessage(CMD_MTK_INFO_TORCH_STATUS, [writeUint16(status)]) def CoverStatusInfo(status): - print("-> CoverStatusInfo") + log.info("-> CoverStatusInfo") sendMessage(CMD_MTK_INFO_COVER_STATUS, [writeUint16(status)]) def WiFiStatusInfo(status, signalval): - print("-> WiFiStatusInfo") + log.info("-> WiFiStatusInfo") sendMessage(CMD_MTK_INFO_WIFI_STATUS, [writeUint16(status), writeUint32(signalval)]) def BTStatusInfo(status): - print("-> BTStatusInfo") + log.info("-> BTStatusInfo") sendMessage(CMD_MTK_INFO_BT_STATUS, [writeUint16(status)]) def BatterySaverStatusInfo(status): - print("-> BatterySaverStatusInfo") + log.info("-> BatterySaverStatusInfo") sendMessage(CMD_MTK_INFO_BATTERY_SAVER_STATUS, [writeUint16(status)]) def FlightModeStatusInfo(status): - print("-> FlightModeStatusInfo") + log.info("-> FlightModeStatusInfo") sendMessage(CMD_MTK_INFO_FLIGHT_MODE_STATUS, [writeUint16(status)]) def HotspotStatusInfo(status): - print("-> HotspotStatusInfo") + log.info("-> HotspotStatusInfo") sendMessage(CMD_MTK_INFO_HOTSPOT_STATUS, [writeUint16(status)]) def MobileDataStatusInfo(status): - print("-> MobileDataStatusInfo") + log.info("-> MobileDataStatusInfo") sendMessage(CMD_MTK_INFO_MOBILE_DATA_STATUS, [writeUint16(status)]) def DoNotDisturbStatusInfo(status): - print("-> DoNotDisturbStatusInfo") + log.info("-> DoNotDisturbStatusInfo") sendMessage(CMD_MTK_INFO_DND_STATUS, [writeUint16(status)]) def VolumeLevelInfo(status, stream): - print("-> VolumeLevelInfo") + log.info("-> VolumeLevelInfo") sendMessage(CMD_MTK_INFO_VOLUME_LEVEL, [writeUint16(status), writeUint16(stream)]) def BatteryLevelInfo(status): - print("-> BatteryLevelInfo") + log.info("-> BatteryLevelInfo") sendMessage(CMD_MTK_INFO_BATTERY_LEVEL, [writeUint16(status)]) def SetCoDiStatus(mode, screen, data1): - print("-> SetCoDiStatus") + log.info("-> SetCoDiStatus") sendMessage(CMD_MTK_SET_CODI_STATUS, [writeUint32(mode), writeUint32(screen), writeUint32(data1)]) def LockStatusInfo(locked, method, strdata): - print("-> LockStatusInfo") + log.info("-> LockStatusInfo") sendMessage(CMD_MTK_INFO_LOCK_STATUS, [writeUint16(locked), writeUint32(method), writeString(strdata)]) def CallMuteStatusInfo(status): - print("-> CallMuteStatusInfo") + log.info("-> CallMuteStatusInfo") sendMessage(CMD_MTK_INFO_CALL_MUTE_STATUS, [writeUint32(status)]) def CallOutputInfo(output): - print("-> CallOutputInfo") + log.info("-> CallOutputInfo") sendMessage(CMD_MTK_INFO_CALL_OUTPUT, [writeUint32(output)]) def CallOutputOptionsInfo(output_options): - print("-> CallOutputOptionsInfo") + log.info("-> CallOutputOptionsInfo") sendMessage(CMD_MTK_INFO_CALL_OUTPUT_OPTIONS, [writeUint32(output_options)]) def CameraStatusInfo(status): - print("-> CameraStatusInfo") + log.info("-> CameraStatusInfo") sendMessage(CMD_MTK_INFO_CAMERA_STATUS, [writeUint32(status)]) def CameraSettingsInfo(parameter, value): - print("-> CameraSettingsInfo") + log.info("-> CameraSettingsInfo") sendMessage(CMD_MTK_INFO_CAMERA_SETTINGS, [writeUint32(parameter), writeUint32(value)]) def VideoStatusInfo(status): - print("-> VideoStatusInfo") + log.info("-> VideoStatusInfo") sendMessage(CMD_MTK_INFO_VIDEO_STATUS, [writeUint32(status)]) def VideoSettingsInfo(parameter, value): - print("-> VideoSettingsInfo") + log.info("-> VideoSettingsInfo") sendMessage(CMD_MTK_INFO_VIDEO_SETTINGS, [writeUint32(parameter), writeUint32(value)]) def CoverLightSensorInfo(value): - print("-> CoverLightSensorInfo") + log.info("-> CoverLightSensorInfo") sendMessage(CMD_MTK_INFO_COVER_LIGHT_SENSOR, [writeUint32(value)]) 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)]) def GetCurrentLanguage(): - print("-> GetCurrentLanguage") + log.info("-> GetCurrentLanguage") sendMessage(CMD_MTK_GET_CURRENT_LANGUAGE) def SetCurrentLanguage(langid): - print("-> SetCurrentLanguage") + log.info("-> SetCurrentLanguage") sendMessage(CMD_MTK_SET_CURRENT_LANGUAGE, [writeString(langid)]) 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)]) def StopMedia(typestr, resname, aftermode): - print("-> StopMedia") + log.info("-> StopMedia") sendMessage(CMD_MTK_STOP_MEDIA, [writeString(typestr), writeString(resname), writeUint32(aftermode)]) def LoadMedia(typestr, resname, resdata, loadmode): - print("-> LoadMedia") + log.info("-> LoadMedia") sendMessage(CMD_MTK_LOAD_MEDIA, [writeString(typestr), writeString(resname), writeBlob(resdata), writeUint32(loadmode)]) def UnloadMedia(typestr, resname): - print("-> UnloadMedia") + log.info("-> UnloadMedia") sendMessage(CMD_MTK_UNLOAD_MEDIA, [writeString(typestr), writeString(resname)]) def HasMedia(typestr, resname): - print("-> HasMedia") + log.info("-> HasMedia") sendMessage(CMD_MTK_HAS_MEDIA, [writeString(typestr), writeString(resname)]) 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)]) def StopAlert(aftermode): - print("-> StopAlert") + log.info("-> StopAlert") sendMessage(CMD_MTK_STOP_ALERT, [writeUint32(aftermode)]) def OrientationInfo(value): - print("-> OrientationInfo") + log.info("-> OrientationInfo") sendMessage(CMD_MTK_ORIENTATION_INFO, [writeUint32(value)]) def ActionCoDiHome(screenoff): - print("-> ActionCoDiHome") + log.info("-> ActionCoDiHome") sendMessage(CMD_MTK_ACTION_CODI_HOME, [writeUint32(screenoff)]) def NextAlarmInfo(appid, daystring, timestr): - print("-> NextAlarmInfo") + log.info("-> NextAlarmInfo") sendMessage(CMD_MTK_INFO_NEXT_ALARM, [writeUint32(appid), writeString(daystring), writeString(timestr)]) def ShowBatteryLevel(percentage, showforseconds): - print("-> ShowBatteryLevel") + log.info("-> ShowBatteryLevel") sendMessage(CMD_MTK_SHOW_BATTERY_LEVEL, [writeUint32(percentage), writeUint32(showforseconds)]) 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)]) 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)]) 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)]) 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)]) 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)]) def LEDisonModeInfo(value): - print("-> LEDisonModeInfo") + log.info("-> LEDisonModeInfo") sendMessage(CMD_MTK_LEDISON_MODE_INFO, [writeUint32(value)]) def LEDisonPatternInfo(animid, animname, animationdata): - print("-> LEDisonPatternInfo") + log.info("-> LEDisonPatternInfo") sendMessage(CMD_MTK_LEDISON_PATTERN_INFO, [writeUint32(animid), writeUTF8String(animname), writeBlob(animationdata)]) 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)]) def ModemSignalInfo(sim1, sim2, sim2type): - print("-> ModemSignalInfo") + log.info("-> ModemSignalInfo") sendMessage(CMD_MTK_MODEM_SIGNAL_INFO, [writeUint32(sim1), writeUint32(sim2), writeUint32(sim2type)]) def WeatherInfo(weatherstate, temp, scale, additionaltext): - print("-> WeatherInfo") + log.info("-> WeatherInfo") sendMessage(CMD_MTK_WEATHER_INFO, [writeUint32(weatherstate), writeUint32(temp), writeString(scale), writeString(additionaltext)]) def ExtraCommand(data1, data2, str1, str2): - print("-> ExtraCommand") + log.info("-> ExtraCommand") sendMessage(CMD_MTK_EXTRA_COMMAND, [writeUint32(data1), writeUint32(data2), writeString(str1), writeString(str2)]) def DateTimeFormat(dateformat, timeformat): - print("-> DateTimeFormat") + log.info("-> DateTimeFormat") sendMessage(CMD_MTK_DATE_TIME_FORMAT_INFO, [writeString(dateformat), writeUint32(timeformat)]) def AlbumArtInfo(albumartpng): - print("-> AlbumArtInfo") + log.info("-> AlbumArtInfo") sendMessage(CMD_MTK_ALBUM_ART_INFO, [writeBlob(albumartpng)]) def CameraFrameImage(width, height, png): - print("-> CameraFrameImage") + log.info("-> CameraFrameImage") sendMessage(CMD_MTK_CAMERA_FRAME_IMG, [writeUint16(width), writeUint16(height), writeBlob(png)]) def KeyPressInfo(keycode, mode, modifiers): - print("-> KeyPressInfo") + log.info("-> KeyPressInfo") sendMessage(CMD_MTK_KEY_PRESS_INFO, [writeUint16(keycode), writeUint16(mode), writeUint16(modifiers)]) def VoiceRecorderSettingsInfo(parameter, value): - print("-> VoiceRecorderSettingsInfo") + log.info("-> VoiceRecorderSettingsInfo") sendMessage(CMD_MTK_INFO_VOICE_RECODER_SETTINGS, [writeUint32(parameter), writeUint32(value)]) def VoiceRecorderStatusInfo(status): - print("-> VoiceRecorderStatusInfo") + log.info("-> VoiceRecorderStatusInfo") sendMessage(CMD_MTK_INFO_VOICE_RECORDER_STATUS, [writeUint32(status)]) def MTKDataChangeAlert(type, data1): - print("-> MTKDataChangeAlert") + log.info("-> MTKDataChangeAlert") sendMessage(CMD_MTK_DATA_CHANGE_ALERT, [writeUint32(type), writeUint32(data1)]) def SetMouse(onOff, absoluteOrRelative): - print("-> SetMouse") + log.info("-> SetMouse") sendMessage(146, [writeUint8(onOff), writeUint8(absoluteOrRelative)]) diff --git a/codi-app/codi_st32_generated_functions.py b/codi-app/codi_st32_generated_functions.py index e0666f8..db61c74 100644 --- a/codi-app/codi_st32_generated_functions.py +++ b/codi-app/codi_st32_generated_functions.py @@ -1,27 +1,7 @@ import struct +import logging import CodiFunctions as cf -codi_version = None -resources_version = None -majorVer = None -minVer = None - -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 majorVer - return majorVer - -def get_protocol_minor(): - global minVer - return minVer - def readUint8(p): return struct.unpack(">B", p[:1])[0], p[1:] @@ -45,7 +25,7 @@ def readString(p): if len(np) >= s: return np[:s], np[s:] else: - print('Error reading string', s, '>', len(np)) + log.error('Error reading string %r%r%r', s, '>', len(np)) return '', p def readUTF8String(p): @@ -188,382 +168,375 @@ CMD_SYNC_SYS_SLEEP_STATUS = 143 CMD_SYNC_RIGHT_USB_OTG_STATUS = 144 CMD_ST_ENTRY_DEEP_SLEEP_STATUS = 145 -def readMessage(msg): - global codi_version - global resources_version - global protocol_major - global protocol_minor +log = logging.getLogger('codi') +def readMessage(msg): cmdId, msg = readUint32(msg) - # print("Got cmdId", cmdId) + # log.info("Got cmdId %r", cmdId) sessionId, msg = readUint32(msg) - # print("Got sessionId", sessionId) + # log.info("Got sessionId %r", sessionId) handled = False if cmdId == CMD_ST32_INFO_CODI_FLASH_VERSION: handled = True - print("<- CoDiFlashVersionInfo") + log.info("<- CoDiFlashVersionInfo") try: version, msg = readString(msg) - print("version =", 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") + log.info("version = %r", version) cf.CoDiFlashVersionInfo(version) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_INFO_PROTOCOL_VERSION: handled = True - print("<- ProtocolVersionInfo") + log.info("<- ProtocolVersionInfo") try: majorVer, msg = readUint8(msg) minVer, msg = readUint8(msg) - print("majorVer =", majorVer) - print("minVer =", minVer) + log.info("majorVer = %r", majorVer) + log.info("minVer = %r", minVer) cf.ProtocolVersionInfo(majorVer, minVer) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_BINARY: handled = True - print("<- SetBinary") + log.info("<- SetBinary") try: data, msg = readBlob(msg) - print("data =", data) + log.info("data = %r", data) cf.SetBinary(data) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_S8: handled = True - print("<- SetSigned8") + log.info("<- SetSigned8") try: num, msg = readInt8(msg) - print("num =", num) + log.info("num = %r", num) cf.SetSigned8(num) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_RESTART: handled = True - print("<- Restart") + log.info("<- Restart") try: restartmode, msg = readUint32(msg) - print("restartmode =", restartmode) + log.info("restartmode = %r", restartmode) cf.Restart(restartmode) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_DATETIME: handled = True - print("<- GetDateTime") + log.info("<- GetDateTime") try: cf.GetDateTime() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_LOCATION_STATUS: handled = True - print("<- SetLocationStatus") + log.info("<- SetLocationStatus") try: status, msg = readUint16(msg) - print("status =", status) + log.info("status = %r", status) cf.SetLocationStatus(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_LOCATION_STATUS: handled = True - print("<- GetLocationStatus") + log.info("<- GetLocationStatus") try: cf.GetLocationStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_TORCH_STATUS: handled = True - print("<- SetTorchStatus") + log.info("<- SetTorchStatus") try: status, msg = readUint16(msg) - print("status =", status) + log.info("status = %r", status) cf.SetTorchStatus(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_TORCH_STATUS: handled = True - print("<- GetTorchStatus") + log.info("<- GetTorchStatus") try: cf.GetTorchStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_COVER_STATUS: handled = True - print("<- GetCoverStatus") + log.info("<- GetCoverStatus") try: cf.GetCoverStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_WIFI_STATUS: handled = True - print("<- SetWiFiStatus") + log.info("<- SetWiFiStatus") try: status, msg = readUint16(msg) - print("status =", status) + log.info("status = %r", status) cf.SetWiFiStatus(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_WIFI_STATUS: handled = True - print("<- GetWiFiStatus") + log.info("<- GetWiFiStatus") try: cf.GetWiFiStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_BT_STATUS: handled = True - print("<- SetBTStatus") + log.info("<- SetBTStatus") try: status, msg = readUint16(msg) - print("status =", status) + log.info("status = %r", status) cf.SetBTStatus(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_BT_STATUS: handled = True - print("<- GetBTStatus") + log.info("<- GetBTStatus") try: cf.GetBTStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_BATTERY_SAVER_STATUS: handled = True - print("<- SetBatterySaverStatus") + log.info("<- SetBatterySaverStatus") try: status, msg = readUint16(msg) - print("status =", status) + log.info("status = %r", status) cf.SetBatterySaverStatus(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_BATTERY_SAVER_STATUS: handled = True - print("<- GetBatterySaverStatus") + log.info("<- GetBatterySaverStatus") try: cf.GetBatterySaverStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_FLIGHT_MODE_STATUS: handled = True - print("<- SetFlightModeStatus") + log.info("<- SetFlightModeStatus") try: status, msg = readUint16(msg) - print("status =", status) + log.info("status = %r", status) cf.SetFlightModeStatus(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_FLIGHT_MODE_STATUS: handled = True - print("<- GetFlightModeStatus") + log.info("<- GetFlightModeStatus") try: cf.GetFlightModeStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_HOTSPOT_STATUS: handled = True - print("<- SetHotspotStatus") + log.info("<- SetHotspotStatus") try: status, msg = readUint16(msg) - print("status =", status) + log.info("status = %r", status) cf.SetHotspotStatus(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_HOTSPOT_STATUS: handled = True - print("<- GetHotspotStatus") + log.info("<- GetHotspotStatus") try: cf.GetHotspotStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_MOBILE_DATA_STATUS: handled = True - print("<- SetMobileDataStatus") + log.info("<- SetMobileDataStatus") try: status, msg = readUint16(msg) - print("status =", status) + log.info("status = %r", status) cf.SetMobileDataStatus(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_MOBILE_DATA_STATUS: handled = True - print("<- GetMobileDataStatus") + log.info("<- GetMobileDataStatus") try: cf.GetMobileDataStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_DND_STATUS: handled = True - print("<- SetDoNotDisturbStatus") + log.info("<- SetDoNotDisturbStatus") try: status, msg = readUint16(msg) - print("status =", status) + log.info("status = %r", status) cf.SetDoNotDisturbStatus(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_DND_STATUS: handled = True - print("<- GetDoNotDisturbStatus") + log.info("<- GetDoNotDisturbStatus") try: cf.GetDoNotDisturbStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_VOLUME_LEVEL: handled = True - print("<- SetVolumeLevel") + log.info("<- SetVolumeLevel") try: status, msg = readUint16(msg) stream, msg = readUint16(msg) - print("status =", status) - print("stream =", stream) + log.info("status = %r", status) + log.info("stream = %r", stream) cf.SetVolumeLevel(status, stream) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_VOLUME_LEVEL: handled = True - print("<- GetVolumeLevel") + log.info("<- GetVolumeLevel") try: stream, msg = readUint16(msg) - print("stream =", stream) + log.info("stream = %r", stream) cf.GetVolumeLevel(stream) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_BATTERY_LEVEL: handled = True - print("<- GetBatteryLevel") + log.info("<- GetBatteryLevel") try: cf.GetBatteryLevel() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_INFO_CODI_STATUS: handled = True - print("<- CoDiStatusInfo") + log.info("<- CoDiStatusInfo") try: mode, msg = readUint32(msg) screen, msg = readUint32(msg) data1, msg = readUint32(msg) - print("mode =", mode) - print("screen =", screen) - print("data1 =", data1) + log.info("mode =", mode) + log.info("screen =", screen) + log.info("data1 =", data1) cf.CoDiStatusInfo(mode, screen, data1) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_LOCK: handled = True - print("<- SetLock") + log.info("<- SetLock") try: status, msg = readUint16(msg) - print("status =", status) + log.info("status =", status) cf.SetLock(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_LOCK_STATUS: handled = True - print("<- GetLockStatus") + log.info("<- GetLockStatus") try: cf.GetLockStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_DISMISS_CALL_SMS: handled = True - print("<- DismissCallSMS") + log.info("<- DismissCallSMS") try: sim, msg = readUint32(msg) line, msg = readUint32(msg) msisdn, msg = readString(msg) text, msg = readUTF8String(msg) - print("sim =", sim) - print("line =", line) - print("msisdn =", msisdn) - print("text =", text) + log.info("sim =", sim) + log.info("line =", line) + log.info("msisdn =", msisdn) + log.info("text =", text) cf.DismissCallSMS(sim, line, msisdn, text) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_ACTION_UNLOCK: handled = True - print("<- ActionUnlock") + log.info("<- ActionUnlock") try: method, msg = readUint32(msg) strdata, msg = readString(msg) - print("method =", method) - print("strdata =", strdata) + log.info("method =", method) + log.info("strdata =", strdata) cf.ActionUnlock(method, strdata) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_INFO_ST_CHARGING: handled = True - print("<- STChargingInfo") + log.info("<- STChargingInfo") try: status, msg = readUint32(msg) measurement, msg = readUint32(msg) - print("status =", status) - print("measurement =", measurement) + log.info("status =", status) + log.info("measurement =", measurement) cf.STChargingInfo(status, measurement) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_PLAY_DTMF: handled = True - print("<- PlayDTMF") + log.info("<- PlayDTMF") try: ascii_num, msg = readUint8(msg) - print("ascii_num =", ascii_num) + log.info("ascii_num =", ascii_num) cf.PlayDTMF(ascii_num) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SEND_DTMF: handled = True - print("<- SendDTMF") + log.info("<- SendDTMF") try: sim, msg = readUint32(msg) line, msg = readUint32(msg) asciinum, msg = readUint8(msg) playit, msg = readUint8(msg) - print("sim =", sim) - print("line =", line) - print("asciinum =", asciinum) - print("playit =", playit) + log.info("sim =", sim) + log.info("line =", line) + log.info("asciinum =", asciinum) + log.info("playit =", playit) cf.SendDTMF(sim, line, asciinum, playit) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_ACTION_CALL: handled = True - print("<- ActionCall") + log.info("<- ActionCall") try: action, msg = readUint32(msg) sim, msg = readUint32(msg) @@ -572,406 +545,406 @@ def readMessage(msg): msisdn, msg = readString(msg) contact, msg = readUTF8String(msg) contact_id, msg = readString(msg) - print("action =", action) - print("sim =", sim) - print("line =", line) - print("numtype =", numtype) - print("msisdn =", msisdn) - print("contact =", contact) - print("contact_id =", contact_id) + log.info("action =", action) + log.info("sim =", sim) + log.info("line =", line) + log.info("numtype =", numtype) + log.info("msisdn =", msisdn) + log.info("contact =", contact) + log.info("contact_id =", contact_id) cf.ActionCall(action, sim, line, numtype, msisdn, contact, contact_id) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SEND_TELE_CODE: handled = True - print("<- SendTeleCode") + log.info("<- SendTeleCode") try: sim, msg = readUint32(msg) line, msg = readUint32(msg) telecode, msg = readString(msg) - print("sim =", sim) - print("line =", line) - print("telecode =", telecode) + log.info("sim =", sim) + log.info("line =", line) + log.info("telecode =", telecode) cf.SendTeleCode(sim, line, telecode) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_CALL_MUTE_STATUS: handled = True - print("<- SetCallMuteStatus") + log.info("<- SetCallMuteStatus") try: status, msg = readUint32(msg) - print("status =", status) + log.info("status =", status) cf.SetCallMuteStatus(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_CALL_MUTE_STATUS: handled = True - print("<- GetCallMuteStatus") + log.info("<- GetCallMuteStatus") try: cf.GetCallMuteStatus() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_CALL_OUTPUT: handled = True - print("<- SetCallOutput") + log.info("<- SetCallOutput") try: status, msg = readUint32(msg) - print("status =", status) + log.info("status =", status) cf.SetCallOutput(status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_CALL_OUTPUT: handled = True - print("<- GetCallOutput") + log.info("<- GetCallOutput") try: cf.GetCallOutput() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_CALL_OUTPUT_OPTIONS: handled = True - print("<- GetCallOutputOptions") + log.info("<- GetCallOutputOptions") try: cf.GetCallOutputOptions() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_ACTION_CAMERA: handled = True - print("<- ActionCamera") + log.info("<- ActionCamera") try: action, msg = readUint32(msg) - print("action =", action) + log.info("action =", action) cf.ActionCamera(action) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_CAMERA_FRAME: handled = True - print("<- GetCameraFrame") + log.info("<- GetCameraFrame") try: cf.GetCameraFrame() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_CAMERA_SETTINGS: handled = True - print("<- SetCameraSettings") + log.info("<- SetCameraSettings") try: parameter, msg = readUint32(msg) value, msg = readUint32(msg) - print("parameter =", parameter) - print("value =", value) + log.info("parameter =", parameter) + log.info("value =", value) cf.SetCameraSettings(parameter, value) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_CAMERA_CAPTURE_IMAGE: handled = True - print("<- CameraCaptureImage") + log.info("<- CameraCaptureImage") try: cf.CameraCaptureImage() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_ACTION_VIDEO: handled = True - print("<- ActionVideo") + log.info("<- ActionVideo") try: action, msg = readUint32(msg) - print("action =", action) + log.info("action =", action) cf.ActionVideo(action) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_VIDEO_FRAME: handled = True - print("<- GetVideoFrame") + log.info("<- GetVideoFrame") try: cf.GetVideoFrame() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_VIDEO_SETTINGS: handled = True - print("<- SetVideoSettings") + log.info("<- SetVideoSettings") try: parameter, msg = readUint32(msg) value, msg = readUint32(msg) - print("parameter =", parameter) - print("value =", value) + log.info("parameter =", parameter) + log.info("value =", value) cf.SetVideoSettings(parameter, value) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_VIDEO_CAPTURE_IMAGE: handled = True - print("<- VideoCaptureImage") + log.info("<- VideoCaptureImage") try: cf.VideoCaptureImage() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_COVER_LIGHT_SENSOR: handled = True - print("<- GetCoverLightSensor") + log.info("<- GetCoverLightSensor") try: cf.GetCoverLightSensor() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_INFO_CURRENT_LANGUAGE: handled = True - print("<- CurrentLanguageInfo") + log.info("<- CurrentLanguageInfo") try: langid, msg = readString(msg) hasallresources, msg = readUint32(msg) data1, msg = readUint32(msg) - print("langid =", langid) - print("hasallresources =", hasallresources) - print("data1 =", data1) + log.info("langid =", langid) + log.info("hasallresources =", hasallresources) + log.info("data1 =", data1) cf.CurrentLanguageInfo(langid, hasallresources, data1) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_INFO_MEDIA_RESOURCE: handled = True - print("<- MediaResourceInfo") + log.info("<- MediaResourceInfo") try: typestr, msg = readString(msg) resname, msg = readString(msg) length, msg = readUint32(msg) status, msg = readUint32(msg) - print("typestr =", typestr) - print("resname =", resname) - print("length =", length) - print("status =", status) + log.info("typestr =", typestr) + log.info("resname =", resname) + log.info("length =", length) + log.info("status =", status) cf.MediaResourceInfo(typestr, resname, length, status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_INFO_MEDIA_ACTIVITY: handled = True - print("<- MediaActivityInfo") + log.info("<- MediaActivityInfo") try: typestr, msg = readString(msg) resname, msg = readString(msg) status, msg = readUint32(msg) - print("typestr =", typestr) - print("resname =", resname) - print("status =", status) + log.info("typestr =", typestr) + log.info("resname =", resname) + log.info("status =", status) cf.MediaActivityInfo(typestr, resname, status) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_INFO_ALERT: handled = True - print("<- AlertInfo") + log.info("<- AlertInfo") try: status, msg = readUint32(msg) response, msg = readUint32(msg) responsestr, msg = readUTF8String(msg) - print("status =", status) - print("response =", response) - print("responsestr =", responsestr) + log.info("status =", status) + log.info("response =", response) + log.info("responsestr =", responsestr) cf.AlertInfo(status, response, responsestr) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_ORIENTATION: handled = True - print("<- GetOrientation") + log.info("<- GetOrientation") try: cf.GetOrientation() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_CALL_HISTORY: handled = True - print("<- GetCallHistory") + log.info("<- GetCallHistory") try: index, msg = readUint32(msg) - print("index =", index) + log.info("index =", index) cf.GetCallHistory(index) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_CONTACTS: handled = True - print("<- GetContacts") + log.info("<- GetContacts") try: index, msg = readUint32(msg) - print("index =", index) + log.info("index =", index) cf.GetContacts(index) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_ACTION_PLAYER: handled = True - print("<- ActionPlayer") + log.info("<- ActionPlayer") try: action, msg = readUint32(msg) - print("action =", action) + log.info("action =", action) cf.ActionPlayer(action) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_ACTION_NOTIFICATION: handled = True - print("<- ActionNotification") + log.info("<- ActionNotification") try: notid, msg = readUint32(msg) action, msg = readUint32(msg) pos, msg = readUint32(msg) - print("notid =", notid) - print("action =", action) - print("pos =", pos) + log.info("notid =", notid) + log.info("action =", action) + log.info("pos =", pos) cf.ActionNotification(notid, action, pos) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_LEDISON_PATTERN: handled = True - print("<- GetLEDisonPattern") + log.info("<- GetLEDisonPattern") try: contactid, msg = readString(msg) contactname, msg = readUTF8String(msg) msisdn, msg = readString(msg) - print("contactid =", contactid) - print("contactname =", contactname) - print("msisdn =", msisdn) + log.info("contactid =", contactid) + log.info("contactname =", contactname) + log.info("msisdn =", msisdn) cf.GetLEDisonPattern(contactid, contactname, msisdn) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_LEDISON_MODE: handled = True - print("<- GetLEDisonMode") + log.info("<- GetLEDisonMode") try: cf.GetLEDisonMode() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_CONTACT_ICON: handled = True - print("<- GetContactIcon") + log.info("<- GetContactIcon") try: contactid, msg = readString(msg) contactname, msg = readUTF8String(msg) msisdn, msg = readString(msg) - print("contactid =", contactid) - print("contactname =", contactname) - print("msisdn =", msisdn) + log.info("contactid =", contactid) + log.info("contactname =", contactname) + log.info("msisdn =", msisdn) cf.GetContactIcon(contactid, contactname, msisdn) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_MODEM_SIGNAL_INFO: handled = True - print("<- GetModemSignalInfo") + log.info("<- GetModemSignalInfo") try: cf.GetModemSignalInfo() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_DATE_TIME_FORMAT: handled = True - print("<- GetDateTimeFormat") + log.info("<- GetDateTimeFormat") try: cf.GetDateTimeFormat() except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_GET_ALBUM_ART: handled = True - print("<- GetAlbumArt") + log.info("<- GetAlbumArt") try: mediasessionformat, msg = readBlob(msg) - print("mediasessionformat =", mediasessionformat) + log.info("mediasessionformat =", mediasessionformat) cf.GetAlbumArt(mediasessionformat) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_ACTION_VOICE_RECODER: handled = True - print("<- ActionVoiceRecorder") + log.info("<- ActionVoiceRecorder") try: action, msg = readUint32(msg) - print("action =", action) + log.info("action =", action) cf.ActionVoiceRecorder(action) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_SET_VOICE_RECORDER_SETTINGS: handled = True - print("<- SetVoiceRecorderSettings") + log.info("<- SetVoiceRecorderSettings") try: parameter, msg = readUint32(msg) value, msg = readUint32(msg) - print("parameter =", parameter) - print("value =", value) + log.info("parameter =", parameter) + log.info("value =", value) cf.SetVoiceRecorderSettings(parameter, value) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_ST32_DATA_CHANGE_ALERT: handled = True - print("<- STDataChangeAlert") + log.info("<- STDataChangeAlert") try: type, msg = readUint32(msg) data1, msg = readUint32(msg) - print("type =", type) - print("data1 =", data1) + log.info("type =", type) + log.info("data1 =", data1) cf.STDataChangeAlert(type, data1) except Exception as e: - print(e) + log.error(e) if cmdId == CMD_SYNC_SYS_SLEEP_STATUS: handled = True - print("<- CoDiOFF") + log.info("<- CoDiOFF") try: par1, msg = readUint8(msg) - print("par1 =", par1) + log.info("par1 =", par1) par2, msg = readUint8(msg) - print("par2 =", par2) + log.info("par2 =", par2) cf.CoDiOFF(par1, par2) except Exception as e: - print(e) + log.error(e) if cmdId == 147: handled = True - print("<- MouseInfo") + log.info("<- MouseInfo") try: mode, msg = readUint8(msg) - print("mode =", mode) + log.info("mode =", mode) x_coord, msg = readInt16(msg) - print("x_coord =", x_coord) + log.info("x_coord =", x_coord) y_coord, msg = readInt16(msg) - print("y_coord =", y_coord) + log.info("y_coord =", y_coord) cf.MouseInfo(mode, x_coord, y_coord) except Exception as e: - print(e) + log.error(e) if cmdId == 148: handled = True - print("<- MouseInfo2") + log.info("<- MouseInfo2") try: pressState, msg = readUint8(msg) - print("pressState =", pressState) + log.info("pressState =", pressState) previousState, msg = readUint8(msg) - print("previousSatate =", previousState) + log.info("previousSatate =", previousState) x_coord, msg = readUint16(msg) - print("x_coord =", x_coord) + log.info("x_coord =", x_coord) y_coord, msg = readUint16(msg) - print("y_coord =", y_coord) + log.info("y_coord =", y_coord) cf.MouseInfo2(pressState, previousState, x_coord, y_coord) except Exception as e: - print(e) + log.error(e) if not handled: - print("<- Unrecognised command", cmdId) \ No newline at end of file + log.info("<- Unrecognised command", cmdId) \ No newline at end of file