Initial commit

This commit is contained in:
Davide Guidi 2020-11-13 11:27:16 +00:00
parent 02cfc2b713
commit 56e041d58e
25 changed files with 2509 additions and 0 deletions

View file

@ -1,2 +1,5 @@
# codi-app
CoDi support for Linux
CoDi support is provided by the codiServer.py script.
A post-install script will create an autostart codi.desktop file for existing users.

49
codi-app/Addressbook.py Normal file
View file

@ -0,0 +1,49 @@
import sqlite3
import CodiStatus
def contactNameForNumber(number):
for c in CodiStatus.Contacts:
if c[2] == number:
return c[1]
return 'Unknown'
def refreshContacts():
CodiStatus.Contacts = []
try:
conn = sqlite3.connect('/home/cosmo/.local/share/evolution/addressbook/system/contacts.db')
c = conn.cursor()
statement = 'select * from folder_id'
contacts = c.execute(statement)
for contact in contacts:
id = ''
name = ''
numbers = []
addContact = True
for l in contact[15].split('\n'):
if l.startswith('X-DELETED-AT:'):
addContact = False
if l.startswith('FN:'):
name = l[3:]
if l.startswith('UID:'):
id = l[4:].strip()
if l.startswith('TEL;'):
tokens = l.split(';')
for t in tokens:
if t.startswith('TYPE='):
t = t[5:]
sep = t.index(':')
phType = t[0:sep].strip()
phNumber = t[sep+1:].strip()
numbers += [(phType, phNumber)]
if name != '' and addContact:
for n in numbers:
CodiStatus.Contacts += [(id, name, n[1])]
conn.commit()
c.close()
conn.close()
except Exception as e:
print('Exception:', e)

263
codi-app/CodiFunctions.py Normal file
View file

@ -0,0 +1,263 @@
from datetime import datetime
import time
import os
import DBusServer
from gi.repository import GLib
import CodiStatus
import Addressbook
import codi_mtk_generated_functions as mtkCmd
import LEDManager
import sqlite3
tapHistory = False
def datetime_from_utc_to_local(utc_datetime):
now_timestamp = time.time()
offset = datetime.fromtimestamp(now_timestamp) - datetime.utcfromtimestamp(now_timestamp)
# print(type(offset))
return utc_datetime + offset
# ST32 calls these functions
def GetBatteryLevel():
mtkCmd.BatteryLevelInfo(CodiStatus.DeviceInfo.batteryLevel)
def GetDoNotDisturbStatus():
mtkCmd.DoNotDisturbStatusInfo(0)
def GetBTStatus():
mtkCmd.BTStatusInfo(0)
def GetWiFiStatus():
mtkCmd.WiFiStatusInfo(1, 100)
def GetLockStatus():
# UNLOCKED 0
# LOCK_PASSWORD 4
mtkCmd.LockStatusInfo(0, 4, '')
def GetLocationStatus():
mtkCmd.LocationStatusInfo(0)
def GetFlightModeStatus():
mtkCmd.FlightModeStatusInfo(0)
def GetHotspotStatus():
mtkCmd.HotspotStatusInfo(0)
def GetVolumeLevel():
mtkCmd.VolumeLevelInfo(50)
def GetBatterySaverStatus():
mtkCmd.BatterySaverStatusInfo(0)
def GetMobileDataStatus():
mtkCmd.MobileDataStatusInfo(1)
def GetModemSignalInfo():
# sim1, sim2, sim2type
mtkCmd.ModemSignalInfo(100, 0, 0)
# def SetLock(status):
# LEDManager.ledsBlue()
def GetDateTime():
now = datetime.now()
mtkCmd.DateTimeInfo(int(now.strftime('%d')),
int(now.strftime('%m')),
int(now.strftime('%Y')),
int(now.strftime('%H')),
int(now.strftime('%M')),
int(now.strftime('%S')),
0)
def ActionCall(action, sim, line, numtype, msisdn, contact, contact_id):
try:
msisdn = str(msisdn, 'utf-8')
if action == 0:
ril = DBusServer.ril0
if sim == 2:
ril = DBusServer.ril1
ril.Dial(msisdn, '')
conn = sqlite3.connect('/home/cosmo/.local/share/history-service/history.sqlite')
try:
c = conn.cursor()
statement = 'insert into voice_events values ("ofono/ofono/ril_0", "' + msisdn + \
'", "' + msisdn + datetime.now().strftime(':%a %b %d %H:%M:%S %Y') + \
'", "self", "' + \
datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.000Z') + \
'", 0, 4, 0, "' + msisdn + '")'
# print(statement)
c.execute(statement)
conn.commit()
c.close()
conn.close()
except Exception as e:
print('Exception:', e)
if action == 14:
# print(dir(DBusServer.ril0['org.ofono.VoiceCallManager']))
DBusServer.ril0['org.ofono.VoiceCallManager'].SwapCalls()
# print(dir(CodiStatus.CallInfo.currentCall))
except Exception as e:
print(e)
def SetCallMuteStatus(status):
try:
DBusServer.ril0['org.ofono.CallVolume'].SetProperty('Muted', GLib.Variant(value=status, format_string='b'))
except Exception as e:
print(e)
def SendDTMF(sim, line, asciinum, palyit):
try:
if asciinum > 48:
asciinum -= 48
# zeroAscii = ord('0')
# DBusServer.ril0['org.ofono.VoiceCallManager'].SendTones('1*2')
if asciinum < 10:
DBusServer.ril0['org.ofono.VoiceCallManager'].SendTones(str(asciinum))
elif asciinum == 42:
DBusServer.ril0['org.ofono.VoiceCallManager'].SendTones('*')
elif asciinum == 35:
DBusServer.ril0['org.ofono.VoiceCallManager'].SendTones('#')
except Exception as e:
print(e)
def SetCallOutput(status):
try:
if status == 0:
os.system('pactl set-sink-port 1 "output-earpiece"')
elif status == 1:
os.system('pactl set-sink-port 1 "output-speaker"')
except Exception as e:
print(e)
def Restart(restartMode):
try:
if restartMode == 0:
mtkCmd.SetMouse(0, 1)
LEDManager.ledsOff()
CodiStatus.DeviceInfo.lidClosed = False
mtkCmd.SetCoDiStatus(3, 3, 3)
os.system('qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout 0 2 -1')
if restartMode == 1:
mtkCmd.SetMouse(0, 1)
CodiStatus.DeviceInfo.lidClosed = False
LEDManager.ledsOff()
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)
# def SetVolumeLevel(status, stream):
# # Not working
# os.system('pactl set-sink-volume sink.primary')
def CoDiOFF(par1, par2):
if CodiStatus.CallInfo.state == 'disconnected':
if CodiStatus.DeviceInfo.lidClosed:
if par2 == 0:
LEDManager.ledsBlue()
else:
LEDManager.ledsOff()
def GetCallHistory(index):
batchSize = 10
conn = sqlite3.connect('/home/cosmo/.local/share/history-service/history.sqlite')
try:
c = conn.cursor()
totalCdr = c.execute('select count(*) from voice_events').fetchall()[0][0]
except Exception as e:
print('Exception:', e)
totalCdr = 0
try:
c = conn.cursor()
history = c.execute('select * from voice_events order by timestamp desc limit ' + str(batchSize) + ' offset ' + str(index)).fetchall()
for i in range(len(history)):
tod = history[i][4]
state = 1
if history[i][7] == 1:
state = 0
if history[i][3] == 'self':
state = 2
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)
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)
except Exception as e:
print('Exception:', e)
c.close()
conn.close()
def GetContacts(index):
Addressbook.refreshContacts()
batch = 10
if index == 100000:
mtkCmd.ContactInfo('0', 0, 100000, '', '')
return
if len(CodiStatus.Contacts) < index:
mtkCmd.ContactInfo('0', 0, batch, '', '')
return
for c in CodiStatus.Contacts[index:index+batch]:
mtkCmd.ContactInfo(c[0], len(CodiStatus.Contacts), batch, c[1], c[2])
tapHistory = False
def MouseInfo(mode, x_coord, y_coord):
global tapHistory
if tapHistory and mode == 2:
os.system('xdotool click 1')
tapHistory = False
return
if mode == 3:
tapHistory = True
else:
tapHistory = False
# if mode == 4:
# os.system('xdotool click 1')
# return
if x_coord < -200 or x_coord > 200 or y_coord < -200 or y_coord > 200:
print('Discarding...')
return
mx = 0
my = 0
if abs(x_coord) > 25:
mx = 1
if abs(y_coord) > 25:
my = 1
if abs(x_coord) < 25 and my == 0:
x_coord /= 2
else:
x_coord *= 2
if abs(y_coord) < 25 and mx == 0:
y_coord /= 2
else:
y_coord *= 2
x = str(-y_coord).replace('-', '\\-')
y = str(-x_coord).replace('-', '\\-')
if mode == 0:
os.system('xdotool mousemove -- ' + x + ' ' + y)
else:
os.system('xdotool mousemove_relative -- ' + x + ' ' + y)

26
codi-app/CodiStatus.py Normal file
View file

@ -0,0 +1,26 @@
class CallInfoClass:
modemId = 0
contactName = ''
msisdn = ''
currentCall = None
state = 'disconnected'
class DeviceInfoClass:
batteryLevel = 0
lidClosed = True
def init():
global DeviceInfo
global CallInfo
global Contacts
CallInfo = CallInfoClass()
DeviceInfo = DeviceInfoClass()
Contacts = []
try:
with open('/proc/battery_status') as f:
DeviceInfo.batteryLevel = int(f.read().split(',')[1])
except Exception as e:
print(e)

56
codi-app/DBusServer.py Normal file
View file

