Skip to content

Commit

Permalink
sip settings as lib + clear screen after boot
Browse files Browse the repository at this point in the history
  • Loading branch information
isra67 committed Feb 22, 2017
1 parent 37a28dc commit d6048d2
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 54 deletions.
4 changes: 2 additions & 2 deletions indoor.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sip_p4ssw0rd = heslo49

[devices]
ringtone = tone2.wav
volume = 20
volume = 60
sound_device_in =
sound_device_out =

Expand All @@ -23,7 +23,7 @@ btn_door_1 = Open Door 1
btn_door_2 = Open Door 2
screen_mode = 4
btn_call_answer = Answer Call
btn_docall = Do Call
btn_docall = Do Call :-)

[common]
server_ip_address_1 = 192.168.1.250
Expand Down
10 changes: 5 additions & 5 deletions indoor.kv
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
Screen:
name: 'waitscr'
id: waitscr
on_enter: lblresult.text = 'Moment...'
on_touch_down: _screen_manager.current = 'camera'
on_enter: lblresult.text = 'Wait a moment...'
# on_touch_down: _screen_manager.current = 'camera'

BoxLayout:
orientation: 'vertical'

Label:
text: 'Oznam:'
text: 'Information:'
font_size: self.height/5
color: 0.6,0.6,0.6,0.9
Label:
Expand All @@ -39,15 +39,15 @@
Screen:
name: 'clock'
id: clock
on_touch_down: root.swap2camera() #_screen_manager.current = 'camera'
on_touch_down: root.swap2camera()

BoxLayout:
MyClockWidget:

Screen:
name: 'digiclock'
id: digiclock
on_touch_down: root.swap2camera() #_screen_manager.current = 'camera'
on_touch_down: root.swap2camera()

BoxLayout:
DigiClockWidget:
Expand Down
3 changes: 3 additions & 0 deletions my_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# ### definitions for settings screen ###
from settingsjson import *

# ### SIP ###
from settingssip import *

# ### tools ###
from itools import *

Expand Down
Binary file modified my_lib/__init__.pyc
Binary file not shown.
Binary file modified my_lib/settingsjson.pyc
Binary file not shown.
36 changes: 36 additions & 0 deletions my_lib/settingssip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/python

# ###############################################################
#
# Imports
#
# ###############################################################


import pjsua as pj

from kivy.logger import Logger


# ###############################################################
#
# Functions
#
# ###############################################################

def setMediaConfig():
"pjSip media configuration"
mc = pj.MediaConfig()
mc.quality = 0 #8
mc.ec_tail_len = 0 #200
mc.clock_rate = 48000 #44100 #16000
Logger.warning('pjSip setMediaConfig: quality:%d ec_tail_len:%d clock_rater:%d'\
% (mc.quality, mc.ec_tail_len, mc.clock_rate))
return mc


def log_cb(level, str, len):
"pjSip logging callback"
# print str,
Logger.info('pjSip cb: ' + str)

Binary file added my_lib/settingssip.pyc
Binary file not shown.
79 changes: 32 additions & 47 deletions pjindoor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
def kill_subprocesses():
"tidy up at exit or break"

Logger.info(__name__ +': destroy lib at exit')
Logger.info(whoami() +': destroy lib at exit')
try:
pj.Lib.destroy()
except:
pass

Logger.info(__name__ +': kill subprocesses at exit')
Logger.info(whoami() +': kill subprocesses at exit')
for proc in procs:
try:
proc.kill()
Expand Down Expand Up @@ -113,12 +113,6 @@ def on_incoming_call(self, call):
current_call.answer(180)


def log_cb(level, str, len):
"pjSip logging callback"
# print str,
Logger.info('pjSip cb: ' + str)


class MyCallCallback(pj.CallCallback):
"Callback to receive events from Call"

Expand Down Expand Up @@ -530,16 +524,6 @@ def init_screen(self):
self.displays[0].setActive()


def setMediaConfig(self):
mc = pj.MediaConfig()
mc.quality = 0 #8
mc.ec_tail_len = 0 #200
mc.clock_rate = 44100 #16000
Logger.warning(whoami() + ': quality:%d ec_tail_len:%d clock_rater:%d'\
% (mc.quality, mc.ec_tail_len, mc.clock_rate))
return mc


def init_myphone(self):
"sip phone init"
global acc, config
Expand All @@ -549,8 +533,6 @@ def init_myphone(self):
# Create library instance
lib = pj.Lib()
self.lib = lib
# uacfg = lib.ua_cfg
# self.dbg('PJSIP max_calls: ' + str(uacfg.max_calls))

