OBiTALK Community

General Support => Day-to-Day Use => Topic started by: QBZappy on October 03, 2011, 03:40:36 PM

Title: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 03, 2011, 03:40:36 PM
I think it would be a good idea to have a thread for anyone interested in offering OBi related apps/scripts, etc... If you have the skills this could be the place to offer and discuss. There would be people on this board who would like the idea of super charging their OBi's. If the OBihai people would offer the ability of the syslog to provide more useful information, much of it could be done just by parsing the syslog records. Imagine all the call states with other relevant call info such as incoming/outing numbers, call duration, dates times, available for apps developers. At the moment a few have tried scrapping the OBi web pages for info.

Some ideas which may have already been requested on the board and other useful ideas:
CID lookup (GV contacts/and other callers)
Reverse number lookups
Outlook integration
Growl/YAK/NCID CID delivery systems
Click2dial to sip phone or to attached OBi phone
Asterisk Click2dial
Dial plan configurator utility/wizard (my favorite). Some of these basic dial plans could easily be setup programmatically with a little input from the user. I only wish I had these skills. (This could possibly relieve RonR from repeating similar dial plan setups  ;D )

Have I missed anything?
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 03, 2011, 08:04:00 PM
Hardware VoIP Monitor: desktop VoIP and PBX monitoring

http://www.reincubate.com/labs/hardware-voip-monitor-desktop-voip-and-pbx-monitoring/#extension

HVoIPM is a small desktop application that can be used to monitor one or more heterogenous VoIP or PBX systems. Users can choose from a range of device monitors (or build their own) to provide telephony data to be logged or displayed on screen. For instance, the software could be used to log all calls made by a certain device, or to flash up a warning or launch a process when a VoIP device's registration state goes offline.

Software is a bit dated, however this free (for non-commercial use) 3rd party app, needs dot net v2, which can read many types of ATA info gives a lot of interesting ideas on how it can be done. Software can be extented to include the OBi.
Title: Re: 3rd party apps development for the OBi 110/100
Post by: Everton on October 04, 2011, 09:42:05 AM
The CNAM lookup from GV Contacts is the single most desirable feature for me.  90-95 % of the calls we receive are from individuals/companies that are in my Contact list.  Any new Number/Name is quickly added to this list and calls from Telemarketers or other undesirable sources are Blocked using Google Voice blocking mechanism.

I would want the information pass to the phone, as oppose to a PC running on the LAN.  I wonder if there are any technical hurdles that would prevent OBi from implementing a CNAM pass-thru from GV Contacts.  There is also the possibility that OBi could utilize their OBiTALK Networking capabilities to do reverse lookups for a minimal annual fee of say $10.00 or where the each user can upload their contact data to the cloud as a lookup source.  Finally, a DDWRT/Tomato "OPT" integration could be possible, if the data could be quickly pass to the OBi1xx and then to the phone between the first and second ring!
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 04, 2011, 11:32:45 AM
Everton,

You should offer to test this app that forum member bhasden generously offered to build. It seems to be exactly what you want.

Quote from: bhasden on October 03, 2011, 03:42:56 PM
Right now it only supports looking up contacts using your Google contacts. If the number is in Google, it will retrieve the name and display it using Growl. I'm in the middle of message around with adding modem support for anyone who has a machine with a modem to retrieve the caller id information from there along with adding support to pull caller information from another source like the WhitePages API. The software is in early beta stages right now which is why I need the help testing it.
Title: Re: 3rd party apps development for the OBi 110/100
Post by: psichel on October 04, 2011, 12:30:50 PM
QuoteI wonder if there are any technical hurdles that would prevent OBi from implementing a CNAM pass-thru from GV Contacts.

Getting GV Contacts is fairly easy, they are listed on your GV inbox page. The technical hurdle is that there is no published API for Google Voice, so there's a risk of Google changing the service and breaking devices in the field.

