wdoekes / asterisk-chan-dongle

chan_dongle channel driver for Huawei UMTS cards, works with Asterisk 14+
Other
300 stars 105 forks source link

Increase Sample Size, Data Length and Timing Interval #31

Open WireFr33 opened 7 years ago

WireFr33 commented 7 years ago

I've downloaded your version of chan_dongle for Asterisk 11.20 and modified it for use with the SIMCOM mini PCIe modules. The method of operation is similar to the Huawei dongles, so changing the AT commands to the SIMCOM equivalents helped.

I receive DTMF and audio from the GSM network on asterisk. However, I do not get audio from asterisk to the GSM network. With the Huawei dongles audio is sent from chan_dongle to the dongle every 20ms, with 160 samples (320 bytes). The SIMCOM documentation states that it requires audio every 40ms, with 320 samples (640 bytes).

I've modified the FRAME_SIZE in cpvt.h to 640, and changed ast_timer_set_rate (pvt->a_timer, 50) to ast_timer_set_rate (pvt->a_timer, 25) on line 369 in channel.c however with debug active chan_dongle still prints "[dongle0] Write frame: samples = 160, data lenght = 320 byte".

Can you assist. How do I increase the frame size sent to the module and change the timing interval from 20ms to 40ms?

wdoekes commented 7 years ago

Hi Amish, this was indeed the proper channel for the issue (not my e-mail).

I don't think the ast_timer_set_rate() does what you expect, as you've observed already. The channel writes are probably coordinated by Asterisk rtp code: the other side gets a frame every 20ms, so it's forwarded. If you want a different frame size, you'd need to adjust the packetization (I guess), ptime in SIP/SDP terminology: https://wiki.asterisk.org/wiki/display/AST/RTP+Packetization

Perhaps something like this?

--- a/chan_dongle.c
+++ b/chan_dongle.c
@@ -1664,6 +1664,7 @@ static int public_state_init(struct public_state * state)
                                return AST_MODULE_LOAD_FAILURE;
                        }
                        ast_format_cap_append(channel_tech.capabilities, ast_format_slin, 0);
+                       ast_format_cap_set_framing(channel_tech.capabilities, 40);
 #elif ASTERISK_VERSION_NUM >= 100000 /* 10-13 */
                        ast_format_set(&chan_dongle_format, AST_FORMAT_SLINEAR, 0);
 # if ASTERISK_VERSION_NUM >= 120000 /* 12+ */

(TOTALLY UNTESTED)