Git Product home page Git Product logo

chan_alsaradio's Introduction

chan_alsaradio

This is a portage of chan_alsaradio for Asterisk 13+

Prerequisites

Was tested with Rapsbian Stretch and asterisk 13.14

sudo update
sudo apt-get install alsa-utils
sudo apt-get install libncurses5-dev uuid-dev libjansson-dev libxml2-dev libsqlite3-dev libasound2-dev

Compile asterisk-13 with chan_alsaradio

First download asterisk sources and chan_alsaradio sources (choose your branch)

cd /usr/src/
sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-13.14.1.tar.gz
sudo tar xzfv asterisk-13.14.1.tar.gz

Get the branch you want
sudo wget https://github.com/gaeldb/chan_alsaradio/archive/master.zip
sudo unzip master.zip

Let's patch with chan_alsaradio sources and compile

cd asterisk-13.14.1
cp ../chan_alsaradio-master/chan_alsaradio.c channels/
echo "chan_alsaradio.so: -lasound" >> channels/Makefile
sudo ./configure
sudo make menuselect
sudo make
sudo make install

Configure

Get you USB Alsa sound card device name

plughw:0,0 will work for most USB sound cards.

cat /proc/asound/cards
aplay -l
arecord -l

Configure IAX in asterisk (to communicate with your IAX client, here iaxRPT: see below)

/etc/asterisk/iax.conf

[iaxrpt]
type=user
context=airlink
auth=md5
secret=whatever
host=dynamic
disallow=all
allow=gsm,ulaw
notransfer=yes
; Allow Asterisk to handle call from this user without IP whitelist = UNSECURE
requirecalltoken=no

Warning: this is unsecure, not for production mode !

/etc/asterisk/extensions.conf

;extensions.conf
[globals]
; END [globals]

[general]
autofallthrough=no
; END [general]

[airlink]
exten => radio1,1,NoOp(Start of radio context)
 same => n,Dial(alsaradio/icomvhf)
 same => n,Hangup()
 
exten => h,1,NoOp(End of radio context)
exten => e,1,NoOp(Error or timeout in radio context)
exten => e,n,Hangup()

; END [airlink]

Reload IAX module and dialplan in asterisk.

Configure your radio/repeater in asterisk (to communicate with your air environnement)

/etc/asterisk/alsaradio.con (use provided default file) and personnalize for your radio

[icomvhf]

input_device=plughw:0,0		; ALSA sound input channel
output_device=plughw:0,0	; ALSA sound output channel
serial_device=/dev/ttyS0	; Serial port for control
serial_disable=0          ; 1 to disable serial control (PTT, PCCMDV2, ...)

Want to autostart asterisk ?

sudo make config
sudo systemctl enable asterisk

Test with IAXRpt

You can download iaxRpt to test your Asterisk airlink gateway. http://www.xelatec.com/xipar/iaxrpt user: iaxrpt password: whatever context: radio1

chan_alsaradio's People

Contributors

gaeldb avatar

Stargazers

 avatar  avatar

Watchers

 avatar

chan_alsaradio's Issues

Provide a serial I/O command controler

We need to add a command controller in order to:

  • read serial output command sent from the radio
  • Send command to the radio

ICOM PCCMDV2 must be supported but we need to abstract the command "protocol" to implement other radio type in the future.

Segfault when channel bridging with Ubuntu 14.04

When joining a channel and bridging it, segfault appears on my dev platform Ubuntu 14.04.
This behavior has never be seen with Raspberry system...

Don't know how to debug this...

[Oct 11 16:36:34] NOTICE[11053][C-00000000]: chan_alsaradio.c:1424 alsaradio_request: Alsaradio channel created
alsaradio -- call started
[Oct 11 16:36:34] NOTICE[11054]: chan_alsaradio.c:669 serthread: serthread: Starting normally on rpt1!!
  ==   == Set device /dev/ttyUSB0 to rpt1
[Oct 11 16:36:34] WARNING[11054]: chan_alsaradio.c:690 serthread: File alsaradio_tune_rpt1.conf not found, device rpt1 using default parameters.
    -- Called alsaradio/rpt1
    -- alsaradio/rpt1 answered IAX2/iaxrpt-15865
    -- Channel alsaradio/rpt1 joined 'simple_bridge' basic-bridge <4ee718ce-1f6d-4b2c-8646-653d54d04650>
[Oct 11 16:36:34] WARNING[11055][C-00000000]: chan_alsaradio.c:1276 alsaradio_indicate: Don't know what to do with condition 26 on alsaradio/rpt1
Erreur de segmentation (core dumped)

New channel ends with a segmentation fault after a first failed channel creation

If alsa device is unavailable during an alsaradio channel creation, le next alsaradio creation will always segfault.

First alsa device unavailable

    -- Accepting AUTHENTICATED call from 10.222.241.32:4569:
    --        > requested format = ulaw,
    --        > requested prefs = (),
    --        > actual format = ulaw,
    --        > host prefs = (gsm|ulaw),
    --        > priority = mine
    -- Executing [rpt@rpt:1] NoOp("IAX2/iaxrpt-16079", "Start RPT context") in new stack
    -- Executing [rpt@rpt:2] Playback("IAX2/iaxrpt-16079", "digits/1&digits/2&digits/3") in new stack
    -- <IAX2/iaxrpt-16079> Playing 'digits/1.gsm' (language 'en')
    -- <IAX2/iaxrpt-16079> Playing 'digits/2.gsm' (language 'en')
    -- <IAX2/iaxrpt-16079> Playing 'digits/3.gsm' (language 'en')
    -- Executing [rpt@rpt:3] Dial("IAX2/iaxrpt-16079", "alsaradio/rpt1") in new stack