FYI: I'm the developer of Phone Amego which provides on-screen Caller ID, click-to-dial, and Macintosh integration for Bluetooth cell phones, landlines, and VoIP (including OBi ATAs). Phone Amego does reverse lookups using many sources: Apple's Address Book (which synchs automatically with Google Contacts), local lookup file or contact card, Daylite CRM from Marketcircle, and online reverse lookup websites. From what I can tell, web reverse lookup services have Terms of Service (TOS) that limit their commercial application or require a subscription.

http://www.sustworks.com/pa_guide/index.html

Enjoy!

- Peter
Title: Re: 3rd party apps development for the OBi 110/100
Post by: bhasden on October 04, 2011, 08:27:12 PM
Quote from: Everton on October 04, 2011, 09:42:05 AM
The CNAM lookup from GV Contacts is the single most desirable feature for me.  90-95 % of the calls we receive are from individuals/companies that are in my Contact list.  Any new Number/Name is quickly added to this list and calls from Telemarketers or other undesirable sources are Blocked using Google Voice blocking mechanism.

I would want the information pass to the phone, as oppose to a PC running on the LAN.  I wonder if there are any technical hurdles that would prevent OBi from implementing a CNAM pass-thru from GV Contacts.  There is also the possibility that OBi could utilize their OBiTALK Networking capabilities to do reverse lookups for a minimal annual fee of say $10.00 or where the each user can upload their contact data to the cloud as a lookup source.  Finally, a DDWRT/Tomato "OPT" integration could be possible, if the data could be quickly pass to the OBi1xx and then to the phone between the first and second ring!


Please visit http://riotouslabs.com (http://riotouslabs.com) to download a copy of GrowlerID. GrowlerID supports notifications through the Growl interface, detecting incoming calls to the Obihai device, retrieving caller id information and photos (photos only work with Growl for now) from Google contacts, retrieving caller id information from FreeCNAM.

The website is absolutely barebones right now. Please provide feeback through the UserVoice forum (http://riotouslabs.uservoice.com (http://riotouslabs.uservoice.com)).

The version available through the website right now will only run until November 1st. It's currently in beta and as a result, may contain bugs and/or broken/partially implemented features.

Thank you to anyone who chooses to help beta test.
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 04, 2011, 10:14:50 PM
bhasden

Hi, I decided to test it by calling myself from a second GV account. I'm having a little trouble setting this up.
1) I don't see the GrowlerID in the All Programs list after installation. Is it set to automatically start with Growl every time?
2) I don't see it registered as an application in Growler and I don't see a way of registering the app.
(I take it back. It took a while, but GrowlerID registered with Growler after I maximized GorwlerID after a few times of trying)
3) In GrowlerID config, use Modem to detect incoming calls is optional? If you select to checkmark I suppose you need a voice modem. If check not selected is the CID being picked up via GV or the OBi device?
4) Clarify how the RJ11 connections are to be made between the various pieces of equipment.

I suppose we will take this to the other forum after these preliminaries. Since it is new, I don't see if there is a place for you to reply or it is only one way feedback from your beta testers.
http://riotouslabs.uservoice.com/forums/136299-general

PS: On clicking apply in the config it's neat to see a nice blue GrowlerID test notification.
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 04, 2011, 10:23:23 PM
Everton,

Quote from: Everton on October 04, 2011, 09:42:05 AM
Finally, a DDWRT/Tomato "OPT" integration could be possible, if the data could be quickly pass to the OBi1xx and then to the phone between the first and second ring!

Not quite sure what you mean by this. Can you explain your idea further?
Title: Re: 3rd party apps development for the OBi 110/100
Post by: bhasden on October 04, 2011, 10:34:31 PM
Quote from: QBZappy on October 04, 2011, 10:14:50 PM
bhasden