accounttype = 'peer-to-peer'
try:
Expand All @@ -561,7 +543,8 @@ def init_myphone(self):
try:
# Init library with default config and some customized logging config
lib.init(log_cfg = pj.LogConfig(level=LOG_LEVEL, callback=log_cb),\
media_cfg=self.setMediaConfig())
media_cfg=setMediaConfig())
# media_cfg=self.setMediaConfig())

comSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
comSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Expand Down Expand Up @@ -1311,13 +1294,13 @@ def on_config_change(self, cfg, section, key, value):
elif token == ('service', 'buttonpress'):
if 'button_status' == value:
self.myAlertBox('App status', 'uptime: ' + self.get_uptime_value())
elif token == ('service', 'buttonlogs'):
if 'button_loghist' == value:
# LoggerHistory.history:
recent_log = []
for record in reversed(LoggerHistory.history):
recent_log.append(record.msg)
self.myAlertListBox('Log history', recent_log)
# elif token == ('service', 'buttonlogs'):
# if 'button_loghist' == value:
# # LoggerHistory.history:
# recent_log = []
# for record in reversed(LoggerHistory.history):
# recent_log.append(record.msg)
# self.myAlertListBox('Log history', recent_log)
elif token == ('service', 'app_rst'):
if 'button_app_rst' == value:
self.myAlertBox('WARNING', 'Application is going to restart!', self.popupClosed)
Expand All @@ -1337,9 +1320,7 @@ def popupClosed(self, popup):
kill_subprocesses()

# send_command('sync')
# send_command('pkill omxplayer')
# send_command('pkill dbus-daemon')
send_command('pkill python')
# send_command('pkill python')

App.get_running_app().stop()

Expand Down Expand Up @@ -1369,9 +1350,12 @@ def close_settings(self, *args):

def myAlertBox(self, titl, txt, cb=None, ad=True):
"Alert box"
global scrmngr

Logger.debug(whoami()+': title='+titl+' msg='+txt)

if not cb is None: scrmngr.current = WAIT_SCR

box = BoxLayout(orientation='vertical', spacing=10)
box.add_widget(Label(text=txt, padding_y=80))
btn = Button(text='OK', size_hint=(1, 0.4))
Expand All @@ -1383,41 +1367,42 @@ def myAlertBox(self, titl, txt, cb=None, ad=True):
p.open()


"""
def myAlertListBox(self, titl, ldata, cb=None, ad=True):
"Alert box"
LJUST = 80
Logger.debug(whoami()+': title='+titl)
box = BoxLayout(orientation='vertical', spacing=5)
box = FloatLayout() #orientation='vertical', spacing=5, align='left')
# listdata = []
# for t in ldata:
# t = t.replace('[','*').replace(']','*')
# print '**'+t
# listdata.append(Label(text=t))#, halign='left'))
data = [{'text': t[:LJUST] + '...' if len(t) > LJUST else t.ljust(LJUST), 'is_selected': False} for t in ldata]
args_converter = lambda row_index, rec: {'text': rec['text'],
'size_hint_y': None,
'height': 25}
args_converter = lambda row_index, rec:\
{'text': rec['text'], 'size_hint': (None, None), 'height': 25} #, 'width': 600}
list_adapter = ListAdapter(data=ldata,
list_adapter = ListAdapter(data=data,
args_converter=args_converter,
cls=ListItemLabel,
selection_mode='single',
allow_empty_selection=True)
# list_view = ListView(item_strings=ldata, padding_y=10)
list_view = ListView(adapter=list_adapter, padding_y=10)
# list_view = ListView(adapter=list_adapter) #, size_hint=(1,1)) #, pos=(0,0), padding_y=10, halign='left')
list_view = ListView(item_strings=ldata, size_hint=(1,1))
box.add_widget(list_view)
# btn = Button(text='OK', size_hint=(1, 0.3))
# box.add_widget(btn)
# btn.bind(on_press=cb)
# for t in ldata:
# box.add_widget(Label(text=t, halign='left', size_hint=(1,None), height=25))
p = Popup(title=titl, content=box, size_hint=(0.8, 0.9), auto_dismiss=ad)
btn = Button(text='OK', size_hint=(None, None), width=128, height=48, pos_hint_y= .5)
box.add_widget(btn)
p = Popup(title=titl, content=box, size_hint=(0.9, 0.9), auto_dismiss=ad)
if cb is None: cb = p.dismiss
btn.bind(on_press=cb)
p.bind(on_press=cb)
p.open()
"""


# ###############################################################
Expand Down
3 changes: 3 additions & 0 deletions share/indoor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ pustaj() {

sleep 1

clear > /dev/tty1
setterm -cursor off > /dev/tty1

## working dir
cd /root/indoorpy
./hid_init.sh
Expand Down

0 comments on commit d6048d2

Please sign in to comment.