@ -0,0 +1,56 @@
from pydbus import SystemBus, SessionBus
from gi.repository import GLib
import PropertyManager
import LEDManager
import codi_mtk_generated_functions as mtkCmd
def addressbookChanged(par1, par2, par3, par4, par5):
print('AddressBook Changed')
mtkCmd.MTKDataChangeAlert(1, 0)
mtkCmd.MTKDataChangeAlert(0, 0)
def init(startMainLoop=True):
global bus
global session
global ril0
global ril1
global power
global network
bus = SystemBus()
# bus.subscribe(signal_fired=print)
power = bus.get('.UPower')
power.onPropertiesChanged = PropertyManager.propertiesChanged
power = bus.get('.UPower', '/org/freedesktop/UPower/devices/battery_battery')
power.onPropertiesChanged = PropertyManager.propertiesChanged
LEDManager.ledsCharging(power.State == 1)
ril0 = bus.get('org.ofono', '/ril_0')
ril0.onCallAdded = PropertyManager.callStatusChanged
ril0.onCallRemoved = PropertyManager.callStatusChanged
ril1 = bus.get('org.ofono', '/ril_1')
ril1.onCallAdded = PropertyManager.callStatusChanged
ril1.onCallRemoved = PropertyManager.callStatusChanged
network = bus.get('org.freedesktop.NetworkManager')
network.onPropertiesChanged = PropertyManager.networkPropertiesChanged
mtkCmd.WiFiStatusInfo(int(network.WirelessEnabled), 100)
PropertyManager.init()
session = SessionBus()
session.subscribe(object='/com/canonical/pim/AddressBook', signal_fired=addressbookChanged)
# help(ril0)
# ril0['org.ofono.CallVolume'].onPropertyChanged = propertyChanged
# ril0['org.ofono.VoiceCallManager'].onPropertyChanged = propertyChanged
# print(dir(ril0['org.ofono.VoiceCallManager']))
# notifications = session.get('org.kde.kglobalaccel', '/component/kmix')
# notifications.onglobalShortcutPressed = volumeChanged
if startMainLoop:
loop = GLib.MainLoop()
loop.run()

32
codi-app/EventListener.py Normal file
View file

@ -0,0 +1,32 @@
import evdev
from evdev import InputDevice, categorize, ecodes
import threading
import DBusServer
import PropertyManager
dev = None
def readEvent():
global dev
for event in dev.read_loop():
# print(event)
if event.code == 115:
PropertyManager.volumeButtonPressed('EventListener', 'increase_volume', event.value)
if event.code == 114:
PropertyManager.volumeButtonPressed('EventListener', 'decrease_volume', event.value)
def init():
global dev
for path in evdev.list_devices():
try:
device = evdev.InputDevice(path)
if device.name == 'mtk-kpd':
print('Device', device.name, 'found.')
dev = InputDevice(device.path)
thread = threading.Thread(target=readEvent)
thread.start()
return
except:
pass

52
codi-app/LEDManager.py Normal file
View file

@ -0,0 +1,52 @@
'''
1 - TAB Led
2 - Right (top)
3 - Left (bottom)
4 - Keyboard backlight
'''
def setLeds(leds):
for l in leds.keys():
for c in leds[l]:
setLed(l, c[0], c[1])
def setLed(ledId, color, enable):
try:
if ledId >=1 and ledId <=7 and \
color >=1 and color <=3 and enable >=0 and enable <=7:
s = str(ledId) + str(color) + str(enable)
if ledId == 4:
s = str(ledId) + str(enable)
with open('/proc/aw9524_led_proc', 'w') as f:
f.write(s)
except Exception as e:
print(e)
def ledsIncomingCall():
leds = { 2: [[1, 1], [2, 0], [3, 0]],
3: [[1, 0], [2, 1], [3, 0]] }
setLeds(leds)
def ledsOff():
leds = { 2: [[1, 0], [2, 0], [3, 0]],
3: [[1, 0], [2, 0], [3, 0]],
4: [[1, 0], [2, 0], [3, 0]],
5: [[1, 0], [2, 0], [3, 0]],
6: [[1, 0], [2, 0], [3, 0]],
7: [[1, 0], [2, 0], [3, 0]] }
setLeds(leds)
def ledsBlue():
leds = { 2: [[1, 0], [2, 0], [3, 1]],
3: [[1, 0], [2, 0], [3, 1]] }
setLeds(leds)
def ledsCharging(state):
if state:
leds = { 1: [[1,1],[2,0],[3,0]] }
else:
leds = { 1: [[1,0],[2,0],[3,0]] }
setLeds(leds)

View file

@ -0,0 +1,99 @@
import DBusServer
import CodiStatus
import codi_mtk_generated_functions as mtkCmd
import CodiFunctions as cf
import LEDManager
import subprocess
import Addressbook
def init():
global CallInfo
global DeviceInfo
CallInfo = CodiStatus.CallInfo
DeviceInfo = CodiStatus.DeviceInfo
def volumeButtonPressed(sender, name, value):
print('<=', sender, name, value)
if name == 'decrease_volume':
if CallInfo.state == 'incoming':
try:
CallInfo.currentCall.Answer()
except Exception as e:
print(e)
else:
mtkCmd.KeyPressInfo(25, value, 0)
if name == 'increase_volume':
if CallInfo.state in ('alerting', 'incoming', 'active', 'dialing'):
try:
CallInfo.currentCall.Hangup()
except Exception as e:
print(e)
else:
mtkCmd.KeyPressInfo(24, value, 0)
def propertiesChanged(sender, property, data):
print('<=', sender, property, data)
if 'LidIsClosed' in property.keys():
value = property['LidIsClosed']
DeviceInfo.lidClosed = value
if CallInfo.state == 'disconnected':
if value:
mtkCmd.SetCoDiStatus(1, 0, 1)
LEDManager.ledsBlue()
mtkCmd.SetMouse(0, 1)
else:
mtkCmd.SetCoDiStatus(1, 7, 1)
LEDManager.ledsOff()
mtkCmd.SetMouse(1, 1)
if 'Energy' in property and 'EnergyFull' in property:
energy = property['Energy']
eFull = property['EnergyFull']
DeviceInfo.batteryLevel = int(energy * 100 / eFull)
cf.GetBatteryLevel()
LEDManager.ledsCharging(DBusServer.power.State == 1)
def networkPropertiesChanged(properties):
print('<=', properties)
mtkCmd.WiFiStatusInfo(int(DBusServer.network.WirelessEnabled), 100)
def propertyChanged(property, value):
print('<=', property, value)
# TODO: This does NOT work for some reason!
if property == 'Muted':
mtkCmd.CallMuteStatusInfo(1)
if property == 'State':
CallInfo.state = value
if value == 'active':
mtkCmd.CallInfo(CallInfo.modemId, 2, '0', CallInfo.contactName, CallInfo.msisdn, 0)
if value == 'disconnected':
mtkCmd.CallInfo(CallInfo.modemId, 0, '0', CallInfo.contactName, CallInfo.msisdn, 0)
mtkCmd.MTKDataChangeAlert(1, 0)
if DeviceInfo.lidClosed:
LEDManager.ledsBlue()
else:
LEDManager.ledsOff()
cf.SetCallOutput(0)
def callStatusChanged(sender, data=None):
print('<=', sender, data)
if data:
CallInfo.currentCall = DBusServer.bus.get('org.ofono', sender)
CallInfo.currentCall.onPropertyChanged = propertyChanged
CallInfo.state = data['State']
if data['State'] in ['incoming', 'dialing']:
CallInfo.modemId = 0
if '/ril_1' in sender:
CallInfo.modemId = 1
CallInfo.contactName = data['Name']
CallInfo.msisdn = data['LineIdentification']
if CallInfo.contactName == '':
CallInfo.contactName = Addressbook.contactNameForNumber(CallInfo.msisdn)
LEDManager.ledsIncomingCall()
if data['State'] == 'incoming':
mtkCmd.CallInfo(CallInfo.modemId, 1, '0', CallInfo.contactName, CallInfo.msisdn, 0)
else:
mtkCmd.CallInfo(CallInfo.modemId, 13, '0', CallInfo.contactName, CallInfo.msisdn, 0)

View file

@ -0,0 +1,59 @@
import serial
import struct
import threading
import codi_st32_generated_functions as st32Cmd
isRunning = True
socket = None
thread = None
lock = threading.Lock()
def init():
global socket
global thread
try:
socket = serial.Serial('/dev/ttyS1', baudrate=115200)
thread = threading.Thread(target=readFromSerial)
thread.start()
except Exception as e:
print(e)
def stop():
global isRunning
global socket
isRunning = False
socket.cancel_read()
def readFromSerial():
global socket
global isRunning
msgHeader = bytes.fromhex('58 21 58 21')
print('Listening...')
while isRunning:
header = socket.read_until(msgHeader, size=300)
# print('Found header', header)
# Read Size
if len(header) >= 4:
msgSize = struct.unpack('>I', socket.read(4))[0]
# print('Found message size', msgSize)
if msgSize <= 300:
msg = socket.read(msgSize-8)
st32Cmd.readMessage(msg)
else:
if isRunning:
print('Message length wrong, ignoring msg')
def sendCommand(cmd):
global socket
global lock
try:
lock.acquire()
socket.write(cmd)
lock.release()
except Exception as e:
print(e)

79
codi-app/codiServer.py Executable file
View file

@ -0,0 +1,79 @@
#!/usr/bin/env python3
import argparse
import sys
import time
from datetime import datetime
from gi.repository import GLib
import DBusServer
import LEDManager
import CodiFunctions as cf
import SerialPortManager
import codi_mtk_generated_functions as mtkCmd
from codi_generated_parser import *
import signal
import CodiStatus
import EventListener
import Addressbook
def signalHandler(_signo, _stack_frame):
# mtkCmd.SetMouse(0, 1)
mtkCmd.SetCoDiStatus(3, 3, 3)
sys.exit(0)
signal.signal(signal.SIGINT, signalHandler)
signal.signal(signal.SIGTERM, signalHandler)
signal.signal(signal.SIGABRT, signalHandler)
signal.signal(signal.SIGHUP, signalHandler)
CodiStatus.init()
def initCodi():
Addressbook.refreshContacts()
mtkCmd.SetCoDiStatus(1, 7, 1)
mtkCmd.SetMouse(1, 1)
cf.GetDateTime()
LEDManager.ledsOff()
mtkCmd.DoNotDisturbStatusInfo(0)
mtkCmd.BTStatusInfo(0)
mtkCmd.WiFiStatusInfo(1, 100)
mtkCmd.ModemSignalInfo(1, 0, 0)
mtkCmd.MTKDataChangeAlert(1, 0)
mtkCmd.MTKDataChangeAlert(0, 0)
cf.SetCallOutput(0)
SerialPortManager.init()
print('Codi Linux Server')
if args['command']:
if args['command'] == 'dbus':
try:
DBusServer.init(False)
eval(args['cmd'])
except Exception as e:
print(e)
SerialPortManager.stop()
exit(0)
else:
firstArg = True
cmd = 'mtkCmd.' + args['command'] + '('
for i in args:
if i != 'command':
if firstArg:
firstArg = False
else:
cmd += ', '
cmd += str(args[i])
cmd += ')'
eval(cmd)
SerialPortManager.stop()
exit(0)
EventListener.init()
initCodi()
DBusServer.init()