Hi, I decided to test it by calling myself from a second GV account. I'm having a little trouble setting this up.
1) I don't see the GrowlerID in the All Programs list after installation. Is it set to automatically start with Growl every time?
2) I don't see it registered as an application in Growler and I don't see a way of registering the app.
(I take it back. It took a while, but GrowlerID registered with Growler after I maximized GorwlerID after a few times of trying)
3) In GrowlerID config, use Modem to detect incoming calls is optional? If you select to checkmark I suppose you need a voice modem. If check not selected is the CID being picked up via GV or the OBi device?
4) Clarify how the RJ11 connections are to be made between the various pieces of equipment.

I suppose we will take this to the other forum after these preliminaries. Since it is new, I don't see if there is a place for you to reply or it is only one way feedback from your beta testers.
http://riotouslabs.uservoice.com/forums/136299-general

PS: On clicking apply in the config it's neat to see a nice blue GrowlerID test notification.


1) GrowlerID should be located under Programs -> Riotous Labs -> GrowlerID. It will not automatically start with Growl. For now, you can copy the shortcut into your Startup folder, although I will be adding a checkbox to the configuration dialog in the next few days.
2) In order for GrowlerID to register as an application in Growl, Growl must first be started. You can download it at http://www.growlforwindows.com (http://www.growlforwindows.com). I should clarify that Growl is not required. If Growl isn't installed you'll get regular windows notifications in the task bar that notify you of an incoming call. The great thing about Growl is that it can forward the notifications to just about anything (iPhone, Android, other computers, etc.).
3) The Modem tab in the configuration is a work in progress feature. In my home setup, I've got the my landline running into the modem of my home server since they're both in the same closet. It's not a feature that would be useful for Obihai users, but for someone who has an existing home phone line and would like to use the GrowlerID software to detect incoming calls.
4) There's no need to connect anything to anything. The only setup that needs to be done for Obihai users is to  enable the Obihai device monitoring and enter your Obihai IP address and password. If you don't have Google Voice enabled, you'll get caller id information from Free CNAM. The caller id lookup order goes Google Voice then Free CNAM. If a contact is found in Google Voice, that's the contact it uses. If the contact isn't found or Google Voice integration is turned off, it will move to searching Free CNAM.


After explaining the setup, I feel like I should definitely create some sort of wizard setup for the software instead of relying on the user to figure everything out through the tabs. I thought they would be straight forward enough, but now I'm thinking they will not be. Originally I was configuring everything through Notepad, so the dialog is new.

Please let me know if you have any other questions or any suggestions.
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 04, 2011, 11:35:36 PM
Methods to reboot the OBi automatically can be found here:
http://www.obitalk.com/forum/index.php?topic=1152.0

Windows vbs script obi-reboot.vbs (offered by infin8loop)

Linux  (offered by earthtoobi)
lwp-request -C admin:<password> -e -d http://192.168.x.x/rebootgetconfig.htm


Bonus:

Common wall timer (Attach the OBi power cord to a daily/weekly timer. Offered by QBZappy  ;D)
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 05, 2011, 12:05:03 AM
bhasden,

No joy.

Does the firmware version of the OBi make any difference?
I am calling from an OBi100 (1.3.0 Build: 2532) to an OBi 110 (1.2.1 Build: 2384).
I am calling using 2 different GV numbers. OBi100 GV number to another OBi110 GV number.

GrowlerID config:
GVoice tab set to GV acct on the OBi110 (user name only, not using the full email address + GV PW)
Obihai tab set to IP of OBi110 + Pass Word

I compared the call history of GV and OBi device. Both show receiving call from OBi100 number. Difference is that OBi110 shows 11 digits (Peer Number with a "1" in front), GV shows 10 digits (call does not show preceeding "1")

Call goes to GV VM. What do you think?
Title: Re: 3rd party apps development for the OBi 110/100
Post by: bhasden on October 05, 2011, 05:19:35 AM
Quote from: QBZappy on October 05, 2011, 12:05:03 AM
bhasden,

No joy.

Does the firmware version of the OBi make any difference?
I am calling from an OBi100 (1.3.0 Build: 2532) to an OBi 110 (1.2.1 Build: 2384).
I am calling using 2 different GV numbers. OBi100 GV number to another OBi110 GV number.

