-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Ofono bridge #83
base: devel
Are you sure you want to change the base?
Conversation
adds `import_sim_phonebook` to `OfonoBridge`
ofono/bridge.py
Outdated
|
||
from helpers import Singleton, setup_logger | ||
|
||
DBusGMainLoop(set_as_default=True) # has to be called first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
threads_init()
Initialize threads in dbus-glib, if this has not already been done.
This must be called before creating a second thread in a program that uses this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this applies to us. If so, that's a big problem since many threads are created before app import even starts
@@ -1,5 +1,4 @@ | |||
from helpers import setup_logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, why? I think you need to revert this particular change, which reverses our "setup_logger" integration work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(as in, revert the logger-> logging replacements, not the from_string addition)
@@ -0,0 +1,2 @@ | |||
KERNEL=="ttyAMA0", ENV{OFONO_DRIVER}="sim900" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll be shipping this file in our own Debian package, most likely
ofono/bridge.py
Outdated
manager = bus.get('org.ofono', '/') | ||
modem_path = manager.GetModems()[0][0] | ||
|
||
if modem_path != '/sim900_0': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to have the sim900 modem as the default modem? As in, what's wrong if it's not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a check because if you run ofono with some plugins, you might have a /stk_test
virtual modem (standing for SimToolKit test
). I wanted to be able to check the modem was correctly initialized at this point, but it might be an issue when we switch to SIM52XX later on. Shall I remove it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"check if it's correctly initialized" - you mean, check if it's available? If so, I'm guessing it might still be there in some cases, just not the 0th element in the list of the modems that you'll get. I suggest using if "/sim900_0" in manager.getModems()[0]
or something along those lines.
ofono/bridge.py
Outdated
@property | ||
def _bus(self): | ||
# lil hack so we always have an up-to-date bus | ||
return pydbus.SystemBus().get('org.ofono', '/sim900_0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That "/sim900_0" string looks like it could benefit from being an attribute, it's repeated 3 times in this class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
ofono/bridge.py
Outdated
return self._get_dbus_interface('MessageManager') | ||
|
||
def _get_dbus_interface(self, name): | ||
''.startswith('org.ofono') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this particular line of code do here? It seems like a leftover line of code.
ofono/bridge.py
Outdated
def main(): | ||
ofono = OfonoBridge() | ||
ofono.start() | ||
mainloop = GLib.MainLoop() # todo : own thread |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it - you have the GLib.MainLoop
, and you have the DBusGMainLoop
initialized in the beginning - are you sure you need both?
ofono/bridge.py
Outdated
|
||
@property | ||
def _bus(self): | ||
# lil hack so we always have an up-to-date bus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's happening with the bus? Why can it get out-of-date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you get the bus, you actually get a snapshot of the currently available methods.
So if you get the bus before the modem is initialized you don't have any method. Using it that way ensures you always have the latest exposed methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood! Would be great to put this explanation in the docstring/comment inside that function =)
ofono/bridge.py
Outdated
if modem_path != '/sim900_0': | ||
raise ValueError("Default modem should be '/sim900_0', was '{}'".format(modem_path)) | ||
|
||
# self.start() #todo: check if it's the suitable place to do it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so - it makes sense not to start() the loop right when the OfonoBridge is initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in, explicit is better than implicit =)
ofono/bridge.py
Outdated
try: | ||
self._bus.SetProperty("Powered", pydbus.Variant('b', True)) | ||
sleep(2) # Let the modem some time to initialize | ||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Just
except:
is enough if you want a catch-all - I think that, if the modem can't power on, we'll want some more information - as much as the exception can provide us, and maybe more, so don't skimp on logging here =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
ofono/bridge.py
Outdated
super(ConversationManager, self).__init__() | ||
self.folder = os.path.expanduser("~/.phone/sms/") # todo: store as a constant somewhere | ||
if not os.path.exists(self.folder): | ||
os.mkdir(self.folder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll probably want os.mkdirs
- it works like mkdir -p
Why do we need it as a separate package (in the ZPUI folder root), instead of having it as a library in one of the apps? |
We don't need it as a separate package, but in my mind 'apps' are programs the user interact with. Ofono bridge is indeed a library on which will depends 'phone app', 'sms app' and maybe others. So i didn't know where to place it in the hierarchy. Open to suggestion ! |
ofono/bridge.py
Outdated
mainloop.run() | ||
except KeyboardInterrupt: | ||
logger.info("Caught CTRL-C:exiting without powering off...") | ||
except AttributeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.exception
instead of just error
, and make it a catch-all (as in, except:
instead of catching AttributeError)? Would be great to have exception information in the logs, as well as protect from future errors.
I'm working on this now. First thing first, modem communications (and easy-to-use timestamps) can be seen by using this ofonod CLI:
You can get the
|
Ofono is already run at startup (debian ships a .service file), shall we have our own fork, we'll use that |
…KeysInput to use baseViewMixin
Codecov Report
@@ Coverage Diff @@
## devel #83 +/- ##
==========================================
+ Coverage 41.26% 41.41% +0.14%
==========================================
Files 260 266 +6
Lines 21830 22224 +394
==========================================
+ Hits 9008 9203 +195
- Misses 12822 13021 +199
Continue to review full report at Codecov.
|
ouch, accident |
…ocess the mapping in view's __init__
…tegerAdjust to use views
…oving cflip out of canvas.py, exposting all these functions (and more) in ui/__init__.py
…ld've been done initially), changing the action_key leakage test to mapping leakage test
ofono bridge progress
purpose
Use ofono as a backend for all phone/texting features
implementation
A new package
ofono
contains all the libraries, the classOfonoBridge
is the interface between ZPUI and Ofono.OfonoBridge
uses D-Bus to communicate with ofono and thus needs a new dependency :pydbus
library (added torequirements.txt
).issues
todo
zpui
ofono
system
00-ofono.rules
for SIM800L (to be placed in/etc/udev/rules.d/
)