View file

@ -0,0 +1,278 @@
import argparse
parser = argparse.ArgumentParser(description="Codi Utility for Linux.")
subparsers = parser.add_subparsers(help="sub-command help", dest="command")
cmd0 = subparsers.add_parser("GetFlashVersion", help="GetFlashVersion")
cmd1 = subparsers.add_parser("DateTimeInfo", help="DateTimeInfo day month year hour minute second tz")
cmd1.add_argument("day", type=int)
cmd1.add_argument("month", type=int)
cmd1.add_argument("year", type=int)
cmd1.add_argument("hour", type=int)
cmd1.add_argument("minute", type=int)
cmd1.add_argument("second", type=int)
cmd1.add_argument("tz", type=int)
cmd2 = subparsers.add_parser("LocationStatusInfo", help="LocationStatusInfo status")
cmd2.add_argument("status", type=int)
cmd3 = subparsers.add_parser("TorchStatusInfo", help="TorchStatusInfo status")
cmd3.add_argument("status", type=int)
cmd4 = subparsers.add_parser("CoverStatusInfo", help="CoverStatusInfo status")
cmd4.add_argument("status", type=int)
cmd5 = subparsers.add_parser("WiFiStatusInfo", help="WiFiStatusInfo status signalval")
cmd5.add_argument("status", type=int)
cmd5.add_argument("signalval", type=int)
cmd6 = subparsers.add_parser("BTStatusInfo", help="BTStatusInfo status")
cmd6.add_argument("status", type=int)
cmd7 = subparsers.add_parser("BatterySaverStatusInfo", help="BatterySaverStatusInfo status")
cmd7.add_argument("status", type=int)
cmd8 = subparsers.add_parser("FlightModeStatusInfo", help="FlightModeStatusInfo status")
cmd8.add_argument("status", type=int)
cmd9 = subparsers.add_parser("HotspotStatusInfo", help="HotspotStatusInfo status")
cmd9.add_argument("status", type=int)
cmd10 = subparsers.add_parser("MobileDataStatusInfo", help="MobileDataStatusInfo status")
cmd10.add_argument("status", type=int)
cmd11 = subparsers.add_parser("DoNotDisturbStatusInfo", help="DoNotDisturbStatusInfo status")
cmd11.add_argument("status", type=int)
cmd12 = subparsers.add_parser("VolumeLevelInfo", help="VolumeLevelInfo status stream")
cmd12.add_argument("status", type=int)
cmd12.add_argument("stream", type=int)
cmd13 = subparsers.add_parser("BatteryLevelInfo", help="BatteryLevelInfo status")
cmd13.add_argument("status", type=int)
cmd14 = subparsers.add_parser("SetCoDiStatus", help="SetCoDiStatus mode screen data1")
cmd14.add_argument("mode", type=int)
cmd14.add_argument("screen", type=int)
cmd14.add_argument("data1", type=int)
cmd15 = subparsers.add_parser("LockStatusInfo", help="LockStatusInfo locked method strdata")
cmd15.add_argument("locked", type=int)
cmd15.add_argument("method", type=int)
cmd15.add_argument("strdata", type=str)
cmd16 = subparsers.add_parser("CallMuteStatusInfo", help="CallMuteStatusInfo status")
cmd16.add_argument("status", type=int)
cmd17 = subparsers.add_parser("CallOutputInfo", help="CallOutputInfo output")
cmd17.add_argument("output", type=int)
cmd18 = subparsers.add_parser("CallOutputOptionsInfo", help="CallOutputOptionsInfo output_options")
cmd18.add_argument("output_options", type=int)
cmd19 = subparsers.add_parser("CameraStatusInfo", help="CameraStatusInfo status")
cmd19.add_argument("status", type=int)
cmd20 = subparsers.add_parser("CameraSettingsInfo", help="CameraSettingsInfo parameter value")
cmd20.add_argument("parameter", type=int)
cmd20.add_argument("value", type=int)
cmd21 = subparsers.add_parser("VideoStatusInfo", help="VideoStatusInfo status")
cmd21.add_argument("status", type=int)
cmd22 = subparsers.add_parser("VideoSettingsInfo", help="VideoSettingsInfo parameter value")
cmd22.add_argument("parameter", type=int)
cmd22.add_argument("value", type=int)
cmd23 = subparsers.add_parser("CoverLightSensorInfo", help="CoverLightSensorInfo value")
cmd23.add_argument("value", type=int)
cmd24 = subparsers.add_parser("LoadLanguageResource", help="LoadLanguageResource langid resname resdata forcereload")
cmd24.add_argument("langid", type=str)
cmd24.add_argument("resname", type=str)
cmd24.add_argument("resdata", type=bytes)
cmd24.add_argument("forcereload", type=int)
cmd25 = subparsers.add_parser("GetCurrentLanguage", help="GetCurrentLanguage")
cmd26 = subparsers.add_parser("SetCurrentLanguage", help="SetCurrentLanguage langid")
cmd26.add_argument("langid", type=str)
cmd27 = subparsers.add_parser("ShowMedia", help="ShowMedia typestr resname seconds speed aftermode")
cmd27.add_argument("typestr", type=str)
cmd27.add_argument("resname", type=str)
cmd27.add_argument("seconds", type=int)
cmd27.add_argument("speed", type=int)
cmd27.add_argument("aftermode", type=int)
cmd28 = subparsers.add_parser("StopMedia", help="StopMedia typestr resname aftermode")
cmd28.add_argument("typestr", type=str)
cmd28.add_argument("resname", type=str)
cmd28.add_argument("aftermode", type=int)
cmd29 = subparsers.add_parser("LoadMedia", help="LoadMedia typestr resname resdata loadmode")
cmd29.add_argument("typestr", type=str)
cmd29.add_argument("resname", type=str)
cmd29.add_argument("resdata", type=bytes)
cmd29.add_argument("loadmode", type=int)
cmd30 = subparsers.add_parser("UnloadMedia", help="UnloadMedia typestr resname")
cmd30.add_argument("typestr", type=str)
cmd30.add_argument("resname", type=str)
cmd31 = subparsers.add_parser("HasMedia", help="HasMedia typestr resname")
cmd31.add_argument("typestr", type=str)
cmd31.add_argument("resname", type=str)
cmd32 = subparsers.add_parser("ShowAlert", help="ShowAlert alertmode alertype alerticondata typestr resname seconds speed aftermode option1 option2")
cmd32.add_argument("alertmode", type=int)
cmd32.add_argument("alertype", type=int)
cmd32.add_argument("alerticondata", type=bytes)
cmd32.add_argument("typestr", type=str)
cmd32.add_argument("resname", type=str)
cmd32.add_argument("seconds", type=int)
cmd32.add_argument("speed", type=int)
cmd32.add_argument("aftermode", type=int)
cmd32.add_argument("option1", type=str)
cmd32.add_argument("option2", type=str)
cmd33 = subparsers.add_parser("StopAlert", help="StopAlert aftermode")
cmd33.add_argument("aftermode", type=int)
cmd34 = subparsers.add_parser("OrientationInfo", help="OrientationInfo value")
cmd34.add_argument("value", type=int)
cmd35 = subparsers.add_parser("ActionCoDiHome", help="ActionCoDiHome screenoff")
cmd35.add_argument("screenoff", type=int)
cmd36 = subparsers.add_parser("NextAlarmInfo", help="NextAlarmInfo appid daystring timestr")
cmd36.add_argument("appid", type=int)
cmd36.add_argument("daystring", type=str)
cmd36.add_argument("timestr", type=str)
cmd37 = subparsers.add_parser("ShowBatteryLevel", help="ShowBatteryLevel percentage showforseconds")
cmd37.add_argument("percentage", type=int)
cmd37.add_argument("showforseconds", type=int)
cmd38 = subparsers.add_parser("ContactInfo", help="ContactInfo contactid totalcontacts batchsize contactname msisdn")
cmd38.add_argument("contactid", type=str)
cmd38.add_argument("totalcontacts", type=int)
cmd38.add_argument("batchsize", type=int)
cmd38.add_argument("contactname", type=str)
cmd38.add_argument("msisdn", type=str)
cmd39 = subparsers.add_parser("CallHistoryInfo", help="CallHistoryInfo cdrid totalcdr batchsize contactname msisdn day month year hour minute second tz state")
cmd39.add_argument("cdrid", type=int)
cmd39.add_argument("totalcdr", type=int)
cmd39.add_argument("batchsize", type=int)
cmd39.add_argument("contactname", type=str)
cmd39.add_argument("msisdn", type=str)
cmd39.add_argument("day", type=int)
cmd39.add_argument("month", type=int)
cmd39.add_argument("year", type=int)
cmd39.add_argument("hour", type=int)
cmd39.add_argument("minute", type=int)
cmd39.add_argument("second", type=int)
cmd39.add_argument("tz", type=int)
cmd39.add_argument("state", type=int)
cmd40 = subparsers.add_parser("NotificationInfo", help="NotificationInfo notid action appname shortinfo longinfo day month year hour minute second tz replyactions replyaction1 replyaction2 replyaction3")
cmd40.add_argument("notid", type=int)
cmd40.add_argument("action", type=int)
cmd40.add_argument("appname", type=str)
cmd40.add_argument("shortinfo", type=str)
cmd40.add_argument("longinfo", type=str)
cmd40.add_argument("day", type=int)
cmd40.add_argument("month", type=int)
cmd40.add_argument("year", type=int)
cmd40.add_argument("hour", type=int)
cmd40.add_argument("minute", type=int)
cmd40.add_argument("second", type=int)
cmd40.add_argument("tz", type=int)
cmd40.add_argument("replyactions", type=int)
cmd40.add_argument("replyaction1", type=str)
cmd40.add_argument("replyaction2", type=str)
cmd40.add_argument("replyaction3", type=str)
cmd41 = subparsers.add_parser("PlayerInfo", help="PlayerInfo appname artist album track offset length state imageadr")
cmd41.add_argument("appname", type=str)
cmd41.add_argument("artist", type=str)
cmd41.add_argument("album", type=str)
cmd41.add_argument("track", type=str)
cmd41.add_argument("offset", type=int)
cmd41.add_argument("length", type=int)
cmd41.add_argument("state", type=int)
cmd41.add_argument("imageadr", type=bytes)
cmd42 = subparsers.add_parser("CallInfo", help="CallInfo modem action contactid contactname msisdn hasicon")
cmd42.add_argument("modem", type=int)
cmd42.add_argument("action", type=int)
cmd42.add_argument("contactid", type=str)
cmd42.add_argument("contactname", type=str)
cmd42.add_argument("msisdn", type=str)
cmd42.add_argument("hasicon", type=int)
cmd43 = subparsers.add_parser("LEDisonModeInfo", help="LEDisonModeInfo value")
cmd43.add_argument("value", type=int)
cmd44 = subparsers.add_parser("LEDisonPatternInfo", help="LEDisonPatternInfo animid animname animationdata")
cmd44.add_argument("animid", type=int)
cmd44.add_argument("animname", type=str)
cmd44.add_argument("animationdata", type=bytes)
cmd45 = subparsers.add_parser("ContactIconInfo", help="ContactIconInfo contactid contactname msisdn icondata")
cmd45.add_argument("contactid", type=str)
cmd45.add_argument("contactname", type=str)
cmd45.add_argument("msisdn", type=str)
cmd45.add_argument("icondata", type=bytes)
cmd46 = subparsers.add_parser("ModemSignalInfo", help="ModemSignalInfo sim1 sim2 sim2type")
cmd46.add_argument("sim1", type=int)
cmd46.add_argument("sim2", type=int)
cmd46.add_argument("sim2type", type=int)
cmd47 = subparsers.add_parser("WeatherInfo", help="WeatherInfo weatherstate temp scale additionaltext")
cmd47.add_argument("weatherstate", type=int)
cmd47.add_argument("temp", type=int)
cmd47.add_argument("scale", type=str)
cmd47.add_argument("additionaltext", type=str)
cmd48 = subparsers.add_parser("ExtraCommand", help="ExtraCommand data1 data2 str1 str2")
cmd48.add_argument("data1", type=int)
cmd48.add_argument("data2", type=int)
cmd48.add_argument("str1", type=str)
cmd48.add_argument("str2", type=str)
cmd49 = subparsers.add_parser("DateTimeFormat", help="DateTimeFormat dateformat timeformat")
cmd49.add_argument("dateformat", type=str)
cmd49.add_argument("timeformat", type=int)
cmd50 = subparsers.add_parser("AlbumArtInfo", help="AlbumArtInfo albumartpng")
cmd50.add_argument("albumartpng", type=bytes)
cmd51 = subparsers.add_parser("CameraFrameImage", help="CameraFrameImage width height png")
cmd51.add_argument("width", type=int)
cmd51.add_argument("height", type=int)
cmd51.add_argument("png", type=bytes)
cmd52 = subparsers.add_parser("KeyPressInfo", help="KeyPressInfo keycode mode modifiers")
cmd52.add_argument("keycode", type=int)
cmd52.add_argument("mode", type=int)
cmd52.add_argument("modifiers", type=int)
cmd53 = subparsers.add_parser("VoiceRecorderSettingsInfo", help="VoiceRecorderSettingsInfo parameter value")
cmd53.add_argument("parameter", type=int)
cmd53.add_argument("value", type=int)
cmd54 = subparsers.add_parser("VoiceRecorderStatusInfo", help="VoiceRecorderStatusInfo status")
cmd54.add_argument("status", type=int)
cmd55 = subparsers.add_parser("MTKDataChangeAlert", help="MTKDataChangeAlert type data1")
cmd55.add_argument("type", type=int)
cmd55.add_argument("data1", type=int)
dbusCmd = subparsers.add_parser("dbus", help="DBUS command")
dbusCmd.add_argument("cmd", type=str)
args = vars(parser.parse_args())