GrowlerID config:
GVoice tab set to GV acct on the OBi110 (user name only, not using the full email address + GV PW)
Obihai tab set to IP of OBi110 + Pass Word

I compared the call history of GV and OBi device. Both show receiving call from OBi100 number. Difference is that OBi110 shows 11 digits (Peer Number with a "1" in front), GV shows 10 digits (call does not show preceeding "1")

Call goes to GV VM. What do you think?


When saving the configuration, do you get any errors? If the configuration saves, that means it was able to authenticate both the Obihai and the GV credentials.
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 05, 2011, 08:03:31 AM
I press "Apply" get test notification, then "OK". No error messages.
Title: Re: 3rd party apps development for the OBi 110/100
Post by: bhasden on October 05, 2011, 08:18:59 AM
Quote from: QBZappy on October 05, 2011, 08:03:31 AM
I press "Apply" get test notification, then "OK". No error messages.

You should be good then. If you disable Growl notifications do you get the balloon notification when an incoming call occurs?
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 05, 2011, 08:23:00 AM
Yes
Sorry I meant to say No. I don't get anything on an incoming call. Without Growl running pressing "Apply" gives me a different style of notification pop up.
Title: Re: 3rd party apps development for the OBi 110/100
Post by: bhasden on October 05, 2011, 08:25:17 AM
Quote from: QBZappy on October 05, 2011, 08:23:00 AM
Yes

Sent you a PM so we can take this out of the forum. Thanks for your help.
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 08, 2011, 02:26:13 PM
I had previously mentioned a desktop application called HVoIPM (Hardware VoIP Monitor) which could be used to monitor the OBi device. The author has graciously offered the source code to the OBi community (and anyone else for that matter) who would like to continue the project. This might be of interest to any current or future 3rd party OBi app developers. You can find it here:

HVoIPM (Hardware VoIP Monitor)
https://github.com/afit/HVoIPM

Author:
Thanks for your email. I'm afraid I no longer have time to support the Hardware VoIP Monitor. I'm glad to read there's an attempt to make something similar. I took the step to publish the full source code of my application today, at https://github.com/afit/HVoIPM. It may be that the community can extend this or use it in building their application.

Best,
Aidan Fitzpatrick
http://www.reincubate.com/labs/hardware-voip-monitor-desktop-voip-and-pbx-monitoring/
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on October 17, 2011, 03:04:45 PM
Here is a tool that might help OBi 3rd party apps developers integrate the OBi with GV calling.

xPLGVoice
http://www.doghouselabs.com/software/index.cgi?cat=xpl&app=xPLGVoice

Description: xPLGVoice gives you access to some features of Google Voice. It allows you to send SMS, enable and disable forwarding phones and initiate calls.

Usage: Edit the config.txt file with your gmail user name and password.

In the right hands this little utility can supplement the OBi feature set. I can see it being able to make outbound calls from Outlook doing a Google callback and then connecting you to the dialed number.
Title: Upload custom AA prompts
Post by: Stewart on October 20, 2011, 01:17:00 AM
Here is a simple script, written in perl, that creates a file of custom auto-attendant prompts, suitable for uploading to your OBi.  I'm running it on Windows under ActiveState's free perl.  It does nothing exotic, so I'd expect it to work ok on a Mac or Linux system as well, using the perl that comes preinstalled.  Let me know of your success or failure on other platforms.

The script looks in the current directory for files named user1.wav, user2.wav ... user10.wav and uses those found to create a combined file, useraa.dat that can be uploaded to the OBi.  Each input file must be mono, 8kHz sampling rate, G.726-32 encoded, with length between 0.25 and 60 seconds.

Various tools I tried, including Audacity, an old copy of Audition, and several converters, would not produce a G.726-32 file of good quality.  One solution is to to create the prompts in your favorite authoring tool, save as 16-bit PCM wav format, then convert with ffmpeg, which is free and readily available for Windows, Mac and Linux.  The command is e.g.

