Monday, May 2, 2016

Raspbx and running scripts

Hi

I have worked with old asterisk version and it was really hard to work with but with little efford really great and customizable. Now i tried new project with RASPBX and i was surprised how easy it was to work with.

In this tutorial i will tell how to install raspbx and run scripts in raspbx

1. Download Raspbx (google it)
2. Download win32diskimager
3.Install win32diskimager
4.Unzip raspbx image
5. Run win32diskimager and install raspbx to memorycard (raspbx site says that 4gb card required, so i used 8gb just to sure)
6.Insert memory card to raspberry pi and start it
7.Log in
8. Default user is root and password raspberry
9. run command:sudo ip addr show
10. get the inet addr/ip addr
11. Use different computer to log in by opening browser and writing that address to browser
12.  FreePBX default user is admin and password is admin also
13. Log in to Freepbx
Asterisk may take 5-10 minutes to start
14.Download config edit module to freepbx from admin modules
14. or you can just download and upgrade all the modules
15. go to config edit module and to extensions_custom.conf add
[nameofdialplan]
exten=> 2000,1,Answer()
exten=> 2000,2,AGI(scriptname.php)

2000 is the extension that you wanna run script when calling
1,2 is the priority or order of actions you wanna perform
there should be scripts ready if you wanna test.

Example wakeupconfirm
[wakeup]
exten=> 2000,1,Answer()
exten=> 2000,2,AGI(wakeconfirm.php)

16. Go to custom destinations tab and make asterisk aware of new custom dialplan by adding
[wakeup],2000,1
description is just name so name it as you like it
17. Create extension for your phone/softphone and try it

Making your own scripts
1. run commands:cd /var/lib/asterisk/agi-bin
this is the path where asterisk will store the scripts
2. run command:nano scriptname.php
you can use other text editors but i use nano
3.write your script
4.run command:chmod 755 scriptname.php
this gives asterisk permission to run the script

Friday, January 29, 2016

MuMuDVB with Raspberry Pi 2 Model B Multicast IPTV: HOW TO

First install operating system for Raspi (Raspberry Pi 2 Model B) we installed Rasbian WHEEZY from https://www.raspberrypi.org/downloads/raspbian/. Format SD-card to FAT32.Then install it to SD-card with win32DiskImager which can be found from http://sourceforge.net/projects/win32diskimager/ select rasbian image and your SD-card and start installing.

When installing is ready we can put the card to Raspi and start it with keyboard,screen and ethernetcable with internet access. First give password to root user called pi, we use iptv for password because its easy to remember. Don’t use GUI because terminal is more practical when u get used to it and know a little bit of commands.

Now that we have logged in and see the command line we are gonna install necessary programs.
After every “Type:some commands” rows hit enter
Type: sudo apt-get install mumudvb
Type: sudo apt-get install patchutils libproc-processtable-perl
Type: sudo apt-get install dvb-apps
Type: sudo apt-get install w-scan

sudo is means we use command as admin (sudo=superior user do)
if some reason it don’t find the packages check network and
Typw: sudo apt-get update

okay we use Pinnacle DVB-T usb stick with Raspi now we need to google where the firmware for usb-stick is and copy it
Type: cd /lib/firmware
Type:sudo wget url_to_your_debian_compatible_firmware

Now we need to scan what frequencies we can watch (or is the stick working)
First reboot with
Type: sudo reboot
and wait Raspi to start, login
Check if Raspi finds the stick
Type: lsusb
and look if your dvb-stick is there. If not check firmware and installation guides

start scanning with w_scan
Type: sudo w_scan –X –c FI
where FI is coyntry FI=finland we check only for finnish TV-channels because that’s only TV we want check your coyntry codes at https://countrycode.org/
now look when w_scan finds some channels (if not check if stick is working or coyntry code is right)
and remember the frequencies , they look something like 562000kHz.

Okay now that we have some frequencies we are gonna make configuration file for MuMu.
Type: sudo nano mumu.conf
and text editor should open, you can replace mumu.conf with somethingyouwant.conf but remember the name and its location is /home/pi/yourfilename.conf
start editing the conf file with text editor and write the minium config mumu needs.
Write:
Type: freq=yourwantedfreq
Type: autoconfiguration=full
now hit ctrl+X and Y when its asked if wanted to save progress then enter when it ask for the filename.

Now test mumu with command
Type: sudo mumudvb –d –c /home/pi/your_conf_file_name.conf
it should work fine and find channels if we have the right frequency.

Mumu generates automaticly SAP announces if autoconfiguration=full is in the config file so if everything work we should now be able to watch channels with VLC with computer in the same network. Look in VLC for playlist->SAP. If you wanna watch TV from outside your own network open VLC select Media->Open Network Stream. Mumu shows IP for the streams.
Type: udp://@ip_to_your_stream:1234

Now if everything is working we want mumu to start when pi starts (if you want it or you can start it manually after login with “Type: sudo mumudvb –d –c /home/pi/your_conf_file_name.conf”
create a script first for starting mumu
Type: sudo nano /etc/init.d/autostart_mumu
and write the following to text file
Type: #!/bin/bash
Type: sudo mumudvb –d –c /home/pi/your_conf_file_name.conf
and hit ctrl+X hit Y and enter
Type: sudo chmod +x /etc/init.d/autostart_mumu
Type:sudo update-rc.d autostart_mumu defaults

FINISHED and finally everything should be working fine…for millhouse :D
quick googling should solve any error occurred, but this is how I got it running
usefull links
http://elinux.org/RPi_Setting_up_a_static_IP_in_Debian
http://www.kettering.edu/offices-administration/information-technology/networks-security-storage/remote-desktop/remote
http://www.mumudvb.net/