View file

@ -0,0 +1,404 @@
import struct
import SerialPortManager
def writeUint8(p):
return struct.pack(">B", p)
def writeUint16(p):
return struct.pack(">H", p)
def writeUint32(p):
return struct.pack(">I", p)
def writeInt8(p):
return struct.pack(">b", p)
def writeInt16(p):
return struct.pack(">h", p)
def writeInt32(p):
return struct.pack(">i", p)
def writeString(s):
return writeUint32(len(s)) + s.encode()
def writeUTF8String(s):
return writeString(s)
def writeBlob(b):
return writeString(b)
def sendMessage(commandId, args=[]):
msgHeader = bytes.fromhex('58 21 58 21')
cmdId = writeUint32(commandId)
cmdSessionId = bytes.fromhex('00 00 00 01')
msgLength = len(msgHeader) + 4 + len(cmdId) + len(cmdSessionId)
for i in args:
msgLength += len(i)
cmd = msgHeader + writeUint32(msgLength) + cmdId + cmdSessionId
for i in args:
cmd += i
SerialPortManager.sendCommand(list(cmd))
CMD_MTK_GET_PROTOCOL_VERSION = 0
CMD_MTK_GET_CODI_FLASH_VERSION = 1
CMD_ST32_INFO_CODI_FLASH_VERSION = 2
CMD_ST32_INFO_PROTOCOL_VERSION = 3
CMD_ST32_SET_BINARY = 4
CMD_ST32_SET_S8 = 5
CMD_ST32_RESTART = 6
CMD_ST32_GET_DATETIME = 7
CMD_MTK_INFO_DATETIME = 8
CMD_ST32_SET_LOCATION_STATUS = 9
CMD_ST32_GET_LOCATION_STATUS = 10
CMD_MTK_INFO_LOCATION_STATUS = 11
CMD_ST32_SET_TORCH_STATUS = 12
CMD_ST32_GET_TORCH_STATUS = 13
CMD_MTK_INFO_TORCH_STATUS = 14
CMD_ST32_GET_COVER_STATUS = 15
CMD_MTK_INFO_COVER_STATUS = 16
CMD_ST32_SET_WIFI_STATUS = 17
CMD_ST32_GET_WIFI_STATUS = 18
CMD_MTK_INFO_WIFI_STATUS = 19
CMD_ST32_SET_BT_STATUS = 20
CMD_ST32_GET_BT_STATUS = 21
CMD_MTK_INFO_BT_STATUS = 22
CMD_ST32_SET_BATTERY_SAVER_STATUS = 23
CMD_ST32_GET_BATTERY_SAVER_STATUS = 24
CMD_MTK_INFO_BATTERY_SAVER_STATUS = 25
CMD_ST32_SET_FLIGHT_MODE_STATUS = 26
CMD_ST32_GET_FLIGHT_MODE_STATUS = 27
CMD_MTK_INFO_FLIGHT_MODE_STATUS = 28
CMD_ST32_SET_HOTSPOT_STATUS = 29
CMD_ST32_GET_HOTSPOT_STATUS = 30
CMD_MTK_INFO_HOTSPOT_STATUS = 31
CMD_ST32_SET_MOBILE_DATA_STATUS = 32
CMD_ST32_GET_MOBILE_DATA_STATUS = 33
CMD_MTK_INFO_MOBILE_DATA_STATUS = 34
CMD_ST32_SET_DND_STATUS = 35
CMD_ST32_GET_DND_STATUS = 36
CMD_MTK_INFO_DND_STATUS = 37
CMD_ST32_SET_VOLUME_LEVEL = 38
CMD_ST32_GET_VOLUME_LEVEL = 39
CMD_MTK_INFO_VOLUME_LEVEL = 40
CMD_ST32_GET_BATTERY_LEVEL = 41
CMD_MTK_INFO_BATTERY_LEVEL = 42
CMD_ST32_INFO_CODI_STATUS = 43
CMD_MTK_SET_CODI_STATUS = 121
CMD_ST32_SET_LOCK = 45
CMD_ST32_GET_LOCK_STATUS = 46
CMD_MTK_INFO_LOCK_STATUS = 47
CMD_ST32_DISMISS_CALL_SMS = 48
CMD_ST32_ACTION_UNLOCK = 49
CMD_ST32_INFO_ST_CHARGING = 50
CMD_ST32_PLAY_DTMF = 51
CMD_ST32_SEND_DTMF = 52
CMD_ST32_ACTION_CALL = 53
CMD_ST32_SEND_TELE_CODE = 54
CMD_ST32_SET_CALL_MUTE_STATUS = 55
CMD_ST32_GET_CALL_MUTE_STATUS = 56
CMD_MTK_INFO_CALL_MUTE_STATUS = 57
CMD_ST32_SET_CALL_OUTPUT = 58
CMD_ST32_GET_CALL_OUTPUT = 59
CMD_MTK_INFO_CALL_OUTPUT = 60
CMD_ST32_GET_CALL_OUTPUT_OPTIONS = 61
CMD_MTK_INFO_CALL_OUTPUT_OPTIONS = 62
CMD_ST32_ACTION_CAMERA = 63
CMD_ST32_GET_CAMERA_FRAME = 64
CMD_ST32_SET_CAMERA_SETTINGS = 65
CMD_ST32_CAMERA_CAPTURE_IMAGE = 66
CMD_ST32_ACTION_VIDEO = 67
CMD_ST32_GET_VIDEO_FRAME = 68
CMD_ST32_SET_VIDEO_SETTINGS = 69
CMD_ST32_VIDEO_CAPTURE_IMAGE = 70
CMD_MTK_INFO_CAMERA_STATUS = 71
CMD_MTK_INFO_CAMERA_SETTINGS = 72
CMD_MTK_INFO_VIDEO_STATUS = 73
CMD_MTK_INFO_VIDEO_SETTINGS = 74
CMD_MTK_INFO_COVER_LIGHT_SENSOR = 75
CMD_ST32_GET_COVER_LIGHT_SENSOR = 76
CMD_MTK_LOAD_LANGUAGE_RESOURCE = 77
CMD_MTK_GET_CURRENT_LANGUAGE = 78
CMD_ST32_INFO_CURRENT_LANGUAGE = 79
CMD_MTK_SET_CURRENT_LANGUAGE = 80
CMD_MTK_SHOW_MEDIA = 81
CMD_MTK_STOP_MEDIA = 82
CMD_MTK_LOAD_MEDIA = 83
CMD_MTK_UNLOAD_MEDIA = 84
CMD_MTK_HAS_MEDIA = 85
CMD_ST32_INFO_MEDIA_RESOURCE = 86
CMD_ST32_INFO_MEDIA_ACTIVITY = 87
CMD_MTK_SHOW_ALERT = 88
CMD_ST32_INFO_ALERT = 89
CMD_MTK_STOP_ALERT = 90
CMD_MTK_ORIENTATION_INFO = 91
CMD_ST32_GET_ORIENTATION = 92
CMD_MTK_ACTION_CODI_HOME = 93
CMD_MTK_INFO_NEXT_ALARM = 94
CMD_MTK_SHOW_BATTERY_LEVEL = 95
CMD_ST32_GET_CALL_HISTORY = 96
CMD_ST32_GET_CONTACTS = 97
CMD_MTK_CONTACT_INFO = 98
CMD_MTK_CALL_HISTORY_INFO = 99
CMD_MTK_NOTIFICATION_INFO = 100
CMD_MTK_PLAYER_INFO = 101
CMD_ST32_ACTION_PLAYER = 102
CMD_MTK_CALL_INFO = 103
CMD_ST32_ACTION_NOTIFICATION = 104
CMD_ST32_GET_LEDISON_PATTERN = 105
CMD_MTK_LEDISON_MODE_INFO = 106
CMD_ST32_GET_LEDISON_MODE = 107
CMD_MTK_LEDISON_PATTERN_INFO = 108
CMD_ST32_GET_CONTACT_ICON = 109
CMD_MTK_CONTACT_ICON_INFO = 110
CMD_MTK_MODEM_SIGNAL_INFO = 111
CMD_MTK_WEATHER_INFO = 112
CMD_MTK_EXTRA_COMMAND = 113
CMD_ST32_GET_MODEM_SIGNAL_INFO = 114
CMD_ST32_GET_DATE_TIME_FORMAT = 115
CMD_MTK_DATE_TIME_FORMAT_INFO = 116
CMD_ST32_GET_ALBUM_ART = 117
CMD_MTK_ALBUM_ART_INFO = 118
CMD_MTK_CAMERA_FRAME_IMG = 119
CMD_MTK_KEY_PRESS_INFO = 120
CMD_ST32_ACTION_VOICE_RECODER = 122
CMD_ST32_SET_VOICE_RECORDER_SETTINGS = 123
CMD_MTK_INFO_VOICE_RECODER_SETTINGS = 124
CMD_MTK_INFO_VOICE_RECORDER_STATUS = 125
CMD_MTK_DATA_CHANGE_ALERT = 126
CMD_ST32_DATA_CHANGE_ALERT = 127
CMD_AEON_MTK_SET_ST32_RESET = 140
CMD_GET_ST32_SW_VERSION = 141
CMD_SYNC_USB_STATUS = 142
CMD_SYNC_SYS_SLEEP_STATUS = 143
CMD_SYNC_RIGHT_USB_OTG_STATUS = 144
CMD_ST_ENTRY_DEEP_SLEEP_STATUS = 145
def GetFlashVersion():
print("-> GetFlashVersion")
sendMessage(CMD_MTK_GET_CODI_FLASH_VERSION)
def DateTimeInfo(day, month, year, hour, minute, second, tz):
print("-> 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")
sendMessage(CMD_MTK_INFO_LOCATION_STATUS, [writeUint16(status)])
def TorchStatusInfo(status):
print("-> TorchStatusInfo")
sendMessage(CMD_MTK_INFO_TORCH_STATUS, [writeUint16(status)])
def CoverStatusInfo(status):
print("-> CoverStatusInfo")
sendMessage(CMD_MTK_INFO_COVER_STATUS, [writeUint16(status)])
def WiFiStatusInfo(status, signalval):
print("-> WiFiStatusInfo")
sendMessage(CMD_MTK_INFO_WIFI_STATUS, [writeUint16(status), writeUint32(signalval)])
def BTStatusInfo(status):
print("-> BTStatusInfo")
sendMessage(CMD_MTK_INFO_BT_STATUS, [writeUint16(status)])
def BatterySaverStatusInfo(status):
print("-> BatterySaverStatusInfo")
sendMessage(CMD_MTK_INFO_BATTERY_SAVER_STATUS, [writeUint16(status)])
def FlightModeStatusInfo(status):
print("-> FlightModeStatusInfo")
sendMessage(CMD_MTK_INFO_FLIGHT_MODE_STATUS, [writeUint16(status)])
def HotspotStatusInfo(status):
print("-> HotspotStatusInfo")
sendMessage(CMD_MTK_INFO_HOTSPOT_STATUS, [writeUint16(status)])
def MobileDataStatusInfo(status):
print("-> MobileDataStatusInfo")
sendMessage(CMD_MTK_INFO_MOBILE_DATA_STATUS, [writeUint16(status)])
def DoNotDisturbStatusInfo(status):
print("-> DoNotDisturbStatusInfo")
sendMessage(CMD_MTK_INFO_DND_STATUS, [writeUint16(status)])
def VolumeLevelInfo(status, stream):
print("-> VolumeLevelInfo")
sendMessage(CMD_MTK_INFO_VOLUME_LEVEL, [writeUint16(status), writeUint16(stream)])
def BatteryLevelInfo(status):
print("-> BatteryLevelInfo")
sendMessage(CMD_MTK_INFO_BATTERY_LEVEL, [writeUint16(status)])
def SetCoDiStatus(mode, screen, data1):
print("-> SetCoDiStatus")
sendMessage(CMD_MTK_SET_CODI_STATUS, [writeUint32(mode), writeUint32(screen), writeUint32(data1)])
def LockStatusInfo(locked, method, strdata):
print("-> LockStatusInfo")
sendMessage(CMD_MTK_INFO_LOCK_STATUS, [writeUint16(locked), writeUint32(method), writeString(strdata)])
def CallMuteStatusInfo(status):
print("-> CallMuteStatusInfo")
sendMessage(CMD_MTK_INFO_CALL_MUTE_STATUS, [writeUint32(status)])
def CallOutputInfo(output):
print("-> CallOutputInfo")
sendMessage(CMD_MTK_INFO_CALL_OUTPUT, [writeUint32(output)])
def CallOutputOptionsInfo(output_options):
print("-> CallOutputOptionsInfo")
sendMessage(CMD_MTK_INFO_CALL_OUTPUT_OPTIONS, [writeUint32(output_options)])
def CameraStatusInfo(status):
print("-> CameraStatusInfo")
sendMessage(CMD_MTK_INFO_CAMERA_STATUS, [writeUint32(status)])
def CameraSettingsInfo(parameter, value):
print("-> CameraSettingsInfo")
sendMessage(CMD_MTK_INFO_CAMERA_SETTINGS, [writeUint32(parameter), writeUint32(value)])
def VideoStatusInfo(status):
print("-> VideoStatusInfo")
sendMessage(CMD_MTK_INFO_VIDEO_STATUS, [writeUint32(status)])
def VideoSettingsInfo(parameter, value):
print("-> VideoSettingsInfo")
sendMessage(CMD_MTK_INFO_VIDEO_SETTINGS, [writeUint32(parameter), writeUint32(value)])
def CoverLightSensorInfo(value):
print("-> CoverLightSensorInfo")
sendMessage(CMD_MTK_INFO_COVER_LIGHT_SENSOR, [writeUint32(value)])
def LoadLanguageResource(langid, resname, resdata, forcereload):
print("-> LoadLanguageResource")
sendMessage(CMD_MTK_LOAD_LANGUAGE_RESOURCE, [writeString(langid), writeString(resname), writeBlob(resdata), writeUint32(forcereload)])
def GetCurrentLanguage():
print("-> GetCurrentLanguage")
sendMessage(CMD_MTK_GET_CURRENT_LANGUAGE)
def SetCurrentLanguage(langid):
print("-> SetCurrentLanguage")
sendMessage(CMD_MTK_SET_CURRENT_LANGUAGE, [writeString(langid)])
def ShowMedia(typestr, resname, seconds, speed, aftermode):
print("-> ShowMedia")
sendMessage(CMD_MTK_SHOW_MEDIA, [writeString(typestr), writeString(resname), writeUint32(seconds), writeUint32(speed), writeUint32(aftermode)])
def StopMedia(typestr, resname, aftermode):
print("-> StopMedia")
sendMessage(CMD_MTK_STOP_MEDIA, [writeString(typestr), writeString(resname), writeUint32(aftermode)])
def LoadMedia(typestr, resname, resdata, loadmode):
print("-> LoadMedia")
sendMessage(CMD_MTK_LOAD_MEDIA, [writeString(typestr), writeString(resname), writeBlob(resdata), writeUint32(loadmode)])
def UnloadMedia(typestr, resname):
print("-> UnloadMedia")
sendMessage(CMD_MTK_UNLOAD_MEDIA, [writeString(typestr), writeString(resname)])
def HasMedia(typestr, resname):
print("-> HasMedia")
sendMessage(CMD_MTK_HAS_MEDIA, [writeString(typestr), writeString(resname)])
def ShowAlert(alertmode, alertype, alerticondata, typestr, resname, seconds, speed, aftermode, option1, option2):
print("-> 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")
sendMessage(CMD_MTK_STOP_ALERT, [writeUint32(aftermode)])
def OrientationInfo(value):
print("-> OrientationInfo")
sendMessage(CMD_MTK_ORIENTATION_INFO, [writeUint32(value)])
def ActionCoDiHome(screenoff):
print("-> ActionCoDiHome")
sendMessage(CMD_MTK_ACTION_CODI_HOME, [writeUint32(screenoff)])
def NextAlarmInfo(appid, daystring, timestr):
print("-> NextAlarmInfo")
sendMessage(CMD_MTK_INFO_NEXT_ALARM, [writeUint32(appid), writeString(daystring), writeString(timestr)])
def ShowBatteryLevel(percentage, showforseconds):
print("-> ShowBatteryLevel")
sendMessage(CMD_MTK_SHOW_BATTERY_LEVEL, [writeUint32(percentage), writeUint32(showforseconds)])
def ContactInfo(contactid, totalcontacts, batchsize, contactname, msisdn):
print("-> 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")
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")
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")
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")
sendMessage(CMD_MTK_CALL_INFO, [writeUint32(modem), writeUint32(action), writeString(contactid), writeUTF8String(contactname), writeString(msisdn), writeUint32(hasicon)])
def LEDisonModeInfo(value):
print("-> LEDisonModeInfo")
sendMessage(CMD_MTK_LEDISON_MODE_INFO, [writeUint32(value)])
def LEDisonPatternInfo(animid, animname, animationdata):
print("-> LEDisonPatternInfo")
sendMessage(CMD_MTK_LEDISON_PATTERN_INFO, [writeUint32(animid), writeUTF8String(animname), writeBlob(animationdata)])
def ContactIconInfo(contactid, contactname, msisdn, icondata):
print("-> ContactIconInfo")
sendMessage(CMD_MTK_CONTACT_ICON_INFO, [writeString(contactid), writeUTF8String(contactname), writeString(msisdn), writeBlob(icondata)])
def ModemSignalInfo(sim1, sim2, sim2type):
print("-> ModemSignalInfo")
sendMessage(CMD_MTK_MODEM_SIGNAL_INFO, [writeUint32(sim1), writeUint32(sim2), writeUint32(sim2type)])
def WeatherInfo(weatherstate, temp, scale, additionaltext):
print("-> WeatherInfo")
sendMessage(CMD_MTK_WEATHER_INFO, [writeUint32(weatherstate), writeUint32(temp), writeString(scale), writeString(additionaltext)])
def ExtraCommand(data1, data2, str1, str2):
print("-> ExtraCommand")
sendMessage(CMD_MTK_EXTRA_COMMAND, [writeUint32(data1), writeUint32(data2), writeString(str1), writeString(str2)])
def DateTimeFormat(dateformat, timeformat):
print("-> DateTimeFormat")
sendMessage(CMD_MTK_DATE_TIME_FORMAT_INFO, [writeString(dateformat), writeUint32(timeformat)])
def AlbumArtInfo(albumartpng):
print("-> AlbumArtInfo")
sendMessage(CMD_MTK_ALBUM_ART_INFO, [writeBlob(albumartpng)])
def CameraFrameImage(width, height, png):
print("-> CameraFrameImage")
sendMessage(CMD_MTK_CAMERA_FRAME_IMG, [writeUint16(width), writeUint16(height), writeBlob(png)])
def KeyPressInfo(keycode, mode, modifiers):
print("-> KeyPressInfo")
sendMessage(CMD_MTK_KEY_PRESS_INFO, [writeUint16(keycode), writeUint16(mode), writeUint16(modifiers)])
def VoiceRecorderSettingsInfo(parameter, value):
print("-> VoiceRecorderSettingsInfo")
sendMessage(CMD_MTK_INFO_VOICE_RECODER_SETTINGS, [writeUint32(parameter), writeUint32(value)])
def VoiceRecorderStatusInfo(status):
print("-> VoiceRecorderStatusInfo")
sendMessage(CMD_MTK_INFO_VOICE_RECORDER_STATUS, [writeUint32(status)])
def MTKDataChangeAlert(type, data1):
print("-> MTKDataChangeAlert")
sendMessage(CMD_MTK_DATA_CHANGE_ALERT, [writeUint32(type), writeUint32(data1)])
def SetMouse(onOff, absoluteOrRelative):
print("-> SetMouse")
sendMessage(146, [writeUint8(onOff), writeUint8(absoluteOrRelative)])