ffmpeg -i original.wav -acodec g726 -ab 32000 user1.wav

Once you have all the user<n>.wav files, run the perl script and upload the useraa.dat to your OBi.

I'd appreciate feedback on any quality issues, better ways to create G.726-32 files, etc.

Before uploading, make backups of your config and current prompts.  While developing this code, I had a bug that caused the OBi to endlessly reboot.  I believe that is now very unlikely, but if it should happen to you, don't panic and see this thread: http://www.obitalk.com/forum/index.php?topic=1726.0  Just in case you don't have a backup, a copy of an empty prompts file, courtesy of Obihai support, is also attached.

This is open source free software and I'm imposing no restrictions on its use.  However, if you fix bugs or add features, please post the improved code here.  If you incorporate it in a larger project, please provide an acknowledgement.

Enjoy.
Title: Re: 3rd party apps development for the OBi 110/100
Post by: Stewart on February 29, 2012, 05:27:14 PM
Quote from: user17600 on February 29, 2012, 05:07:36 PMI don't get any of the intermediate messages that seem to be built into the script.  I get a pause and them a "wrote file" message.  So something's not right...
I'm not familiar with Strawberry and was using ActiveState perl to test.

The first 'open' statement should be trying to open user1.wav in the current directory (not necessarily the directory the script is in).  At the command line, if you type "dir user1.wav" and press enter (just before or after running the script), does the file appear in the listing?  If so, can you open it by other means, e.g. does "copy user1.wav testxxx.wav" give any errors?
Title: Re: 3rd party apps development for the OBi 110/100
Post by: QBZappy on February 19, 2013, 02:04:01 PM
Well it has come to my attention that the "mother of all 3rd party apps for OBi devices" is graciously being offered by our long time friend and top contributor RonR.

Dial Plan Generator for OBi100/110/202
http://www.dslreports.com/forum/r28024065-Dial-Plan-Generator-for-OBi100-110-202

Welcome back to the voip cumminity. Considering that your offering at DSL Reports is an "OBi" Dial Plan Generator, it surely belongs in this thread, and on this forum.

Why don't you personally offer it to us in this thread.
Title: re: Upload Custom AA prompts
Post by: John_Sauter on September 02, 2013, 05:50:43 AM
In the nearly two years since Stewart's posting ffmpeg has changed.  Instead of -ab 32000 you should use -ar 8k.  Here is the script I use to upload my Auto Attendant prompts:

#!/bin/bash
# Create with espeak -m -f <text file> -w <wave file>
# wave files for each synthesized Obihai prompt.
espeak -m -f welcome.txt -w welcome.wav
espeak -m -f main.txt -w main.wav
# Convert all of the prompts to g726 format using ffmpeg:
ffmpeg -y -i welcome.wav -acodec g726 -ar 8k user1.wav
ffmpeg -y -i noise_2sec.wav -acodec g726 -ar 8k user2.wav
ffmpeg -y -i main.wav -acodec g726 -ar 8k user3.wav
ffmpeg -y -i silence_1sec.wav -acodec g726 -ar 8k user4.wav
#
# Convert the user1.wav through up to user10.wav files
# into Okihai's upload format:
perl aa.pl
#
# Use the upload firmware feature of the Oki110.
# Specify the file useraa.dat created by the above
# perl script.  After a reboot the new voices
# will be available.
#

For completeness, and to prevent it from being lost, here is Stuart's perl program referenced above.  If this is whitespace-damaged you should download it from Stuart's original posting, a few replies ago in this thread.