[Oct 11 14:37:45] NOTICE[27949][C-00000000]: chan_alsaradio.c:641 find_desc: Founded device rpt1 at <0x33a0ba0>
[Oct 11 14:37:45] NOTICE[27949][C-00000000]: chan_alsaradio.c:1422 alsaradio_request: alsaradio_request type:alsaradio, dev:rpt1, format:(slin)
[Oct 11 14:37:45] ERROR[27949][C-00000000]: chan_alsaradio.c:1347 alsaradio_new: Here new
[Oct 11 14:37:45] ERROR[27949][C-00000000]: chan_alsaradio.c:1351 alsaradio_new: Avant tech set
[Oct 11 14:37:45] ERROR[27949][C-00000000]: chan_alsaradio.c:1353 alsaradio_new: Après tech set
[Oct 11 14:37:45] ERROR[27949][C-00000000]: chan_alsaradio.c:763 setformat: Here new set 1
[Oct 11 14:37:45] ERROR[27949][C-00000000]: chan_alsaradio.c:765 setformat: Middle
[Oct 11 14:37:45] ERROR[27949][C-00000000]: chan_alsaradio.c:768 setformat: Here new set 2
[Oct 11 14:37:45] NOTICE[27949][C-00000000]: chan_alsaradio.c:1976 alsa_card_init: Opening device hw:0,0 in read mode
[Oct 11 14:37:45] ERROR[27949][C-00000000]: chan_alsaradio.c:1993 alsa_card_init: set_channels failed: Invalid argument
[Oct 11 14:37:45] WARNING[27949][C-00000000]: chan_alsaradio.c:1998 alsa_card_init: Rate not correct, requested 8000, got 44100
[Oct 11 14:37:45] NOTICE[27949][C-00000000]: chan_alsaradio.c:2005 alsa_card_init: Period size is: 320
[Oct 11 14:37:45] NOTICE[27949][C-00000000]: chan_alsaradio.c:2013 alsa_card_init: Buffer size is set to 8320 frames
[Oct 11 14:37:45] NOTICE[27949][C-00000000]: chan_alsaradio.c:2054 alsa_card_init: Acquired fd 17 from the poll descriptor
[Oct 11 14:37:45] ERROR[27949][C-00000000]: chan_alsaradio.c:1973 alsa_card_init: snd_pcm_open failed: Device or resource busy
[Oct 11 14:37:45] ERROR[27949][C-00000000]: chan_alsaradio.c:780 setformat: Problem opening ALSA OUT device: hw:0,0
[Oct 11 14:37:45] ERROR[27949][C-00000000]: chan_alsaradio.c:1444 alsaradio_request: Unable to create new aradio channel
[Oct 11 14:37:45] WARNING[27949][C-00000000]: app_dial.c:2525 dial_exec_full: Unable to create channel of type 'alsaradio' (cause 0 - Unknown)
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [rpt@rpt:4] Hangup("IAX2/iaxrpt-16079", "") in new stack
  == Spawn extension (rpt, rpt, 4) exited non-zero on 'IAX2/iaxrpt-16079'
    -- Executing [h@rpt:1] NoOp("IAX2/iaxrpt-16079", "End of RPT context") in new stack
    -- Hungup 'IAX2/iaxrpt-16079'

Next will segfault:

*CLI>     -- Accepting AUTHENTICATED call from 10.222.241.32:4569:
    --        > requested format = ulaw,
    --        > requested prefs = (),
    --        > actual format = ulaw,
    --        > host prefs = (gsm|ulaw),
    --        > priority = mine
    -- Executing [rpt@rpt:1] NoOp("IAX2/iaxrpt-1499", "Start RPT context") in new stack
    -- Executing [rpt@rpt:2] Playback("IAX2/iaxrpt-1499", "digits/1&digits/2&digits/3") in new stack
    -- <IAX2/iaxrpt-1499> Playing 'digits/1.gsm' (language 'en')
    -- <IAX2/iaxrpt-1499> Playing 'digits/2.gsm' (language 'en')
    -- <IAX2/iaxrpt-1499> Playing 'digits/3.gsm' (language 'en')
    -- Executing [rpt@rpt:3] Dial("IAX2/iaxrpt-1499", "alsaradio/rpt1") in new stack
[Oct 11 14:38:05] NOTICE[27956][C-00000001]: chan_alsaradio.c:641 find_desc: Founded device rpt1 at <0x33a0ba0>
[Oct 11 14:38:05] NOTICE[27956][C-00000001]: chan_alsaradio.c:1422 alsaradio_request: alsaradio_request type:alsaradio, dev:rpt1, format:(slin)
[Oct 11 14:38:05] ERROR[27956][C-00000001]: chan_alsaradio.c:1347 alsaradio_new: Here new
[Oct 11 14:38:05] ERROR[27956][C-00000001]: chan_alsaradio.c:1351 alsaradio_new: Avant tech set
[Oct 11 14:38:05] ERROR[27956][C-00000001]: chan_alsaradio.c:1353 alsaradio_new: Après tech set
Erreur de segmentation (core dumped)

Open serial thread when loading module

Actually, serial I/O thread is opened when catch a call.

We need to open the serial port when we load module in order to listen RX command line permanently.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.