Hello everybody and many thanks to Moy for its useful reply!
1. What kind of events can cause the exit of "ftdm_channel_wait" function? I've seen the "ftdm_event_type_t" that defines "FTDM_EVENT_DTMF" and "FTDM_EVENT_OOB". Is it the answer to my question?
Events such as CAS/RBS events and DTMF events if you have hardware DTMF enabled (and your hardware supports it). Given that you are using Sangoma hardware, it should work if you have a hardware DTMF enabled in the wanpipe configuration files (ie /etc/wanpipe/wanpipe1.conf)
I'm using an E1 PRI so, if I've correctly understood, CAS/RBS events don't exist. Regarding DTMF I've found some TDMV_HW_DTMF=NO in my wanpipe*.conf, now I will correct them to TDMV_HW_DTMF=YES and try again.
2. Is there something that I need to do before call "ftdm_channel_wait" to enable the "events generation"? Did you call ftdm_span_start() to start the signaling thread on the span?
Yes, of course! :) Thanks again. Best regards! Andrea