#!/usr/bin/perl -w
use Digest::MD5 qw(md5);
$data = $names = '';
$filcnt = 0;
for $i (1 .. 10) {
    next unless open(IN, "user$i.wav");
    print "Reading user$i.wav\n";
    binmode(IN);
    unless (($cnt = read(IN, $rbuf, 60 * 4000)) > 1000 && $cnt < 60 * 4000
            && ($pos = index($rbuf, "data")) > 20 && $pos < 100) {
        print "Invalid size or format -- ignoring file\n";
        next;
    }
    $samps = ($cnt - $pos - 8) & ~7; # truncate to multiple of 8 bytes
    $names .= pack("a8 N N N", "\%USER$i\%", length($data), 0, 0);
    $data .= pack("N N", $samps, 0) . substr($rbuf, $pos + 8, $samps);
    ++$filcnt;
}
length($data) < 120 * 4000 or die "Total exceeds 120 seconds -- aborting\n";
$body = pack("N N", length($data), 0) . $data;
$body .= pack("N N", $filcnt, 0) . $names;
open(OUT, ">useraa.dat") or die "Can't write output file\n";
binmode(OUT);
print OUT "OBUSRLGE", pack("N", length($body)), md5($body), "\0\0\0\0", $body;
close(OUT) or die "Error writing output file\n";
print "Wrote useraa.dat\n";

Title: Caller ID from the OBi 202 to xbmc and YAC Listeners
Post by: DMcK on October 13, 2013, 03:32:17 PM
Hi,

Here's my caller ID to xbmc and YAC Listener script!  It's not pretty, but it seems to work (with very little testing!)  You'll need a linux server for this to work. I'm using Ubuntu 12.04 and the following instructions are for that. You'll need to enable syslog on your OBi (System Management>Device Admin>Syslog and add your server IP, Port 514, Level 7)

~/YourScript.sh:
#!/bin/bash
##############
## lockfile ##
##############
exec 9>/tmp/callerid-lockfile
if ! flock -n 9  ; then
  exit 1
fi
# this script now runs under the lock until 9 is closed. it will be closed automatically when the script ends.

####################
##  Configuration ##
####################
LOGLOCATION="/var/log/obi202.log"    # the location of your syslog log
IPADDRESSSTART="192.168.0."   # only the first 3 values and dots for your LAN IP Address
XBMCIPs=(116 115 112)    # the last value(s) of the ip address(es) of your xbmc devices(s)
XBMCPORT="8080"        # default port for xbmc webserver
XBMCPOPUPDURATION="7000"     # in msecs (i.e., 7000 = an xbmc popup for 7 seconds)
YACIPs=(234 190)      # the last value(s) of ip address(es) for computer you want YAC popups
YACPORT="10629"     # default port for YAC is 10629.

