Difference between revisions of "Internet of Things and VoIP"
(→Assign Number to extension and make calls) |
(→Link system commands with number) |
||
Line 93: | Line 93: | ||
Use your mobile to control Dragino by dialling a number. | Use your mobile to control Dragino by dialling a number. | ||
− | ===Link system commands with | + | ===Link system commands with phone numbers=== |
One way to link numbers and system commands is use the '''''System''''' application in Asterisk. We can add below lines to '''''[demo]''''' context in the /etc/asterisk/extensions.conf file | One way to link numbers and system commands is use the '''''System''''' application in Asterisk. We can add below lines to '''''[demo]''''' context in the /etc/asterisk/extensions.conf file | ||
− | exten => 7466,1,System(/bin/echo "test" > /tmp/setpinnum.txt) -- dial 7466 | + | exten => 7466,1,System(/bin/echo "test" > /tmp/setpinnum.txt) -- dial 7466 to call system command |
exten => 7466,2,Hangup --hangup the call | exten => 7466,2,Hangup --hangup the call | ||
Revision as of 02:36, 29 November 2012
Contents
Introduction
This topic is talking about to set up the relationship between IoT and IP Telephony network.
We will do different tests below to show how to integrate IoT into VoIP network. We will use the open source Asterisk software here for voip connection.
Test 1: Install Asterisk in Dragino make internal calls
Purpose
Asterisk is a powerful, open source software to build telephony system. Softphone can be runed in either PC or smart phone. The purpose for this test is getting start with Asterisk and soft phone. Below is the set up of this test. Image...
Install and run Asterisk in Dragino
make sure your Dragino have network connection, Run:
root@dragino-bc8622:~# opkg update // Update the valid package list root@dragino-bc8622:~# opkg install asterisk18 // install asterisk v1.8 root@dragino-bc8622:~# opkg install asterisk18-app-system // install asterisk system command applications.
after install Asterisk, we can run:
root@dragino-bc8622:~# asterisk // Start Asterisk Server root@dragino-bc8622:~# asterisk -vvvvvvgrc // Connect to Asterisk Server console, here we can see debug info for asterisk server. Asterisk 1.8.7.1, Copyright (C) 1999 - 2011 Digium, Inc. and others. Created by Mark Spencer <markster@digium.com> Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details. This is free software, with components licensed under the GNU General Public License version 2 and other licenses; you are welcome to redistribute it under certain conditions. Type 'core show license' for details. ========================================================================= == Parsing '/etc/asterisk/asterisk.conf': == Found Connected to Asterisk 1.8.7.1 currently running on dragino-bc8622 (pid = 1207) Verbosity was 0 and is now 6 -- Remote UNIX connection dragino-bc8622*CLI>
Register IP phone extensions
Set up phone extensions, modify the file /etc/asterisk/sip.conf and add below at the end of this file.
[dragino-test1] type=friend ; Friends place calls and receive calls context=demo ; Context for incoming calls from this user secret=password host=dynamic ; This peer register with us dtmfmode=rfc2833 ; Choices are inband, rfc2833, or info allow=ulaw ; dtmfmode=inband only works with ulaw or alaw!
[dragino-test2] type=friend ; Friends place calls and receive calls context=demo ; Context for incoming calls from this user secret=password host=dynamic ; This peer register with us dtmfmode=rfc2833 ; Choices are inband, rfc2833, or info allow=ulaw ; dtmfmode=inband only works with ulaw or alaw!
After modify the sip.conf file, we can run below command to active the change
dragino-bc8622*CLI> core reload
This Dragino has a IP 192.168.1.5. So now the complete resigster infomation for these two accounts are as below:
Account 1: Server IP: 192.168.1.5 Username: dragino-test1 Password: password
Account 2: Server IP: 192.168.1.5 Username: dragino-test2 Password: password
Now we need to register the Android Mobile to the server, to do this , you can download the free softphone 3CXPhone and install in Android. then create a profile in 3CXphone and input below info:
- Name: Dragino-Test
- User: dragino-test1
- ID: dragino-test1
- Password: password
- Local PBX IP: 192.168.1.5
Save this profile and the Android phone can register to the Dragino. you should be able to see below info in Dragion after registered:
-- Registered SIP 'dragino-test1' at 192.168.1.220:33696 > Saved useragent "3CXPhone for Android 2.0.5" for peer dragino-test1
To make internal calls, we need another extensions, we can set up this in a PC. Download and install the free softphone x-lite and set up with Account 2 info.
Assign Number to extension and make calls
Now we have two extensions in this small phone system now, we can do it by modifing the /etc/asterisk/extensions.conf file. open this file and find the context [demo], add:
exten => 501,1,Dial(SIP/dragino-test1,20,tr) ; number 501 is call to Account 1. exten => 502,1,Dial(SIP/dragino-test2,20,tr) ; number 502 is call to Account 2.
Then save the change and reload asterisk in asterisk console.
After doing above, you will be able to make calls between your mobile(phone number:501) and the PC (phone number: 502).
Test 2: Dial a number to call system commands
Purphose
Use your mobile to control Dragino by dialling a number.
Link system commands with phone numbers
One way to link numbers and system commands is use the System application in Asterisk. We can add below lines to [demo] context in the /etc/asterisk/extensions.conf file
exten => 7466,1,System(/bin/echo "test" > /tmp/setpinnum.txt) -- dial 7466 to call system command exten => 7466,2,Hangup --hangup the call
In this link: how to use SPI. We show how to control the relay by a linux command. so we can use write lines here to use phone call to control the relay. like below:
exten => 7467,1,System(lua /root/SPI_Test.lua sh) --dial 7467 and the system will swith the relay to NO exten => 7467,2,Hangup exten => 7468,1,System(lua /root/SPI_Test.lua sl) --dial 7468 and the system will swith the relay to NC. exten => 7468,2,Hangup