View file

@ -0,0 +1,947 @@
import struct
import CodiFunctions as cf
def readUint8(p):
return struct.unpack(">B", p[:1])[0], p[1:]
def readUint16(p):
return struct.unpack(">H", p[:2])[0], p[2:]
def readUint32(p):
return struct.unpack(">I", p[:4])[0], p[4:]
def readInt8(p):
return struct.unpack(">b", p[:1])[0], p[1:]
def readInt16(p):
return struct.unpack(">h", p[:2])[0], p[2:]
def readInt32(p):
return struct.unpack(">i", p[:4])[0], p[4:]
def readString(p):
s, np = readUint32(p)
if len(np) >= s:
return np[:s], np[s:]
else:
print('Error reading string', s, '>', len(np))
return '', p
def readUTF8String(p):
return readString(p)
def readBlob(p):
return readString(p)
CMD_MTK_GET_PROTOCOL_VERSION = 0
CMD_MTK_GET_CODI_FLASH_VERSION = 1
CMD_ST32_INFO_CODI_FLASH_VERSION = 2
CMD_ST32_INFO_PROTOCOL_VERSION = 3
CMD_ST32_SET_BINARY = 4
CMD_ST32_SET_S8 = 5
CMD_ST32_RESTART = 6
CMD_ST32_GET_DATETIME = 7
CMD_MTK_INFO_DATETIME = 8
CMD_ST32_SET_LOCATION_STATUS = 9
CMD_ST32_GET_LOCATION_STATUS = 10
CMD_MTK_INFO_LOCATION_STATUS = 11
CMD_ST32_SET_TORCH_STATUS = 12
CMD_ST32_GET_TORCH_STATUS = 13
CMD_MTK_INFO_TORCH_STATUS = 14
CMD_ST32_GET_COVER_STATUS = 15
CMD_MTK_INFO_COVER_STATUS = 16
CMD_ST32_SET_WIFI_STATUS = 17
CMD_ST32_GET_WIFI_STATUS = 18
CMD_MTK_INFO_WIFI_STATUS = 19
CMD_ST32_SET_BT_STATUS = 20
CMD_ST32_GET_BT_STATUS = 21
CMD_MTK_INFO_BT_STATUS = 22
CMD_ST32_SET_BATTERY_SAVER_STATUS = 23
CMD_ST32_GET_BATTERY_SAVER_STATUS = 24
CMD_MTK_INFO_BATTERY_SAVER_STATUS = 25
CMD_ST32_SET_FLIGHT_MODE_STATUS = 26
CMD_ST32_GET_FLIGHT_MODE_STATUS = 27
CMD_MTK_INFO_FLIGHT_MODE_STATUS = 28
CMD_ST32_SET_HOTSPOT_STATUS = 29
CMD_ST32_GET_HOTSPOT_STATUS = 30
CMD_MTK_INFO_HOTSPOT_STATUS = 31
CMD_ST32_SET_MOBILE_DATA_STATUS = 32
CMD_ST32_GET_MOBILE_DATA_STATUS = 33
CMD_MTK_INFO_MOBILE_DATA_STATUS = 34
CMD_ST32_SET_DND_STATUS = 35
CMD_ST32_GET_DND_STATUS = 36
CMD_MTK_INFO_DND_STATUS = 37
CMD_ST32_SET_VOLUME_LEVEL = 38
CMD_ST32_GET_VOLUME_LEVEL = 39
CMD_MTK_INFO_VOLUME_LEVEL = 40
CMD_ST32_GET_BATTERY_LEVEL = 41
CMD_MTK_INFO_BATTERY_LEVEL = 42
CMD_ST32_INFO_CODI_STATUS = 43
CMD_MTK_SET_CODI_STATUS = 121
CMD_ST32_SET_LOCK = 45
CMD_ST32_GET_LOCK_STATUS = 46
CMD_MTK_INFO_LOCK_STATUS = 47
CMD_ST32_DISMISS_CALL_SMS = 48
CMD_ST32_ACTION_UNLOCK = 49
CMD_ST32_INFO_ST_CHARGING = 50
CMD_ST32_PLAY_DTMF = 51
CMD_ST32_SEND_DTMF = 52
CMD_ST32_ACTION_CALL = 53
CMD_ST32_SEND_TELE_CODE = 54
CMD_ST32_SET_CALL_MUTE_STATUS = 55
CMD_ST32_GET_CALL_MUTE_STATUS = 56
CMD_MTK_INFO_CALL_MUTE_STATUS = 57
CMD_ST32_SET_CALL_OUTPUT = 58
CMD_ST32_GET_CALL_OUTPUT = 59
CMD_MTK_INFO_CALL_OUTPUT = 60
CMD_ST32_GET_CALL_OUTPUT_OPTIONS = 61
CMD_MTK_INFO_CALL_OUTPUT_OPTIONS = 62
CMD_ST32_ACTION_CAMERA = 63
CMD_ST32_GET_CAMERA_FRAME = 64
CMD_ST32_SET_CAMERA_SETTINGS = 65
CMD_ST32_CAMERA_CAPTURE_IMAGE = 66
CMD_ST32_ACTION_VIDEO = 67
CMD_ST32_GET_VIDEO_FRAME = 68
CMD_ST32_SET_VIDEO_SETTINGS = 69
CMD_ST32_VIDEO_CAPTURE_IMAGE = 70
CMD_MTK_INFO_CAMERA_STATUS = 71
CMD_MTK_INFO_CAMERA_SETTINGS = 72
CMD_MTK_INFO_VIDEO_STATUS = 73
CMD_MTK_INFO_VIDEO_SETTINGS = 74
CMD_MTK_INFO_COVER_LIGHT_SENSOR = 75
CMD_ST32_GET_COVER_LIGHT_SENSOR = 76
CMD_MTK_LOAD_LANGUAGE_RESOURCE = 77
CMD_MTK_GET_CURRENT_LANGUAGE = 78
CMD_ST32_INFO_CURRENT_LANGUAGE = 79
CMD_MTK_SET_CURRENT_LANGUAGE = 80
CMD_MTK_SHOW_MEDIA = 81
CMD_MTK_STOP_MEDIA = 82
CMD_MTK_LOAD_MEDIA = 83
CMD_MTK_UNLOAD_MEDIA = 84
CMD_MTK_HAS_MEDIA = 85
CMD_ST32_INFO_MEDIA_RESOURCE = 86
CMD_ST32_INFO_MEDIA_ACTIVITY = 87
CMD_MTK_SHOW_ALERT = 88
CMD_ST32_INFO_ALERT = 89
CMD_MTK_STOP_ALERT = 90
CMD_MTK_ORIENTATION_INFO = 91
CMD_ST32_GET_ORIENTATION = 92
CMD_MTK_ACTION_CODI_HOME = 93
CMD_MTK_INFO_NEXT_ALARM = 94
CMD_MTK_SHOW_BATTERY_LEVEL = 95
CMD_ST32_GET_CALL_HISTORY = 96
CMD_ST32_GET_CONTACTS = 97
CMD_MTK_CONTACT_INFO = 98
CMD_MTK_CALL_HISTORY_INFO = 99
CMD_MTK_NOTIFICATION_INFO = 100
CMD_MTK_PLAYER_INFO = 101
CMD_ST32_ACTION_PLAYER = 102
CMD_MTK_CALL_INFO = 103
CMD_ST32_ACTION_NOTIFICATION = 104
CMD_ST32_GET_LEDISON_PATTERN = 105
CMD_MTK_LEDISON_MODE_INFO = 106
CMD_ST32_GET_LEDISON_MODE = 107
CMD_MTK_LEDISON_PATTERN_INFO = 108
CMD_ST32_GET_CONTACT_ICON = 109
CMD_MTK_CONTACT_ICON_INFO = 110
CMD_MTK_MODEM_SIGNAL_INFO = 111
CMD_MTK_WEATHER_INFO = 112
CMD_MTK_EXTRA_COMMAND = 113
CMD_ST32_GET_MODEM_SIGNAL_INFO = 114
CMD_ST32_GET_DATE_TIME_FORMAT = 115
CMD_MTK_DATE_TIME_FORMAT_INFO = 116
CMD_ST32_GET_ALBUM_ART = 117
CMD_MTK_ALBUM_ART_INFO = 118
CMD_MTK_CAMERA_FRAME_IMG = 119
CMD_MTK_KEY_PRESS_INFO = 120
CMD_ST32_ACTION_VOICE_RECODER = 122
CMD_ST32_SET_VOICE_RECORDER_SETTINGS = 123
CMD_MTK_INFO_VOICE_RECODER_SETTINGS = 124
CMD_MTK_INFO_VOICE_RECORDER_STATUS = 125
CMD_MTK_DATA_CHANGE_ALERT = 126
CMD_ST32_DATA_CHANGE_ALERT = 127
CMD_AEON_MTK_SET_ST32_RESET = 140
CMD_GET_ST32_SW_VERSION = 141
CMD_SYNC_USB_STATUS = 142
CMD_SYNC_SYS_SLEEP_STATUS = 143
CMD_SYNC_RIGHT_USB_OTG_STATUS = 144
CMD_ST_ENTRY_DEEP_SLEEP_STATUS = 145
def readMessage(msg):
cmdId, msg = readUint32(msg)
# print("Got cmdId", cmdId)
sessionId, msg = readUint32(msg)
# print("Got sessionId", sessionId)
handled = False
if cmdId == CMD_ST32_INFO_CODI_FLASH_VERSION:
handled = True
print("<- CoDiFlashVersionInfo")
try:
version, msg = readString(msg)
print("version =", version)
cf.CoDiFlashVersionInfo(version)
except Exception as e:
print(e)
if cmdId == CMD_ST32_INFO_PROTOCOL_VERSION:
handled = True
print("<- ProtocolVersionInfo")
try:
majorVer, msg = readUint8(msg)
minVer, msg = readUint8(msg)
print("majorVer =", majorVer)
print("minVer =", minVer)
cf.ProtocolVersionInfo(majorVer, minVer)
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_BINARY:
handled = True
print("<- SetBinary")
try:
data, msg = readBlob(msg)
print("data =", data)
cf.SetBinary(data)
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_S8:
handled = True
print("<- SetSigned8")
try:
num, msg = readInt8(msg)
print("num =", num)
cf.SetSigned8(num)
except Exception as e:
print(e)
if cmdId == CMD_ST32_RESTART:
handled = True
print("<- Restart")
try:
restartmode, msg = readUint32(msg)
print("restartmode =", restartmode)
cf.Restart(restartmode)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_DATETIME:
handled = True
print("<- GetDateTime")
try:
cf.GetDateTime()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_LOCATION_STATUS:
handled = True
print("<- SetLocationStatus")
try:
status, msg = readUint16(msg)
print("status =", status)
cf.SetLocationStatus(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_LOCATION_STATUS:
handled = True
print("<- GetLocationStatus")
try:
cf.GetLocationStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_TORCH_STATUS:
handled = True
print("<- SetTorchStatus")
try:
status, msg = readUint16(msg)
print("status =", status)
cf.SetTorchStatus(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_TORCH_STATUS:
handled = True
print("<- GetTorchStatus")
try:
cf.GetTorchStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_COVER_STATUS:
handled = True
print("<- GetCoverStatus")
try:
cf.GetCoverStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_WIFI_STATUS:
handled = True
print("<- SetWiFiStatus")
try:
status, msg = readUint16(msg)
print("status =", status)
cf.SetWiFiStatus(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_WIFI_STATUS:
handled = True
print("<- GetWiFiStatus")
try:
cf.GetWiFiStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_BT_STATUS:
handled = True
print("<- SetBTStatus")
try:
status, msg = readUint16(msg)
print("status =", status)
cf.SetBTStatus(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_BT_STATUS:
handled = True
print("<- GetBTStatus")
try:
cf.GetBTStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_BATTERY_SAVER_STATUS:
handled = True
print("<- SetBatterySaverStatus")
try:
status, msg = readUint16(msg)
print("status =", status)
cf.SetBatterySaverStatus(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_BATTERY_SAVER_STATUS:
handled = True
print("<- GetBatterySaverStatus")
try:
cf.GetBatterySaverStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_FLIGHT_MODE_STATUS:
handled = True
print("<- SetFlightModeStatus")
try:
status, msg = readUint16(msg)
print("status =", status)
cf.SetFlightModeStatus(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_FLIGHT_MODE_STATUS:
handled = True
print("<- GetFlightModeStatus")
try:
cf.GetFlightModeStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_HOTSPOT_STATUS:
handled = True
print("<- SetHotspotStatus")
try:
status, msg = readUint16(msg)
print("status =", status)
cf.SetHotspotStatus(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_HOTSPOT_STATUS:
handled = True
print("<- GetHotspotStatus")
try:
cf.GetHotspotStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_MOBILE_DATA_STATUS:
handled = True
print("<- SetMobileDataStatus")
try:
status, msg = readUint16(msg)
print("status =", status)
cf.SetMobileDataStatus(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_MOBILE_DATA_STATUS:
handled = True
print("<- GetMobileDataStatus")
try:
cf.GetMobileDataStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_DND_STATUS:
handled = True
print("<- SetDoNotDisturbStatus")
try:
status, msg = readUint16(msg)
print("status =", status)
cf.SetDoNotDisturbStatus(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_DND_STATUS:
handled = True
print("<- GetDoNotDisturbStatus")
try:
cf.GetDoNotDisturbStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_VOLUME_LEVEL:
handled = True
print("<- SetVolumeLevel")
try:
status, msg = readUint16(msg)
stream, msg = readUint16(msg)
print("status =", status)
print("stream =", stream)
cf.SetVolumeLevel(status, stream)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_VOLUME_LEVEL:
handled = True
print("<- GetVolumeLevel")
try:
stream, msg = readUint16(msg)
print("stream =", stream)
cf.GetVolumeLevel(stream)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_BATTERY_LEVEL:
handled = True
print("<- GetBatteryLevel")
try:
cf.GetBatteryLevel()
except Exception as e:
print(e)
if cmdId == CMD_ST32_INFO_CODI_STATUS:
handled = True
print("<- CoDiStatusInfo")
try:
mode, msg = readUint32(msg)
screen, msg = readUint32(msg)
data1, msg = readUint32(msg)
print("mode =", mode)
print("screen =", screen)
print("data1 =", data1)
cf.CoDiStatusInfo(mode, screen, data1)
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_LOCK:
handled = True
print("<- SetLock")
try:
status, msg = readUint16(msg)
print("status =", status)
cf.SetLock(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_LOCK_STATUS:
handled = True
print("<- GetLockStatus")
try:
cf.GetLockStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_DISMISS_CALL_SMS:
handled = True
print("<- 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)
cf.DismissCallSMS(sim, line, msisdn, text)
except Exception as e:
print(e)
if cmdId == CMD_ST32_ACTION_UNLOCK:
handled = True
print("<- ActionUnlock")
try:
method, msg = readUint32(msg)
strdata, msg = readString(msg)
print("method =", method)
print("strdata =", strdata)
cf.ActionUnlock(method, strdata)
except Exception as e:
print(e)
if cmdId == CMD_ST32_INFO_ST_CHARGING:
handled = True
print("<- STChargingInfo")
try:
status, msg = readUint32(msg)
measurement, msg = readUint32(msg)
print("status =", status)
print("measurement =", measurement)
cf.STChargingInfo(status, measurement)
except Exception as e:
print(e)
if cmdId == CMD_ST32_PLAY_DTMF:
handled = True
print("<- PlayDTMF")
try:
ascii_num, msg = readUint8(msg)
print("ascii_num =", ascii_num)
cf.PlayDTMF(ascii_num)
except Exception as e:
print(e)
if cmdId == CMD_ST32_SEND_DTMF:
handled = True
print("<- 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)
cf.SendDTMF(sim, line, asciinum, playit)
except Exception as e:
print(e)
if cmdId == CMD_ST32_ACTION_CALL:
handled = True
print("<- ActionCall")
try:
action, msg = readUint32(msg)
sim, msg = readUint32(msg)
line, msg = readUint32(msg)
numtype, msg = readUint32(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)
cf.ActionCall(action, sim, line, numtype, msisdn, contact, contact_id)
except Exception as e:
print(e)
if cmdId == CMD_ST32_SEND_TELE_CODE:
handled = True
print("<- SendTeleCode")
try:
sim, msg = readUint32(msg)
line, msg = readUint32(msg)
telecode, msg = readString(msg)
print("sim =", sim)
print("line =", line)
print("telecode =", telecode)
cf.SendTeleCode(sim, line, telecode)
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_CALL_MUTE_STATUS:
handled = True
print("<- SetCallMuteStatus")
try:
status, msg = readUint32(msg)
print("status =", status)
cf.SetCallMuteStatus(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_CALL_MUTE_STATUS:
handled = True
print("<- GetCallMuteStatus")
try:
cf.GetCallMuteStatus()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_CALL_OUTPUT:
handled = True
print("<- SetCallOutput")
try:
status, msg = readUint32(msg)
print("status =", status)
cf.SetCallOutput(status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_CALL_OUTPUT:
handled = True
print("<- GetCallOutput")
try:
cf.GetCallOutput()
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_CALL_OUTPUT_OPTIONS:
handled = True
print("<- GetCallOutputOptions")
try:
cf.GetCallOutputOptions()
except Exception as e:
print(e)
if cmdId == CMD_ST32_ACTION_CAMERA:
handled = True
print("<- ActionCamera")
try:
action, msg = readUint32(msg)
print("action =", action)
cf.ActionCamera(action)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_CAMERA_FRAME:
handled = True
print("<- GetCameraFrame")
try:
cf.GetCameraFrame()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_CAMERA_SETTINGS:
handled = True
print("<- SetCameraSettings")
try:
parameter, msg = readUint32(msg)
value, msg = readUint32(msg)
print("parameter =", parameter)
print("value =", value)
cf.SetCameraSettings(parameter, value)
except Exception as e:
print(e)
if cmdId == CMD_ST32_CAMERA_CAPTURE_IMAGE:
handled = True
print("<- CameraCaptureImage")
try:
cf.CameraCaptureImage()
except Exception as e:
print(e)
if cmdId == CMD_ST32_ACTION_VIDEO:
handled = True
print("<- ActionVideo")
try:
action, msg = readUint32(msg)
print("action =", action)
cf.ActionVideo(action)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_VIDEO_FRAME:
handled = True
print("<- GetVideoFrame")
try:
cf.GetVideoFrame()
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_VIDEO_SETTINGS:
handled = True
print("<- SetVideoSettings")
try:
parameter, msg = readUint32(msg)
value, msg = readUint32(msg)
print("parameter =", parameter)
print("value =", value)
cf.SetVideoSettings(parameter, value)
except Exception as e:
print(e)
if cmdId == CMD_ST32_VIDEO_CAPTURE_IMAGE:
handled = True
print("<- VideoCaptureImage")
try:
cf.VideoCaptureImage()
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_COVER_LIGHT_SENSOR:
handled = True
print("<- GetCoverLightSensor")
try:
cf.GetCoverLightSensor()
except Exception as e:
print(e)
if cmdId == CMD_ST32_INFO_CURRENT_LANGUAGE:
handled = True
print("<- CurrentLanguageInfo")
try:
langid, msg = readString(msg)
hasallresources, msg = readUint32(msg)
data1, msg = readUint32(msg)
print("langid =", langid)
print("hasallresources =", hasallresources)
print("data1 =", data1)
cf.CurrentLanguageInfo(langid, hasallresources, data1)
except Exception as e:
print(e)
if cmdId == CMD_ST32_INFO_MEDIA_RESOURCE:
handled = True
print("<- 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)
cf.MediaResourceInfo(typestr, resname, length, status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_INFO_MEDIA_ACTIVITY:
handled = True
print("<- MediaActivityInfo")
try:
typestr, msg = readString(msg)
resname, msg = readString(msg)
status, msg = readUint32(msg)
print("typestr =", typestr)
print("resname =", resname)
print("status =", status)
cf.MediaActivityInfo(typestr, resname, status)
except Exception as e:
print(e)
if cmdId == CMD_ST32_INFO_ALERT:
handled = True
print("<- AlertInfo")
try:
status, msg = readUint32(msg)
response, msg = readUint32(msg)
responsestr, msg = readUTF8String(msg)
print("status =", status)
print("response =", response)
print("responsestr =", responsestr)
cf.AlertInfo(status, response, responsestr)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_ORIENTATION:
handled = True
print("<- GetOrientation")
try:
cf.GetOrientation()
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_CALL_HISTORY:
handled = True
print("<- GetCallHistory")
try:
index, msg = readUint32(msg)
print("index =", index)
cf.GetCallHistory(index)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_CONTACTS:
handled = True
print("<- GetContacts")
try:
index, msg = readUint32(msg)
print("index =", index)
cf.GetContacts(index)
except Exception as e:
print(e)
if cmdId == CMD_ST32_ACTION_PLAYER:
handled = True
print("<- ActionPlayer")
try:
action, msg = readUint32(msg)
print("action =", action)
cf.ActionPlayer(action)
except Exception as e:
print(e)
if cmdId == CMD_ST32_ACTION_NOTIFICATION:
handled = True
print("<- ActionNotification")
try:
notid, msg = readUint32(msg)
action, msg = readUint32(msg)
pos, msg = readUint32(msg)
print("notid =", notid)
print("action =", action)
print("pos =", pos)
cf.ActionNotification(notid, action, pos)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_LEDISON_PATTERN:
handled = True
print("<- GetLEDisonPattern")
try:
contactid, msg = readString(msg)
contactname, msg = readUTF8String(msg)
msisdn, msg = readString(msg)
print("contactid =", contactid)
print("contactname =", contactname)
print("msisdn =", msisdn)
cf.GetLEDisonPattern(contactid, contactname, msisdn)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_LEDISON_MODE:
handled = True
print("<- GetLEDisonMode")
try:
cf.GetLEDisonMode()
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_CONTACT_ICON:
handled = True
print("<- GetContactIcon")
try:
contactid, msg = readString(msg)
contactname, msg = readUTF8String(msg)
msisdn, msg = readString(msg)
print("contactid =", contactid)
print("contactname =", contactname)
print("msisdn =", msisdn)
cf.GetContactIcon(contactid, contactname, msisdn)
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_MODEM_SIGNAL_INFO:
handled = True
print("<- GetModemSignalInfo")
try:
cf.GetModemSignalInfo()
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_DATE_TIME_FORMAT:
handled = True
print("<- GetDateTimeFormat")
try:
cf.GetDateTimeFormat()
except Exception as e:
print(e)
if cmdId == CMD_ST32_GET_ALBUM_ART:
handled = True
print("<- GetAlbumArt")
try:
mediasessionformat, msg = readBlob(msg)
print("mediasessionformat =", mediasessionformat)
cf.GetAlbumArt(mediasessionformat)
except Exception as e:
print(e)
if cmdId == CMD_ST32_ACTION_VOICE_RECODER:
handled = True
print("<- ActionVoiceRecorder")
try:
action, msg = readUint32(msg)
print("action =", action)
cf.ActionVoiceRecorder(action)
except Exception as e:
print(e)
if cmdId == CMD_ST32_SET_VOICE_RECORDER_SETTINGS:
handled = True
print("<- SetVoiceRecorderSettings")
try:
parameter, msg = readUint32(msg)
value, msg = readUint32(msg)
print("parameter =", parameter)
print("value =", value)
cf.SetVoiceRecorderSettings(parameter, value)
except Exception as e:
print(e)
if cmdId == CMD_ST32_DATA_CHANGE_ALERT:
handled = True
print("<- STDataChangeAlert")
try:
type, msg = readUint32(msg)
data1, msg = readUint32(msg)
print("type =", type)
print("data1 =", data1)
cf.STDataChangeAlert(type, data1)
except Exception as e:
print(e)
if cmdId == 143:
handled = True
print("<- CoDiOFF")
try:
par1, msg = readUint8(msg)
print("par1 =", par1)
par2, msg = readUint8(msg)
print("par2 =", par2)
cf.CoDiOFF(par1, par2)
except Exception as e:
print(e)
if cmdId == 147:
handled = True
print("<- MouseInfo")
try:
mode, msg = readUint8(msg)
print("mode =", mode)
x_coord, msg = readInt16(msg)
print("x_coord =", x_coord)
y_coord, msg = readInt16(msg)
print("y_coord =", y_coord)
cf.MouseInfo(mode, x_coord, y_coord)
except Exception as e:
print(e)
if cmdId == 148:
handled = True
print("<- MouseInfo2")
try:
pressState, msg = readUint8(msg)
print("pressState =", pressState)
previousState, msg = readUint8(msg)
print("previousSatate =", previousState)
x_coord, msg = readUint16(msg)
print("x_coord =", x_coord)
y_coord, msg = readUint16(msg)
print("y_coord =", y_coord)
cf.MouseInfo2(pressState, previousState, x_coord, y_coord)
except Exception as e:
print(e)
if not handled:
print("<- Unrecognised command", cmdId)

5
debian/changelog vendored Normal file
View file

@ -0,0 +1,5 @@
codi-app (0.1) stable; urgency=medium
* Initial release.
-- Davide Guidi <davide@planetcom.co.uk> Thu, 12 Nov 2020 21:30:03 +0000

1
debian/codi-app.install vendored Normal file
View file

@ -0,0 +1 @@
codi-app/* /usr/lib/codi

2
debian/codi-app0.1.substvars vendored Normal file
View file

@ -0,0 +1,2 @@
misc:Depends=
misc:Pre-Depends=

12
debian/codi-app0.1/DEBIAN/control vendored Normal file
View file

@ -0,0 +1,12 @@
Package: codi-app0.1
Source: codi-app
Version: 0.1
Architecture: arm64
Maintainer: Davide Guidi <davide@planetcom.co.uk>
Installed-Size: 9
Pre-Depends: dpkg (>= 1.16.1), python3.7
Depends: python3, python3-pydbus, python3-serial, python3-evdev, xdotool
Section: base
Priority: required
Description: Linux support for Cosmo Communicator CoDi
This package provide limited Cover Display functionality for Linux

2
debian/codi-app0.1/DEBIAN/md5sums vendored Normal file
View file

@ -0,0 +1,2 @@
171eebccc0f4df33f4215fe5bd83806e usr/share/doc/codi-app0.1/changelog.gz
e82b74912569e0320c7c5bfb9e54048e usr/share/doc/codi-app0.1/copyright

Binary file not shown.

View file

@ -0,0 +1,45 @@
ormat: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: codi-app
Source: https://github.com/gemian/codi-app
Files: *
Copyright: 2020 Davide Guidi
License: GPL-3
Files: debian/*
Copyright: Davide Guidi
License: LGPL-3
License: GPL-3
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3 of the License.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General
Public License can be found in "/usr/share/common-licenses/GPL-3".
License: LGPL-3
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU Lesser General
Public License can be found in "/usr/share/common-licenses/LGPL-3".

1
debian/compat vendored Normal file
View file

@ -0,0 +1 @@
9

13
debian/control vendored Normal file
View file

@ -0,0 +1,13 @@
Source: codi-app
Section: admin
Priority: required
Maintainer: Davide Guidi <davide@planetcom.co.uk>
Build-Depends: debhelper (>= 9), python3.7, dh-virtualenv (>= 0.8)
Standards-Version: 3.9.5
Package: codi-app
Architecture: any
Pre-Depends: dpkg (>= 1.16.1), python3.7, ${misc:Pre-Depends}
Depends: python3, python3-pydbus, python3-serial, python3-evdev, xdotool
Description: Linux support for Cosmo Communicator CoDi
This package provide limited Cover Display functionality for Linux

45
debian/copyright vendored Normal file
View file

@ -0,0 +1,45 @@
ormat: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: codi-app
Source: https://github.com/gemian/codi-app
Files: *
Copyright: 2020 Davide Guidi
License: GPL-3
Files: debian/*
Copyright: Davide Guidi
License: LGPL-3
License: GPL-3
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 3 of the License.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General
Public License can be found in "/usr/share/common-licenses/GPL-3".
License: LGPL-3
This package is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU Lesser General
Public License can be found in "/usr/share/common-licenses/LGPL-3".

29
debian/postinst vendored Normal file
View file

@ -0,0 +1,29 @@
#!/bin/sh
DESKTOP_FILE='[Desktop Entry]
Comment=CoDi functionalitites
Exec=/usr/lib/codi/codiServer.py
GenericName=
Icon=system-run
MimeType=
Name=
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username='
echo "Installing autostart script for existing users..."
for username in `ls /home`;
do
DEST="/home/$username/.config/autostart/codi.desktop"
echo "Installing codi.desktop in $DEST"
echo "$DESKTOP_FILE" > $DEST
chown $username.$username $DEST
done
exit 0

7
debian/rules vendored Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
%:
dh $@