####################################
##   Extract string from the log  ##
####################################
sleep 0.1        # allow a bit of time for log messages to complete.
STRINGFROMLOG=$(tac $LOGLOCATION | grep -B 1 -m1 'Command: 1, 3, 0, 0, 4, 1086133200,' | tac)         # invert log to find first line before "Command: 1, 3, 0...". This is the last Caller ID entry.
STRINGFROMLOG=$(sed -n -e 's/^.*1086133200, //p' <<< $STRINGFROMLOG)         # Strip off everything after "1086133200, " to leave just the CID info.
DATE=${STRINGFROMLOG:0:15}
UNIXDATE=$(date --date "$DATE" +%s)
NOW=$(date +%s)
TIMEDIFF=$(($NOW-$UNIXDATE))
if [ "$TIMEDIFF" -gt "10" ]    # if the current date/time and the date/time from the log are more that 10s apart, then the log updated from something other than an incoming call. exit.
then exit
fi
NAME=$(sed "s/.*'\(.*\)'[^']*$/\1/" <<< $STRINGFROMLOG)    # strip out the name between the single quotes
NAMEFORCURL=${NAME// /%20}                        # curl command doesn't like spaces so use %20 instead
NUMBER=$(sed 's/.*\ //' <<< $STRINGFROMLOG)       # gets all characters after the last space (i.e., the number)

####################
##  XBMC Portion  ##
####################
MIDDLE='","message":"'
END='"\},"displaytime":'$XBMCPOPUPDURATION',"id":1\}'
for i in ${XBMCIPs[@]}; do
   START='http://'$IPADDRESSSTART${i}':'$XBMCPORT'/jsonrpc?request=\{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":\{"title":"'
   URL=$START$NAMEFORCURL$MIDDLE$NUMBER$END   # assemble the URL string for curl
   curl --request GET $URL    # send the notification request to xbmc
done

####################
##   YAC Portion  ##
####################
START="@CALL"
MIDDLE="~"
for i in ${YACIPs[@]}; do
   MESSAGE=$START$NAME$MIDDLE$NUMBER      # assemble the message string for netcat
   echo $MESSAGE| nc -w 1 $IPADDRESSSTART${i} $YACPORT       # send the message to the YAC Listeners
done

exit 0


Change the configuration section of the script as required. Enable the webserver (Settings>Services>Webserver>Allow control of XBMC via HTTP) in xbmc.  Install YAC on any computers you want Caller ID notification and put a YAC Listener shortcut in your start folder. If you have passwords set up in the xbmc webserver, you'll need to modify the START variable in the xbmc section accordingly (i.e., 'http://' becomes 'http://username:password@'.  

Make the script executable:
sudo chmod 777 ~/YourScript.sh

My syslog is going to /var/log/obi202.log. configure rsyslog to write the log file there:
sudo touch /var/log/obi202.log
sudo nano /etc/rsyslog.conf
->Add the following:
#
# Log from OBI202
#
local7.*    /var/log/obi202.log



Add the '-r" switch as shown below:
sudo nano /etc/default/rsyslog
->change the last line to:         RSYSLOGD_OPTIONS="-c5 -r"


I changed ownership of the file while testing. I think you'll need to also, but I'm not sure. It doesn't hurt:
sudo chown yourusername:yourusername /var/log/obi202.log

Rotate the log occasionally so it doesn't get too big:
sudo nano /etc/logrotate.d/obi202.log
->Add the following:
/var/log/obi202.log monthly
{
   rotate 4
   missingok
   notifyempty
   compress
   create }


restart rsyslog:
sudo service rsyslog restart

Change the ownership and permissions of the lockfile:
sudo chown yourusername:yourusername callerid-lockfile
sudo chmod 777 callerid-lockfile


I monitor the log file and launch the script using incron:
sudo apt-get install incron
sudo nano /etc/incron.allow
->Add this:    root
sudo incrontab -e
->Add this:   /var/log/obi202.log IN_MODIFY /bin/bash /home/yourusername/YourScript.sh


I think that's everything. With the exception of the script, much of that was from memory or some simple notes. So I hope I got it all.

Enjoy!
Title: Re: re: Upload Custom AA prompts
Post by: lucaspiller on June 03, 2014, 09:38:32 AM
Here is John's script in code tags, so that emoticons aren't processed.


#!/usr/bin/perl -w
use Digest::MD5 qw(md5);
$data = $names = '';
$filcnt = 0;
for $i (1 .. 10) {
    next unless open(IN, "user$i.wav");
    print "Reading user$i.wav\n";
    binmode(IN);
    unless (($cnt = read(IN, $rbuf, 60 * 4000)) > 1000 && $cnt < 60 * 4000
            && ($pos = index($rbuf, "data")) > 20 && $pos < 100) {
        print "Invalid size or format -- ignoring file\n";
        next;
    }
    $samps = ($cnt - $pos - 8) & ~7; # truncate to multiple of 8 bytes
    $names .= pack("a8 N N N", "\%USER$i\%", length($data), 0, 0);
    $data .= pack("N N", $samps, 0) . substr($rbuf, $pos + 8, $samps);
    ++$filcnt;
}
length($data) < 120 * 4000 or die "Total exceeds 120 seconds -- aborting\n";
$body = pack("N N", length($data), 0) . $data;
$body .= pack("N N", $filcnt, 0) . $names;
open(OUT, ">useraa.dat") or die "Can't write output file\n";
binmode(OUT);
print OUT "OBUSRLGE", pack("N", length($body)), md5($body), "\0\0\0\0", $body;
close(OUT) or die "Error writing output file\n";
print "Wrote useraa.dat\n";