<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14676] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14676">14676</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2009-08-29 08:24:59 -0500 (Sat, 29 Aug 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>celliax: indented</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchbranchesgmaruzzmod_celliaxcelliaxh">freeswitch/branches/gmaruzz/mod_celliax/celliax.h</a></li>
<li><a href="#freeswitchbranchesgmaruzzmod_celliaxcelliax_protocolc">freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c</a></li>
<li><a href="#freeswitchbranchesgmaruzzmod_celliaxmod_celliaxc">freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchbranchesgmaruzzmod_celliaxcelliaxh"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/celliax.h (14675 => 14676)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/celliax.h        2009-08-29 13:15:21 UTC (rev 14675)
+++ freeswitch/branches/gmaruzz/mod_celliax/celliax.h        2009-08-29 13:24:59 UTC (rev 14676)
</span><span class="lines">@@ -85,9 +85,9 @@
</span><span class="cx"> 
</span><span class="cx"> #define                AT_BUFSIZ 8192
</span><span class="cx"> //FIXME FIXME FIXME #define AT_MESG_MAX_LENGTH 2048 /* much more than 10 SMSs */
</span><del>-#define AT_MESG_MAX_LENGTH 2048 /* much more than 10 SMSs */
</del><ins>+#define AT_MESG_MAX_LENGTH 2048        /* much more than 10 SMSs */
</ins><span class="cx"> //FIXME FIXME FIXME #define AT_MESG_MAX_LINES 256   /* 256 lines, so it can contains the results of AT+CLAC, that gives all the AT commands the phone supports */
</span><del>-#define AT_MESG_MAX_LINES 20   /* 256 lines, so it can contains the results of AT+CLAC, that gives all the AT commands the phone supports */
</del><ins>+#define AT_MESG_MAX_LINES 20        /* 256 lines, so it can contains the results of AT+CLAC, that gives all the AT commands the phone supports */
</ins><span class="cx"> 
</span><span class="cx"> //#define SAMPLERATE_SKYPIAX 16000
</span><span class="cx"> //#define SAMPLES_PER_FRAME SAMPLERATE_SKYPIAX/50
</span><span class="lines">@@ -213,13 +213,13 @@
</span><span class="cx">  * \brief structure for storing the results of AT commands, in an array of AT_MESG_MAX_LINES * AT_MESG_MAX_LENGTH chars
</span><span class="cx">  */
</span><span class="cx"> struct s_result {
</span><del>-  int elemcount;
-  char result[AT_MESG_MAX_LINES][AT_MESG_MAX_LENGTH];
</del><ins>+        int elemcount;
+        char result[AT_MESG_MAX_LINES][AT_MESG_MAX_LENGTH];
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> struct ciapa_struct {
</span><del>-int state;
-int hangupcause;
</del><ins>+        int state;
+        int hangupcause;
</ins><span class="cx"> };
</span><span class="cx"> typedef struct ciapa_struct ciapa_t;
</span><span class="cx"> 
</span><span class="lines">@@ -309,138 +309,138 @@
</span><span class="cx">         unsigned long ob_failed_calls;
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-  char controldevice_name[50];  /*!&lt; \brief name of the serial device controlling the interface, possibly none */
-  int controldevprotocol;       /*!&lt; \brief which protocol is used for serial control of this interface */
-  char controldevprotocolname[50];  /*!&lt; \brief name of the serial device controlling protocol, one of &quot;at&quot; &quot;fbus2&quot; &quot;no_serial&quot; &quot;alsa_voicemodem&quot; */
-  int controldevfd;             /*!&lt; \brief serial controlling file descriptor for this interface */
-  //pthread_t controldev_thread;  /*!&lt; \brief serial control thread for this interface, running during the call */
-  speed_t controldevice_speed;
-  int controldev_dead;

-  char at_dial_pre_number[64];
-  char at_dial_post_number[64];
-  char at_dial_expect[64];
-  unsigned int at_early_audio;
-  char at_hangup[64];
-  char at_hangup_expect[64];
-  char at_answer[64];
-  char at_answer_expect[64];
-  unsigned int at_initial_pause;
-  char at_preinit_1[64];
-  char at_preinit_1_expect[64];
-  char at_preinit_2[64];
-  char at_preinit_2_expect[64];
-  char at_preinit_3[64];
-  char at_preinit_3_expect[64];
-  char at_preinit_4[64];
-  char at_preinit_4_expect[64];
-  char at_preinit_5[64];
-  char at_preinit_5_expect[64];
-  unsigned int at_after_preinit_pause;
</del><ins>+        char controldevice_name[50];        /*!&lt; \brief name of the serial device controlling the interface, possibly none */
+        int controldevprotocol;                /*!&lt; \brief which protocol is used for serial control of this interface */
+        char controldevprotocolname[50];        /*!&lt; \brief name of the serial device controlling protocol, one of &quot;at&quot; &quot;fbus2&quot; &quot;no_serial&quot; &quot;alsa_voicemodem&quot; */
+        int controldevfd;                        /*!&lt; \brief serial controlling file descriptor for this interface */
+        //pthread_t controldev_thread;  /*!&lt; \brief serial control thread for this interface, running during the call */
+        speed_t controldevice_speed;
+        int controldev_dead;
</ins><span class="cx"> 
</span><del>-  char at_postinit_1[64];
-  char at_postinit_1_expect[64];
-  char at_postinit_2[64];
-  char at_postinit_2_expect[64];
-  char at_postinit_3[64];
-  char at_postinit_3_expect[64];
-  char at_postinit_4[64];
-  char at_postinit_4_expect[64];
-  char at_postinit_5[64];
-  char at_postinit_5_expect[64];
</del><ins>+        char at_dial_pre_number[64];
+        char at_dial_post_number[64];
+        char at_dial_expect[64];
+        unsigned int at_early_audio;
+        char at_hangup[64];
+        char at_hangup_expect[64];
+        char at_answer[64];
+        char at_answer_expect[64];
+        unsigned int at_initial_pause;
+        char at_preinit_1[64];
+        char at_preinit_1_expect[64];
+        char at_preinit_2[64];
+        char at_preinit_2_expect[64];
+        char at_preinit_3[64];
+        char at_preinit_3_expect[64];
+        char at_preinit_4[64];
+        char at_preinit_4_expect[64];
+        char at_preinit_5[64];
+        char at_preinit_5_expect[64];
+        unsigned int at_after_preinit_pause;
</ins><span class="cx"> 
</span><del>-  char at_send_dtmf[64];
</del><ins>+        char at_postinit_1[64];
+        char at_postinit_1_expect[64];
+        char at_postinit_2[64];
+        char at_postinit_2_expect[64];
+        char at_postinit_3[64];
+        char at_postinit_3_expect[64];
+        char at_postinit_4[64];
+        char at_postinit_4_expect[64];
+        char at_postinit_5[64];
+        char at_postinit_5_expect[64];
</ins><span class="cx"> 
</span><del>-  char at_query_battchg[64];
-  char at_query_battchg_expect[64];
-  char at_query_signal[64];
-  char at_query_signal_expect[64];
-  char at_call_idle[64];
-  char at_call_incoming[64];
-  char at_call_active[64];
-  char at_call_failed[64];
-  char at_call_calling[64];
</del><ins>+        char at_send_dtmf[64];
</ins><span class="cx"> 
</span><ins>+        char at_query_battchg[64];
+        char at_query_battchg_expect[64];
+        char at_query_signal[64];
+        char at_query_signal_expect[64];
+        char at_call_idle[64];
+        char at_call_incoming[64];
+        char at_call_active[64];
+        char at_call_failed[64];
+        char at_call_calling[64];
+
</ins><span class="cx"> #define CIEV_STRING_SIZE 64
</span><del>-  char at_indicator_noservice_string[64];
-  char at_indicator_nosignal_string[64];
-  char at_indicator_lowsignal_string[64];
-  char at_indicator_lowbattchg_string[64];
-  char at_indicator_nobattchg_string[64];
-  char at_indicator_callactive_string[64];
-  char at_indicator_nocallactive_string[64];
-  char at_indicator_nocallsetup_string[64];
-  char at_indicator_callsetupincoming_string[64];
-  char at_indicator_callsetupoutgoing_string[64];
-  char at_indicator_callsetupremoteringing_string[64];
</del><ins>+        char at_indicator_noservice_string[64];
+        char at_indicator_nosignal_string[64];
+        char at_indicator_lowsignal_string[64];
+        char at_indicator_lowbattchg_string[64];
+        char at_indicator_nobattchg_string[64];
+        char at_indicator_callactive_string[64];
+        char at_indicator_nocallactive_string[64];
+        char at_indicator_nocallsetup_string[64];
+        char at_indicator_callsetupincoming_string[64];
+        char at_indicator_callsetupoutgoing_string[64];
+        char at_indicator_callsetupremoteringing_string[64];
</ins><span class="cx"> 
</span><del>-  int at_indicator_callp;
-  int at_indicator_callsetupp;
-  int at_indicator_roamp;
-  int at_indicator_battchgp;
-  int at_indicator_servicep;
-  int at_indicator_signalp;
</del><ins>+        int at_indicator_callp;
+        int at_indicator_callsetupp;
+        int at_indicator_roamp;
+        int at_indicator_battchgp;
+        int at_indicator_servicep;
+        int at_indicator_signalp;
</ins><span class="cx"> 
</span><del>-  int at_has_clcc;
-  int at_has_ecam;
</del><ins>+        int at_has_clcc;
+        int at_has_ecam;
</ins><span class="cx"> 
</span><del>-  char at_cmgw[16];
-  int no_ucs2;
-  time_t celliax_serial_sync_period;
</del><ins>+        char at_cmgw[16];
+        int no_ucs2;
+        time_t celliax_serial_sync_period;
</ins><span class="cx"> 
</span><del>-  time_t celliax_serial_synced_timestamp;
-  struct s_result line_array;
</del><ins>+        time_t celliax_serial_synced_timestamp;
+        struct s_result line_array;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-  int unread_sms_msg_id;
-  int reading_sms_msg;
-  char sms_message[4800];
-  int sms_cnmi_not_supported;
-  char sms_receiving_program[256];
</del><ins>+        int unread_sms_msg_id;
+        int reading_sms_msg;
+        char sms_message[4800];
+        int sms_cnmi_not_supported;
+        char sms_receiving_program[256];
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-  struct timeval call_incoming_time;
-  int phone_callflow;           /*!&lt; \brief 'callflow' of the phone interface (as opposed to skype interface) */
-  switch_mutex_t *controldev_lock;
</del><ins>+        struct timeval call_incoming_time;
+        int phone_callflow;                        /*!&lt; \brief 'callflow' of the phone interface (as opposed to skype interface) */
+        switch_mutex_t *controldev_lock;
</ins><span class="cx"> 
</span><del>-  int phonebook_listing;
-  int phonebook_querying;
-  int phonebook_listing_received_calls;
</del><ins>+        int phonebook_listing;
+        int phonebook_querying;
+        int phonebook_listing_received_calls;
</ins><span class="cx"> 
</span><del>-  int phonebook_first_entry;
-  int phonebook_last_entry;
-  int phonebook_number_lenght;
-  int phonebook_text_lenght;
-  FILE *phonebook_writing_fp;
</del><ins>+        int phonebook_first_entry;
+        int phonebook_last_entry;
+        int phonebook_number_lenght;
+        int phonebook_text_lenght;
+        FILE *phonebook_writing_fp;
</ins><span class="cx"> 
</span><del>-  struct timeval ringtime;
-  ciapa_t *owner;
</del><ins>+        struct timeval ringtime;
+        ciapa_t *owner;
</ins><span class="cx"> #ifdef CELLIAX_ALSA
</span><del>-  snd_pcm_t *alsac;             /*!&lt; \brief handle of the ALSA capture audio device */
-  snd_pcm_t *alsap;             /*!&lt; \brief handle of the ALSA playback audio device */
-  char alsacname[50];           /*!&lt; \brief name of the ALSA capture audio device */
-  char alsapname[50];           /*!&lt; \brief name of the ALSA playback audio device */
-  int alsa_period_size;         /*!&lt; \brief ALSA period_size, in byte */
-  int alsa_periods_in_buffer;   /*!&lt; \brief how many periods in ALSA buffer, to calculate buffer_size */
-  unsigned long int alsa_buffer_size;   /*!&lt; \brief ALSA buffer_size, in byte */
-  int alsawrite_filled;
-  int alsa_capture_is_mono;
-  int alsa_play_is_mono;
-  struct pollfd pfd;
-#endif// CELLIAX_ALSA
</del><ins>+        snd_pcm_t *alsac;                        /*!&lt; \brief handle of the ALSA capture audio device */
+        snd_pcm_t *alsap;                        /*!&lt; \brief handle of the ALSA playback audio device */
+        char alsacname[50];                        /*!&lt; \brief name of the ALSA capture audio device */
+        char alsapname[50];                        /*!&lt; \brief name of the ALSA playback audio device */
+        int alsa_period_size;                /*!&lt; \brief ALSA period_size, in byte */
+        int alsa_periods_in_buffer;        /*!&lt; \brief how many periods in ALSA buffer, to calculate buffer_size */
+        unsigned long int alsa_buffer_size;        /*!&lt; \brief ALSA buffer_size, in byte */
+        int alsawrite_filled;
+        int alsa_capture_is_mono;
+        int alsa_play_is_mono;
+        struct pollfd pfd;
+#endif                                                        // CELLIAX_ALSA
</ins><span class="cx"> 
</span><del>-  time_t audio_play_reset_timestamp;
-  int audio_play_reset_period;
</del><ins>+        time_t audio_play_reset_timestamp;
+        int audio_play_reset_period;
</ins><span class="cx"> 
</span><del>-switch_timer_t timer;
-    teletone_dtmf_detect_state_t dtmf_detect;
-  switch_time_t old_dtmf_timestamp;
</del><ins>+        switch_timer_t timer;
+        teletone_dtmf_detect_state_t dtmf_detect;
+        switch_time_t old_dtmf_timestamp;
</ins><span class="cx"> 
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef struct private_object private_t;
</span><span class="cx"> 
</span><del>-void *SWITCH_THREAD_FUNC celliax_api_thread_func(switch_thread_t * thread, void *obj);
</del><ins>+void *SWITCH_THREAD_FUNC celliax_api_thread_func(switch_thread_t *thread, void *obj);
</ins><span class="cx"> int celliax_audio_read(private_t * tech_pvt);
</span><span class="cx"> int celliax_audio_init(private_t * tech_pvt);
</span><span class="cx"> int celliax_signaling_read(private_t * tech_pvt);
</span><span class="lines">@@ -449,21 +449,21 @@
</span><span class="cx"> int celliax_senddigit(private_t * tech_pvt, char digit);
</span><span class="cx"> 
</span><span class="cx"> void *celliax_do_tcp_srv_thread_func(void *obj);
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_tcp_srv_thread(switch_thread_t * thread, void *obj);
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_tcp_srv_thread(switch_thread_t *thread, void *obj);
</ins><span class="cx"> 
</span><span class="cx"> void *celliax_do_tcp_cli_thread_func(void *obj);
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_tcp_cli_thread(switch_thread_t * thread, void *obj);
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_tcp_cli_thread(switch_thread_t *thread, void *obj);
</ins><span class="cx"> 
</span><span class="cx"> void *celliax_do_skypeapi_thread_func(void *obj);
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_skypeapi_thread(switch_thread_t * thread, void *obj);
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_skypeapi_thread(switch_thread_t *thread, void *obj);
</ins><span class="cx"> int dtmf_received(private_t * tech_pvt, char *value);
</span><span class="cx"> int start_audio_threads(private_t * tech_pvt);
</span><span class="cx"> int new_inbound_channel(private_t * tech_pvt);
</span><span class="cx"> int outbound_channel_answered(private_t * tech_pvt);
</span><span class="cx"> //int celliax_signaling_write(private_t * tech_pvt, char *msg_to_skype);
</span><span class="cx"> #if defined(WIN32) &amp;&amp; !defined(__CYGWIN__)
</span><del>-int celliax_pipe_read(switch_file_t * pipe, short *buf, int howmany);
-int celliax_pipe_write(switch_file_t * pipe, short *buf, int howmany);
</del><ins>+int celliax_pipe_read(switch_file_t *pipe, short *buf, int howmany);
+int celliax_pipe_write(switch_file_t *pipe, short *buf, int howmany);
</ins><span class="cx"> /* Visual C do not have strsep ? */
</span><span class="cx"> char *strsep(char **stringp, const char *delim);
</span><span class="cx"> #else
</span><span class="lines">@@ -501,13 +501,9 @@
</span><span class="cx"> int celliax_serial_write_AT_ack(private_t * tech_pvt, const char *data);
</span><span class="cx"> int celliax_serial_write_AT_ack_nocr_longtime(private_t * tech_pvt, const char *data);
</span><span class="cx"> int celliax_serial_write_AT_noack(private_t * tech_pvt, const char *data);
</span><del>-int celliax_serial_write_AT_expect1(private_t * tech_pvt, const char *data,
-                                    const char *expected_string, int expect_crlf,
-                                    int seconds);
-int celliax_serial_AT_expect(private_t * tech_pvt, const char *expected_string,
-                             int expect_crlf, int seconds);
-int celliax_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_usec,
-                           int timeout_sec, const char *expected_string, int expect_crlf);
</del><ins>+int celliax_serial_write_AT_expect1(private_t * tech_pvt, const char *data, const char *expected_string, int expect_crlf, int seconds);
+int celliax_serial_AT_expect(private_t * tech_pvt, const char *expected_string, int expect_crlf, int seconds);
+int celliax_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_usec, int timeout_sec, const char *expected_string, int expect_crlf);
</ins><span class="cx"> int celliax_serial_read(private_t * tech_pvt);
</span><span class="cx"> #ifdef NOTDEF
</span><span class="cx"> int celliax_serial_getstatus(private_t * tech_pvt);
</span><span class="lines">@@ -517,13 +513,11 @@
</span><span class="cx"> int celliax_serial_hangup_AT(private_t * tech_pvt);
</span><span class="cx"> int celliax_serial_call_AT(private_t * tech_pvt, char *dstr);
</span><span class="cx"> int celliax_serial_getstatus_AT(private_t * tech_pvt);
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx"> #define RESULT_FAILURE 0
</span><span class="cx"> #define RESULT_SUCCESS 1
</span><del>-int utf_to_ucs2(private_t * tech_pvt, char *utf_in, size_t inbytesleft, char *ucs2_out,
-                size_t outbytesleft);
-int ucs2_to_utf8(private_t * tech_pvt, char *ucs2_in, char *utf8_out,
-                 size_t outbytesleft);
</del><ins>+int utf_to_ucs2(private_t * tech_pvt, char *utf_in, size_t inbytesleft, char *ucs2_out, size_t outbytesleft);
+int ucs2_to_utf8(private_t * tech_pvt, char *ucs2_in, char *utf8_out, size_t outbytesleft);
</ins><span class="cx"> //#define PUSHA_UNLOCKA(x)    pthread_cleanup_push(celliax_unlocka_log, (void *) x);
</span><span class="cx"> //#define POPPA_UNLOCKA(x)    pthread_cleanup_pop(0);
</span><span class="cx"> 
</span><span class="lines">@@ -531,7 +525,7 @@
</span><span class="cx"> #define POPPA_UNLOCKA(x)    if(option_debug &gt; 100) ERRORA(&quot;POPPA_UNLOCKA: %p\n&quot;, SKYPIAX_P_LOG, (void *)x);
</span><span class="cx"> //#define LOKKA(x)    if(option_debug &gt; 100) ERRORA(&quot;LOKKA: %p\n&quot;, SKYPIAX_P_LOG, (void *)x);
</span><span class="cx"> #define LOKKA(x)    switch_mutex_lock(x);
</span><del>-#define UNLOCKA(x)  switch_mutex_unlock(x);  
</del><ins>+#define UNLOCKA(x)  switch_mutex_unlock(x);
</ins><span class="cx"> //#define UNLOCKA(x)    if(option_debug &gt; 100) ERRORA(&quot;UNLOCKA: %p\n&quot;, SKYPIAX_P_LOG, (void *)x);
</span><span class="cx"> 
</span><span class="cx"> #define celliax_queue_control(x, y) ERRORA(&quot;celliax_queue_control: %p, %d\n&quot;, SKYPIAX_P_LOG, (void *)x, y);
</span><span class="lines">@@ -552,7 +546,7 @@
</span><span class="cx"> int alsa_init(private_t * tech_pvt);
</span><span class="cx"> int alsa_shutdown(private_t * tech_pvt);
</span><span class="cx"> snd_pcm_t *alsa_open_dev(private_t * tech_pvt, snd_pcm_stream_t stream);
</span><del>-int alsa_write(private_t * tech_pvt, short * data, int datalen);
-int alsa_read(private_t * tech_pvt, short * data, int datalen);
</del><ins>+int alsa_write(private_t * tech_pvt, short *data, int datalen);
+int alsa_read(private_t * tech_pvt, short *data, int datalen);
</ins><span class="cx"> 
</span><span class="cx"> #endif /* CELLIAX_ALSA */
</span></span></pre></div>
<a id="freeswitchbranchesgmaruzzmod_celliaxcelliax_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c (14675 => 14676)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c        2009-08-29 13:15:21 UTC (rev 14675)
+++ freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c        2009-08-29 13:24:59 UTC (rev 14676)
</span><span class="lines">@@ -17,7 +17,7 @@
</span><span class="cx"> extern int running;
</span><span class="cx"> int celliax_dir_entry_extension = 1;
</span><span class="cx"> 
</span><del>-int option_debug=100;
</del><ins>+int option_debug = 100;
</ins><span class="cx"> 
</span><span class="cx"> #ifdef NOTDEF
</span><span class="cx"> /*************************************/
</span><span class="lines">@@ -136,8 +136,7 @@
</span><span class="cx">                                 } else if (!strncasecmp(message, &quot;ERROR 592 ALTER CALL&quot;, 19)) {
</span><span class="cx">                                         ERRORA(&quot;Skype got ERROR about TRANSFERRING, no problem: |||%s|||\n&quot;, SKYPIAX_P_LOG, message);
</span><span class="cx">                                 } else if (!strncasecmp(message, &quot;ERROR 559 CALL&quot;, 13)) {
</span><del>-                                        DEBUGA_SKYPE(&quot;Skype got ERROR about a failed action (probably TRYING to HANGUP A CALL), no problem: |||%s|||\n&quot;, SKYPIAX_P_LOG,
-                                                                 message);
</del><ins>+                                        DEBUGA_SKYPE(&quot;Skype got ERROR about a failed action (probably TRYING to HANGUP A CALL), no problem: |||%s|||\n&quot;, SKYPIAX_P_LOG, message);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         ERRORA(&quot;Skype got ERROR: |||%s|||\n&quot;, SKYPIAX_P_LOG, message);
</span><span class="cx">                                         tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FINISHED;
</span><span class="lines">@@ -178,8 +177,7 @@
</span><span class="cx">                                 if (!strcasecmp(id, tech_pvt-&gt;skype_user)) {
</span><span class="cx">                                         tech_pvt-&gt;SkypiaxHandles.currentuserhandle = 1;
</span><span class="cx">                                         DEBUGA_SKYPE
</span><del>-                                                (&quot;Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n&quot;,
-                                                 SKYPIAX_P_LOG, message, obj, id, tech_pvt-&gt;skype_user);
</del><ins>+                                                (&quot;Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n&quot;, SKYPIAX_P_LOG, message, obj, id, tech_pvt-&gt;skype_user);
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         if (!strcasecmp(message, &quot;USER&quot;)) {
</span><span class="lines">@@ -496,7 +494,7 @@
</span><span class="cx">         }                                                        //read_from_pipe
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx"> 
</span><span class="cx"> void *celliax_do_tcp_srv_thread_func(void *obj)
</span><span class="cx"> {
</span><span class="lines">@@ -627,8 +625,7 @@
</span><span class="cx">                                                                 /* send the complete frame through the pipe to our code waiting for incoming audio */
</span><span class="cx">                                                                 howmany = celliax_pipe_write(tech_pvt-&gt;audiopipe[1], totalbuf, SAMPLES_PER_FRAME * sizeof(short));
</span><span class="cx">                                                                 if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
</span><del>-                                                                        ERRORA(&quot;howmany is %d, but was expected to be %d\n&quot;, SKYPIAX_P_LOG,
-                                                                                   howmany, (int) (SAMPLES_PER_FRAME * sizeof(short)));
</del><ins>+                                                                        ERRORA(&quot;howmany is %d, but was expected to be %d\n&quot;, SKYPIAX_P_LOG, howmany, (int) (SAMPLES_PER_FRAME * sizeof(short)));
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                                 /* done with the stored half frame */
</span><span class="cx">                                                                 tech_pvt-&gt;audiobuf_is_loaded = 0;
</span><span class="lines">@@ -874,7 +871,7 @@
</span><span class="cx"> /* PLATFORM SPECIFIC */
</span><span class="cx"> /***************************/
</span><span class="cx"> #if defined(WIN32) &amp;&amp; !defined(__CYGWIN__)
</span><del>-int celliax_pipe_read(switch_file_t * pipe, short *buf, int howmany)
</del><ins>+int celliax_pipe_read(switch_file_t *pipe, short *buf, int howmany)
</ins><span class="cx"> {
</span><span class="cx">         switch_size_t quantity;
</span><span class="cx"> 
</span><span class="lines">@@ -887,7 +884,7 @@
</span><span class="cx">         return howmany;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int celliax_pipe_write(switch_file_t * pipe, short *buf, int howmany)
</del><ins>+int celliax_pipe_write(switch_file_t *pipe, short *buf, int howmany)
</ins><span class="cx"> {
</span><span class="cx">         switch_size_t quantity;
</span><span class="cx"> 
</span><span class="lines">@@ -1189,8 +1186,7 @@
</span><span class="cx"> 
</span><span class="cx">         celliax_sleep(200000);                //0,2 sec
</span><span class="cx"> 
</span><del>-        if (tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
-                &amp;&amp; tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
</del><ins>+        if (tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0 &amp;&amp; tech_pvt-&gt;SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
</ins><span class="cx">                 if (win32_Initialize_CreateWindowClass(tech_pvt)) {
</span><span class="cx">                         if (win32_Initialize_CreateMainWindow(tech_pvt)) {
</span><span class="cx">                                 if (SendMessage
</span><span class="lines">@@ -1373,1898 +1369,1746 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-int celliax_serial_init(private_t *tech_pvt, speed_t controldevice_speed)
</del><ins>+int celliax_serial_init(private_t * tech_pvt, speed_t controldevice_speed)
</ins><span class="cx"> {
</span><del>-  int fd;
-  int rt;
-  struct termios tp;
</del><ins>+        int fd;
+        int rt;
+        struct termios tp;
</ins><span class="cx"> 
</span><span class="cx"> /* if there is a file descriptor, close it. But it is probably just an old value, so don't check for close success*/
</span><del>-  fd = tech_pvt-&gt;controldevfd;
-  if (fd) {
-    close(fd);
-  }
</del><ins>+        fd = tech_pvt-&gt;controldevfd;
+        if (fd) {
+                close(fd);
+        }
</ins><span class="cx"> /*  open the serial port */
</span><span class="cx"> #ifdef __CYGWIN__
</span><del>-  fd = open(tech_pvt-&gt;controldevice_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
-  sleep(1);
-  close(fd);
</del><ins>+        fd = open(tech_pvt-&gt;controldevice_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
+        sleep(1);
+        close(fd);
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><del>-  fd = open(tech_pvt-&gt;controldevice_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
-  if (fd == -1) {
-    DEBUGA_SKYPE(&quot;serial error: %s\n&quot;, SKYPIAX_P_LOG, strerror(errno));
-    tech_pvt-&gt;controldevfd = fd;
-    return -1;
-  }
</del><ins>+        fd = open(tech_pvt-&gt;controldevice_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
+        if (fd == -1) {
+                DEBUGA_SKYPE(&quot;serial error: %s\n&quot;, SKYPIAX_P_LOG, strerror(errno));
+                tech_pvt-&gt;controldevfd = fd;
+                return -1;
+        }
</ins><span class="cx"> /*  flush it */
</span><del>-  rt = tcflush(fd, TCIFLUSH);
-  if (rt == -1) {
-    ERRORA(&quot;serial error: %s&quot;, SKYPIAX_P_LOG, strerror(errno));
-  }
</del><ins>+        rt = tcflush(fd, TCIFLUSH);
+        if (rt == -1) {
+                ERRORA(&quot;serial error: %s&quot;, SKYPIAX_P_LOG, strerror(errno));
+        }
</ins><span class="cx"> /*  attributes */
</span><del>-  tp.c_cflag = B0 | CS8 | CLOCAL | CREAD | HUPCL;
-  tp.c_iflag = IGNPAR;
-  tp.c_cflag &amp;= ~CRTSCTS;
-  tp.c_oflag = 0;
-  tp.c_lflag = 0;
-  tp.c_cc[VMIN] = 1;
-  tp.c_cc[VTIME] = 0;
</del><ins>+        tp.c_cflag = B0 | CS8 | CLOCAL | CREAD | HUPCL;
+        tp.c_iflag = IGNPAR;
+        tp.c_cflag &amp;= ~CRTSCTS;
+        tp.c_oflag = 0;
+        tp.c_lflag = 0;
+        tp.c_cc[VMIN] = 1;
+        tp.c_cc[VTIME] = 0;
</ins><span class="cx"> /*  set controldevice_speed */
</span><del>-  rt = cfsetispeed(&amp;tp, tech_pvt-&gt;controldevice_speed);
-  if (rt == -1) {
-    ERRORA(&quot;serial error: %s, speed was: %d&quot;, SKYPIAX_P_LOG, strerror(errno), tech_pvt-&gt;controldevice_speed);
-  }
-  rt = cfsetospeed(&amp;tp, tech_pvt-&gt;controldevice_speed);
-  if (rt == -1) {
-    ERRORA(&quot;serial error: %s&quot;, SKYPIAX_P_LOG, strerror(errno));
-  }
</del><ins>+        rt = cfsetispeed(&amp;tp, tech_pvt-&gt;controldevice_speed);
+        if (rt == -1) {
+                ERRORA(&quot;serial error: %s, speed was: %d&quot;, SKYPIAX_P_LOG, strerror(errno), tech_pvt-&gt;controldevice_speed);
+        }
+        rt = cfsetospeed(&amp;tp, tech_pvt-&gt;controldevice_speed);
+        if (rt == -1) {
+                ERRORA(&quot;serial error: %s&quot;, SKYPIAX_P_LOG, strerror(errno));
+        }
</ins><span class="cx"> /*  set port attributes */
</span><del>-  if (tcsetattr(fd, TCSADRAIN, &amp;tp) == -1) {
-    ERRORA(&quot;serial error: %s&quot;, SKYPIAX_P_LOG, strerror(errno));
-  }
-  rt = tcsetattr(fd, TCSANOW, &amp;tp);
-  if (rt == -1) {
-    ERRORA(&quot;serial error: %s&quot;, SKYPIAX_P_LOG, strerror(errno));
-  }
-  unsigned int status = 0;
</del><ins>+        if (tcsetattr(fd, TCSADRAIN, &amp;tp) == -1) {
+                ERRORA(&quot;serial error: %s&quot;, SKYPIAX_P_LOG, strerror(errno));
+        }
+        rt = tcsetattr(fd, TCSANOW, &amp;tp);
+        if (rt == -1) {
+                ERRORA(&quot;serial error: %s&quot;, SKYPIAX_P_LOG, strerror(errno));
+        }
+        unsigned int status = 0;
</ins><span class="cx"> #ifndef __CYGWIN__
</span><del>-  ioctl(fd, TIOCMGET, &amp;status);
-  status |= TIOCM_DTR;          /*  Set DTR high */
-  status &amp;= ~TIOCM_RTS;         /*  Set RTS low */
-  ioctl(fd, TIOCMSET, &amp;status);
-  ioctl(fd, TIOCMGET, &amp;status);
-  unsigned int flags = TIOCM_DTR;
-  ioctl(fd, TIOCMBIS, &amp;flags);
-  flags = TIOCM_RTS;
-  ioctl(fd, TIOCMBIC, &amp;flags);
-  ioctl(fd, TIOCMGET, &amp;status);
</del><ins>+        ioctl(fd, TIOCMGET, &amp;status);
+        status |= TIOCM_DTR;                /*  Set DTR high */
+        status &amp;= ~TIOCM_RTS;                /*  Set RTS low */
+        ioctl(fd, TIOCMSET, &amp;status);
+        ioctl(fd, TIOCMGET, &amp;status);
+        unsigned int flags = TIOCM_DTR;
+        ioctl(fd, TIOCMBIS, &amp;flags);
+        flags = TIOCM_RTS;
+        ioctl(fd, TIOCMBIC, &amp;flags);
+        ioctl(fd, TIOCMGET, &amp;status);
</ins><span class="cx"> #else /* __CYGWIN__ */
</span><del>-  ioctl(fd, TIOCMGET, &amp;status);
-  status |= TIOCM_DTR;          /*  Set DTR high */
-  status &amp;= ~TIOCM_RTS;         /*  Set RTS low */
-  ioctl(fd, TIOCMSET, &amp;status);
</del><ins>+        ioctl(fd, TIOCMGET, &amp;status);
+        status |= TIOCM_DTR;                /*  Set DTR high */
+        status &amp;= ~TIOCM_RTS;                /*  Set RTS low */
+        ioctl(fd, TIOCMSET, &amp;status);
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><del>-  tech_pvt-&gt;controldevfd = fd;
-  DEBUGA_SKYPE(&quot;Syncing Serial\n&quot;, SKYPIAX_P_LOG);
-  rt = celliax_serial_sync(tech_pvt);
-  if (rt == -1) {
-    ERRORA(&quot;Serial init error\n&quot;, SKYPIAX_P_LOG);
-    return -1;
-  }
-  return (fd);
</del><ins>+        tech_pvt-&gt;controldevfd = fd;
+        DEBUGA_SKYPE(&quot;Syncing Serial\n&quot;, SKYPIAX_P_LOG);
+        rt = celliax_serial_sync(tech_pvt);
+        if (rt == -1) {
+                ERRORA(&quot;Serial init error\n&quot;, SKYPIAX_P_LOG);
+                return -1;
+        }
+        return (fd);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_read(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
-    return celliax_serial_read_AT(tech_pvt, 0, 100000, 0, NULL, 1);    // a 10th of a second timeout
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_read_AT(tech_pvt, 0, 100000, 0, NULL, 1);        // a 10th of a second timeout
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
-    return celliax_serial_read_FBUS2(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_read_FBUS2(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><span class="cx"> #ifdef CELLIAX_CVM
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
-    return celliax_serial_read_CVM_BUSMAIL(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_read_CVM_BUSMAIL(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><del>-  return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_sync(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
-    return celliax_serial_sync_AT(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_sync_AT(tech_pvt);
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
-    return celliax_serial_sync_FBUS2(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_sync_FBUS2(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><span class="cx"> #ifdef CELLIAX_CVM
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
-    return celliax_serial_sync_CVM_BUSMAIL(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_sync_CVM_BUSMAIL(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><span class="cx"> 
</span><del>-  return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_config(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
-    return celliax_serial_config_AT(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_config_AT(tech_pvt);
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
-    return celliax_serial_config_FBUS2(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_config_FBUS2(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><span class="cx"> #ifdef CELLIAX_CVM
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
-    return celliax_serial_config_CVM_BUSMAIL(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_config_CVM_BUSMAIL(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><del>-  return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_config_AT(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  int res;
</del><ins>+        int res;
</ins><span class="cx"> 
</span><span class="cx"> /* initial_pause? */
</span><del>-  if (tech_pvt-&gt;at_initial_pause) {
-    DEBUGA_SKYPE(&quot;sleeping for %d usec\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_initial_pause);
-    usleep(tech_pvt-&gt;at_initial_pause);
-  }
</del><ins>+        if (tech_pvt-&gt;at_initial_pause) {
+                DEBUGA_SKYPE(&quot;sleeping for %d usec\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_initial_pause);
+                usleep(tech_pvt-&gt;at_initial_pause);
+        }
</ins><span class="cx"> 
</span><span class="cx"> /* go until first empty preinit string, or last preinit string */
</span><del>-  while (1) {
</del><ins>+        while (1) {
</ins><span class="cx"> 
</span><del>-    if (strlen(tech_pvt-&gt;at_preinit_1)) {
-      res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_preinit_1, tech_pvt-&gt;at_preinit_1_expect);
-      if (res) {
-        DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;at_preinit_1, tech_pvt-&gt;at_preinit_1_expect);
-      }
-    } else {
-      break;
-    }
</del><ins>+                if (strlen(tech_pvt-&gt;at_preinit_1)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_preinit_1, tech_pvt-&gt;at_preinit_1_expect);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_preinit_1, tech_pvt-&gt;at_preinit_1_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx"> 
</span><del>-    if (strlen(tech_pvt-&gt;at_preinit_2)) {
-      res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_preinit_2, tech_pvt-&gt;at_preinit_2_expect);
-      if (res) {
-        DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;at_preinit_2, tech_pvt-&gt;at_preinit_2_expect);
-      }
-    } else {
-      break;
-    }
</del><ins>+                if (strlen(tech_pvt-&gt;at_preinit_2)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_preinit_2, tech_pvt-&gt;at_preinit_2_expect);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_preinit_2, tech_pvt-&gt;at_preinit_2_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx"> 
</span><del>-    if (strlen(tech_pvt-&gt;at_preinit_3)) {
-      res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_preinit_3, tech_pvt-&gt;at_preinit_3_expect);
-      if (res) {
-        DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;at_preinit_3, tech_pvt-&gt;at_preinit_3_expect);
-      }
-    } else {
-      break;
-    }
</del><ins>+                if (strlen(tech_pvt-&gt;at_preinit_3)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_preinit_3, tech_pvt-&gt;at_preinit_3_expect);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_preinit_3, tech_pvt-&gt;at_preinit_3_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx"> 
</span><del>-    if (strlen(tech_pvt-&gt;at_preinit_4)) {
-      res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_preinit_4, tech_pvt-&gt;at_preinit_4_expect);
-      if (res) {
-        DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;at_preinit_4, tech_pvt-&gt;at_preinit_4_expect);
-      }
-    } else {
-      break;
-    }
</del><ins>+                if (strlen(tech_pvt-&gt;at_preinit_4)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_preinit_4, tech_pvt-&gt;at_preinit_4_expect);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_preinit_4, tech_pvt-&gt;at_preinit_4_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx"> 
</span><del>-    if (strlen(tech_pvt-&gt;at_preinit_5)) {
-      res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_preinit_5, tech_pvt-&gt;at_preinit_5_expect);
-      if (res) {
-        DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;at_preinit_5, tech_pvt-&gt;at_preinit_5_expect);
-      }
-    } else {
-      break;
-    }
</del><ins>+                if (strlen(tech_pvt-&gt;at_preinit_5)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_preinit_5, tech_pvt-&gt;at_preinit_5_expect);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_preinit_5, tech_pvt-&gt;at_preinit_5_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx"> 
</span><del>-    break;
-  }
</del><ins>+                break;
+        }
</ins><span class="cx"> 
</span><span class="cx"> /* after_preinit_pause? */
</span><del>-  if (tech_pvt-&gt;at_after_preinit_pause) {
-    DEBUGA_SKYPE(&quot;sleeping for %d usec\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_after_preinit_pause);
-    usleep(tech_pvt-&gt;at_after_preinit_pause);
-  }
</del><ins>+        if (tech_pvt-&gt;at_after_preinit_pause) {
+                DEBUGA_SKYPE(&quot;sleeping for %d usec\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_after_preinit_pause);
+                usleep(tech_pvt-&gt;at_after_preinit_pause);
+        }
</ins><span class="cx"> 
</span><del>-  /* phone, brother, art you alive? */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT&quot;);
-  if (res) {
-    ERRORA(&quot;no response to AT\n&quot;, SKYPIAX_P_LOG);
-    return -1;
-  }
-  /* for motorola, bring it back to &quot;normal&quot; mode if it happens to be in another mode */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+mode=0&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+mode=0 does not get OK from the phone. If it is NOT Motorola,&quot;
-              &quot; no problem.\n&quot;, SKYPIAX_P_LOG);
-  }
-  usleep(50000);
-  /* for motorola end */
</del><ins>+        /* phone, brother, art you alive? */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT&quot;);
+        if (res) {
+                ERRORA(&quot;no response to AT\n&quot;, SKYPIAX_P_LOG);
+                return -1;
+        }
+        /* for motorola, bring it back to &quot;normal&quot; mode if it happens to be in another mode */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+mode=0&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+mode=0 does not get OK from the phone. If it is NOT Motorola,&quot; &quot; no problem.\n&quot;, SKYPIAX_P_LOG);
+        }
+        usleep(50000);
+        /* for motorola end */
</ins><span class="cx"> 
</span><del>-  /* reset AT configuration to phone default */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;ATZ&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;ATZ failed\n&quot;, SKYPIAX_P_LOG);
-  }
</del><ins>+        /* reset AT configuration to phone default */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;ATZ&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;ATZ failed\n&quot;, SKYPIAX_P_LOG);
+        }
</ins><span class="cx"> 
</span><del>-  /* disable AT command echo */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;ATE0&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;ATE0 failed\n&quot;, SKYPIAX_P_LOG);
-  }
</del><ins>+        /* disable AT command echo */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;ATE0&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;ATE0 failed\n&quot;, SKYPIAX_P_LOG);
+        }
</ins><span class="cx"> 
</span><del>-  /* disable extended error reporting */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CMEE=0&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CMEE failed\n&quot;, SKYPIAX_P_LOG);
-  }
</del><ins>+        /* disable extended error reporting */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CMEE=0&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CMEE failed\n&quot;, SKYPIAX_P_LOG);
+        }
</ins><span class="cx"> 
</span><del>-  /* various phone manufacturer identifier */
-  char at_command[5];
-  int i;
-  for (i = 0; i &lt; 10; i++) {
-    memset(at_command, 0, sizeof(at_command));
-    sprintf(at_command, &quot;ATI%d&quot;, i);
-    res = celliax_serial_write_AT_ack(tech_pvt, at_command);
-    if (res) {
-      DEBUGA_SKYPE(&quot;ATI%d command failed, continue\n&quot;, SKYPIAX_P_LOG, i);
-    }
-  }
</del><ins>+        /* various phone manufacturer identifier */
+        char at_command[5];
+        int i;
+        for (i = 0; i &lt; 10; i++) {
+                memset(at_command, 0, sizeof(at_command));
+                sprintf(at_command, &quot;ATI%d&quot;, i);
+                res = celliax_serial_write_AT_ack(tech_pvt, at_command);
+                if (res) {
+                        DEBUGA_SKYPE(&quot;ATI%d command failed, continue\n&quot;, SKYPIAX_P_LOG, i);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  /* phone manufacturer */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CGMI&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CGMI failed\n&quot;, SKYPIAX_P_LOG);
-  }
</del><ins>+        /* phone manufacturer */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CGMI&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CGMI failed\n&quot;, SKYPIAX_P_LOG);
+        }
</ins><span class="cx"> 
</span><del>-  /* phone model */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CGMM&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CGMM failed\n&quot;, SKYPIAX_P_LOG);
-  }
</del><ins>+        /* phone model */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CGMM&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CGMM failed\n&quot;, SKYPIAX_P_LOG);
+        }
</ins><span class="cx"> 
</span><del>-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CGSN&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CGSN failed\n&quot;, SKYPIAX_P_LOG);
-  }
</del><ins>+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CGSN&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CGSN failed\n&quot;, SKYPIAX_P_LOG);
+        }
</ins><span class="cx"> 
</span><span class="cx"> /* this take a lot of time to complete on devices with slow serial link (eg.: 9600bps) */
</span><del>-  /* signal incoming SMS with a +CMTI unsolicited msg */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CNMI=3,1,0,0,0&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CNMI=3,1,0,0,0 failed, continue\n&quot;, SKYPIAX_P_LOG);
-    tech_pvt-&gt;sms_cnmi_not_supported = 1;
-    tech_pvt-&gt;celliax_serial_sync_period = 30;
-  }
-  /* what is the Message Center address (number) to which the SMS has to be sent? */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCA?&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CSCA? failed, continue\n&quot;, SKYPIAX_P_LOG);
-  }
-  /* what is the Message Format of SMSs? */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CMGF?&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CMGF? failed, continue\n&quot;, SKYPIAX_P_LOG);
-  }
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CMGF=1&quot;);    //TODO: support phones that only accept pdu mode
-  if (res) {
-    ERRORA(&quot;Error setting SMS sending mode to TEXT on the cellphone\n&quot;, SKYPIAX_P_LOG);
-    return RESULT_FAILURE;
-  }
-  /* what is the Charset of SMSs? */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS?&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CSCS? failed, continue\n&quot;, SKYPIAX_P_LOG);
-  }
</del><ins>+        /* signal incoming SMS with a +CMTI unsolicited msg */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CNMI=3,1,0,0,0&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CNMI=3,1,0,0,0 failed, continue\n&quot;, SKYPIAX_P_LOG);
+                tech_pvt-&gt;sms_cnmi_not_supported = 1;
+                tech_pvt-&gt;celliax_serial_sync_period = 30;
+        }
+        /* what is the Message Center address (number) to which the SMS has to be sent? */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCA?&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CSCA? failed, continue\n&quot;, SKYPIAX_P_LOG);
+        }
+        /* what is the Message Format of SMSs? */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CMGF?&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CMGF? failed, continue\n&quot;, SKYPIAX_P_LOG);
+        }
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CMGF=1&quot;);        //TODO: support phones that only accept pdu mode
+        if (res) {
+                ERRORA(&quot;Error setting SMS sending mode to TEXT on the cellphone\n&quot;, SKYPIAX_P_LOG);
+                return RESULT_FAILURE;
+        }
+        /* what is the Charset of SMSs? */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS?&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CSCS? failed, continue\n&quot;, SKYPIAX_P_LOG);
+        }
</ins><span class="cx"> 
</span><del>-  tech_pvt-&gt;no_ucs2 = 0;
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;UCS2\&quot;&quot;);
-  if (res) {
-    WARNINGA
-      (&quot;AT+CSCS=\&quot;UCS2\&quot; (set TE messages to ucs2)  do not got OK from the phone, let's try with 'GSM'\n&quot;,
-       SKYPIAX_P_LOG);
-    tech_pvt-&gt;no_ucs2 = 1;
-  }
</del><ins>+        tech_pvt-&gt;no_ucs2 = 0;
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;UCS2\&quot;&quot;);
+        if (res) {
+                WARNINGA(&quot;AT+CSCS=\&quot;UCS2\&quot; (set TE messages to ucs2)  do not got OK from the phone, let's try with 'GSM'\n&quot;, SKYPIAX_P_LOG);
+                tech_pvt-&gt;no_ucs2 = 1;
+        }
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;no_ucs2) {
-    res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;GSM\&quot;&quot;);
-    if (res) {
-      WARNINGA(&quot;AT+CSCS=\&quot;GSM\&quot; (set TE messages to GSM)  do not got OK from the phone\n&quot;,
-               SKYPIAX_P_LOG);
-    }
-    //res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSMP=17,167,0,16&quot;); //&quot;flash&quot;, class 0  sms 7 bit
-    res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSMP=17,167,0,0&quot;); //normal, 7 bit message
-    if (res) {
-      WARNINGA(&quot;AT+CSMP do not got OK from the phone, continuing\n&quot;, SKYPIAX_P_LOG);
-    }
-  } else {
-    //res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSMP=17,167,0,20&quot;); //&quot;flash&quot;, class 0 sms 16 bit unicode
-    res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSMP=17,167,0,8&quot;); //unicode, 16 bit message
-    if (res) {
-      WARNINGA(&quot;AT+CSMP do not got OK from the phone, continuing\n&quot;, SKYPIAX_P_LOG);
-    }
-  }
</del><ins>+        if (tech_pvt-&gt;no_ucs2) {
+                res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;GSM\&quot;&quot;);
+                if (res) {
+                        WARNINGA(&quot;AT+CSCS=\&quot;GSM\&quot; (set TE messages to GSM)  do not got OK from the phone\n&quot;, SKYPIAX_P_LOG);
+                }
+                //res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSMP=17,167,0,16&quot;); //&quot;flash&quot;, class 0  sms 7 bit
+                res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSMP=17,167,0,0&quot;);        //normal, 7 bit message
+                if (res) {
+                        WARNINGA(&quot;AT+CSMP do not got OK from the phone, continuing\n&quot;, SKYPIAX_P_LOG);
+                }
+        } else {
+                //res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSMP=17,167,0,20&quot;); //&quot;flash&quot;, class 0 sms 16 bit unicode
+                res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSMP=17,167,0,8&quot;);        //unicode, 16 bit message
+                if (res) {
+                        WARNINGA(&quot;AT+CSMP do not got OK from the phone, continuing\n&quot;, SKYPIAX_P_LOG);
+                }
+        }
</ins><span class="cx"> 
</span><del>-  /* is the unsolicited reporting of mobile equipment event supported? */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CMER=?&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CMER=? failed, continue\n&quot;, SKYPIAX_P_LOG);
-  }
-  /* request unsolicited reporting of mobile equipment indicators' events, to be screened by categories reported by +CIND=? */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CMER=3,0,0,1&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CMER=? failed, continue\n&quot;, SKYPIAX_P_LOG);
-  }
</del><ins>+        /* is the unsolicited reporting of mobile equipment event supported? */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CMER=?&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CMER=? failed, continue\n&quot;, SKYPIAX_P_LOG);
+        }
+        /* request unsolicited reporting of mobile equipment indicators' events, to be screened by categories reported by +CIND=? */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CMER=3,0,0,1&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CMER=? failed, continue\n&quot;, SKYPIAX_P_LOG);
+        }
</ins><span class="cx"> 
</span><del>-  /* is the solicited reporting of mobile equipment indications supported? */
</del><ins>+        /* is the solicited reporting of mobile equipment indications supported? */
</ins><span class="cx"> 
</span><del>-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CIND=?&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CIND=? failed, continue\n&quot;, SKYPIAX_P_LOG);
-  }
</del><ins>+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CIND=?&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CIND=? failed, continue\n&quot;, SKYPIAX_P_LOG);
+        }
</ins><span class="cx"> 
</span><del>-  /* is the unsolicited reporting of call monitoring supported? sony-ericsson specific */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT*ECAM=?&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT*ECAM=? failed, continue\n&quot;, SKYPIAX_P_LOG);
-  }
-  /* enable the unsolicited reporting of call monitoring. sony-ericsson specific */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT*ECAM=1&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT*ECAM=1 failed, continue\n&quot;, SKYPIAX_P_LOG);
-    tech_pvt-&gt;at_has_ecam = 0;
-  } else {
-    tech_pvt-&gt;at_has_ecam = 1;
-  }
</del><ins>+        /* is the unsolicited reporting of call monitoring supported? sony-ericsson specific */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT*ECAM=?&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT*ECAM=? failed, continue\n&quot;, SKYPIAX_P_LOG);
+        }
+        /* enable the unsolicited reporting of call monitoring. sony-ericsson specific */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT*ECAM=1&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT*ECAM=1 failed, continue\n&quot;, SKYPIAX_P_LOG);
+                tech_pvt-&gt;at_has_ecam = 0;
+        } else {
+                tech_pvt-&gt;at_has_ecam = 1;
+        }
</ins><span class="cx"> 
</span><del>-  /* disable unsolicited signaling of call list */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CLCC=0&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CLCC=0 failed, continue\n&quot;, SKYPIAX_P_LOG);
-    tech_pvt-&gt;at_has_clcc = 0;
-  } else {
-    tech_pvt-&gt;at_has_clcc = 1;
-  }
</del><ins>+        /* disable unsolicited signaling of call list */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CLCC=0&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CLCC=0 failed, continue\n&quot;, SKYPIAX_P_LOG);
+                tech_pvt-&gt;at_has_clcc = 0;
+        } else {
+                tech_pvt-&gt;at_has_clcc = 1;
+        }
</ins><span class="cx"> 
</span><del>-  /* give unsolicited caller id when incoming call */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CLIP=1&quot;);
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+CLIP failed, continue\n&quot;, SKYPIAX_P_LOG);
-  }
-  /* for motorola */
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+MCST=1&quot;);    /* motorola call control codes
-                                                           (to know when call is disconnected (they
-                                                           don't give you &quot;no carrier&quot;) */
-  if (res) {
-    DEBUGA_SKYPE(&quot;AT+MCST=1 does not get OK from the phone. If it is NOT Motorola,&quot;
-              &quot; no problem.\n&quot;, SKYPIAX_P_LOG);
-  }
-  /* for motorola end */
</del><ins>+        /* give unsolicited caller id when incoming call */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CLIP=1&quot;);
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+CLIP failed, continue\n&quot;, SKYPIAX_P_LOG);
+        }
+        /* for motorola */
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+MCST=1&quot;);        /* motorola call control codes
+                                                                                                                                   (to know when call is disconnected (they
+                                                                                                                                   don't give you &quot;no carrier&quot;) */
+        if (res) {
+                DEBUGA_SKYPE(&quot;AT+MCST=1 does not get OK from the phone. If it is NOT Motorola,&quot; &quot; no problem.\n&quot;, SKYPIAX_P_LOG);
+        }
+        /* for motorola end */
</ins><span class="cx"> 
</span><span class="cx"> /* go until first empty postinit string, or last postinit string */
</span><del>-  while (1) {
</del><ins>+        while (1) {
</ins><span class="cx"> 
</span><del>-    if (strlen(tech_pvt-&gt;at_postinit_1)) {
-      res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_postinit_1, tech_pvt-&gt;at_postinit_1_expect);
-      if (res) {
-        DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;at_postinit_1, tech_pvt-&gt;at_postinit_1_expect);
-      }
-    } else {
-      break;
-    }
</del><ins>+                if (strlen(tech_pvt-&gt;at_postinit_1)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_postinit_1, tech_pvt-&gt;at_postinit_1_expect);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_postinit_1, tech_pvt-&gt;at_postinit_1_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx"> 
</span><del>-    if (strlen(tech_pvt-&gt;at_postinit_2)) {
-      res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_postinit_2, tech_pvt-&gt;at_postinit_2_expect);
-      if (res) {
-        DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;at_postinit_2, tech_pvt-&gt;at_postinit_2_expect);
-      }
-    } else {
-      break;
-    }
</del><ins>+                if (strlen(tech_pvt-&gt;at_postinit_2)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_postinit_2, tech_pvt-&gt;at_postinit_2_expect);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_postinit_2, tech_pvt-&gt;at_postinit_2_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx"> 
</span><del>-    if (strlen(tech_pvt-&gt;at_postinit_3)) {
-      res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_postinit_3, tech_pvt-&gt;at_postinit_3_expect);
-      if (res) {
-        DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;at_postinit_3, tech_pvt-&gt;at_postinit_3_expect);
-      }
-    } else {
-      break;
-    }
</del><ins>+                if (strlen(tech_pvt-&gt;at_postinit_3)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_postinit_3, tech_pvt-&gt;at_postinit_3_expect);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_postinit_3, tech_pvt-&gt;at_postinit_3_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx"> 
</span><del>-    if (strlen(tech_pvt-&gt;at_postinit_4)) {
-      res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_postinit_4, tech_pvt-&gt;at_postinit_4_expect);
-      if (res) {
-        DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;at_postinit_4, tech_pvt-&gt;at_postinit_4_expect);
-      }
-    } else {
-      break;
-    }
</del><ins>+                if (strlen(tech_pvt-&gt;at_postinit_4)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_postinit_4, tech_pvt-&gt;at_postinit_4_expect);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_postinit_4, tech_pvt-&gt;at_postinit_4_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx"> 
</span><del>-    if (strlen(tech_pvt-&gt;at_postinit_5)) {
-      res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_postinit_5, tech_pvt-&gt;at_postinit_5_expect);
-      if (res) {
-        DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;at_postinit_5, tech_pvt-&gt;at_postinit_5_expect);
-      }
-    } else {
-      break;
-    }
</del><ins>+                if (strlen(tech_pvt-&gt;at_postinit_5)) {
+                        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_postinit_5, tech_pvt-&gt;at_postinit_5_expect);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_postinit_5, tech_pvt-&gt;at_postinit_5_expect);
+                        }
+                } else {
+                        break;
+                }
</ins><span class="cx"> 
</span><del>-    break;
-  }
</del><ins>+                break;
+        }
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_sync_AT(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  usleep(10000);                /* 10msec */
-  time(&amp;tech_pvt-&gt;celliax_serial_synced_timestamp);
-  return 0;
</del><ins>+        usleep(10000);                                /* 10msec */
+        time(&amp;tech_pvt-&gt;celliax_serial_synced_timestamp);
+        return 0;
</ins><span class="cx"> }
</span><del>-int celliax_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_usec,
-                           int timeout_sec, const char *expected_string, int expect_crlf)
</del><ins>+int celliax_serial_read_AT(private_t * tech_pvt, int look_for_ack, int timeout_usec, int timeout_sec, const char *expected_string, int expect_crlf)
</ins><span class="cx"> {
</span><del>-  int select_err;
-  int res;
-  fd_set read_fds;
-  struct timeval timeout;
-  char tmp_answer[AT_BUFSIZ];
-  char tmp_answer2[AT_BUFSIZ];
-  char *tmp_answer_ptr;
-  char *last_line_ptr;
-  int i = 0;
-  int read_count = 0;
-  int la_counter = 0;
-  int at_ack = -1;
-  int la_read = 0;
</del><ins>+        int select_err;
+        int res;
+        fd_set read_fds;
+        struct timeval timeout;
+        char tmp_answer[AT_BUFSIZ];
+        char tmp_answer2[AT_BUFSIZ];
+        char *tmp_answer_ptr;
+        char *last_line_ptr;
+        int i = 0;
+        int read_count = 0;
+        int la_counter = 0;
+        int at_ack = -1;
+        int la_read = 0;
</ins><span class="cx"> 
</span><del>-  FD_ZERO(&amp;read_fds);
-  FD_SET(tech_pvt-&gt;controldevfd, &amp;read_fds);
</del><ins>+        FD_ZERO(&amp;read_fds);
+        FD_SET(tech_pvt-&gt;controldevfd, &amp;read_fds);
</ins><span class="cx"> 
</span><del>-  //NOTICA (&quot; INSIDE this celliax_serial_device %s \n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;controldevice_name);
-  tmp_answer_ptr = tmp_answer;
-  memset(tmp_answer, 0, sizeof(char) * AT_BUFSIZ);
</del><ins>+        //NOTICA (&quot; INSIDE this celliax_serial_device %s \n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;controldevice_name);
+        tmp_answer_ptr = tmp_answer;
+        memset(tmp_answer, 0, sizeof(char) * AT_BUFSIZ);
</ins><span class="cx"> 
</span><del>-  timeout.tv_sec = timeout_sec;
-  timeout.tv_usec = timeout_usec;
-  PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
-  LOKKA(tech_pvt-&gt;controldev_lock);
</del><ins>+        timeout.tv_sec = timeout_sec;
+        timeout.tv_usec = timeout_usec;
+        PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
+        LOKKA(tech_pvt-&gt;controldev_lock);
</ins><span class="cx"> 
</span><del>-  while ((select_err = select(tech_pvt-&gt;controldevfd + 1, &amp;read_fds, NULL, NULL, &amp;timeout)) &gt; 0) {
-    timeout.tv_sec = timeout_sec;   //reset the timeout, linux modify it
-    timeout.tv_usec = timeout_usec; //reset the timeout, linux modify it
-    read_count =
-      read(tech_pvt-&gt;controldevfd, tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer));
</del><ins>+        while ((select_err = select(tech_pvt-&gt;controldevfd + 1, &amp;read_fds, NULL, NULL, &amp;timeout)) &gt; 0) {
+                timeout.tv_sec = timeout_sec;        //reset the timeout, linux modify it
+                timeout.tv_usec = timeout_usec;        //reset the timeout, linux modify it
+                read_count = read(tech_pvt-&gt;controldevfd, tmp_answer_ptr, AT_BUFSIZ - (tmp_answer_ptr - tmp_answer));
</ins><span class="cx"> 
</span><del>-    if (read_count == 0) {
-      ERRORA
-        (&quot;read 0 bytes!!! Nenormalno! Marking this celliax_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n&quot;,
-         SKYPIAX_P_LOG, tech_pvt-&gt;controldevice_name);
-      tech_pvt-&gt;controldev_dead = 1;
-      close(tech_pvt-&gt;controldevfd);
-      UNLOCKA(tech_pvt-&gt;controldev_lock);
-      if (tech_pvt-&gt;owner) {
-        tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
-        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-      }
-      return -1;
-    }
</del><ins>+                if (read_count == 0) {
+                        ERRORA
+                                (&quot;read 0 bytes!!! Nenormalno! Marking this celliax_serial_device %s as dead, andif it is owned by a channel, hanging up. Maybe the phone is stuck, switched off, power down or battery exhausted\n&quot;,
+                                 SKYPIAX_P_LOG, tech_pvt-&gt;controldevice_name);
+                        tech_pvt-&gt;controldev_dead = 1;
+                        close(tech_pvt-&gt;controldevfd);
+                        UNLOCKA(tech_pvt-&gt;controldev_lock);
+                        if (tech_pvt-&gt;owner) {
+                                tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                        }
+                        return -1;
+                }
</ins><span class="cx"> 
</span><del>-    if (option_debug &gt; 90) {
-      //DEBUGA_SKYPE(&quot;1 read %d bytes, --|%s|--\n&quot;, SKYPIAX_P_LOG, read_count, tmp_answer_ptr);
-      //DEBUGA_SKYPE(&quot;2 read %d bytes, --|%s|--\n&quot;, SKYPIAX_P_LOG, read_count, tmp_answer);
-    }
-    tmp_answer_ptr = tmp_answer_ptr + read_count;
</del><ins>+                if (option_debug &gt; 90) {
+                        //DEBUGA_SKYPE(&quot;1 read %d bytes, --|%s|--\n&quot;, SKYPIAX_P_LOG, read_count, tmp_answer_ptr);
+                        //DEBUGA_SKYPE(&quot;2 read %d bytes, --|%s|--\n&quot;, SKYPIAX_P_LOG, read_count, tmp_answer);
+                }
+                tmp_answer_ptr = tmp_answer_ptr + read_count;
</ins><span class="cx"> 
</span><del>-    char *token_ptr;
</del><ins>+                char *token_ptr;
</ins><span class="cx"> 
</span><del>-    la_counter = 0;
-    memset(tmp_answer2, 0, sizeof(char) * AT_BUFSIZ);
-    strcpy(tmp_answer2, tmp_answer);
-    if ((token_ptr = strtok(tmp_answer2, &quot;\n\r&quot;))) {
-      last_line_ptr = token_ptr;
-      strncpy(tech_pvt-&gt;line_array.result[la_counter], token_ptr, AT_MESG_MAX_LENGTH);
-      if (strlen(token_ptr) &gt; AT_MESG_MAX_LENGTH) {
-        WARNINGA
-          (&quot;AT mesg longer than buffer, original message was: |%s|, in buffer only: |%s|\n&quot;,
-           SKYPIAX_P_LOG, token_ptr, tech_pvt-&gt;line_array.result[la_counter]);
-      }
-      la_counter++;
-      while ((token_ptr = strtok(NULL, &quot;\n\r&quot;))) {
-        last_line_ptr = token_ptr;
-        strncpy(tech_pvt-&gt;line_array.result[la_counter], token_ptr, AT_MESG_MAX_LENGTH);
-        if (strlen(token_ptr) &gt; AT_MESG_MAX_LENGTH) {
-          WARNINGA
-            (&quot;AT mesg longer than buffer, original message was: |%s|, in buffer only: |%s|\n&quot;,
-             SKYPIAX_P_LOG, token_ptr, tech_pvt-&gt;line_array.result[la_counter]);
-        }
-        la_counter++;
-      }
-    } else {
-      last_line_ptr = tmp_answer;
-    }
</del><ins>+                la_counter = 0;
+                memset(tmp_answer2, 0, sizeof(char) * AT_BUFSIZ);
+                strcpy(tmp_answer2, tmp_answer);
+                if ((token_ptr = strtok(tmp_answer2, &quot;\n\r&quot;))) {
+                        last_line_ptr = token_ptr;
+                        strncpy(tech_pvt-&gt;line_array.result[la_counter], token_ptr, AT_MESG_MAX_LENGTH);
+                        if (strlen(token_ptr) &gt; AT_MESG_MAX_LENGTH) {
+                                WARNINGA
+                                        (&quot;AT mesg longer than buffer, original message was: |%s|, in buffer only: |%s|\n&quot;,
+                                         SKYPIAX_P_LOG, token_ptr, tech_pvt-&gt;line_array.result[la_counter]);
+                        }
+                        la_counter++;
+                        while ((token_ptr = strtok(NULL, &quot;\n\r&quot;))) {
+                                last_line_ptr = token_ptr;
+                                strncpy(tech_pvt-&gt;line_array.result[la_counter], token_ptr, AT_MESG_MAX_LENGTH);
+                                if (strlen(token_ptr) &gt; AT_MESG_MAX_LENGTH) {
+                                        WARNINGA
+                                                (&quot;AT mesg longer than buffer, original message was: |%s|, in buffer only: |%s|\n&quot;,
+                                                 SKYPIAX_P_LOG, token_ptr, tech_pvt-&gt;line_array.result[la_counter]);
+                                }
+                                la_counter++;
+                        }
+                } else {
+                        last_line_ptr = tmp_answer;
+                }
</ins><span class="cx"> 
</span><del>-    if (expected_string &amp;&amp; !expect_crlf) {
-      DEBUGA_SKYPE
-        (&quot;last_line_ptr=|%s|, expected_string=|%s|, expect_crlf=%d, memcmp(last_line_ptr, expected_string, strlen(expected_string)) = %d\n&quot;,
-         SKYPIAX_P_LOG, last_line_ptr, expected_string, expect_crlf, memcmp(last_line_ptr,
-                                                                            expected_string,
-                                                                            strlen
-                                                                            (expected_string)));
-    }
</del><ins>+                if (expected_string &amp;&amp; !expect_crlf) {
+                        DEBUGA_SKYPE
+                                (&quot;last_line_ptr=|%s|, expected_string=|%s|, expect_crlf=%d, memcmp(last_line_ptr, expected_string, strlen(expected_string)) = %d\n&quot;,
+                                 SKYPIAX_P_LOG, last_line_ptr, expected_string, expect_crlf, memcmp(last_line_ptr, expected_string, strlen(expected_string)));
+                }
</ins><span class="cx"> 
</span><del>-    if (expected_string &amp;&amp; !expect_crlf
-        &amp;&amp; !memcmp(last_line_ptr, expected_string, strlen(expected_string))
-      ) {
-      strncpy(tech_pvt-&gt;line_array.result[la_counter], last_line_ptr, AT_MESG_MAX_LENGTH);
-      // match expected string -&gt; accept it withtout CRLF
-      la_counter++;
</del><ins>+                if (expected_string &amp;&amp; !expect_crlf &amp;&amp; !memcmp(last_line_ptr, expected_string, strlen(expected_string))
+                        ) {
+                        strncpy(tech_pvt-&gt;line_array.result[la_counter], last_line_ptr, AT_MESG_MAX_LENGTH);
+                        // match expected string -&gt; accept it withtout CRLF
+                        la_counter++;
</ins><span class="cx"> 
</span><del>-    }
-    /* if the last line read was not a complete line, we'll read the rest in the future */
-    else if (tmp_answer[strlen(tmp_answer) - 1] != '\r'
-             &amp;&amp; tmp_answer[strlen(tmp_answer) - 1] != '\n')
-      la_counter--;
</del><ins>+                }
+                /* if the last line read was not a complete line, we'll read the rest in the future */
+                else if (tmp_answer[strlen(tmp_answer) - 1] != '\r' &amp;&amp; tmp_answer[strlen(tmp_answer) - 1] != '\n')
+                        la_counter--;
</ins><span class="cx"> 
</span><del>-    /* let's list the complete lines read so far, without re-listing the lines that has yet been listed */
-    if (option_debug &gt; 1) {
-      for (i = la_read; i &lt; la_counter; i++)
-        DEBUGA_SKYPE(&quot;Read line %d: |%s|\n&quot;, SKYPIAX_P_LOG, i, tech_pvt-&gt;line_array.result[i]);
-    }
</del><ins>+                /* let's list the complete lines read so far, without re-listing the lines that has yet been listed */
+                if (option_debug &gt; 1) {
+                        for (i = la_read; i &lt; la_counter; i++)
+                                DEBUGA_SKYPE(&quot;Read line %d: |%s|\n&quot;, SKYPIAX_P_LOG, i, tech_pvt-&gt;line_array.result[i]);
+                }
</ins><span class="cx"> 
</span><del>-    /* let's interpret the complete lines read so far (WITHOUT looking for OK, ERROR, and EXPECTED_STRING), without re-interpreting the lines that has been yet interpreted, so we're sure we don't miss anything */
-    for (i = la_read; i &lt; la_counter; i++) {
</del><ins>+                /* let's interpret the complete lines read so far (WITHOUT looking for OK, ERROR, and EXPECTED_STRING), without re-interpreting the lines that has been yet interpreted, so we're sure we don't miss anything */
+                for (i = la_read; i &lt; la_counter; i++) {
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;RING&quot;) == 0)) {
-        /* with first RING we wait for callid */
-        gettimeofday(&amp;(tech_pvt-&gt;ringtime), NULL);
-        /* give CALLID (+CLIP) a chance, wait for the next RING before answering */
-        if (tech_pvt-&gt;phone_callflow == CALLFLOW_INCOMING_RING) {
-          /* we're at the second ring, set the interface state, will be answered by celliax_do_monitor */
-          DEBUGA_SKYPE(&quot;|%s| got second RING\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
-          tech_pvt-&gt;interface_state = SKYPIAX_STATE_RING;
-        } else {
-          /* we're at the first ring, so there is no CALLID yet thus clean the previous one 
-             just in case we don't receive the caller identification in this new call */
-          memset(tech_pvt-&gt;callid_name, 0, sizeof(tech_pvt-&gt;callid_name));
-          memset(tech_pvt-&gt;callid_number, 0, sizeof(tech_pvt-&gt;callid_number));
-          /* only send AT+CLCC? if the device previously reported its support */
-          if (tech_pvt-&gt;at_has_clcc != 0) {
-            /* we're at the first ring, try to get CALLID (with +CLCC) */
-            DEBUGA_SKYPE(&quot;|%s| got first RING, sending AT+CLCC?\n&quot;, SKYPIAX_P_LOG,
-                      tech_pvt-&gt;line_array.result[i]);
-            res = celliax_serial_write_AT_noack(tech_pvt, &quot;AT+CLCC?&quot;);
-            if (res) {
-              ERRORA(&quot;AT+CLCC? (call list) was not correctly sent to the phone\n&quot;,
-                     SKYPIAX_P_LOG);
-            }
-          } else {
-            DEBUGA_SKYPE(&quot;|%s| got first RING, but not sending AT+CLCC? as this device &quot;
-                      &quot;seems not to support\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
-          }
-        }
-        tech_pvt-&gt;phone_callflow = CALLFLOW_INCOMING_RING;
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;RING&quot;) == 0)) {
+                                /* with first RING we wait for callid */
+                                gettimeofday(&amp;(tech_pvt-&gt;ringtime), NULL);
+                                /* give CALLID (+CLIP) a chance, wait for the next RING before answering */
+                                if (tech_pvt-&gt;phone_callflow == CALLFLOW_INCOMING_RING) {
+                                        /* we're at the second ring, set the interface state, will be answered by celliax_do_monitor */
+                                        DEBUGA_SKYPE(&quot;|%s| got second RING\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                        tech_pvt-&gt;interface_state = SKYPIAX_STATE_RING;
+                                } else {
+                                        /* we're at the first ring, so there is no CALLID yet thus clean the previous one 
+                                           just in case we don't receive the caller identification in this new call */
+                                        memset(tech_pvt-&gt;callid_name, 0, sizeof(tech_pvt-&gt;callid_name));
+                                        memset(tech_pvt-&gt;callid_number, 0, sizeof(tech_pvt-&gt;callid_number));
+                                        /* only send AT+CLCC? if the device previously reported its support */
+                                        if (tech_pvt-&gt;at_has_clcc != 0) {
+                                                /* we're at the first ring, try to get CALLID (with +CLCC) */
+                                                DEBUGA_SKYPE(&quot;|%s| got first RING, sending AT+CLCC?\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                                res = celliax_serial_write_AT_noack(tech_pvt, &quot;AT+CLCC?&quot;);
+                                                if (res) {
+                                                        ERRORA(&quot;AT+CLCC? (call list) was not correctly sent to the phone\n&quot;, SKYPIAX_P_LOG);
+                                                }
+                                        } else {
+                                                DEBUGA_SKYPE(&quot;|%s| got first RING, but not sending AT+CLCC? as this device &quot;
+                                                                         &quot;seems not to support\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                        }
+                                }
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_INCOMING_RING;
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CLCC&quot;, 5) == 0)) {
-        /* with clcc we wait for clip */
-        memset(tech_pvt-&gt;callid_name, 0, sizeof(tech_pvt-&gt;callid_name));
-        memset(tech_pvt-&gt;callid_number, 0, sizeof(tech_pvt-&gt;callid_number));
-        int commacount = 0;
-        int a = 0;
-        int b = 0;
-        int c = 0;
</del><ins>+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CLCC&quot;, 5) == 0)) {
+                                /* with clcc we wait for clip */
+                                memset(tech_pvt-&gt;callid_name, 0, sizeof(tech_pvt-&gt;callid_name));
+                                memset(tech_pvt-&gt;callid_number, 0, sizeof(tech_pvt-&gt;callid_number));
+                                int commacount = 0;
+                                int a = 0;
+                                int b = 0;
+                                int c = 0;
</ins><span class="cx"> 
</span><del>-        for (a = 0; a &lt; strlen(tech_pvt-&gt;line_array.result[i]); a++) {
</del><ins>+                                for (a = 0; a &lt; strlen(tech_pvt-&gt;line_array.result[i]); a++) {
</ins><span class="cx"> 
</span><del>-          if (tech_pvt-&gt;line_array.result[i][a] == ',') {
-            commacount++;
-          }
-          if (commacount == 5) {
-            if (tech_pvt-&gt;line_array.result[i][a] != ',' &amp;&amp; tech_pvt-&gt;line_array.result[i][a] != '&quot;') {
-              tech_pvt-&gt;callid_number[b] = tech_pvt-&gt;line_array.result[i][a];
-              b++;
-            }
-          }
-          if (commacount == 7) {
-            if (tech_pvt-&gt;line_array.result[i][a] != ',' &amp;&amp; tech_pvt-&gt;line_array.result[i][a] != '&quot;') {
-              tech_pvt-&gt;callid_name[c] = tech_pvt-&gt;line_array.result[i][a];
-              c++;
-            }
-          }
-        }
</del><ins>+                                        if (tech_pvt-&gt;line_array.result[i][a] == ',') {
+                                                commacount++;
+                                        }
+                                        if (commacount == 5) {
+                                                if (tech_pvt-&gt;line_array.result[i][a] != ',' &amp;&amp; tech_pvt-&gt;line_array.result[i][a] != '&quot;') {
+                                                        tech_pvt-&gt;callid_number[b] = tech_pvt-&gt;line_array.result[i][a];
+                                                        b++;
+                                                }
+                                        }
+                                        if (commacount == 7) {
+                                                if (tech_pvt-&gt;line_array.result[i][a] != ',' &amp;&amp; tech_pvt-&gt;line_array.result[i][a] != '&quot;') {
+                                                        tech_pvt-&gt;callid_name[c] = tech_pvt-&gt;line_array.result[i][a];
+                                                        c++;
+                                                }
+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-        tech_pvt-&gt;phone_callflow = CALLFLOW_INCOMING_RING;
-        DEBUGA_SKYPE(&quot;|%s| CLCC CALLID: name is %s, number is %s\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;line_array.result[i],
-                  tech_pvt-&gt;callid_name[0] ? tech_pvt-&gt;callid_name : &quot;not available&quot;,
-                  tech_pvt-&gt;callid_number[0] ? tech_pvt-&gt;callid_number : &quot;not available&quot;);
-      }
</del><ins>+                                tech_pvt-&gt;phone_callflow = CALLFLOW_INCOMING_RING;
+                                DEBUGA_SKYPE(&quot;|%s| CLCC CALLID: name is %s, number is %s\n&quot;, SKYPIAX_P_LOG,
+                                                         tech_pvt-&gt;line_array.result[i],
+                                                         tech_pvt-&gt;callid_name[0] ? tech_pvt-&gt;callid_name : &quot;not available&quot;,
+                                                         tech_pvt-&gt;callid_number[0] ? tech_pvt-&gt;callid_number : &quot;not available&quot;);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CLIP&quot;, 5) == 0)) {
-        /* with CLIP, we want to answer right away */
-        memset(tech_pvt-&gt;callid_name, 0, sizeof(tech_pvt-&gt;callid_name));
-        memset(tech_pvt-&gt;callid_number, 0, sizeof(tech_pvt-&gt;callid_number));
</del><ins>+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CLIP&quot;, 5) == 0)) {
+                                /* with CLIP, we want to answer right away */
+                                memset(tech_pvt-&gt;callid_name, 0, sizeof(tech_pvt-&gt;callid_name));
+                                memset(tech_pvt-&gt;callid_number, 0, sizeof(tech_pvt-&gt;callid_number));
</ins><span class="cx"> 
</span><del>-        int commacount = 0;
-        int a = 0;
-        int b = 0;
-        int c = 0;
</del><ins>+                                int commacount = 0;
+                                int a = 0;
+                                int b = 0;
+                                int c = 0;
</ins><span class="cx"> 
</span><del>-        for (a = 7; a &lt; strlen(tech_pvt-&gt;line_array.result[i]); a++) {
-          if (tech_pvt-&gt;line_array.result[i][a] == ',') {
-            commacount++;
-          }
-          if (commacount == 0) {
-            if (tech_pvt-&gt;line_array.result[i][a] != ',' &amp;&amp; tech_pvt-&gt;line_array.result[i][a] != '&quot;') {
-              tech_pvt-&gt;callid_number[b] = tech_pvt-&gt;line_array.result[i][a];
-              b++;
-            }
-          }
-          if (commacount == 4) {
-            if (tech_pvt-&gt;line_array.result[i][a] != ',' &amp;&amp; tech_pvt-&gt;line_array.result[i][a] != '&quot;') {
-              tech_pvt-&gt;callid_name[c] = tech_pvt-&gt;line_array.result[i][a];
-              c++;
-            }
-          }
-        }
</del><ins>+                                for (a = 7; a &lt; strlen(tech_pvt-&gt;line_array.result[i]); a++) {
+                                        if (tech_pvt-&gt;line_array.result[i][a] == ',') {
+                                                commacount++;
+                                        }
+                                        if (commacount == 0) {
+                                                if (tech_pvt-&gt;line_array.result[i][a] != ',' &amp;&amp; tech_pvt-&gt;line_array.result[i][a] != '&quot;') {
+                                                        tech_pvt-&gt;callid_number[b] = tech_pvt-&gt;line_array.result[i][a];
+                                                        b++;
+                                                }
+                                        }
+                                        if (commacount == 4) {
+                                                if (tech_pvt-&gt;line_array.result[i][a] != ',' &amp;&amp; tech_pvt-&gt;line_array.result[i][a] != '&quot;') {
+                                                        tech_pvt-&gt;callid_name[c] = tech_pvt-&gt;line_array.result[i][a];
+                                                        c++;
+                                                }
+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_RING) {
-          gettimeofday(&amp;(tech_pvt-&gt;call_incoming_time), NULL);
-          DEBUGA_SKYPE(&quot;SKYPIAX_STATE_RING call_incoming_time.tv_sec=%ld\n&quot;,
-                    SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec);
</del><ins>+                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_RING) {
+                                        gettimeofday(&amp;(tech_pvt-&gt;call_incoming_time), NULL);
+                                        DEBUGA_SKYPE(&quot;SKYPIAX_STATE_RING call_incoming_time.tv_sec=%ld\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec);
</ins><span class="cx"> 
</span><del>-        }
</del><ins>+                                }
</ins><span class="cx"> 
</span><del>-        tech_pvt-&gt;interface_state = SKYPIAX_STATE_RING;
-        tech_pvt-&gt;phone_callflow = CALLFLOW_INCOMING_RING;
-        DEBUGA_SKYPE(&quot;|%s| CLIP INCOMING CALLID: name is %s, number is %s\n&quot;, SKYPIAX_P_LOG,
-                  tech_pvt-&gt;line_array.result[i],
-                  tech_pvt-&gt;callid_name[0] != 1 ? tech_pvt-&gt;callid_name : &quot;not available&quot;,
-                  tech_pvt-&gt;callid_number[0] ? tech_pvt-&gt;callid_number : &quot;not available&quot;);
-      }
</del><ins>+                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_RING;
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_INCOMING_RING;
+                                DEBUGA_SKYPE(&quot;|%s| CLIP INCOMING CALLID: name is %s, number is %s\n&quot;, SKYPIAX_P_LOG,
+                                                         tech_pvt-&gt;line_array.result[i],
+                                                         tech_pvt-&gt;callid_name[0] != 1 ? tech_pvt-&gt;callid_name : &quot;not available&quot;,
+                                                         tech_pvt-&gt;callid_number[0] ? tech_pvt-&gt;callid_number : &quot;not available&quot;);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;BUSY&quot;) == 0)) {
-        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_LINEBUSY;
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_LINEBUSY\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
-          ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_BUSY);
-          celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_BUSY);
-        } else {
-          ERRORA(&quot;Why BUSY now?\n&quot;, SKYPIAX_P_LOG);
-        }
-      }
-      if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;NO ANSWER&quot;) == 0)) {
-        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_NOANSWER;
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_NOANSWER\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
-          tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_NO_ANSWER;
-          celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-        } else {
-          ERRORA(&quot;Why NO ANSWER now?\n&quot;, SKYPIAX_P_LOG);
-        }
-      }
-      if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;NO CARRIER&quot;) == 0)) {
-        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_NOCARRIER;
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_NOCARRIER\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
-                        //cicopet
-                celliax_hangup(tech_pvt);
-          //tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
-          //celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-        } else {
-          ERRORA(&quot;Why NO CARRIER now?\n&quot;, SKYPIAX_P_LOG);
-        }
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;BUSY&quot;) == 0)) {
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_LINEBUSY;
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_LINEBUSY\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
+                                        ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_BUSY);
+                                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_BUSY);
+                                } else {
+                                        ERRORA(&quot;Why BUSY now?\n&quot;, SKYPIAX_P_LOG);
+                                }
+                        }
+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;NO ANSWER&quot;) == 0)) {
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_NOANSWER;
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_NOANSWER\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
+                                        tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_NO_ANSWER;
+                                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                                } else {
+                                        ERRORA(&quot;Why NO ANSWER now?\n&quot;, SKYPIAX_P_LOG);
+                                }
+                        }
+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;NO CARRIER&quot;) == 0)) {
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_NOCARRIER;
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_NOCARRIER\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
+                                        //cicopet
+                                        celliax_hangup(tech_pvt);
+                                        //tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                        //celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                                } else {
+                                        ERRORA(&quot;Why NO CARRIER now?\n&quot;, SKYPIAX_P_LOG);
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CBC:&quot;, 5) == 0)) {
-        int power_supply, battery_strenght, err;
</del><ins>+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CBC:&quot;, 5) == 0)) {
+                                int power_supply, battery_strenght, err;
</ins><span class="cx"> 
</span><del>-        power_supply = battery_strenght = 0;
</del><ins>+                                power_supply = battery_strenght = 0;
</ins><span class="cx"> 
</span><del>-        err =
-          sscanf(&amp;tech_pvt-&gt;line_array.result[i][6], &quot;%d,%d&quot;, &amp;power_supply, &amp;battery_strenght);
-        if (err &lt; 2) {
-          DEBUGA_SKYPE(&quot;|%s| is not formatted as: |+CBC: xx,yy| now trying  |+CBC:xx,yy|\n&quot;,
-                    SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</del><ins>+                                err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][6], &quot;%d,%d&quot;, &amp;power_supply, &amp;battery_strenght);
+                                if (err &lt; 2) {
+                                        DEBUGA_SKYPE(&quot;|%s| is not formatted as: |+CBC: xx,yy| now trying  |+CBC:xx,yy|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-          err =
-            sscanf(&amp;tech_pvt-&gt;line_array.result[i][5], &quot;%d,%d&quot;, &amp;power_supply,
-                   &amp;battery_strenght);
-          DEBUGA_SKYPE(&quot;|%s| +CBC: Powered by %s, battery strenght=%d\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i], power_supply ? &quot;power supply&quot; : &quot;battery&quot;,
-                    battery_strenght);
</del><ins>+                                        err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][5], &quot;%d,%d&quot;, &amp;power_supply, &amp;battery_strenght);
+                                        DEBUGA_SKYPE(&quot;|%s| +CBC: Powered by %s, battery strenght=%d\n&quot;, SKYPIAX_P_LOG,
+                                                                 tech_pvt-&gt;line_array.result[i], power_supply ? &quot;power supply&quot; : &quot;battery&quot;, battery_strenght);
</ins><span class="cx"> 
</span><del>-        }
</del><ins>+                                }
</ins><span class="cx"> 
</span><del>-        if (err &lt; 2) {
-          DEBUGA_SKYPE(&quot;|%s| is not formatted as: |+CBC:xx,yy| giving up\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-        }
</del><ins>+                                if (err &lt; 2) {
+                                        DEBUGA_SKYPE(&quot;|%s| is not formatted as: |+CBC:xx,yy| giving up\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                }
</ins><span class="cx"> 
</span><del>-        else {
-          if (option_debug &gt; 1)
-            DEBUGA_SKYPE(&quot;|%s| +CBC: Powered by %s, battery strenght=%d\n&quot;, SKYPIAX_P_LOG,
-                      tech_pvt-&gt;line_array.result[i], power_supply ? &quot;power supply&quot; : &quot;battery&quot;,
-                      battery_strenght);
-          if (!power_supply) {
-            if (battery_strenght &lt; 10) {
-              ERRORA(&quot;|%s| BATTERY ALMOST EXHAUSTED\n&quot;, SKYPIAX_P_LOG,
-                     tech_pvt-&gt;line_array.result[i]);
-            } else if (battery_strenght &lt; 20) {
-              WARNINGA(&quot;|%s| BATTERY LOW\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</del><ins>+                                else {
+                                        if (option_debug &gt; 1)
+                                                DEBUGA_SKYPE(&quot;|%s| +CBC: Powered by %s, battery strenght=%d\n&quot;, SKYPIAX_P_LOG,
+                                                                         tech_pvt-&gt;line_array.result[i], power_supply ? &quot;power supply&quot; : &quot;battery&quot;, battery_strenght);
+                                        if (!power_supply) {
+                                                if (battery_strenght &lt; 10) {
+                                                        ERRORA(&quot;|%s| BATTERY ALMOST EXHAUSTED\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                                } else if (battery_strenght &lt; 20) {
+                                                        WARNINGA(&quot;|%s| BATTERY LOW\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-            }
</del><ins>+                                                }
</ins><span class="cx"> 
</span><del>-          }
-        }
</del><ins>+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-      }
</del><ins>+                        }
</ins><span class="cx"> 
</span><del>-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CSQ:&quot;, 5) == 0)) {
-        int signal_quality, ber, err;
</del><ins>+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CSQ:&quot;, 5) == 0)) {
+                                int signal_quality, ber, err;
</ins><span class="cx"> 
</span><del>-        signal_quality = ber = 0;
</del><ins>+                                signal_quality = ber = 0;
</ins><span class="cx"> 
</span><del>-        err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][6], &quot;%d,%d&quot;, &amp;signal_quality, &amp;ber);
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| +CSQ: Signal Quality: %d, Error Rate=%d\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i], signal_quality, ber);
-        if (err &lt; 2) {
-          ERRORA(&quot;|%s| is not formatted as: |+CSQ: xx,yy|\n&quot;, SKYPIAX_P_LOG,
-                 tech_pvt-&gt;line_array.result[i]);
-        } else {
-          if (signal_quality &lt; 11 || signal_quality == 99) {
-            WARNINGA
-              (&quot;|%s| CELLPHONE GETS ALMOST NO SIGNAL, consider to move it or additional antenna\n&quot;,
-               SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
-          } else if (signal_quality &lt; 15) {
-            WARNINGA(&quot;|%s| CELLPHONE GETS SIGNAL LOW\n&quot;, SKYPIAX_P_LOG,
-                     tech_pvt-&gt;line_array.result[i]);
</del><ins>+                                err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][6], &quot;%d,%d&quot;, &amp;signal_quality, &amp;ber);
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| +CSQ: Signal Quality: %d, Error Rate=%d\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i], signal_quality, ber);
+                                if (err &lt; 2) {
+                                        ERRORA(&quot;|%s| is not formatted as: |+CSQ: xx,yy|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                } else {
+                                        if (signal_quality &lt; 11 || signal_quality == 99) {
+                                                WARNINGA
+                                                        (&quot;|%s| CELLPHONE GETS ALMOST NO SIGNAL, consider to move it or additional antenna\n&quot;,
+                                                         SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                        } else if (signal_quality &lt; 15) {
+                                                WARNINGA(&quot;|%s| CELLPHONE GETS SIGNAL LOW\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-          }
</del><ins>+                                        }
</ins><span class="cx"> 
</span><del>-        }
</del><ins>+                                }
</ins><span class="cx"> 
</span><del>-      }
-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGW:&quot;, 6) == 0)) {
-        int err;
</del><ins>+                        }
+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGW:&quot;, 6) == 0)) {
+                                int err;
</ins><span class="cx"> 
</span><del>-        err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][7], &quot;%s&quot;, tech_pvt-&gt;at_cmgw);
-        DEBUGA_SKYPE(&quot;|%s| +CMGW: %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_cmgw);
-        if (err &lt; 1) {
-          ERRORA(&quot;|%s| is not formatted as: |+CMGW: xxxx|\n&quot;, SKYPIAX_P_LOG,
-                 tech_pvt-&gt;line_array.result[i]);
-        }
</del><ins>+                                err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][7], &quot;%s&quot;, tech_pvt-&gt;at_cmgw);
+                                DEBUGA_SKYPE(&quot;|%s| +CMGW: %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_cmgw);
+                                if (err &lt; 1) {
+                                        ERRORA(&quot;|%s| is not formatted as: |+CMGW: xxxx|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                }
</ins><span class="cx"> 
</span><del>-      }
</del><ins>+                        }
</ins><span class="cx"> 
</span><del>-      /* at_call_* are unsolicited messages sent by the modem to signal us about call processing activity and events */
-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_call_idle) == 0)) {
-        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_IDLE;
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_IDLE\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
-        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
-          DEBUGA_SKYPE(&quot;just received a remote HANGUP\n&quot;, SKYPIAX_P_LOG);
-          tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_NORMAL;
-          celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-          DEBUGA_SKYPE(&quot;just sent SKYPIAX_CONTROL_HANGUP\n&quot;, SKYPIAX_P_LOG);
-        }
-      }
</del><ins>+                        /* at_call_* are unsolicited messages sent by the modem to signal us about call processing activity and events */
+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_call_idle) == 0)) {
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_IDLE;
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_IDLE\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
+                                        DEBUGA_SKYPE(&quot;just received a remote HANGUP\n&quot;, SKYPIAX_P_LOG);
+                                        tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_NORMAL;
+                                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                                        DEBUGA_SKYPE(&quot;just sent SKYPIAX_CONTROL_HANGUP\n&quot;, SKYPIAX_P_LOG);
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_call_incoming) == 0)) {
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_call_incoming) == 0)) {
</ins><span class="cx"> 
</span><del>-        //char list_command[64];
</del><ins>+                                //char list_command[64];
</ins><span class="cx"> 
</span><del>-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_INCOMING\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
</del><ins>+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_INCOMING\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-        if (tech_pvt-&gt;phone_callflow != CALLFLOW_CALL_INCOMING
-            &amp;&amp; tech_pvt-&gt;phone_callflow != CALLFLOW_INCOMING_RING) {
-          //mark the time of CALLFLOW_CALL_INCOMING
-          gettimeofday(&amp;(tech_pvt-&gt;call_incoming_time), NULL);
-          tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_INCOMING;
-          DEBUGA_SKYPE(&quot;CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld\n&quot;,
-                    SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec);
</del><ins>+                                if (tech_pvt-&gt;phone_callflow != CALLFLOW_CALL_INCOMING &amp;&amp; tech_pvt-&gt;phone_callflow != CALLFLOW_INCOMING_RING) {
+                                        //mark the time of CALLFLOW_CALL_INCOMING
+                                        gettimeofday(&amp;(tech_pvt-&gt;call_incoming_time), NULL);
+                                        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_INCOMING;
+                                        DEBUGA_SKYPE(&quot;CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec);
</ins><span class="cx"> 
</span><del>-        }
-      }
</del><ins>+                                }
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_call_active) == 0)) {
-              tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_ACTIVE;
-              DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_ACTIVE\n&quot;, SKYPIAX_P_LOG,
-                              tech_pvt-&gt;line_array.result[i]);
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_call_active) == 0)) {
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_ACTIVE;
+                                DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_ACTIVE\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-              if (tech_pvt-&gt;interface_state == CALLFLOW_CALL_DIALING) {
-                      DEBUGA_PBX(&quot;just received a remote ANSWER\n&quot;, SKYPIAX_P_LOG);
-                      if (tech_pvt-&gt;phone_callflow == SKYPIAX_STATE_UP) {
-                              //celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_RINGING);
-                              DEBUGA_PBX(&quot;just sent SKYPIAX_CONTROL_RINGING\n&quot;, SKYPIAX_P_LOG);
-                              DEBUGA_PBX(&quot;going to send SKYPIAX_CONTROL_ANSWER\n&quot;, SKYPIAX_P_LOG);
-                              //celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_ANSWER);
-                              tech_pvt-&gt;interface_state = CALLFLOW_CALL_REMOTEANSWER;
-                              DEBUGA_PBX(&quot;just sent SKYPIAX_CONTROL_ANSWER\n&quot;, SKYPIAX_P_LOG);
-                      }
-              } else {
-              }
-              //tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
-              //DEBUGA_PBX(&quot;just interface_state UP\n&quot;, SKYPIAX_P_LOG);
-      }
</del><ins>+                                if (tech_pvt-&gt;interface_state == CALLFLOW_CALL_DIALING) {
+                                        DEBUGA_PBX(&quot;just received a remote ANSWER\n&quot;, SKYPIAX_P_LOG);
+                                        if (tech_pvt-&gt;phone_callflow == SKYPIAX_STATE_UP) {
+                                                //celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_RINGING);
+                                                DEBUGA_PBX(&quot;just sent SKYPIAX_CONTROL_RINGING\n&quot;, SKYPIAX_P_LOG);
+                                                DEBUGA_PBX(&quot;going to send SKYPIAX_CONTROL_ANSWER\n&quot;, SKYPIAX_P_LOG);
+                                                //celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_ANSWER);
+                                                tech_pvt-&gt;interface_state = CALLFLOW_CALL_REMOTEANSWER;
+                                                DEBUGA_PBX(&quot;just sent SKYPIAX_CONTROL_ANSWER\n&quot;, SKYPIAX_P_LOG);
+                                        }
+                                } else {
+                                }
+                                //tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
+                                //DEBUGA_PBX(&quot;just interface_state UP\n&quot;, SKYPIAX_P_LOG);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_call_calling) == 0)) {
-        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_DIALING;
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_DIALING\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_call_failed) == 0)) {
-        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_FAILED;
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_FAILED\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
-          tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
-          celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-        }
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_call_calling) == 0)) {
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_DIALING;
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_DIALING\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_call_failed) == 0)) {
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_FAILED;
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_FAILED\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
+                                        tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CSCA:&quot;, 6) == 0)) {   //TODO SMS FIXME in config!
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| +CSCA: Message Center Address!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CSCA:&quot;, 6) == 0)) {        //TODO SMS FIXME in config!
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| +CSCA: Message Center Address!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGF:&quot;, 6) == 0)) {   //TODO SMS FIXME in config!
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| +CMGF: Message Format!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGF:&quot;, 6) == 0)) {        //TODO SMS FIXME in config!
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| +CMGF: Message Format!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMTI:&quot;, 6) == 0)) {   //TODO SMS FIXME in config!
-        int err;
-        int pos;
</del><ins>+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMTI:&quot;, 6) == 0)) {        //TODO SMS FIXME in config!
+                                int err;
+                                int pos;
</ins><span class="cx"> 
</span><del>-        //FIXME all the following commands in config!
-        if (option_debug)
-          DEBUGA_SKYPE(&quot;|%s| +CMTI: Incoming SMS!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
</del><ins>+                                //FIXME all the following commands in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE(&quot;|%s| +CMTI: Incoming SMS!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-        err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][12], &quot;%d&quot;, &amp;pos);
-        if (err &lt; 1) {
-          ERRORA(&quot;|%s| is not formatted as: |+CMTI: \&quot;MT\&quot;,xx|\n&quot;, SKYPIAX_P_LOG,
-                 tech_pvt-&gt;line_array.result[i]);
-        } else {
-          DEBUGA_SKYPE(&quot;|%s| +CMTI: Incoming SMS in position: %d!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i], pos);
-          tech_pvt-&gt;unread_sms_msg_id = pos;
-          usleep(1000);
</del><ins>+                                err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][12], &quot;%d&quot;, &amp;pos);
+                                if (err &lt; 1) {
+                                        ERRORA(&quot;|%s| is not formatted as: |+CMTI: \&quot;MT\&quot;,xx|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                } else {
+                                        DEBUGA_SKYPE(&quot;|%s| +CMTI: Incoming SMS in position: %d!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i], pos);
+                                        tech_pvt-&gt;unread_sms_msg_id = pos;
+                                        usleep(1000);
</ins><span class="cx"> 
</span><del>-          if (tech_pvt-&gt;unread_sms_msg_id) {
-            char at_command[256];
</del><ins>+                                        if (tech_pvt-&gt;unread_sms_msg_id) {
+                                                char at_command[256];
</ins><span class="cx"> 
</span><del>-            if (tech_pvt-&gt;no_ucs2 == 0) {
-              res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;UCS2\&quot;&quot;);
-              if (res) {
-                ERRORA
-                  (&quot;AT+CSCS=\&quot;UCS2\&quot; (set TE messages to ucs2)  do not got OK from the phone, continuing\n&quot;,
-                   SKYPIAX_P_LOG);
-                //memset(tech_pvt-&gt;sms_message, 0, sizeof(tech_pvt-&gt;sms_message));
-              }
-            }
</del><ins>+                                                if (tech_pvt-&gt;no_ucs2 == 0) {
+                                                        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;UCS2\&quot;&quot;);
+                                                        if (res) {
+                                                                ERRORA(&quot;AT+CSCS=\&quot;UCS2\&quot; (set TE messages to ucs2)  do not got OK from the phone, continuing\n&quot;, SKYPIAX_P_LOG);
+                                                                //memset(tech_pvt-&gt;sms_message, 0, sizeof(tech_pvt-&gt;sms_message));
+                                                        }
+                                                }
</ins><span class="cx"> 
</span><del>-            memset(at_command, 0, sizeof(at_command));
-            sprintf(at_command, &quot;AT+CMGR=%d&quot;, tech_pvt-&gt;unread_sms_msg_id);
-            memset(tech_pvt-&gt;sms_message, 0, sizeof(tech_pvt-&gt;sms_message));
</del><ins>+                                                memset(at_command, 0, sizeof(at_command));
+                                                sprintf(at_command, &quot;AT+CMGR=%d&quot;, tech_pvt-&gt;unread_sms_msg_id);
+                                                memset(tech_pvt-&gt;sms_message, 0, sizeof(tech_pvt-&gt;sms_message));
</ins><span class="cx"> 
</span><del>-            tech_pvt-&gt;reading_sms_msg = 1;
-            res = celliax_serial_write_AT_ack(tech_pvt, at_command);
-            tech_pvt-&gt;reading_sms_msg = 0;
-            if (res) {
-              ERRORA
-                (&quot;AT+CMGR (read SMS) do not got OK from the phone, message sent was:|||%s|||\n&quot;,
-                 SKYPIAX_P_LOG, at_command);
-            }
-            res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;GSM\&quot;&quot;);
-            if (res) {
-              ERRORA
-                (&quot;AT+CSCS=\&quot;GSM\&quot; (set TE messages to GSM) do not got OK from the phone\n&quot;,
-                 SKYPIAX_P_LOG);
-            }
-            memset(at_command, 0, sizeof(at_command));
-            sprintf(at_command, &quot;AT+CMGD=%d&quot;, tech_pvt-&gt;unread_sms_msg_id);    /* delete the message */
-            tech_pvt-&gt;unread_sms_msg_id = 0;
-            res = celliax_serial_write_AT_ack(tech_pvt, at_command);
-            if (res) {
-              ERRORA
-                (&quot;AT+CMGD (Delete SMS) do not got OK from the phone, message sent was:|||%s|||\n&quot;,
-                 SKYPIAX_P_LOG, at_command);
-            }
</del><ins>+                                                tech_pvt-&gt;reading_sms_msg = 1;
+                                                res = celliax_serial_write_AT_ack(tech_pvt, at_command);
+                                                tech_pvt-&gt;reading_sms_msg = 0;
+                                                if (res) {
+                                                        ERRORA(&quot;AT+CMGR (read SMS) do not got OK from the phone, message sent was:|||%s|||\n&quot;, SKYPIAX_P_LOG, at_command);
+                                                }
+                                                res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;GSM\&quot;&quot;);
+                                                if (res) {
+                                                        ERRORA(&quot;AT+CSCS=\&quot;GSM\&quot; (set TE messages to GSM) do not got OK from the phone\n&quot;, SKYPIAX_P_LOG);
+                                                }
+                                                memset(at_command, 0, sizeof(at_command));
+                                                sprintf(at_command, &quot;AT+CMGD=%d&quot;, tech_pvt-&gt;unread_sms_msg_id);        /* delete the message */
+                                                tech_pvt-&gt;unread_sms_msg_id = 0;
+                                                res = celliax_serial_write_AT_ack(tech_pvt, at_command);
+                                                if (res) {
+                                                        ERRORA(&quot;AT+CMGD (Delete SMS) do not got OK from the phone, message sent was:|||%s|||\n&quot;, SKYPIAX_P_LOG, at_command);
+                                                }
</ins><span class="cx"> 
</span><del>-            if (strlen(tech_pvt-&gt;sms_message)) {
-              //FIXME manager_event(EVENT_FLAG_SYSTEM, &quot;CELLIAXincomingsms&quot;,
-                            //FIXME &quot;Interface: %s\r\nSMS_Message: %s\r\n&quot;, tech_pvt-&gt;name,
-                            //FIXME tech_pvt-&gt;sms_message);
-              if (strlen(tech_pvt-&gt;sms_receiving_program)) {
-                int fd1[2];
-                pid_t pid1;
-                char *arg1[] = { tech_pvt-&gt;sms_receiving_program, (char *) NULL };
-                int i;
</del><ins>+                                                if (strlen(tech_pvt-&gt;sms_message)) {
+                                                        //FIXME manager_event(EVENT_FLAG_SYSTEM, &quot;CELLIAXincomingsms&quot;,
+                                                        //FIXME &quot;Interface: %s\r\nSMS_Message: %s\r\n&quot;, tech_pvt-&gt;name,
+                                                        //FIXME tech_pvt-&gt;sms_message);
+                                                        if (strlen(tech_pvt-&gt;sms_receiving_program)) {
+                                                                int fd1[2];
+                                                                pid_t pid1;
+                                                                char *arg1[] = { tech_pvt-&gt;sms_receiving_program, (char *) NULL };
+                                                                int i;
</ins><span class="cx"> 
</span><del>-                NOTICA(&quot;incoming SMS message:&gt;&gt;&gt;%s&lt;&lt;&lt;\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;sms_message);
-                pipe(fd1);
-                pid1 = fork();
</del><ins>+                                                                NOTICA(&quot;incoming SMS message:&gt;&gt;&gt;%s&lt;&lt;&lt;\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;sms_message);
+                                                                pipe(fd1);
+                                                                pid1 = fork();
</ins><span class="cx"> 
</span><del>-                if (pid1 == 0) {    //child
-                  int err;
</del><ins>+                                                                if (pid1 == 0) {        //child
+                                                                        int err;
</ins><span class="cx"> 
</span><del>-                  dup2(fd1[0], 0);  // Connect stdin to pipe output
-                  close(fd1[1]);    // close input pipe side
-                close(tech_pvt-&gt;controldevfd);
-                  setsid();     //session id
-                  err = execvp(arg1[0], arg1);  //exec our program, with stdin connected to pipe output
-                  if (err) {
-                    ERRORA
-                      (&quot;'sms_receiving_program' is set in config file to '%s', and it gave us back this error: %d, (%s). SMS received was:---%s---\n&quot;,
-                       SKYPIAX_P_LOG, tech_pvt-&gt;sms_receiving_program, err, strerror(errno),
-                       tech_pvt-&gt;sms_message);
-                  }
-                  close(fd1[0]);    // close output pipe side
-                }
</del><ins>+                                                                        dup2(fd1[0], 0);        // Connect stdin to pipe output
+                                                                        close(fd1[1]);        // close input pipe side
+                                                                        close(tech_pvt-&gt;controldevfd);
+                                                                        setsid();        //session id
+                                                                        err = execvp(arg1[0], arg1);        //exec our program, with stdin connected to pipe output
+                                                                        if (err) {
+                                                                                ERRORA
+                                                                                        (&quot;'sms_receiving_program' is set in config file to '%s', and it gave us back this error: %d, (%s). SMS received was:---%s---\n&quot;,
+                                                                                         SKYPIAX_P_LOG, tech_pvt-&gt;sms_receiving_program, err, strerror(errno), tech_pvt-&gt;sms_message);
+                                                                        }
+                                                                        close(fd1[0]);        // close output pipe side
+                                                                }
</ins><span class="cx"> //starting here continue the parent
</span><del>-                close(fd1[0]);  // close output pipe side
-                // write the msg on the pipe input
-                for (i = 0; i &lt; strlen(tech_pvt-&gt;sms_message); i++) {
-                  write(fd1[1], &amp;tech_pvt-&gt;sms_message[i], 1);
-                }
-                close(fd1[1]);  // close pipe input, let our program know we've finished
-              } else {
-                ERRORA
-                  (&quot;got SMS incoming message, but 'sms_receiving_program' is not set in config file. SMS received was:---%s---\n&quot;,
-                   SKYPIAX_P_LOG, tech_pvt-&gt;sms_message);
-              }
-            }
-#if 1                           //is this one needed? maybe it can interrupt an incoming call that is just to announce itself
-            if (tech_pvt-&gt;phone_callflow == CALLFLOW_CALL_IDLE
-                &amp;&amp; tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner == NULL) {
-              /* we're not in a call, neither calling */
-              res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CKPD=\&quot;EEE\&quot;&quot;);
-              if (res) {
-                ERRORA
-                  (&quot;AT+CKPD=\&quot;EEE\&quot; (cellphone screen back to user) do not got OK from the phone\n&quot;,
-                   SKYPIAX_P_LOG);
-              }
-            }
</del><ins>+                                                                close(fd1[0]);        // close output pipe side
+                                                                // write the msg on the pipe input
+                                                                for (i = 0; i &lt; strlen(tech_pvt-&gt;sms_message); i++) {
+                                                                        write(fd1[1], &amp;tech_pvt-&gt;sms_message[i], 1);
+                                                                }
+                                                                close(fd1[1]);        // close pipe input, let our program know we've finished
+                                                        } else {
+                                                                ERRORA
+                                                                        (&quot;got SMS incoming message, but 'sms_receiving_program' is not set in config file. SMS received was:---%s---\n&quot;,
+                                                                         SKYPIAX_P_LOG, tech_pvt-&gt;sms_message);
+                                                        }
+                                                }
+#if 1                                                        //is this one needed? maybe it can interrupt an incoming call that is just to announce itself
+                                                if (tech_pvt-&gt;phone_callflow == CALLFLOW_CALL_IDLE &amp;&amp; tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner == NULL) {
+                                                        /* we're not in a call, neither calling */
+                                                        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CKPD=\&quot;EEE\&quot;&quot;);
+                                                        if (res) {
+                                                                ERRORA(&quot;AT+CKPD=\&quot;EEE\&quot; (cellphone screen back to user) do not got OK from the phone\n&quot;, SKYPIAX_P_LOG);
+                                                        }
+                                                }
</ins><span class="cx"> #endif
</span><del>-          }                     //unread_msg_id
</del><ins>+                                        }                        //unread_msg_id
</ins><span class="cx"> 
</span><del>-        }                       //CMTI well formatted
</del><ins>+                                }                                //CMTI well formatted
</ins><span class="cx"> 
</span><del>-      }                         //CMTI
</del><ins>+                        }                                        //CMTI
</ins><span class="cx"> 
</span><del>-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+MMGL:&quot;, 6) == 0)) {   //TODO MOTOROLA SMS FIXME in config!
-        int err = 0;
-        //int unread_msg_id=0;
</del><ins>+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+MMGL:&quot;, 6) == 0)) {        //TODO MOTOROLA SMS FIXME in config!
+                                int err = 0;
+                                //int unread_msg_id=0;
</ins><span class="cx"> 
</span><del>-        if (option_debug)
-          DEBUGA_SKYPE(&quot;|%s| +MMGL: Listing Motorola SMSs!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
</del><ins>+                                if (option_debug)
+                                        DEBUGA_SKYPE(&quot;|%s| +MMGL: Listing Motorola SMSs!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-        err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][7], &quot;%d&quot;, &amp;tech_pvt-&gt;unread_sms_msg_id);
-        if (err &lt; 1) {
-          ERRORA(&quot;|%s| is not formatted as: |+MMGL: xx|\n&quot;, SKYPIAX_P_LOG,
-                 tech_pvt-&gt;line_array.result[i]);
-        }
-      }
-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGL:&quot;, 6) == 0)) {   //TODO  SMS FIXME in config!
-        if (option_debug)
-          DEBUGA_SKYPE(&quot;|%s| +CMGL: Listing SMSs!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+MMGR:&quot;, 6) == 0)) {   //TODO MOTOROLA SMS FIXME in config!
-        if (option_debug)
-          DEBUGA_SKYPE(&quot;|%s| +MMGR: Reading Motorola SMS!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-        if (tech_pvt-&gt;reading_sms_msg)
-          tech_pvt-&gt;reading_sms_msg++;
-      }
-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGR: \&quot;STO U&quot;, 13) == 0)) {  //TODO  SMS FIXME in config!
-        if (option_debug)
-          DEBUGA_SKYPE(&quot;|%s| +CMGR: Reading stored UNSENT SMS!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      } else if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGR: \&quot;STO S&quot;, 13) == 0)) {   //TODO  SMS FIXME in config!
-        if (option_debug)
-          DEBUGA_SKYPE(&quot;|%s| +CMGR: Reading stored SENT SMS!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      } else if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGR: \&quot;REC R&quot;, 13) == 0)) {   //TODO  SMS FIXME in config!
-        if (option_debug)
-          DEBUGA_SKYPE(&quot;|%s| +CMGR: Reading received READ SMS!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      } else if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGR: \&quot;REC U&quot;, 13) == 0)) {   //TODO  SMS FIXME in config!
-        if (option_debug)
-          DEBUGA_SKYPE(&quot;|%s| +CMGR: Reading received UNREAD SMS!\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-        if (tech_pvt-&gt;reading_sms_msg)
-          tech_pvt-&gt;reading_sms_msg++;
-      }
</del><ins>+                                err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][7], &quot;%d&quot;, &amp;tech_pvt-&gt;unread_sms_msg_id);
+                                if (err &lt; 1) {
+                                        ERRORA(&quot;|%s| is not formatted as: |+MMGL: xx|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                }
+                        }
+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGL:&quot;, 6) == 0)) {        //TODO  SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE(&quot;|%s| +CMGL: Listing SMSs!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+MMGR:&quot;, 6) == 0)) {        //TODO MOTOROLA SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE(&quot;|%s| +MMGR: Reading Motorola SMS!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                if (tech_pvt-&gt;reading_sms_msg)
+                                        tech_pvt-&gt;reading_sms_msg++;
+                        }
+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGR: \&quot;STO U&quot;, 13) == 0)) {        //TODO  SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE(&quot;|%s| +CMGR: Reading stored UNSENT SMS!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        } else if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGR: \&quot;STO S&quot;, 13) == 0)) {        //TODO  SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE(&quot;|%s| +CMGR: Reading stored SENT SMS!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        } else if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGR: \&quot;REC R&quot;, 13) == 0)) {        //TODO  SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE(&quot;|%s| +CMGR: Reading received READ SMS!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        } else if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGR: \&quot;REC U&quot;, 13) == 0)) {        //TODO  SMS FIXME in config!
+                                if (option_debug)
+                                        DEBUGA_SKYPE(&quot;|%s| +CMGR: Reading received UNREAD SMS!\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                if (tech_pvt-&gt;reading_sms_msg)
+                                        tech_pvt-&gt;reading_sms_msg++;
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;+MCST: 17&quot;) == 0)) {    /* motorola call processing unsolicited messages */
-        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_INFLUX;
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_INFLUX\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;+MCST: 17&quot;) == 0)) {        /* motorola call processing unsolicited messages */
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_INFLUX;
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_INFLUX\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;+MCST: 68&quot;) == 0)) {    /* motorola call processing unsolicited messages */
-        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_NOSERVICE;
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_NOSERVICE\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
-          tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
-          celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-        }
-      }
-      if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;+MCST: 70&quot;) == 0)) {    /* motorola call processing unsolicited messages */
-        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_OUTGOINGRESTRICTED;
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_OUTGOINGRESTRICTED\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
-          tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
-          celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-        }
-      }
-      if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;+MCST: 72&quot;) == 0)) {    /* motorola call processing unsolicited messages */
-        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_SECURITYFAIL;
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_SECURITYFAIL\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
-          tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
-          celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-        }
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;+MCST: 68&quot;) == 0)) {        /* motorola call processing unsolicited messages */
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_NOSERVICE;
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_NOSERVICE\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
+                                        tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                                }
+                        }
+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;+MCST: 70&quot;) == 0)) {        /* motorola call processing unsolicited messages */
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_OUTGOINGRESTRICTED;
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_OUTGOINGRESTRICTED\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
+                                        tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                                }
+                        }
+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;+MCST: 72&quot;) == 0)) {        /* motorola call processing unsolicited messages */
+                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_SECURITYFAIL;
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| CALLFLOW_CALL_SECURITYFAIL\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner) {
+                                        tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
+                                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CPBR&quot;, 5) == 0)) {    /* phonebook stuff begins */
</del><ins>+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CPBR&quot;, 5) == 0)) {        /* phonebook stuff begins */
</ins><span class="cx"> 
</span><del>-        if (tech_pvt-&gt;phonebook_querying) {    /* probably phonebook struct begins */
-          int err, first_entry, last_entry, number_lenght, text_lenght;
</del><ins>+                                if (tech_pvt-&gt;phonebook_querying) {        /* probably phonebook struct begins */
+                                        int err, first_entry, last_entry, number_lenght, text_lenght;
</ins><span class="cx"> 
</span><del>-          if (option_debug)
-            DEBUGA_SKYPE(&quot;phonebook struct: |%s|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</del><ins>+                                        if (option_debug)
+                                                DEBUGA_SKYPE(&quot;phonebook struct: |%s|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-          err =
-            sscanf(&amp;tech_pvt-&gt;line_array.result[i][8], &quot;%d-%d),%d,%d&quot;, &amp;first_entry, &amp;last_entry,
-                   &amp;number_lenght, &amp;text_lenght);
-          if (err &lt; 4) {
</del><ins>+                                        err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][8], &quot;%d-%d),%d,%d&quot;, &amp;first_entry, &amp;last_entry, &amp;number_lenght, &amp;text_lenght);
+                                        if (err &lt; 4) {
</ins><span class="cx"> 
</span><del>-            err =
-              sscanf(&amp;tech_pvt-&gt;line_array.result[i][7], &quot;%d-%d,%d,%d&quot;, &amp;first_entry,
-                     &amp;last_entry, &amp;number_lenght, &amp;text_lenght);
-          }
</del><ins>+                                                err = sscanf(&amp;tech_pvt-&gt;line_array.result[i][7], &quot;%d-%d,%d,%d&quot;, &amp;first_entry, &amp;last_entry, &amp;number_lenght, &amp;text_lenght);
+                                        }
</ins><span class="cx"> 
</span><del>-          if (err &lt; 4) {
-            ERRORA
-              (&quot;phonebook struct: |%s| is nor formatted as: |+CPBR: (1-750),40,14| neither as: |+CPBR: 1-750,40,14|\n&quot;,
-               SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
-          } else {
</del><ins>+                                        if (err &lt; 4) {
+                                                ERRORA
+                                                        (&quot;phonebook struct: |%s| is nor formatted as: |+CPBR: (1-750),40,14| neither as: |+CPBR: 1-750,40,14|\n&quot;,
+                                                         SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                        } else {
</ins><span class="cx"> 
</span><del>-            if (option_debug)
-              DEBUGA_SKYPE
-                (&quot;First entry: %d, last entry: %d, phone number max lenght: %d, text max lenght: %d\n&quot;,
-                 SKYPIAX_P_LOG, first_entry, last_entry, number_lenght, text_lenght);
-            tech_pvt-&gt;phonebook_first_entry = first_entry;
-            tech_pvt-&gt;phonebook_last_entry = last_entry;
-            tech_pvt-&gt;phonebook_number_lenght = number_lenght;
-            tech_pvt-&gt;phonebook_text_lenght = text_lenght;
-          }
</del><ins>+                                                if (option_debug)
+                                                        DEBUGA_SKYPE
+                                                                (&quot;First entry: %d, last entry: %d, phone number max lenght: %d, text max lenght: %d\n&quot;,
+                                                                 SKYPIAX_P_LOG, first_entry, last_entry, number_lenght, text_lenght);
+                                                tech_pvt-&gt;phonebook_first_entry = first_entry;
+                                                tech_pvt-&gt;phonebook_last_entry = last_entry;
+                                                tech_pvt-&gt;phonebook_number_lenght = number_lenght;
+                                                tech_pvt-&gt;phonebook_text_lenght = text_lenght;
+                                        }
</ins><span class="cx"> 
</span><del>-        } else {                /* probably phonebook entry begins */
</del><ins>+                                } else {                /* probably phonebook entry begins */
</ins><span class="cx"> 
</span><del>-          if (tech_pvt-&gt;phonebook_listing) {
-            int err, entry_id, entry_type;
</del><ins>+                                        if (tech_pvt-&gt;phonebook_listing) {
+                                                int err, entry_id, entry_type;
</ins><span class="cx"> 
</span><del>-            char entry_number[256];
-            char entry_text[256];
</del><ins>+                                                char entry_number[256];
+                                                char entry_text[256];
</ins><span class="cx"> 
</span><del>-            if (option_debug)
-              DEBUGA_SKYPE(&quot;phonebook entry: |%s|\n&quot;, SKYPIAX_P_LOG,
-                        tech_pvt-&gt;line_array.result[i]);
</del><ins>+                                                if (option_debug)
+                                                        DEBUGA_SKYPE(&quot;phonebook entry: |%s|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-            err =
-              sscanf(&amp;tech_pvt-&gt;line_array.result[i][7], &quot;%d,\&quot;%255[0-9+]\&quot;,%d,\&quot;%255[^\&quot;]\&quot;&quot;,
-                     &amp;entry_id, entry_number, &amp;entry_type, entry_text);
-            if (err &lt; 4) {
-              ERRORA
-                (&quot;err=%d, phonebook entry: |%s| is not formatted as: |+CPBR: 504,\&quot;+39025458068\&quot;,145,\&quot;ciao a tutti\&quot;|\n&quot;,
-                 SKYPIAX_P_LOG, err, tech_pvt-&gt;line_array.result[i]);
-            } else {
-              //TODO: sanitize entry_text
-              if (option_debug)
-                DEBUGA_SKYPE(&quot;Number: %s, Text: %s, Type: %d\n&quot;, SKYPIAX_P_LOG, entry_number,
-                          entry_text, entry_type);
-              /* write entry in phonebook file */
-              if (tech_pvt-&gt;phonebook_writing_fp) {
-                celliax_dir_entry_extension++;
</del><ins>+                                                err =
+                                                        sscanf(&amp;tech_pvt-&gt;line_array.result[i][7], &quot;%d,\&quot;%255[0-9+]\&quot;,%d,\&quot;%255[^\&quot;]\&quot;&quot;, &amp;entry_id, entry_number, &amp;entry_type, entry_text);
+                                                if (err &lt; 4) {
+                                                        ERRORA
+                                                                (&quot;err=%d, phonebook entry: |%s| is not formatted as: |+CPBR: 504,\&quot;+39025458068\&quot;,145,\&quot;ciao a tutti\&quot;|\n&quot;,
+                                                                 SKYPIAX_P_LOG, err, tech_pvt-&gt;line_array.result[i]);
+                                                } else {
+                                                        //TODO: sanitize entry_text
+                                                        if (option_debug)
+                                                                DEBUGA_SKYPE(&quot;Number: %s, Text: %s, Type: %d\n&quot;, SKYPIAX_P_LOG, entry_number, entry_text, entry_type);
+                                                        /* write entry in phonebook file */
+                                                        if (tech_pvt-&gt;phonebook_writing_fp) {
+                                                                celliax_dir_entry_extension++;
</ins><span class="cx"> 
</span><del>-                fprintf(tech_pvt-&gt;phonebook_writing_fp,
-                        &quot;%s  =&gt; ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromcell=%s|phonebook_entry_owner=%s\n&quot;,
-                        entry_number, entry_text, &quot;no&quot;,
-                        tech_pvt-&gt;celliax_dir_entry_extension_prefix, &quot;2&quot;,
-                        celliax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
-                fprintf(tech_pvt-&gt;phonebook_writing_fp,
-                        &quot;%s  =&gt; ,%sDO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromcell=%s|phonebook_entry_owner=%s\n&quot;,
-                        entry_number, entry_text, &quot;no&quot;,
-                        tech_pvt-&gt;celliax_dir_entry_extension_prefix, &quot;3&quot;,
-                        celliax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
-              }
-            }
</del><ins>+                                                                fprintf(tech_pvt-&gt;phonebook_writing_fp,
+                                                                                &quot;%s  =&gt; ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromcell=%s|phonebook_entry_owner=%s\n&quot;,
+                                                                                entry_number, entry_text, &quot;no&quot;,
+                                                                                tech_pvt-&gt;celliax_dir_entry_extension_prefix, &quot;2&quot;, celliax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
+                                                                fprintf(tech_pvt-&gt;phonebook_writing_fp,
+                                                                                &quot;%s  =&gt; ,%sDO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromcell=%s|phonebook_entry_owner=%s\n&quot;,
+                                                                                entry_number, entry_text, &quot;no&quot;,
+                                                                                tech_pvt-&gt;celliax_dir_entry_extension_prefix, &quot;3&quot;, celliax_dir_entry_extension, &quot;yes&quot;, &quot;not_specified&quot;);
+                                                        }
+                                                }
</ins><span class="cx"> 
</span><del>-          }
</del><ins>+                                        }
</ins><span class="cx"> 
</span><del>-          if (tech_pvt-&gt;phonebook_listing_received_calls) {
-            int err, entry_id, entry_type;
</del><ins>+                                        if (tech_pvt-&gt;phonebook_listing_received_calls) {
+                                                int err, entry_id, entry_type;
</ins><span class="cx"> 
</span><del>-            char entry_number[256] = &quot;&quot;;
-            char entry_text[256] = &quot;&quot;;
</del><ins>+                                                char entry_number[256] = &quot;&quot;;
+                                                char entry_text[256] = &quot;&quot;;
</ins><span class="cx"> 
</span><del>-            if (option_debug)
-              DEBUGA_SKYPE(&quot;phonebook entry: |%s|\n&quot;, SKYPIAX_P_LOG,
-                        tech_pvt-&gt;line_array.result[i]);
</del><ins>+                                                if (option_debug)
+                                                        DEBUGA_SKYPE(&quot;phonebook entry: |%s|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-            err =
-              sscanf(&amp;tech_pvt-&gt;line_array.result[i][7], &quot;%d,\&quot;%255[0-9+]\&quot;,%d,\&quot;%255[^\&quot;]\&quot;&quot;,
-                     &amp;entry_id, entry_number, &amp;entry_type, entry_text);
-            if (err &lt; 1) {      //we match only on the progressive id, maybe the remote party has not sent its number, and/or there is no corresponding text entry in the phone directory
-              ERRORA
-                (&quot;err=%d, phonebook entry: |%s| is not formatted as: |+CPBR: 504,\&quot;+39025458068\&quot;,145,\&quot;ciao a tutti\&quot;|\n&quot;,
-                 SKYPIAX_P_LOG, err, tech_pvt-&gt;line_array.result[i]);
-            } else {
-              //TODO: sanitize entry_text
</del><ins>+                                                err =
+                                                        sscanf(&amp;tech_pvt-&gt;line_array.result[i][7], &quot;%d,\&quot;%255[0-9+]\&quot;,%d,\&quot;%255[^\&quot;]\&quot;&quot;, &amp;entry_id, entry_number, &amp;entry_type, entry_text);
+                                                if (err &lt; 1) {        //we match only on the progressive id, maybe the remote party has not sent its number, and/or there is no corresponding text entry in the phone directory
+                                                        ERRORA
+                                                                (&quot;err=%d, phonebook entry: |%s| is not formatted as: |+CPBR: 504,\&quot;+39025458068\&quot;,145,\&quot;ciao a tutti\&quot;|\n&quot;,
+                                                                 SKYPIAX_P_LOG, err, tech_pvt-&gt;line_array.result[i]);
+                                                } else {
+                                                        //TODO: sanitize entry_text
</ins><span class="cx"> 
</span><del>-              if (option_debug)
-                DEBUGA_SKYPE(&quot;Number: %s, Text: %s, Type: %d\n&quot;, SKYPIAX_P_LOG, entry_number,
-                          entry_text, entry_type);
-              memset(tech_pvt-&gt;callid_name, 0, sizeof(tech_pvt-&gt;callid_name));
-              memset(tech_pvt-&gt;callid_number, 0, sizeof(tech_pvt-&gt;callid_number));
-              strncpy(tech_pvt-&gt;callid_name, entry_text, sizeof(tech_pvt-&gt;callid_name));
-              strncpy(tech_pvt-&gt;callid_number, entry_number, sizeof(tech_pvt-&gt;callid_number));
-              if (option_debug)
-                DEBUGA_SKYPE(&quot;incoming callid: Text: %s, Number: %s\n&quot;, SKYPIAX_P_LOG,
-                          tech_pvt-&gt;callid_name, tech_pvt-&gt;callid_number);
</del><ins>+                                                        if (option_debug)
+                                                                DEBUGA_SKYPE(&quot;Number: %s, Text: %s, Type: %d\n&quot;, SKYPIAX_P_LOG, entry_number, entry_text, entry_type);
+                                                        memset(tech_pvt-&gt;callid_name, 0, sizeof(tech_pvt-&gt;callid_name));
+                                                        memset(tech_pvt-&gt;callid_number, 0, sizeof(tech_pvt-&gt;callid_number));
+                                                        strncpy(tech_pvt-&gt;callid_name, entry_text, sizeof(tech_pvt-&gt;callid_name));
+                                                        strncpy(tech_pvt-&gt;callid_number, entry_number, sizeof(tech_pvt-&gt;callid_number));
+                                                        if (option_debug)
+                                                                DEBUGA_SKYPE(&quot;incoming callid: Text: %s, Number: %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;callid_name, tech_pvt-&gt;callid_number);
</ins><span class="cx"> 
</span><del>-              DEBUGA_SKYPE(&quot;|%s| CPBR INCOMING CALLID: name is %s, number is %s\n&quot;,
-                        SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i],
-                        tech_pvt-&gt;callid_name[0] != 1 ? tech_pvt-&gt;callid_name : &quot;not available&quot;,
-                        tech_pvt-&gt;callid_number[0] ? tech_pvt-&gt;callid_number : &quot;not available&quot;);
</del><ins>+                                                        DEBUGA_SKYPE(&quot;|%s| CPBR INCOMING CALLID: name is %s, number is %s\n&quot;,
+                                                                                 SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i],
+                                                                                 tech_pvt-&gt;callid_name[0] != 1 ? tech_pvt-&gt;callid_name : &quot;not available&quot;,
+                                                                                 tech_pvt-&gt;callid_number[0] ? tech_pvt-&gt;callid_number : &quot;not available&quot;);
</ins><span class="cx"> 
</span><del>-              /* mark the time of RING */
-              gettimeofday(&amp;(tech_pvt-&gt;ringtime), NULL);
-              tech_pvt-&gt;interface_state = SKYPIAX_STATE_RING;
-              tech_pvt-&gt;phone_callflow = CALLFLOW_INCOMING_RING;
</del><ins>+                                                        /* mark the time of RING */
+                                                        gettimeofday(&amp;(tech_pvt-&gt;ringtime), NULL);
+                                                        tech_pvt-&gt;interface_state = SKYPIAX_STATE_RING;
+                                                        tech_pvt-&gt;phone_callflow = CALLFLOW_INCOMING_RING;
</ins><span class="cx"> 
</span><del>-            }
</del><ins>+                                                }
</ins><span class="cx"> 
</span><del>-          }
</del><ins>+                                        }
</ins><span class="cx"> 
</span><del>-          else {
-            DEBUGA_SKYPE(&quot;phonebook entry: |%s|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</del><ins>+                                        else {
+                                                DEBUGA_SKYPE(&quot;phonebook entry: |%s|\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
</ins><span class="cx"> 
</span><del>-          }
-        }
</del><ins>+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-      }
</del><ins>+                        }
</ins><span class="cx"> 
</span><del>-      if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;*ECAV&quot;, 5) == 0) || (strncmp(tech_pvt-&gt;line_array.result[i], &quot;*ECAM&quot;, 5) == 0)) { /* sony-ericsson call processing unsolicited messages */
-        int res, ccid, ccstatus, calltype, processid, exitcause, number, type;
-        res = ccid = ccstatus = calltype = processid = exitcause = number = type = 0;
-        res =
-          sscanf(&amp;tech_pvt-&gt;line_array.result[i][6], &quot;%d,%d,%d,%d,%d,%d,%d&quot;, &amp;ccid, &amp;ccstatus,
-                 &amp;calltype, &amp;processid, &amp;exitcause, &amp;number, &amp;type);
-        /* only changes the phone_callflow if enought parameters were parsed */
-        if (res &gt;= 3) {
-          switch (ccstatus) {
-          case 0:
-            if (tech_pvt-&gt;owner) {
-              ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_DOWN);
-              tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_NORMAL;
-              celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-            }
-            tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_IDLE;
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-            if (option_debug &gt; 1)
-              DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: IDLE\n&quot;, SKYPIAX_P_LOG,
-                        tech_pvt-&gt;line_array.result[i]);
-            break;
-          case 1:
-            if (option_debug &gt; 1)
-              DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: CALLING\n&quot;, SKYPIAX_P_LOG,
-                        tech_pvt-&gt;line_array.result[i]);
-            break;
-          case 2:
-            if (tech_pvt-&gt;owner) {
-              ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_DIALING);
-            }
-            tech_pvt-&gt;interface_state = CALLFLOW_CALL_DIALING;
-            if (option_debug &gt; 1)
-              DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: CONNECTING\n&quot;, SKYPIAX_P_LOG,
-                        tech_pvt-&gt;line_array.result[i]);
-            break;
-          case 3:
-            if (tech_pvt-&gt;owner) {
-              ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_UP);
-              celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_ANSWER);
-            }
-            tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_ACTIVE;
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
-            if (option_debug &gt; 1)
-              DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: ACTIVE\n&quot;, SKYPIAX_P_LOG,
-                        tech_pvt-&gt;line_array.result[i]);
-            break;
-          case 4:
-            if (option_debug &gt; 1)
-              DEBUGA_SKYPE
-                (&quot;|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle HOLD event\n&quot;,
-                 SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
-            break;
-          case 5:
-            if (option_debug &gt; 1)
-              DEBUGA_SKYPE
-                (&quot;|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle WAITING event\n&quot;,
-                 SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
-            break;
-          case 6:
-            if (option_debug &gt; 1)
-              DEBUGA_SKYPE
-                (&quot;|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle ALERTING event\n&quot;,
-                 SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
-            break;
-          case 7:
-            if (tech_pvt-&gt;owner) {
-              ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_BUSY);
-              celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_BUSY);
-            }
-            tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_LINEBUSY;
-            tech_pvt-&gt;interface_state = SKYPIAX_STATE_BUSY;
-            if (option_debug &gt; 1)
-              DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: BUSY\n&quot;, SKYPIAX_P_LOG,
-                        tech_pvt-&gt;line_array.result[i]);
-            break;
-          }
-        } else {
-          if (option_debug &gt; 1)
-            DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: could not parse parameters\n&quot;,
-                      SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
-        }
</del><ins>+                        if ((strncmp(tech_pvt-&gt;line_array.result[i], &quot;*ECAV&quot;, 5) == 0) || (strncmp(tech_pvt-&gt;line_array.result[i], &quot;*ECAM&quot;, 5) == 0)) {        /* sony-ericsson call processing unsolicited messages */
+                                int res, ccid, ccstatus, calltype, processid, exitcause, number, type;
+                                res = ccid = ccstatus = calltype = processid = exitcause = number = type = 0;
+                                res = sscanf(&amp;tech_pvt-&gt;line_array.result[i][6], &quot;%d,%d,%d,%d,%d,%d,%d&quot;, &amp;ccid, &amp;ccstatus, &amp;calltype, &amp;processid, &amp;exitcause, &amp;number, &amp;type);
+                                /* only changes the phone_callflow if enought parameters were parsed */
+                                if (res &gt;= 3) {
+                                        switch (ccstatus) {
+                                        case 0:
+                                                if (tech_pvt-&gt;owner) {
+                                                        ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_DOWN);
+                                                        tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_NORMAL;
+                                                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                                                }
+                                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_IDLE;
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                                                if (option_debug &gt; 1)
+                                                        DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: IDLE\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                                break;
+                                        case 1:
+                                                if (option_debug &gt; 1)
+                                                        DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: CALLING\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                                break;
+                                        case 2:
+                                                if (tech_pvt-&gt;owner) {
+                                                        ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_DIALING);
+                                                }
+                                                tech_pvt-&gt;interface_state = CALLFLOW_CALL_DIALING;
+                                                if (option_debug &gt; 1)
+                                                        DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: CONNECTING\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                                break;
+                                        case 3:
+                                                if (tech_pvt-&gt;owner) {
+                                                        ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_UP);
+                                                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_ANSWER);
+                                                }
+                                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_ACTIVE;
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
+                                                if (option_debug &gt; 1)
+                                                        DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: ACTIVE\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                                break;
+                                        case 4:
+                                                if (option_debug &gt; 1)
+                                                        DEBUGA_SKYPE
+                                                                (&quot;|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle HOLD event\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                                break;
+                                        case 5:
+                                                if (option_debug &gt; 1)
+                                                        DEBUGA_SKYPE
+                                                                (&quot;|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle WAITING event\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                                break;
+                                        case 6:
+                                                if (option_debug &gt; 1)
+                                                        DEBUGA_SKYPE
+                                                                (&quot;|%s| Sony-Ericsson *ECAM/*ECAV: don't know how to handle ALERTING event\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                                break;
+                                        case 7:
+                                                if (tech_pvt-&gt;owner) {
+                                                        ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_BUSY);
+                                                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_BUSY);
+                                                }
+                                                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_LINEBUSY;
+                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_BUSY;
+                                                if (option_debug &gt; 1)
+                                                        DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: BUSY\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                                break;
+                                        }
+                                } else {
+                                        if (option_debug &gt; 1)
+                                                DEBUGA_SKYPE(&quot;|%s| Sony-Ericsson *ECAM/*ECAV: could not parse parameters\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                }
</ins><span class="cx"> 
</span><del>-      }
</del><ins>+                        }
</ins><span class="cx"> 
</span><del>-      /* at_indicator_* are unsolicited messages sent by the phone to signal us that some of its visual indicators on its screen has changed, based on CIND CMER ETSI docs */
-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_noservice_string) == 0)) {
-        if (option_debug &gt; 1)
-          ERRORA(&quot;|%s| at_indicator_noservice_string\n&quot;, SKYPIAX_P_LOG,
-                 tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        /* at_indicator_* are unsolicited messages sent by the phone to signal us that some of its visual indicators on its screen has changed, based on CIND CMER ETSI docs */
+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_noservice_string) == 0)) {
+                                if (option_debug &gt; 1)
+                                        ERRORA(&quot;|%s| at_indicator_noservice_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_nosignal_string) == 0)) {
-        if (option_debug &gt; 1)
-          ERRORA(&quot;|%s| at_indicator_nosignal_string\n&quot;, SKYPIAX_P_LOG,
-                 tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_nosignal_string) == 0)) {
+                                if (option_debug &gt; 1)
+                                        ERRORA(&quot;|%s| at_indicator_nosignal_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_lowsignal_string) == 0)) {
-        if (option_debug &gt; 1)
-          WARNINGA(&quot;|%s| at_indicator_lowsignal_string\n&quot;, SKYPIAX_P_LOG,
-                   tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_lowsignal_string) == 0)) {
+                                if (option_debug &gt; 1)
+                                        WARNINGA(&quot;|%s| at_indicator_lowsignal_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_lowbattchg_string) == 0)) {
-        if (option_debug &gt; 1)
-          WARNINGA(&quot;|%s| at_indicator_lowbattchg_string\n&quot;, SKYPIAX_P_LOG,
-                   tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_lowbattchg_string) == 0)) {
+                                if (option_debug &gt; 1)
+                                        WARNINGA(&quot;|%s| at_indicator_lowbattchg_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_nobattchg_string) == 0)) {
-        if (option_debug &gt; 1)
-          ERRORA(&quot;|%s| at_indicator_nobattchg_string\n&quot;, SKYPIAX_P_LOG,
-                 tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_nobattchg_string) == 0)) {
+                                if (option_debug &gt; 1)
+                                        ERRORA(&quot;|%s| at_indicator_nobattchg_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_callactive_string) == 0)) {
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| at_indicator_callactive_string\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_callactive_string) == 0)) {
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| at_indicator_callactive_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_nocallactive_string) == 0)) {
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| at_indicator_nocallactive_string\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_nocallactive_string) == 0)) {
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| at_indicator_nocallactive_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_nocallsetup_string) == 0)) {
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| at_indicator_nocallsetup_string\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_nocallsetup_string) == 0)) {
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| at_indicator_nocallsetup_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_callsetupincoming_string) ==
-           0)) {
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| at_indicator_callsetupincoming_string\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_callsetupincoming_string) == 0)) {
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| at_indicator_callsetupincoming_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_callsetupoutgoing_string) ==
-           0)) {
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| at_indicator_callsetupoutgoing_string\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_callsetupoutgoing_string) == 0)) {
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| at_indicator_callsetupoutgoing_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-      if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_callsetupremoteringing_string)
-           == 0)) {
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;|%s| at_indicator_callsetupremoteringing_string\n&quot;, SKYPIAX_P_LOG,
-                    tech_pvt-&gt;line_array.result[i]);
-      }
</del><ins>+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], tech_pvt-&gt;at_indicator_callsetupremoteringing_string)
+                                 == 0)) {
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;|%s| at_indicator_callsetupremoteringing_string\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                        }
</ins><span class="cx"> 
</span><del>-    }
</del><ins>+                }
</ins><span class="cx"> 
</span><del>-    /* let's look for OK, ERROR and EXPECTED_STRING in the complete lines read so far, without re-looking at the lines that has been yet looked at */
-    for (i = la_read; i &lt; la_counter; i++) {
-      if (expected_string) {
-        if ((strncmp(tech_pvt-&gt;line_array.result[i], expected_string, strlen(expected_string))
-             == 0)) {
-          if (option_debug &gt; 1)
-            DEBUGA_SKYPE(&quot;|%s| got what EXPECTED\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
-          at_ack = AT_OK;
-        }
-      } else {
-        if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;OK&quot;) == 0)) {
-          if (option_debug &gt; 1)
-            DEBUGA_SKYPE(&quot;got OK\n&quot;, SKYPIAX_P_LOG);
-          at_ack = AT_OK;
-        }
-      }
-      if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;ERROR&quot;) == 0)) {
-        if (option_debug &gt; 1)
-          DEBUGA_SKYPE(&quot;got ERROR\n&quot;, SKYPIAX_P_LOG);
-        at_ack = AT_ERROR;
-      }
</del><ins>+                /* let's look for OK, ERROR and EXPECTED_STRING in the complete lines read so far, without re-looking at the lines that has been yet looked at */
+                for (i = la_read; i &lt; la_counter; i++) {
+                        if (expected_string) {
+                                if ((strncmp(tech_pvt-&gt;line_array.result[i], expected_string, strlen(expected_string))
+                                         == 0)) {
+                                        if (option_debug &gt; 1)
+                                                DEBUGA_SKYPE(&quot;|%s| got what EXPECTED\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;line_array.result[i]);
+                                        at_ack = AT_OK;
+                                }
+                        } else {
+                                if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;OK&quot;) == 0)) {
+                                        if (option_debug &gt; 1)
+                                                DEBUGA_SKYPE(&quot;got OK\n&quot;, SKYPIAX_P_LOG);
+                                        at_ack = AT_OK;
+                                }
+                        }
+                        if ((strcmp(tech_pvt-&gt;line_array.result[i], &quot;ERROR&quot;) == 0)) {
+                                if (option_debug &gt; 1)
+                                        DEBUGA_SKYPE(&quot;got ERROR\n&quot;, SKYPIAX_P_LOG);
+                                at_ack = AT_ERROR;
+                        }
</ins><span class="cx"> 
</span><del>-      /* if we are reading an sms message from memory, put the line into the sms buffer if the line is not &quot;OK&quot; or &quot;ERROR&quot; */
-      if (tech_pvt-&gt;reading_sms_msg &gt; 1 &amp;&amp; at_ack == -1) {
-        int c;
-        char sms_body[16000];
-        int err;
</del><ins>+                        /* if we are reading an sms message from memory, put the line into the sms buffer if the line is not &quot;OK&quot; or &quot;ERROR&quot; */
+                        if (tech_pvt-&gt;reading_sms_msg &gt; 1 &amp;&amp; at_ack == -1) {
+                                int c;
+                                char sms_body[16000];
+                                int err;
</ins><span class="cx"> 
</span><del>-        if (strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGR&quot;, 5) == 0) {    /* we are reading the &quot;header&quot; of an SMS */
-          char content[512];
-          char content2[512];
</del><ins>+                                if (strncmp(tech_pvt-&gt;line_array.result[i], &quot;+CMGR&quot;, 5) == 0) {        /* we are reading the &quot;header&quot; of an SMS */
+                                        char content[512];
+                                        char content2[512];
</ins><span class="cx"> 
</span><del>-          memset(content, '\0', sizeof(content));
</del><ins>+                                        memset(content, '\0', sizeof(content));
</ins><span class="cx"> 
</span><del>-          int inside_comma = 0;
-          int inside_quote = 0;
-          int d = 0;
</del><ins>+                                        int inside_comma = 0;
+                                        int inside_quote = 0;
+                                        int d = 0;
</ins><span class="cx"> 
</span><del>-          for (c = 0; c &lt; strlen(tech_pvt-&gt;line_array.result[i]); c++) {
-            if (tech_pvt-&gt;line_array.result[i][c] == ','
-                &amp;&amp; tech_pvt-&gt;line_array.result[i][c - 1] != '\\' &amp;&amp; inside_quote == 0) {
-              if (inside_comma) {
-                inside_comma = 0;
-                //NOTICA(&quot;inside_comma=%d, inside_quote=%d, we're at=%s\n&quot;, SKYPIAX_P_LOG, inside_comma, inside_quote, &amp;tech_pvt-&gt;line_array.result[i][c]);
-              } else {
-                inside_comma = 1;
-                //NOTICA(&quot;inside_comma=%d, inside_quote=%d, we're at=%s\n&quot;, SKYPIAX_P_LOG, inside_comma, inside_quote, &amp;tech_pvt-&gt;line_array.result[i][c]);
-              }
-            }
-            if (tech_pvt-&gt;line_array.result[i][c] == '&quot;'
-                &amp;&amp; tech_pvt-&gt;line_array.result[i][c - 1] != '\\') {
-              if (inside_quote) {
-                inside_quote = 0;
-                //ERRORA(&quot;END_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n&quot;, SKYPIAX_P_LOG, inside_comma, inside_quote, &amp;tech_pvt-&gt;line_array.result[i][c]);
-                DEBUGA_SKYPE(&quot;content=%s\n&quot;, SKYPIAX_P_LOG, content);
</del><ins>+                                        for (c = 0; c &lt; strlen(tech_pvt-&gt;line_array.result[i]); c++) {
+                                                if (tech_pvt-&gt;line_array.result[i][c] == ',' &amp;&amp; tech_pvt-&gt;line_array.result[i][c - 1] != '\\' &amp;&amp; inside_quote == 0) {
+                                                        if (inside_comma) {
+                                                                inside_comma = 0;
+                                                                //NOTICA(&quot;inside_comma=%d, inside_quote=%d, we're at=%s\n&quot;, SKYPIAX_P_LOG, inside_comma, inside_quote, &amp;tech_pvt-&gt;line_array.result[i][c]);
+                                                        } else {
+                                                                inside_comma = 1;
+                                                                //NOTICA(&quot;inside_comma=%d, inside_quote=%d, we're at=%s\n&quot;, SKYPIAX_P_LOG, inside_comma, inside_quote, &amp;tech_pvt-&gt;line_array.result[i][c]);
+                                                        }
+                                                }
+                                                if (tech_pvt-&gt;line_array.result[i][c] == '&quot;' &amp;&amp; tech_pvt-&gt;line_array.result[i][c - 1] != '\\') {
+                                                        if (inside_quote) {
+                                                                inside_quote = 0;
+                                                                //ERRORA(&quot;END_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n&quot;, SKYPIAX_P_LOG, inside_comma, inside_quote, &amp;tech_pvt-&gt;line_array.result[i][c]);
+                                                                DEBUGA_SKYPE(&quot;content=%s\n&quot;, SKYPIAX_P_LOG, content);
</ins><span class="cx"> 
</span><del>-                strncat(tech_pvt-&gt;sms_message, &quot;---&quot;,
-                        ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
-                strncat(tech_pvt-&gt;sms_message, content,
-                        ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
-                strncat(tech_pvt-&gt;sms_message, &quot;|||&quot;,
-                        ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
</del><ins>+                                                                strncat(tech_pvt-&gt;sms_message, &quot;---&quot;, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
+                                                                strncat(tech_pvt-&gt;sms_message, content, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
+                                                                strncat(tech_pvt-&gt;sms_message, &quot;|||&quot;, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
</ins><span class="cx"> 
</span><del>-                memset(content2, '\0', sizeof(content2));
-                err = ucs2_to_utf8(tech_pvt, content, content2, sizeof(content2));
</del><ins>+                                                                memset(content2, '\0', sizeof(content2));
+                                                                err = ucs2_to_utf8(tech_pvt, content, content2, sizeof(content2));
</ins><span class="cx"> 
</span><del>-                strncat(tech_pvt-&gt;sms_message, &quot;---&quot;,
-                        ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
-                if (!err)
-                  strncat(tech_pvt-&gt;sms_message, content2,
-                          ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
-                strncat(tech_pvt-&gt;sms_message, &quot;|||&quot;,
-                        ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
-                memset(content, '\0', sizeof(content));
-                d = 0;
-              } else {
-                inside_quote = 1;
-                //WARNINGA(&quot;START_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n&quot;, SKYPIAX_P_LOG, inside_comma, inside_quote, &amp;tech_pvt-&gt;line_array.result[i][c]);
-              }
-            }
-            if (inside_quote &amp;&amp; tech_pvt-&gt;line_array.result[i][c] != '&quot;') {
</del><ins>+                                                                strncat(tech_pvt-&gt;sms_message, &quot;---&quot;, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
+                                                                if (!err)
+                                                                        strncat(tech_pvt-&gt;sms_message, content2, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
+                                                                strncat(tech_pvt-&gt;sms_message, &quot;|||&quot;, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
+                                                                memset(content, '\0', sizeof(content));
+                                                                d = 0;
+                                                        } else {
+                                                                inside_quote = 1;
+                                                                //WARNINGA(&quot;START_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n&quot;, SKYPIAX_P_LOG, inside_comma, inside_quote, &amp;tech_pvt-&gt;line_array.result[i][c]);
+                                                        }
+                                                }
+                                                if (inside_quote &amp;&amp; tech_pvt-&gt;line_array.result[i][c] != '&quot;') {
</ins><span class="cx"> 
</span><del>-              content[d] = tech_pvt-&gt;line_array.result[i][c];
-              d++;
</del><ins>+                                                        content[d] = tech_pvt-&gt;line_array.result[i][c];
+                                                        d++;
</ins><span class="cx"> 
</span><del>-            }
</del><ins>+                                                }
</ins><span class="cx"> 
</span><del>-          }
-        }                       //it was the +CMGR answer from the cellphone
-        else {
-          strncat(tech_pvt-&gt;sms_message, &quot;---&quot;,
-                  ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
-          strncat(tech_pvt-&gt;sms_message, tech_pvt-&gt;line_array.result[i],
-                  ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
-          strncat(tech_pvt-&gt;sms_message, &quot;|||&quot;,
-                  ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
</del><ins>+                                        }
+                                }                                //it was the +CMGR answer from the cellphone
+                                else {
+                                        strncat(tech_pvt-&gt;sms_message, &quot;---&quot;, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
+                                        strncat(tech_pvt-&gt;sms_message, tech_pvt-&gt;line_array.result[i], ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
+                                        strncat(tech_pvt-&gt;sms_message, &quot;|||&quot;, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
</ins><span class="cx"> 
</span><del>-          memset(sms_body, '\0', sizeof(sms_body));
-          err = ucs2_to_utf8(tech_pvt, tech_pvt-&gt;line_array.result[i], sms_body, sizeof(sms_body));
</del><ins>+                                        memset(sms_body, '\0', sizeof(sms_body));
+                                        err = ucs2_to_utf8(tech_pvt, tech_pvt-&gt;line_array.result[i], sms_body, sizeof(sms_body));
</ins><span class="cx"> 
</span><del>-          strncat(tech_pvt-&gt;sms_message, &quot;---&quot;,
-                  ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
-          if (!err)
-            strncat(tech_pvt-&gt;sms_message, sms_body,
-                    ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
-          strncat(tech_pvt-&gt;sms_message, &quot;|||&quot;,
-                  ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
</del><ins>+                                        strncat(tech_pvt-&gt;sms_message, &quot;---&quot;, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
+                                        if (!err)
+                                                strncat(tech_pvt-&gt;sms_message, sms_body, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
+                                        strncat(tech_pvt-&gt;sms_message, &quot;|||&quot;, ((sizeof(tech_pvt-&gt;sms_message) - strlen(tech_pvt-&gt;sms_message)) - 1));
</ins><span class="cx"> 
</span><del>-          DEBUGA_SKYPE(&quot;sms_message=%s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;sms_message);
</del><ins>+                                        DEBUGA_SKYPE(&quot;sms_message=%s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;sms_message);
</ins><span class="cx"> 
</span><del>-        }                       //it was the UCS2 from cellphone
</del><ins>+                                }                                //it was the UCS2 from cellphone
</ins><span class="cx"> 
</span><del>-      }                         //we were reading the SMS
</del><ins>+                        }                                        //we were reading the SMS
</ins><span class="cx"> 
</span><del>-    }
</del><ins>+                }
</ins><span class="cx"> 
</span><del>-    la_read = la_counter;
</del><ins>+                la_read = la_counter;
</ins><span class="cx"> 
</span><del>-    if (look_for_ack &amp;&amp; at_ack &gt; -1)
-      break;
</del><ins>+                if (look_for_ack &amp;&amp; at_ack &gt; -1)
+                        break;
</ins><span class="cx"> 
</span><del>-    if (la_counter &gt; AT_MESG_MAX_LINES) {
-      ERRORA(&quot;Too many lines in result (&gt;%d). Stopping reader.\n&quot;, SKYPIAX_P_LOG,
-             AT_MESG_MAX_LINES);
-      at_ack = AT_ERROR;
-      break;
-    }
-  }
</del><ins>+                if (la_counter &gt; AT_MESG_MAX_LINES) {
+                        ERRORA(&quot;Too many lines in result (&gt;%d). Stopping reader.\n&quot;, SKYPIAX_P_LOG, AT_MESG_MAX_LINES);
+                        at_ack = AT_ERROR;
+                        break;
+                }
+        }
</ins><span class="cx"> 
</span><del>-  UNLOCKA(tech_pvt-&gt;controldev_lock);
-  POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
-  if (select_err == -1) {
-    ERRORA(&quot;select returned -1 on %s, setting controldev_dead, error was: %s\n&quot;,
-           SKYPIAX_P_LOG, tech_pvt-&gt;controldevice_name, strerror(errno));
-    tech_pvt-&gt;controldev_dead = 1;
-    close(tech_pvt-&gt;controldevfd);
-    if (tech_pvt-&gt;owner)
-      celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-    return -1;
-  }
</del><ins>+        UNLOCKA(tech_pvt-&gt;controldev_lock);
+        POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
+        if (select_err == -1) {
+                ERRORA(&quot;select returned -1 on %s, setting controldev_dead, error was: %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;controldevice_name, strerror(errno));
+                tech_pvt-&gt;controldev_dead = 1;
+                close(tech_pvt-&gt;controldevfd);
+                if (tech_pvt-&gt;owner)
+                        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;phone_callflow == CALLFLOW_CALL_INCOMING &amp;&amp; tech_pvt-&gt;call_incoming_time.tv_sec) {    //after three sec of CALLFLOW_CALL_INCOMING, we assume the phone is incapable of notifying RING (eg: motorola c350), so we try to answer
-    char list_command[64];
-    struct timeval call_incoming_timeout;
-    gettimeofday(&amp;call_incoming_timeout, NULL);
-    call_incoming_timeout.tv_sec -= 3;
-    DEBUGA_SKYPE
-      (&quot;CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n&quot;,
-       SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
-    if (call_incoming_timeout.tv_sec &gt; tech_pvt-&gt;call_incoming_time.tv_sec) {
</del><ins>+        if (tech_pvt-&gt;phone_callflow == CALLFLOW_CALL_INCOMING &amp;&amp; tech_pvt-&gt;call_incoming_time.tv_sec) {        //after three sec of CALLFLOW_CALL_INCOMING, we assume the phone is incapable of notifying RING (eg: motorola c350), so we try to answer
+                char list_command[64];
+                struct timeval call_incoming_timeout;
+                gettimeofday(&amp;call_incoming_timeout, NULL);
+                call_incoming_timeout.tv_sec -= 3;
+                DEBUGA_SKYPE
+                        (&quot;CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n&quot;,
+                         SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
+                if (call_incoming_timeout.tv_sec &gt; tech_pvt-&gt;call_incoming_time.tv_sec) {
</ins><span class="cx"> 
</span><del>-      tech_pvt-&gt;call_incoming_time.tv_sec = 0;
-      tech_pvt-&gt;call_incoming_time.tv_usec = 0;
-      DEBUGA_SKYPE
-        (&quot;CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n&quot;,
-         SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
-      res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CPBS=RC&quot;);
-      if (res) {
-        ERRORA
-          (&quot;AT+CPBS=RC (select memory of received calls) was not answered by the phone\n&quot;,
-           SKYPIAX_P_LOG);
-      }
-      tech_pvt-&gt;phonebook_querying = 1;
-      res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CPBR=?&quot;);
-      if (res) {
-        ERRORA
-          (&quot;AT+CPBS=RC (select memory of received calls) was not answered by the phone\n&quot;,
-           SKYPIAX_P_LOG);
-      }
-      tech_pvt-&gt;phonebook_querying = 0;
-      sprintf(list_command, &quot;AT+CPBR=%d,%d&quot;, tech_pvt-&gt;phonebook_first_entry,
-              tech_pvt-&gt;phonebook_last_entry);
-      tech_pvt-&gt;phonebook_listing_received_calls = 1;
-      res = celliax_serial_write_AT_expect_longtime(tech_pvt, list_command, &quot;OK&quot;);
-      if (res) {
-        WARNINGA(&quot;AT+CPBR=%d,%d failed, continue\n&quot;, SKYPIAX_P_LOG,
-                 tech_pvt-&gt;phonebook_first_entry, tech_pvt-&gt;phonebook_last_entry);
-      }
-      tech_pvt-&gt;phonebook_listing_received_calls = 0;
-    }
-  }
</del><ins>+                        tech_pvt-&gt;call_incoming_time.tv_sec = 0;
+                        tech_pvt-&gt;call_incoming_time.tv_usec = 0;
+                        DEBUGA_SKYPE
+                                (&quot;CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n&quot;,
+                                 SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
+                        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CPBS=RC&quot;);
+                        if (res) {
+                                ERRORA(&quot;AT+CPBS=RC (select memory of received calls) was not answered by the phone\n&quot;, SKYPIAX_P_LOG);
+                        }
+                        tech_pvt-&gt;phonebook_querying = 1;
+                        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CPBR=?&quot;);
+                        if (res) {
+                                ERRORA(&quot;AT+CPBS=RC (select memory of received calls) was not answered by the phone\n&quot;, SKYPIAX_P_LOG);
+                        }
+                        tech_pvt-&gt;phonebook_querying = 0;
+                        sprintf(list_command, &quot;AT+CPBR=%d,%d&quot;, tech_pvt-&gt;phonebook_first_entry, tech_pvt-&gt;phonebook_last_entry);
+                        tech_pvt-&gt;phonebook_listing_received_calls = 1;
+                        res = celliax_serial_write_AT_expect_longtime(tech_pvt, list_command, &quot;OK&quot;);
+                        if (res) {
+                                WARNINGA(&quot;AT+CPBR=%d,%d failed, continue\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;phonebook_first_entry, tech_pvt-&gt;phonebook_last_entry);
+                        }
+                        tech_pvt-&gt;phonebook_listing_received_calls = 0;
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;phone_callflow == CALLFLOW_INCOMING_RING) {
-    struct timeval call_incoming_timeout;
-    gettimeofday(&amp;call_incoming_timeout, NULL);
-    call_incoming_timeout.tv_sec -= 10;
-    DEBUGA_SKYPE
-      (&quot;CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n&quot;,
-       SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
-    if (call_incoming_timeout.tv_sec &gt; tech_pvt-&gt;ringtime.tv_sec) {
-      ERRORA(&quot;Ringing stopped and I have not answered. Why?\n&quot;, SKYPIAX_P_LOG);
-      DEBUGA_SKYPE
-        (&quot;CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n&quot;,
-         SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
-      if (tech_pvt-&gt;owner) {
-        celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
-        tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
-      }
-    }
-  }
-  tech_pvt-&gt;line_array.elemcount = la_counter;
-  //NOTICA (&quot; OUTSIDE this celliax_serial_device %s \n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;controldevice_name);
-  if (look_for_ack)
-    return at_ack;
-  else
-    return 0;
</del><ins>+        if (tech_pvt-&gt;phone_callflow == CALLFLOW_INCOMING_RING) {
+                struct timeval call_incoming_timeout;
+                gettimeofday(&amp;call_incoming_timeout, NULL);
+                call_incoming_timeout.tv_sec -= 10;
+                DEBUGA_SKYPE
+                        (&quot;CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n&quot;,
+                         SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
+                if (call_incoming_timeout.tv_sec &gt; tech_pvt-&gt;ringtime.tv_sec) {
+                        ERRORA(&quot;Ringing stopped and I have not answered. Why?\n&quot;, SKYPIAX_P_LOG);
+                        DEBUGA_SKYPE
+                                (&quot;CALLFLOW_CALL_INCOMING call_incoming_time.tv_sec=%ld, call_incoming_timeout.tv_sec=%ld\n&quot;,
+                                 SKYPIAX_P_LOG, tech_pvt-&gt;call_incoming_time.tv_sec, call_incoming_timeout.tv_sec);
+                        if (tech_pvt-&gt;owner) {
+                                celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_HANGUP);
+                                tech_pvt-&gt;owner-&gt;hangupcause = SKYPIAX_CAUSE_FAILURE;
+                        }
+                }
+        }
+        tech_pvt-&gt;line_array.elemcount = la_counter;
+        //NOTICA (&quot; OUTSIDE this celliax_serial_device %s \n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;controldevice_name);
+        if (look_for_ack)
+                return at_ack;
+        else
+                return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_write_AT(private_t * tech_pvt, const char *data)
</span><span class="cx"> {
</span><del>-  int howmany;
-  int i;
-  int res;
-  int count;
</del><ins>+        int howmany;
+        int i;
+        int res;
+        int count;
</ins><span class="cx"> 
</span><del>-  howmany = strlen(data);
</del><ins>+        howmany = strlen(data);
</ins><span class="cx"> 
</span><del>-  for (i = 0; i &lt; howmany; i++) {
-    res = write(tech_pvt-&gt;controldevfd, &amp;data[i], 1);
</del><ins>+        for (i = 0; i &lt; howmany; i++) {
+                res = write(tech_pvt-&gt;controldevfd, &amp;data[i], 1);
</ins><span class="cx"> 
</span><del>-    if (res != 1) {
-      DEBUGA_SKYPE(&quot;Error sending (%.1s): %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], res,
-                strerror(errno));
-      usleep(100000);
-      for (count = 0; count &lt; 10; count++) {
-        res = write(tech_pvt-&gt;controldevfd, &amp;data[i], 1);
-        if (res == 1) {
-          DEBUGA_SKYPE(&quot;Successfully RE-sent (%.1s): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i],
-                    count, res, strerror(errno));
-          break;
-        } else
-          DEBUGA_SKYPE(&quot;Error RE-sending (%.1s): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i],
-                    count, res, strerror(errno));
-        usleep(100000);
</del><ins>+                if (res != 1) {
+                        DEBUGA_SKYPE(&quot;Error sending (%.1s): %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], res, strerror(errno));
+                        usleep(100000);
+                        for (count = 0; count &lt; 10; count++) {
+                                res = write(tech_pvt-&gt;controldevfd, &amp;data[i], 1);
+                                if (res == 1) {
+                                        DEBUGA_SKYPE(&quot;Successfully RE-sent (%.1s): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], count, res, strerror(errno));
+                                        break;
+                                } else
+                                        DEBUGA_SKYPE(&quot;Error RE-sending (%.1s): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], count, res, strerror(errno));
+                                usleep(100000);
</ins><span class="cx"> 
</span><del>-      }
-      if (res != 1) {
-        ERRORA(&quot;Error RE-sending (%.1s): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], count,
-               res, strerror(errno));
-        return -1;
-      }
-    }
-    if (option_debug &gt; 1)
-      DEBUGA_SKYPE(&quot;sent data... (%.1s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i]);
-    usleep(1000);               /* release the cpu */
-  }
</del><ins>+                        }
+                        if (res != 1) {
+                                ERRORA(&quot;Error RE-sending (%.1s): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], count, res, strerror(errno));
+                                return -1;
+                        }
+                }
+                if (option_debug &gt; 1)
+                        DEBUGA_SKYPE(&quot;sent data... (%.1s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i]);
+                usleep(1000);                        /* release the cpu */
+        }
</ins><span class="cx"> 
</span><del>-  res = write(tech_pvt-&gt;controldevfd, &quot;\r&quot;, 1);
</del><ins>+        res = write(tech_pvt-&gt;controldevfd, &quot;\r&quot;, 1);
</ins><span class="cx"> 
</span><del>-  if (res != 1) {
-    DEBUGA_SKYPE(&quot;Error sending (carriage return): %d (%s)\n&quot;, SKYPIAX_P_LOG, res,
-              strerror(errno));
-    usleep(100000);
-    for (count = 0; count &lt; 10; count++) {
-      res = write(tech_pvt-&gt;controldevfd, &quot;\r&quot;, 1);
</del><ins>+        if (res != 1) {
+                DEBUGA_SKYPE(&quot;Error sending (carriage return): %d (%s)\n&quot;, SKYPIAX_P_LOG, res, strerror(errno));
+                usleep(100000);
+                for (count = 0; count &lt; 10; count++) {
+                        res = write(tech_pvt-&gt;controldevfd, &quot;\r&quot;, 1);
</ins><span class="cx"> 
</span><del>-      if (res == 1) {
-        DEBUGA_SKYPE(&quot;Successfully RE-sent carriage return: %d %d (%s)\n&quot;, SKYPIAX_P_LOG,
-                  count, res, strerror(errno));
-        break;
-      } else
-        DEBUGA_SKYPE(&quot;Error RE-sending (carriage return): %d %d (%s)\n&quot;, SKYPIAX_P_LOG,
-                  count, res, strerror(errno));
-      usleep(100000);
</del><ins>+                        if (res == 1) {
+                                DEBUGA_SKYPE(&quot;Successfully RE-sent carriage return: %d %d (%s)\n&quot;, SKYPIAX_P_LOG, count, res, strerror(errno));
+                                break;
+                        } else
+                                DEBUGA_SKYPE(&quot;Error RE-sending (carriage return): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, count, res, strerror(errno));
+                        usleep(100000);
</ins><span class="cx"> 
</span><del>-    }
-    if (res != 1) {
-      ERRORA(&quot;Error RE-sending (carriage return): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, count,
-             res, strerror(errno));
-      return -1;
-    }
-  }
-  if (option_debug &gt; 1)
-    DEBUGA_SKYPE(&quot;sent (carriage return)\n&quot;, SKYPIAX_P_LOG);
-  usleep(1000);                 /* release the cpu */
</del><ins>+                }
+                if (res != 1) {
+                        ERRORA(&quot;Error RE-sending (carriage return): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, count, res, strerror(errno));
+                        return -1;
+                }
+        }
+        if (option_debug &gt; 1)
+                DEBUGA_SKYPE(&quot;sent (carriage return)\n&quot;, SKYPIAX_P_LOG);
+        usleep(1000);                                /* release the cpu */
</ins><span class="cx"> 
</span><del>-  return howmany;
</del><ins>+        return howmany;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_write_AT_nocr(private_t * tech_pvt, const char *data)
</span><span class="cx"> {
</span><del>-  int howmany;
-  int i;
-  int res;
-  int count;
</del><ins>+        int howmany;
+        int i;
+        int res;
+        int count;
</ins><span class="cx"> 
</span><del>-  howmany = strlen(data);
</del><ins>+        howmany = strlen(data);
</ins><span class="cx"> 
</span><del>-  for (i = 0; i &lt; howmany; i++) {
-    res = write(tech_pvt-&gt;controldevfd, &amp;data[i], 1);
</del><ins>+        for (i = 0; i &lt; howmany; i++) {
+                res = write(tech_pvt-&gt;controldevfd, &amp;data[i], 1);
</ins><span class="cx"> 
</span><del>-    if (res != 1) {
-      DEBUGA_SKYPE(&quot;Error sending (%.1s): %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], res,
-                strerror(errno));
-      usleep(100000);
-      for (count = 0; count &lt; 10; count++) {
-        res = write(tech_pvt-&gt;controldevfd, &amp;data[i], 1);
-        if (res == 1)
-          break;
-        else
-          DEBUGA_SKYPE(&quot;Error RE-sending (%.1s): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i],
-                    count, res, strerror(errno));
-        usleep(100000);
</del><ins>+                if (res != 1) {
+                        DEBUGA_SKYPE(&quot;Error sending (%.1s): %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], res, strerror(errno));
+                        usleep(100000);
+                        for (count = 0; count &lt; 10; count++) {
+                                res = write(tech_pvt-&gt;controldevfd, &amp;data[i], 1);
+                                if (res == 1)
+                                        break;
+                                else
+                                        DEBUGA_SKYPE(&quot;Error RE-sending (%.1s): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], count, res, strerror(errno));
+                                usleep(100000);
</ins><span class="cx"> 
</span><del>-      }
-      if (res != 1) {
-        ERRORA(&quot;Error RE-sending (%.1s): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], count,
-               res, strerror(errno));
-        return -1;
-      }
-    }
-    if (option_debug &gt; 1)
-      DEBUGA_SKYPE(&quot;sent data... (%.1s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i]);
-    usleep(1000);               /* release the cpu */
-  }
</del><ins>+                        }
+                        if (res != 1) {
+                                ERRORA(&quot;Error RE-sending (%.1s): %d %d (%s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i], count, res, strerror(errno));
+                                return -1;
+                        }
+                }
+                if (option_debug &gt; 1)
+                        DEBUGA_SKYPE(&quot;sent data... (%.1s)\n&quot;, SKYPIAX_P_LOG, &amp;data[i]);
+                usleep(1000);                        /* release the cpu */
+        }
</ins><span class="cx"> 
</span><del>-  usleep(1000);                 /* release the cpu */
</del><ins>+        usleep(1000);                                /* release the cpu */
</ins><span class="cx"> 
</span><del>-  return howmany;
</del><ins>+        return howmany;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_write_AT_noack(private_t * tech_pvt, const char *data)
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-  if (option_debug &gt; 1)
-    DEBUGA_SKYPE(&quot;celliax_serial_write_AT_noack: %s\n&quot;, SKYPIAX_P_LOG, data);
</del><ins>+        if (option_debug &gt; 1)
+                DEBUGA_SKYPE(&quot;celliax_serial_write_AT_noack: %s\n&quot;, SKYPIAX_P_LOG, data);
</ins><span class="cx"> 
</span><del>-  PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
-  LOKKA(tech_pvt-&gt;controldev_lock);
-  if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
</del><ins>+        PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
+        LOKKA(tech_pvt-&gt;controldev_lock);
+        if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
</ins><span class="cx"> 
</span><del>-    ERRORA(&quot;Error sending data... (%s)\n&quot;, SKYPIAX_P_LOG, strerror(errno));
-    UNLOCKA(tech_pvt-&gt;controldev_lock);
-    return -1;
-  }
-  UNLOCKA(tech_pvt-&gt;controldev_lock);
-  POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
</del><ins>+                ERRORA(&quot;Error sending data... (%s)\n&quot;, SKYPIAX_P_LOG, strerror(errno));
+                UNLOCKA(tech_pvt-&gt;controldev_lock);
+                return -1;
+        }
+        UNLOCKA(tech_pvt-&gt;controldev_lock);
+        POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_write_AT_ack(private_t * tech_pvt, const char *data)
</span><span class="cx"> {
</span><del>-  int at_result = AT_ERROR;
</del><ins>+        int at_result = AT_ERROR;
</ins><span class="cx"> 
</span><del>-  PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
-  LOKKA(tech_pvt-&gt;controldev_lock);
-  if (option_debug &gt; 1)
-    DEBUGA_SKYPE(&quot;sending: %s\n&quot;, SKYPIAX_P_LOG, data);
-  if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
-    ERRORA(&quot;Error sending data... (%s) \n&quot;, SKYPIAX_P_LOG, strerror(errno));
-    UNLOCKA(tech_pvt-&gt;controldev_lock);
-    return -1;
-  }
</del><ins>+        PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
+        LOKKA(tech_pvt-&gt;controldev_lock);
+        if (option_debug &gt; 1)
+                DEBUGA_SKYPE(&quot;sending: %s\n&quot;, SKYPIAX_P_LOG, data);
+        if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
+                ERRORA(&quot;Error sending data... (%s) \n&quot;, SKYPIAX_P_LOG, strerror(errno));
+                UNLOCKA(tech_pvt-&gt;controldev_lock);
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, 2, NULL, 1); // 2.5 sec timeout
-  UNLOCKA(tech_pvt-&gt;controldev_lock);
-  POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
</del><ins>+        at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, 2, NULL, 1);        // 2.5 sec timeout
+        UNLOCKA(tech_pvt-&gt;controldev_lock);
+        POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
</ins><span class="cx"> 
</span><del>-  return at_result;
</del><ins>+        return at_result;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_write_AT_ack_nocr_longtime(private_t * tech_pvt, const char *data)
</span><span class="cx"> {
</span><del>-  int at_result = AT_ERROR;
</del><ins>+        int at_result = AT_ERROR;
</ins><span class="cx"> 
</span><del>-  PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
-  LOKKA(tech_pvt-&gt;controldev_lock);
-  if (option_debug &gt; 1)
-    DEBUGA_SKYPE(&quot;sending: %s\n&quot;, SKYPIAX_P_LOG, data);
-  if (celliax_serial_write_AT_nocr(tech_pvt, data) != strlen(data)) {
-    ERRORA(&quot;Error sending data... (%s) \n&quot;, SKYPIAX_P_LOG, strerror(errno));
-    UNLOCKA(tech_pvt-&gt;controldev_lock);
-    return -1;
-  }
</del><ins>+        PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
+        LOKKA(tech_pvt-&gt;controldev_lock);
+        if (option_debug &gt; 1)
+                DEBUGA_SKYPE(&quot;sending: %s\n&quot;, SKYPIAX_P_LOG, data);
+        if (celliax_serial_write_AT_nocr(tech_pvt, data) != strlen(data)) {
+                ERRORA(&quot;Error sending data... (%s) \n&quot;, SKYPIAX_P_LOG, strerror(errno));
+                UNLOCKA(tech_pvt-&gt;controldev_lock);
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, 20, NULL, 1);    // 20.5 sec timeout
-  UNLOCKA(tech_pvt-&gt;controldev_lock);
-  POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
</del><ins>+        at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, 20, NULL, 1);        // 20.5 sec timeout
+        UNLOCKA(tech_pvt-&gt;controldev_lock);
+        POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
</ins><span class="cx"> 
</span><del>-  return at_result;
</del><ins>+        return at_result;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int celliax_serial_write_AT_expect1(private_t * tech_pvt, const char *data,
-                                    const char *expected_string, int expect_crlf,
-                                    int seconds)
</del><ins>+int celliax_serial_write_AT_expect1(private_t * tech_pvt, const char *data, const char *expected_string, int expect_crlf, int seconds)
</ins><span class="cx"> {
</span><del>-  int at_result = AT_ERROR;
</del><ins>+        int at_result = AT_ERROR;
</ins><span class="cx"> 
</span><del>-  PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
-  LOKKA(tech_pvt-&gt;controldev_lock);
-  if (option_debug &gt; 1)
-    DEBUGA_SKYPE(&quot;sending: %s, expecting: %s\n&quot;, SKYPIAX_P_LOG, data, expected_string);
-  if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
-    ERRORA(&quot;Error sending data... (%s) \n&quot;, SKYPIAX_P_LOG, strerror(errno));
-    UNLOCKA(tech_pvt-&gt;controldev_lock);
-    return -1;
-  }
</del><ins>+        PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
+        LOKKA(tech_pvt-&gt;controldev_lock);
+        if (option_debug &gt; 1)
+                DEBUGA_SKYPE(&quot;sending: %s, expecting: %s\n&quot;, SKYPIAX_P_LOG, data, expected_string);
+        if (celliax_serial_write_AT(tech_pvt, data) != strlen(data)) {
+                ERRORA(&quot;Error sending data... (%s) \n&quot;, SKYPIAX_P_LOG, strerror(errno));
+                UNLOCKA(tech_pvt-&gt;controldev_lock);
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, seconds, expected_string, expect_crlf);  // 20.5 sec timeout, used for querying the SIM and sending SMSs
-  UNLOCKA(tech_pvt-&gt;controldev_lock);
-  POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
</del><ins>+        at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, seconds, expected_string, expect_crlf);        // 20.5 sec timeout, used for querying the SIM and sending SMSs
+        UNLOCKA(tech_pvt-&gt;controldev_lock);
+        POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
</ins><span class="cx"> 
</span><del>-  return at_result;
</del><ins>+        return at_result;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int celliax_serial_AT_expect(private_t * tech_pvt, const char *expected_string,
-                             int expect_crlf, int seconds)
</del><ins>+int celliax_serial_AT_expect(private_t * tech_pvt, const char *expected_string, int expect_crlf, int seconds)
</ins><span class="cx"> {
</span><del>-  int at_result = AT_ERROR;
</del><ins>+        int at_result = AT_ERROR;
</ins><span class="cx"> 
</span><del>-  PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
-  LOKKA(tech_pvt-&gt;controldev_lock);
-  if (option_debug &gt; 1)
-    DEBUGA_SKYPE(&quot;expecting: %s\n&quot;, SKYPIAX_P_LOG, expected_string);
</del><ins>+        PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
+        LOKKA(tech_pvt-&gt;controldev_lock);
+        if (option_debug &gt; 1)
+                DEBUGA_SKYPE(&quot;expecting: %s\n&quot;, SKYPIAX_P_LOG, expected_string);
</ins><span class="cx"> 
</span><del>-  at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, seconds, expected_string, expect_crlf);  // 20.5 sec timeout, used for querying the SIM and sending SMSs
-  UNLOCKA(tech_pvt-&gt;controldev_lock);
-  POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
</del><ins>+        at_result = celliax_serial_read_AT(tech_pvt, 1, 500000, seconds, expected_string, expect_crlf);        // 20.5 sec timeout, used for querying the SIM and sending SMSs
+        UNLOCKA(tech_pvt-&gt;controldev_lock);
+        POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
</ins><span class="cx"> 
</span><del>-  return at_result;
</del><ins>+        return at_result;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_answer(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
-    return celliax_serial_answer_AT(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_answer_AT(tech_pvt);
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
-    return celliax_serial_answer_FBUS2(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_answer_FBUS2(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><span class="cx"> #ifdef CELLIAX_CVM
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
-    return celliax_serial_answer_CVM_BUSMAIL(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_answer_CVM_BUSMAIL(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><del>-  return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_answer_AT(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  int res;
</del><ins>+        int res;
</ins><span class="cx"> 
</span><del>-  res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_answer, tech_pvt-&gt;at_answer_expect);
-  if (res) {
-    DEBUGA_SKYPE
-      (&quot;at_answer command failed, command used: %s, expecting: %s, trying with AT+CKPD=\&quot;S\&quot;\n&quot;,
-       SKYPIAX_P_LOG, tech_pvt-&gt;at_answer, tech_pvt-&gt;at_answer_expect);
</del><ins>+        res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_answer, tech_pvt-&gt;at_answer_expect);
+        if (res) {
+                DEBUGA_SKYPE
+                        (&quot;at_answer command failed, command used: %s, expecting: %s, trying with AT+CKPD=\&quot;S\&quot;\n&quot;,
+                         SKYPIAX_P_LOG, tech_pvt-&gt;at_answer, tech_pvt-&gt;at_answer_expect);
</ins><span class="cx"> 
</span><del>-    res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CKPD=\&quot;S\&quot;&quot;);
-    if (res) {
-      ERRORA(&quot;at_answer command failed, command used: 'AT+CKPD=\&quot;S\&quot;', giving up\n&quot;,
-             SKYPIAX_P_LOG);
-      return -1;
-    }
-  }
-  //tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
-  //tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_ACTIVE;
-  DEBUGA_SKYPE(&quot;AT: call answered\n&quot;, SKYPIAX_P_LOG);
-  return 0;
</del><ins>+                res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CKPD=\&quot;S\&quot;&quot;);
+                if (res) {
+                        ERRORA(&quot;at_answer command failed, command used: 'AT+CKPD=\&quot;S\&quot;', giving up\n&quot;, SKYPIAX_P_LOG);
+                        return -1;
+                }
+        }
+        //tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
+        //tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_ACTIVE;
+        DEBUGA_SKYPE(&quot;AT: call answered\n&quot;, SKYPIAX_P_LOG);
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_hangup(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
-    return celliax_serial_hangup_AT(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_hangup_AT(tech_pvt);
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
-    return celliax_serial_hangup_FBUS2(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_hangup_FBUS2(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><span class="cx"> #ifdef CELLIAX_CVM
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
-    return celliax_serial_hangup_CVM_BUSMAIL(tech_pvt);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_hangup_CVM_BUSMAIL(tech_pvt);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><del>-  return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_hangup_AT(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  int res;
</del><ins>+        int res;
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
-    res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_hangup, tech_pvt-&gt;at_hangup_expect);
-    if (res) {
-      DEBUGA_SKYPE
-        (&quot;at_hangup command failed, command used: %s, trying to use AT+CKPD=\&quot;EEE\&quot;\n&quot;,
-         SKYPIAX_P_LOG, tech_pvt-&gt;at_hangup);
-      res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CKPD=\&quot;EEE\&quot;&quot;);
-      if (res) {
-        ERRORA(&quot;at_hangup command failed, command used: 'AT+CKPD=\&quot;EEE\&quot;'\n&quot;,
-               SKYPIAX_P_LOG);
-        return -1;
-      }
-    }
-  }
-  tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-  tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_IDLE;
-  return 0;
</del><ins>+        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
+                res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_hangup, tech_pvt-&gt;at_hangup_expect);
+                if (res) {
+                        DEBUGA_SKYPE(&quot;at_hangup command failed, command used: %s, trying to use AT+CKPD=\&quot;EEE\&quot;\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_hangup);
+                        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CKPD=\&quot;EEE\&quot;&quot;);
+                        if (res) {
+                                ERRORA(&quot;at_hangup command failed, command used: 'AT+CKPD=\&quot;EEE\&quot;'\n&quot;, SKYPIAX_P_LOG);
+                                return -1;
+                        }
+                }
+        }
+        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_IDLE;
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_call(private_t * tech_pvt, char *dstr)
</span><span class="cx"> {
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
-    return celliax_serial_call_AT(tech_pvt, dstr);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT)
+                return celliax_serial_call_AT(tech_pvt, dstr);
</ins><span class="cx"> #ifdef CELLIAX_FBUS2
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
-    return celliax_serial_call_FBUS2(tech_pvt, dstr);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_FBUS2)
+                return celliax_serial_call_FBUS2(tech_pvt, dstr);
</ins><span class="cx"> #endif /* CELLIAX_FBUS2 */
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_NO_SERIAL)
-    return 0;
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_NO_SERIAL)
+                return 0;
</ins><span class="cx"> #ifdef CELLIAX_CVM
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
-    return celliax_serial_call_CVM_BUSMAIL(tech_pvt, dstr);
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_CVM_BUSMAIL)
+                return celliax_serial_call_CVM_BUSMAIL(tech_pvt, dstr);
</ins><span class="cx"> #endif /* CELLIAX_CVM */
</span><del>-  return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_call_AT(private_t * tech_pvt, char *dstr)
</span><span class="cx"> {
</span><del>-  int res;
-  char at_command[256];
</del><ins>+        int res;
+        char at_command[256];
</ins><span class="cx"> 
</span><del>-  if (option_debug)
-    DEBUGA_PBX(&quot;Dialing %s\n&quot;, SKYPIAX_P_LOG, dstr);
-  memset(at_command, 0, sizeof(at_command));
-  tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_DIALING;
-  tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
-  //ast_uri_decode(dstr);
</del><ins>+        if (option_debug)
+                DEBUGA_PBX(&quot;Dialing %s\n&quot;, SKYPIAX_P_LOG, dstr);
+        memset(at_command, 0, sizeof(at_command));
+        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_DIALING;
+        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
+        //ast_uri_decode(dstr);
</ins><span class="cx"> /*
</span><span class="cx">   size_t fixdstr = strspn(dstr, AST_DIGIT_ANYDIG);
</span><span class="cx">   if (fixdstr == 0) {
</span><span class="lines">@@ -3273,125 +3117,119 @@
</span><span class="cx">     return -1;
</span><span class="cx">   }
</span><span class="cx"> */
</span><del>-  //dstr[fixdstr] = '\0';
-  sprintf(at_command, &quot;%s%s%s&quot;, tech_pvt-&gt;at_dial_pre_number, dstr, tech_pvt-&gt;at_dial_post_number);
-    DEBUGA_PBX(&quot;Dialstring %s\n&quot;, SKYPIAX_P_LOG, at_command);
-  res = celliax_serial_write_AT_expect(tech_pvt, at_command, tech_pvt-&gt;at_dial_expect);
-  if (res) {
-    ERRORA(&quot;dial command failed, dial string was: %s\n&quot;, SKYPIAX_P_LOG, at_command);
-    return -1;
-  }
-  // jet - early audio
-  //if (tech_pvt-&gt;at_early_audio) {
-    //ast_queue_control(tech_pvt-&gt;owner, AST_CONTROL_ANSWER);
-  //}
</del><ins>+        //dstr[fixdstr] = '\0';
+        sprintf(at_command, &quot;%s%s%s&quot;, tech_pvt-&gt;at_dial_pre_number, dstr, tech_pvt-&gt;at_dial_post_number);
+        DEBUGA_PBX(&quot;Dialstring %s\n&quot;, SKYPIAX_P_LOG, at_command);
+        res = celliax_serial_write_AT_expect(tech_pvt, at_command, tech_pvt-&gt;at_dial_expect);
+        if (res) {
+                ERRORA(&quot;dial command failed, dial string was: %s\n&quot;, SKYPIAX_P_LOG, at_command);
+                return -1;
+        }
+        // jet - early audio
+        //if (tech_pvt-&gt;at_early_audio) {
+        //ast_queue_control(tech_pvt-&gt;owner, AST_CONTROL_ANSWER);
+        //}
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int ucs2_to_utf8(private_t * tech_pvt, char *ucs2_in, char *utf8_out,
-                 size_t outbytesleft)
</del><ins>+int ucs2_to_utf8(private_t * tech_pvt, char *ucs2_in, char *utf8_out, size_t outbytesleft)
</ins><span class="cx"> {
</span><del>-  char converted[16000];
-  iconv_t iconv_format;
-  int iconv_res;
-  char *outbuf;
-  char *inbuf;
-  size_t inbytesleft;
-  int c;
-  char stringa[5];
-  double hexnum;
-  int i = 0;
</del><ins>+        char converted[16000];
+        iconv_t iconv_format;
+        int iconv_res;
+        char *outbuf;
+        char *inbuf;
+        size_t inbytesleft;
+        int c;
+        char stringa[5];
+        double hexnum;
+        int i = 0;
</ins><span class="cx"> 
</span><del>-  memset(converted, '\0', sizeof(converted));
</del><ins>+        memset(converted, '\0', sizeof(converted));
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;ucs2_in=%s\n&quot;, SKYPIAX_P_LOG, ucs2_in);
-  /* cicopet */
-  for (c = 0; c &lt; strlen(ucs2_in); c++) {
-    sprintf(stringa, &quot;0x%c%c&quot;, ucs2_in[c], ucs2_in[c + 1]);
-    c++;
-    hexnum = strtod(stringa, NULL);
-    converted[i] = hexnum;
-    i++;
-  }
</del><ins>+        DEBUGA_SKYPE(&quot;ucs2_in=%s\n&quot;, SKYPIAX_P_LOG, ucs2_in);
+        /* cicopet */
+        for (c = 0; c &lt; strlen(ucs2_in); c++) {
+                sprintf(stringa, &quot;0x%c%c&quot;, ucs2_in[c], ucs2_in[c + 1]);
+                c++;
+                hexnum = strtod(stringa, NULL);
+                converted[i] = hexnum;
+                i++;
+        }
</ins><span class="cx"> 
</span><del>-  outbuf = utf8_out;
-  inbuf = converted;
</del><ins>+        outbuf = utf8_out;
+        inbuf = converted;
</ins><span class="cx"> 
</span><del>-  iconv_format = iconv_open(&quot;UTF8&quot;, &quot;UCS-2BE&quot;);
-  if (iconv_format == (iconv_t) - 1) {
-    ERRORA(&quot;error: %s\n&quot;, SKYPIAX_P_LOG, strerror(errno));
-    return -1;
-  }
</del><ins>+        iconv_format = iconv_open(&quot;UTF8&quot;, &quot;UCS-2BE&quot;);
+        if (iconv_format == (iconv_t) - 1) {
+                ERRORA(&quot;error: %s\n&quot;, SKYPIAX_P_LOG, strerror(errno));
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  inbytesleft = i;
-  iconv_res = iconv(iconv_format, &amp;inbuf, &amp;inbytesleft, &amp;outbuf, &amp;outbytesleft);
-  if (iconv_res == (size_t) - 1) {
-    DEBUGA_SKYPE(&quot;ciao in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n&quot;,
-              SKYPIAX_P_LOG, inbuf, (int)inbytesleft, outbuf, (int)outbytesleft, converted,
-              utf8_out);
-    DEBUGA_SKYPE(&quot;error: %s %d\n&quot;, SKYPIAX_P_LOG, strerror(errno), errno);
-    return -1;
-  }
-  DEBUGA_SKYPE
-    (&quot;iconv_res=%d,  in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n&quot;,
-     SKYPIAX_P_LOG, iconv_res, inbuf, (int)inbytesleft, outbuf, (int)outbytesleft, converted,
-     utf8_out);
-  iconv_close(iconv_format);
</del><ins>+        inbytesleft = i;
+        iconv_res = iconv(iconv_format, &amp;inbuf, &amp;inbytesleft, &amp;outbuf, &amp;outbytesleft);
+        if (iconv_res == (size_t) -1) {
+                DEBUGA_SKYPE(&quot;ciao in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n&quot;,
+                                         SKYPIAX_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, converted, utf8_out);
+                DEBUGA_SKYPE(&quot;error: %s %d\n&quot;, SKYPIAX_P_LOG, strerror(errno), errno);
+                return -1;
+        }
+        DEBUGA_SKYPE
+                (&quot;iconv_res=%d,  in=%s, inleft=%d, out=%s, outleft=%d, converted=%s, utf8_out=%s\n&quot;,
+                 SKYPIAX_P_LOG, iconv_res, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, converted, utf8_out);
+        iconv_close(iconv_format);
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-int utf_to_ucs2(private_t * tech_pvt, char *utf_in, size_t inbytesleft, char *ucs2_out,
-                size_t outbytesleft)
</del><ins>+int utf_to_ucs2(private_t * tech_pvt, char *utf_in, size_t inbytesleft, char *ucs2_out, size_t outbytesleft)
</ins><span class="cx"> {
</span><del>-  /* cicopet */
-  iconv_t iconv_format;
-  int iconv_res;
-  char *outbuf;
-  char *inbuf;
-  char converted[16000];
-  int i;
-  char stringa[16];
-  char stringa2[16];
</del><ins>+        /* cicopet */
+        iconv_t iconv_format;
+        int iconv_res;
+        char *outbuf;
+        char *inbuf;
+        char converted[16000];
+        int i;
+        char stringa[16];
+        char stringa2[16];
</ins><span class="cx"> 
</span><del>-  memset(converted, '\0', sizeof(converted));
</del><ins>+        memset(converted, '\0', sizeof(converted));
</ins><span class="cx"> 
</span><del>-  outbuf = converted;
-  inbuf = utf_in;
</del><ins>+        outbuf = converted;
+        inbuf = utf_in;
</ins><span class="cx"> 
</span><del>-  iconv_format = iconv_open(&quot;UCS-2BE&quot;, &quot;UTF8&quot;);
-  if (iconv_format == (iconv_t) - 1) {
-    ERRORA(&quot;error: %s\n&quot;, SKYPIAX_P_LOG, strerror(errno));
-    return -1;
-  }
-  outbytesleft = 16000;
</del><ins>+        iconv_format = iconv_open(&quot;UCS-2BE&quot;, &quot;UTF8&quot;);
+        if (iconv_format == (iconv_t) - 1) {
+                ERRORA(&quot;error: %s\n&quot;, SKYPIAX_P_LOG, strerror(errno));
+                return -1;
+        }
+        outbytesleft = 16000;
</ins><span class="cx"> 
</span><del>-  DEBUGA_SKYPE(&quot;in=%s, inleft=%d, out=%s, outleft=%d, utf_in=%s, converted=%s\n&quot;,
-            SKYPIAX_P_LOG, inbuf, (int)inbytesleft, outbuf, (int)outbytesleft, utf_in, converted);
-  iconv_res = iconv(iconv_format, &amp;inbuf, &amp;inbytesleft, &amp;outbuf, &amp;outbytesleft);
-  if (iconv_res == (size_t) - 1) {
-    ERRORA(&quot;error: %s %d\n&quot;, SKYPIAX_P_LOG, strerror(errno), errno);
-    return -1;
-  }
-  DEBUGA_SKYPE
-    (&quot;iconv_res=%d,  in=%s, inleft=%d, out=%s, outleft=%d, utf_in=%s, converted=%s\n&quot;,
-     SKYPIAX_P_LOG, iconv_res, inbuf, (int)inbytesleft, outbuf, (int)outbytesleft, utf_in,
-     converted);
-  iconv_close(iconv_format);
</del><ins>+        DEBUGA_SKYPE(&quot;in=%s, inleft=%d, out=%s, outleft=%d, utf_in=%s, converted=%s\n&quot;,
+                                 SKYPIAX_P_LOG, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf_in, converted);
+        iconv_res = iconv(iconv_format, &amp;inbuf, &amp;inbytesleft, &amp;outbuf, &amp;outbytesleft);
+        if (iconv_res == (size_t) -1) {
+                ERRORA(&quot;error: %s %d\n&quot;, SKYPIAX_P_LOG, strerror(errno), errno);
+                return -1;
+        }
+        DEBUGA_SKYPE
+                (&quot;iconv_res=%d,  in=%s, inleft=%d, out=%s, outleft=%d, utf_in=%s, converted=%s\n&quot;,
+                 SKYPIAX_P_LOG, iconv_res, inbuf, (int) inbytesleft, outbuf, (int) outbytesleft, utf_in, converted);
+        iconv_close(iconv_format);
</ins><span class="cx"> 
</span><del>-  for (i = 0; i &lt; 16000 - outbytesleft; i++) {
-    memset(stringa, '\0', sizeof(stringa));
-    memset(stringa2, '\0', sizeof(stringa2));
-    sprintf(stringa, &quot;%02X&quot;, converted[i]);
-    DEBUGA_SKYPE(&quot;character is |%02X|\n&quot;, SKYPIAX_P_LOG, converted[i]);
-    stringa2[0] = stringa[strlen(stringa) - 2];
-    stringa2[1] = stringa[strlen(stringa) - 1];
-    strncat(ucs2_out, stringa2, ((outbytesleft - strlen(ucs2_out)) - 1));   //add the received line to the buffer
-    DEBUGA_SKYPE(&quot;stringa=%s, stringa2=%s, ucs2_out=%s\n&quot;, SKYPIAX_P_LOG, stringa, stringa2,
-              ucs2_out);
-  }
-  return 0;
</del><ins>+        for (i = 0; i &lt; 16000 - outbytesleft; i++) {
+                memset(stringa, '\0', sizeof(stringa));
+                memset(stringa2, '\0', sizeof(stringa2));
+                sprintf(stringa, &quot;%02X&quot;, converted[i]);
+                DEBUGA_SKYPE(&quot;character is |%02X|\n&quot;, SKYPIAX_P_LOG, converted[i]);
+                stringa2[0] = stringa[strlen(stringa) - 2];
+                stringa2[1] = stringa[strlen(stringa) - 1];
+                strncat(ucs2_out, stringa2, ((outbytesleft - strlen(ucs2_out)) - 1));        //add the received line to the buffer
+                DEBUGA_SKYPE(&quot;stringa=%s, stringa2=%s, ucs2_out=%s\n&quot;, SKYPIAX_P_LOG, stringa, stringa2, ucs2_out);
+        }
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -3399,51 +3237,51 @@
</span><span class="cx">  * Part of PBX interface */
</span><span class="cx"> int celliax_answer(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  int res;
</del><ins>+        int res;
</ins><span class="cx"> 
</span><del>-  if (option_debug) {
-    DEBUGA_PBX(&quot;ENTERING FUNC\n&quot;, SKYPIAX_P_LOG);
-  }
-  /* do something to actually answer the call, if needed (eg. pick up the phone) */
-  if (tech_pvt-&gt;controldevprotocol != PROTOCOL_NO_SERIAL) {
-    if (celliax_serial_answer(tech_pvt)) {
-      ERRORA(&quot;celliax_answer FAILED\n&quot;, SKYPIAX_P_LOG);
-      if (option_debug) {
-        DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
-      }
-      return -1;
-    }
-  }
-  tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
-  tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_ACTIVE;
</del><ins>+        if (option_debug) {
+                DEBUGA_PBX(&quot;ENTERING FUNC\n&quot;, SKYPIAX_P_LOG);
+        }
+        /* do something to actually answer the call, if needed (eg. pick up the phone) */
+        if (tech_pvt-&gt;controldevprotocol != PROTOCOL_NO_SERIAL) {
+                if (celliax_serial_answer(tech_pvt)) {
+                        ERRORA(&quot;celliax_answer FAILED\n&quot;, SKYPIAX_P_LOG);
+                        if (option_debug) {
+                                DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
+                        }
+                        return -1;
+                }
+        }
+        tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
+        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_ACTIVE;
</ins><span class="cx"> 
</span><del>-  while (tech_pvt-&gt;interface_state == SKYPIAX_STATE_RING) {
-    usleep(10000);              //10msec
-  }
-  if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_UP) {
-    ERRORA(&quot;call answering failed\n&quot;, SKYPIAX_P_LOG);
-    res = -1;
-  } else {
-    if (option_debug)
-      DEBUGA_PBX(&quot;call answered\n&quot;, SKYPIAX_P_LOG);
-    res = 0;
</del><ins>+        while (tech_pvt-&gt;interface_state == SKYPIAX_STATE_RING) {
+                usleep(10000);                        //10msec
+        }
+        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_UP) {
+                ERRORA(&quot;call answering failed\n&quot;, SKYPIAX_P_LOG);
+                res = -1;
+        } else {
+                if (option_debug)
+                        DEBUGA_PBX(&quot;call answered\n&quot;, SKYPIAX_P_LOG);
+                res = 0;
</ins><span class="cx"> #ifdef CELLIAX_PORTAUDIO
</span><del>-    speex_echo_state_reset(tech_pvt-&gt;stream-&gt;echo_state);
</del><ins>+                speex_echo_state_reset(tech_pvt-&gt;stream-&gt;echo_state);
</ins><span class="cx"> #endif // CELLIAX_PORTAUDIO
</span><span class="cx"> 
</span><del>-                                                                        new_inbound_channel(tech_pvt);
-    if (tech_pvt-&gt;owner) {
-      DEBUGA_PBX(&quot;going to send SKYPIAX_STATE_UP\n&quot;, SKYPIAX_P_LOG);
-      ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_UP);
-      //ast_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_ANSWER);
-      //celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_ANSWER);
-      DEBUGA_PBX(&quot;just sent SKYPIAX_STATE_UP\n&quot;, SKYPIAX_P_LOG);
-    }
-  }
-  if (option_debug) {
-    DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
-  }
-  return res;
</del><ins>+                new_inbound_channel(tech_pvt);
+                if (tech_pvt-&gt;owner) {
+                        DEBUGA_PBX(&quot;going to send SKYPIAX_STATE_UP\n&quot;, SKYPIAX_P_LOG);
+                        ast_setstate(tech_pvt-&gt;owner, SKYPIAX_STATE_UP);
+                        //ast_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_ANSWER);
+                        //celliax_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_ANSWER);
+                        DEBUGA_PBX(&quot;just sent SKYPIAX_STATE_UP\n&quot;, SKYPIAX_P_LOG);
+                }
+        }
+        if (option_debug) {
+                DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
+        }
+        return res;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /*! \brief  Hangup celliax call
</span><span class="lines">@@ -3452,376 +3290,353 @@
</span><span class="cx"> int celliax_hangup(private_t * tech_pvt)
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-  /* if there is not celliax pvt why we are here ? */
-  if (!tech_pvt) {
-    ERRORA(&quot;Asked to hangup channel not connected\n&quot;, SKYPIAX_P_LOG);
-    return 0;
-  }
</del><ins>+        /* if there is not celliax pvt why we are here ? */
+        if (!tech_pvt) {
+                ERRORA(&quot;Asked to hangup channel not connected\n&quot;, SKYPIAX_P_LOG);
+                return 0;
+        }
</ins><span class="cx"> 
</span><del>-    DEBUGA_SKYPE(&quot;ENTERING FUNC\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        DEBUGA_SKYPE(&quot;ENTERING FUNC\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><span class="cx"> #ifdef NOTDEF
</span><del>-  /* shutdown the serial monitoring thread */
-  if (tech_pvt-&gt;controldev_thread &amp;&amp; (tech_pvt-&gt;controldev_thread != SKYPIAX_PTHREADT_NULL)
-      &amp;&amp; (tech_pvt-&gt;controldev_thread != SKYPIAX_PTHREADT_STOP)) {
-    if (pthread_cancel(tech_pvt-&gt;controldev_thread)) {
-      ERRORA(&quot;controldev_thread pthread_cancel failed, maybe he killed himself?\n&quot;,
-             SKYPIAX_P_LOG);
-    }
-    /* push it, maybe is stuck in a select or so */
-    if (pthread_kill(tech_pvt-&gt;controldev_thread, SIGURG)) {
-      DEBUGA_SKYPE(&quot;controldev_thread pthread_kill failed, no problem\n&quot;, SKYPIAX_P_LOG);
-    }
-#ifndef __CYGWIN__              /* under cygwin, this seems to be not reliable, get stuck at times */
-    /* wait for it to die */
-    if (pthread_join(tech_pvt-&gt;controldev_thread, NULL)) {
-      ERRORA(&quot;controldev_thread pthread_join failed, BAD\n&quot;, SKYPIAX_P_LOG);
-    }
</del><ins>+        /* shutdown the serial monitoring thread */
+        if (tech_pvt-&gt;controldev_thread &amp;&amp; (tech_pvt-&gt;controldev_thread != SKYPIAX_PTHREADT_NULL)
+                &amp;&amp; (tech_pvt-&gt;controldev_thread != SKYPIAX_PTHREADT_STOP)) {
+                if (pthread_cancel(tech_pvt-&gt;controldev_thread)) {
+                        ERRORA(&quot;controldev_thread pthread_cancel failed, maybe he killed himself?\n&quot;, SKYPIAX_P_LOG);
+                }
+                /* push it, maybe is stuck in a select or so */
+                if (pthread_kill(tech_pvt-&gt;controldev_thread, SIGURG)) {
+                        DEBUGA_SKYPE(&quot;controldev_thread pthread_kill failed, no problem\n&quot;, SKYPIAX_P_LOG);
+                }
+#ifndef __CYGWIN__                                /* under cygwin, this seems to be not reliable, get stuck at times */
+                /* wait for it to die */
+                if (pthread_join(tech_pvt-&gt;controldev_thread, NULL)) {
+                        ERRORA(&quot;controldev_thread pthread_join failed, BAD\n&quot;, SKYPIAX_P_LOG);
+                }
</ins><span class="cx"> #else /* __CYGWIN__ */
</span><span class="cx"> /* allow the serial thread to die */
</span><del>-    usleep(300000);             //300msecs
</del><ins>+                usleep(300000);                        //300msecs
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><del>-  }
-  tech_pvt-&gt;controldev_thread = SKYPIAX_PTHREADT_NULL;
-#endif// NOTDEF
</del><ins>+        }
+        tech_pvt-&gt;controldev_thread = SKYPIAX_PTHREADT_NULL;
+#endif // NOTDEF
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;controldevprotocol != PROTOCOL_NO_SERIAL) {
-    if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
-      /* actually hangup through the serial port */
-      if (tech_pvt-&gt;controldevprotocol != PROTOCOL_NO_SERIAL) {
-        int res;
-        res = celliax_serial_hangup(tech_pvt);
-        if (res) {
-          ERRORA(&quot;celliax_serial_hangup error: %d\n&quot;, SKYPIAX_P_LOG, res);
-          if (option_debug) {
-            DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
-          }
-          return -1;
-        }
-      }
</del><ins>+        if (tech_pvt-&gt;controldevprotocol != PROTOCOL_NO_SERIAL) {
+                if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
+                        /* actually hangup through the serial port */
+                        if (tech_pvt-&gt;controldevprotocol != PROTOCOL_NO_SERIAL) {
+                                int res;
+                                res = celliax_serial_hangup(tech_pvt);
+                                if (res) {
+                                        ERRORA(&quot;celliax_serial_hangup error: %d\n&quot;, SKYPIAX_P_LOG, res);
+                                        if (option_debug) {
+                                                DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
+                                        }
+                                        return -1;
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-      while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
-        usleep(10000);          //10msec
-      }
-      if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
-        ERRORA(&quot;call hangup failed\n&quot;, SKYPIAX_P_LOG);
-        return -1;
-      } else {
-        DEBUGA_SKYPE(&quot;call hungup\n&quot;, SKYPIAX_P_LOG);
-      }
-    }
-  } else {
-    tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
-    tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_IDLE;
-  }
</del><ins>+                        while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
+                                usleep(10000);        //10msec
+                        }
+                        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
+                                ERRORA(&quot;call hangup failed\n&quot;, SKYPIAX_P_LOG);
+                                return -1;
+                        } else {
+                                DEBUGA_SKYPE(&quot;call hungup\n&quot;, SKYPIAX_P_LOG);
+                        }
+                }
+        } else {
+                tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
+                tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_IDLE;
+        }
</ins><span class="cx"> 
</span><del>-                switch_set_flag(tech_pvt, TFLAG_HANGUP);
</del><ins>+        switch_set_flag(tech_pvt, TFLAG_HANGUP);
</ins><span class="cx"> #ifdef NOTDEF
</span><del>-  /* if there is a dsp struct alloced, free it */
-  if (tech_pvt-&gt;dsp) {
-    ast_dsp_free(tech_pvt-&gt;dsp);
-    tech_pvt-&gt;dsp = NULL;
-  }
</del><ins>+        /* if there is a dsp struct alloced, free it */
+        if (tech_pvt-&gt;dsp) {
+                ast_dsp_free(tech_pvt-&gt;dsp);
+                tech_pvt-&gt;dsp = NULL;
+        }
</ins><span class="cx"> #ifndef __CYGWIN__
</span><span class="cx"> #ifdef CELLIAX_ALSA
</span><span class="cx"> /* restart alsa */
</span><del>-  snd_pcm_drop(tech_pvt-&gt;alsap);
-  snd_pcm_prepare(tech_pvt-&gt;alsap);
</del><ins>+        snd_pcm_drop(tech_pvt-&gt;alsap);
+        snd_pcm_prepare(tech_pvt-&gt;alsap);
</ins><span class="cx"> 
</span><del>-  snd_pcm_prepare(tech_pvt-&gt;alsac);
-  snd_pcm_start(tech_pvt-&gt;alsac);
</del><ins>+        snd_pcm_prepare(tech_pvt-&gt;alsac);
+        snd_pcm_start(tech_pvt-&gt;alsac);
</ins><span class="cx"> #endif /* CELLIAX_ALSA */
</span><span class="cx"> 
</span><span class="cx"> #endif /* __CYGWIN__ */
</span><span class="cx"> #ifdef CELLIAX_PORTAUDIO
</span><del>-  speex_echo_state_reset(tech_pvt-&gt;stream-&gt;echo_state);
</del><ins>+        speex_echo_state_reset(tech_pvt-&gt;stream-&gt;echo_state);
</ins><span class="cx"> #endif // CELLIAX_PORTAUDIO
</span><span class="cx"> 
</span><del>-  /* re-init the serial port, be paranoid */
-  if (tech_pvt-&gt;controldevprotocol != PROTOCOL_NO_SERIAL) {
-    tech_pvt-&gt;controldevfd = celliax_serial_init(p, tech_pvt-&gt;controldevice_speed);
-    if (tech_pvt-&gt;controldevfd &lt; 1) {
-      ERRORA(&quot;bad, bad, bad\n&quot;, SKYPIAX_P_LOG);
-      if (option_debug) {
-        DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
-      }
-      return -1;
-    }
-  }
</del><ins>+        /* re-init the serial port, be paranoid */
+        if (tech_pvt-&gt;controldevprotocol != PROTOCOL_NO_SERIAL) {
+                tech_pvt-&gt;controldevfd = celliax_serial_init(p, tech_pvt-&gt;controldevice_speed);
+                if (tech_pvt-&gt;controldevfd &lt; 1) {
+                        ERRORA(&quot;bad, bad, bad\n&quot;, SKYPIAX_P_LOG);
+                        if (option_debug) {
+                                DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
+                        }
+                        return -1;
+                }
+        }
</ins><span class="cx"> #ifndef ASTERISK_VERSION_1_4
</span><del>-  /* subtract one to the usage count of Celliax-type channels */
-  LOKKA(celliax_usecnt_lock);
-  celliax_usecnt--;
-  if (celliax_usecnt &lt; 0)
-    ERRORA(&quot;Usecnt &lt; 0???\n&quot;, SKYPIAX_P_LOG);
-  UNLOCKA(celliax_usecnt_lock);
-  ast_update_use_count();
</del><ins>+        /* subtract one to the usage count of Celliax-type channels */
+        LOKKA(celliax_usecnt_lock);
+        celliax_usecnt--;
+        if (celliax_usecnt &lt; 0)
+                ERRORA(&quot;Usecnt &lt; 0???\n&quot;, SKYPIAX_P_LOG);
+        UNLOCKA(celliax_usecnt_lock);
+        ast_update_use_count();
</ins><span class="cx"> #else /* ASTERISK_VERSION_1_4 */
</span><span class="cx">         ast_module_unref(ast_module_info-&gt;self);
</span><span class="cx"> #endif /* ASTERISK_VERSION_1_4 */
</span><span class="cx"> 
</span><del>-  /* our celliax pvt interface is no more part of a channel */
-  tech_pvt-&gt;owner = NULL;
-  /* our channel has no more this celliax pvt interface to manage */
-  c-&gt;tech_pvt = NULL;
-  /* set the channel state to DOWN, eg. available, not in active use */
-  if (ast_setstate(c, SKYPIAX_STATE_DOWN)) {
-    ERRORA(&quot;ast_setstate failed, BAD\n&quot;, SKYPIAX_P_LOG);
-    if (option_debug) {
-      DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
-    }
-    return -1;
-  }
</del><ins>+        /* our celliax pvt interface is no more part of a channel */
+        tech_pvt-&gt;owner = NULL;
+        /* our channel has no more this celliax pvt interface to manage */
+        c-&gt;tech_pvt = NULL;
+        /* set the channel state to DOWN, eg. available, not in active use */
+        if (ast_setstate(c, SKYPIAX_STATE_DOWN)) {
+                ERRORA(&quot;ast_setstate failed, BAD\n&quot;, SKYPIAX_P_LOG);
+                if (option_debug) {
+                        DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
+                }
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  if (option_debug)
-    DEBUGA_PBX(&quot;Hanged Up\n&quot;, SKYPIAX_P_LOG);
-  /* restart the monitor thread, so it can recheck which interfaces it have to watch during its loop (the interfaces that are not owned by channels) */
-  if (celliax_restart_monitor()) {
-    ERRORA(&quot;celliax_restart_monitor failed, BAD\n&quot;, SKYPIAX_P_LOG);
-    if (option_debug) {
-      DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
-    }
-    return -1;
-  }
-
-#endif// NOTDEF
-  if (option_debug) {
-    DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
-  }
-  return 0;
</del><ins>+        if (option_debug)
+                DEBUGA_PBX(&quot;Hanged Up\n&quot;, SKYPIAX_P_LOG);
+        /* restart the monitor thread, so it can recheck which interfaces it have to watch during its loop (the interfaces that are not owned by channels) */
+        if (celliax_restart_monitor()) {
+                ERRORA(&quot;celliax_restart_monitor failed, BAD\n&quot;, SKYPIAX_P_LOG);
+                if (option_debug) {
+                        DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
+                }
+                return -1;
+        }
+#endif // NOTDEF
+        if (option_debug) {
+                DEBUGA_PBX(&quot;EXITING FUNC\n&quot;, SKYPIAX_P_LOG);
+        }
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> #ifdef NOTDEF
</span><span class="cx"> int celliax_serial_call_AT(private_t * tech_pvt, char *dstr)
</span><span class="cx"> {
</span><del>-  int res;
-  char at_command[256];
</del><ins>+        int res;
+        char at_command[256];
</ins><span class="cx"> 
</span><del>-  if (option_debug)
-    DEBUGA_PBX(&quot;Dialing %s\n&quot;, SKYPIAX_P_LOG, dstr);
-  memset(at_command, 0, sizeof(at_command));
-  tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_DIALING;
-  tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
-  ast_uri_decode(dstr);
-  size_t fixdstr = strspn(dstr, SKYPIAX_DIGIT_ANYDIG);
-  if (fixdstr == 0) {
-    ERRORA(&quot;dial command failed because of invalid dial number. dial string was: %s\n&quot;,
-           SKYPIAX_P_LOG, dstr);
-    return -1;
-  }
-  dstr[fixdstr] = '\0';
-  sprintf(at_command, &quot;%s%s%s&quot;, tech_pvt-&gt;at_dial_pre_number, dstr, tech_pvt-&gt;at_dial_post_number);
-  res = celliax_serial_write_AT_expect(tech_pvt, at_command, tech_pvt-&gt;at_dial_expect);
-  if (res) {
-    ERRORA(&quot;dial command failed, dial string was: %s\n&quot;, SKYPIAX_P_LOG, at_command);
-    return -1;
-  }
-  // jet - early audio
-  if (tech_pvt-&gt;at_early_audio) {
-    ast_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_ANSWER);
-  }
</del><ins>+        if (option_debug)
+                DEBUGA_PBX(&quot;Dialing %s\n&quot;, SKYPIAX_P_LOG, dstr);
+        memset(at_command, 0, sizeof(at_command));
+        tech_pvt-&gt;phone_callflow = CALLFLOW_CALL_DIALING;
+        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING;
+        ast_uri_decode(dstr);
+        size_t fixdstr = strspn(dstr, SKYPIAX_DIGIT_ANYDIG);
+        if (fixdstr == 0) {
+                ERRORA(&quot;dial command failed because of invalid dial number. dial string was: %s\n&quot;, SKYPIAX_P_LOG, dstr);
+                return -1;
+        }
+        dstr[fixdstr] = '\0';
+        sprintf(at_command, &quot;%s%s%s&quot;, tech_pvt-&gt;at_dial_pre_number, dstr, tech_pvt-&gt;at_dial_post_number);
+        res = celliax_serial_write_AT_expect(tech_pvt, at_command, tech_pvt-&gt;at_dial_expect);
+        if (res) {
+                ERRORA(&quot;dial command failed, dial string was: %s\n&quot;, SKYPIAX_P_LOG, at_command);
+                return -1;
+        }
+        // jet - early audio
+        if (tech_pvt-&gt;at_early_audio) {
+                ast_queue_control(tech_pvt-&gt;owner, SKYPIAX_CONTROL_ANSWER);
+        }
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_console_at(int fd, int argc, char *argv[])
</span><span class="cx"> {
</span><del>-  private_t * tech_pvt = celliax_console_find_desc(celliax_console_active);
-  char at_cmd[1024];
-  int i, a, c;
</del><ins>+        private_t *tech_pvt = celliax_console_find_desc(celliax_console_active);
+        char at_cmd[1024];
+        int i, a, c;
</ins><span class="cx"> 
</span><del>-  if (argc == 1)
-    return RESULT_SHOWUSAGE;
-  if (!tech_pvt) {
-    ast_cli(fd,
-            &quot;No \&quot;current\&quot; console for celliax_at, please enter 'help celliax_console'\n&quot;);
-    return RESULT_SUCCESS;
-  }
-  if (tech_pvt-&gt;controldevprotocol != PROTOCOL_AT) {
-    ast_cli(fd,
-            &quot;The \&quot;current\&quot; console is not connected to an 'AT modem' (cellphone)\n&quot;);
-    return RESULT_SUCCESS;
-  }
</del><ins>+        if (argc == 1)
+                return RESULT_SHOWUSAGE;
+        if (!tech_pvt) {
+                ast_cli(fd, &quot;No \&quot;current\&quot; console for celliax_at, please enter 'help celliax_console'\n&quot;);
+                return RESULT_SUCCESS;
+        }
+        if (tech_pvt-&gt;controldevprotocol != PROTOCOL_AT) {
+                ast_cli(fd, &quot;The \&quot;current\&quot; console is not connected to an 'AT modem' (cellphone)\n&quot;);
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx"> 
</span><del>-  memset(at_cmd, 0, sizeof(at_cmd));
-  c = 0;
-  for (i = 1; i &lt; argc; i++) {
-    for (a = 0; a &lt; strlen(argv[i]); a++) {
-      at_cmd[c] = argv[i][a];
-      c++;
-      if (c == 1022)
-        break;
-    }
-    if (i != argc - 1) {
-      at_cmd[c] = ' ';
-      c++;
-    }
-    if (c == 1023)
-      break;
-  }
-  celliax_serial_write_AT_noack(tech_pvt, at_cmd);
-  return RESULT_SUCCESS;
</del><ins>+        memset(at_cmd, 0, sizeof(at_cmd));
+        c = 0;
+        for (i = 1; i &lt; argc; i++) {
+                for (a = 0; a &lt; strlen(argv[i]); a++) {
+                        at_cmd[c] = argv[i][a];
+                        c++;
+                        if (c == 1022)
+                                break;
+                }
+                if (i != argc - 1) {
+                        at_cmd[c] = ' ';
+                        c++;
+                }
+                if (c == 1023)
+                        break;
+        }
+        celliax_serial_write_AT_noack(tech_pvt, at_cmd);
+        return RESULT_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int celliax_serial_getstatus_AT(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  int res;
</del><ins>+        int res;
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;owner) {
-    if (tech_pvt-&gt;owner-&gt;state != SKYPIAX_STATE_UP &amp;&amp; tech_pvt-&gt;owner-&gt;state != SKYPIAX_STATE_DOWN) {
-      DEBUGA_SKYPE(&quot;No getstatus, we're neither UP nor DOWN\n&quot;, SKYPIAX_P_LOG);
-      return 0;
-    }
-  }
</del><ins>+        if (tech_pvt-&gt;owner) {
+                if (tech_pvt-&gt;owner-&gt;state != SKYPIAX_STATE_UP &amp;&amp; tech_pvt-&gt;owner-&gt;state != SKYPIAX_STATE_DOWN) {
+                        DEBUGA_SKYPE(&quot;No getstatus, we're neither UP nor DOWN\n&quot;, SKYPIAX_P_LOG);
+                        return 0;
+                }
+        }
</ins><span class="cx"> 
</span><del>-  PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
-  LOKKA(tech_pvt-&gt;controldev_lock);
-  res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT&quot;);
-  if (res) {
-    ERRORA(&quot;AT was not acknowledged, continuing but maybe there is a problem\n&quot;,
-           SKYPIAX_P_LOG);
-  }
-  usleep(1000);
</del><ins>+        PUSHA_UNLOCKA(tech_pvt-&gt;controldev_lock);
+        LOKKA(tech_pvt-&gt;controldev_lock);
+        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT&quot;);
+        if (res) {
+                ERRORA(&quot;AT was not acknowledged, continuing but maybe there is a problem\n&quot;, SKYPIAX_P_LOG);
+        }
+        usleep(1000);
</ins><span class="cx"> 
</span><del>-  if (strlen(tech_pvt-&gt;at_query_battchg)) {
-    res =
-      celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_query_battchg, tech_pvt-&gt;at_query_battchg_expect);
-    if (res) {
-      WARNINGA(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-               tech_pvt-&gt;at_query_battchg, tech_pvt-&gt;at_query_battchg_expect);
-    }
-    usleep(1000);
-  }
</del><ins>+        if (strlen(tech_pvt-&gt;at_query_battchg)) {
+                res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_query_battchg, tech_pvt-&gt;at_query_battchg_expect);
+                if (res) {
+                        WARNINGA(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_query_battchg, tech_pvt-&gt;at_query_battchg_expect);
+                }
+                usleep(1000);
+        }
</ins><span class="cx"> 
</span><del>-  if (strlen(tech_pvt-&gt;at_query_signal)) {
-    res =
-      celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_query_signal, tech_pvt-&gt;at_query_signal_expect);
-    if (res) {
-      WARNINGA(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG,
-               tech_pvt-&gt;at_query_signal, tech_pvt-&gt;at_query_signal_expect);
-    }
-    usleep(1000);
-  }
-  //FIXME all the following commands in config!
</del><ins>+        if (strlen(tech_pvt-&gt;at_query_signal)) {
+                res = celliax_serial_write_AT_expect(tech_pvt, tech_pvt-&gt;at_query_signal, tech_pvt-&gt;at_query_signal_expect);
+                if (res) {
+                        WARNINGA(&quot;%s does not get %s from the phone. Continuing.\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_query_signal, tech_pvt-&gt;at_query_signal_expect);
+                }
+                usleep(1000);
+        }
+        //FIXME all the following commands in config!
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;sms_cnmi_not_supported) {
-    res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+MMGL=\&quot;HEADER ONLY\&quot;&quot;);
-    if (res) {
-      WARNINGA
-        (&quot;%s does not get %s from the modem, maybe a long msg is incoming. If this cellmodem is not a Motorola, you are arriving here because your cellmodem do not supports CNMI kind of incoming SMS alert; please let it know to the developers of Celliax. If this cellmodem is a Motorola and this message keeps repeating, and you cannot correctly receive SMSs from this interface, please manually clean all messages from the cellmodem/SIM. Continuing.\n&quot;,
-         SKYPIAX_P_LOG, &quot;AT+MMGL=\&quot;HEADER ONLY\&quot;&quot;, &quot;OK&quot;);
-    } else {
-      usleep(1000);
-      if (tech_pvt-&gt;unread_sms_msg_id) {
-        char at_command[256];
</del><ins>+        if (tech_pvt-&gt;sms_cnmi_not_supported) {
+                res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+MMGL=\&quot;HEADER ONLY\&quot;&quot;);
+                if (res) {
+                        WARNINGA
+                                (&quot;%s does not get %s from the modem, maybe a long msg is incoming. If this cellmodem is not a Motorola, you are arriving here because your cellmodem do not supports CNMI kind of incoming SMS alert; please let it know to the developers of Celliax. If this cellmodem is a Motorola and this message keeps repeating, and you cannot correctly receive SMSs from this interface, please manually clean all messages from the cellmodem/SIM. Continuing.\n&quot;,
+                                 SKYPIAX_P_LOG, &quot;AT+MMGL=\&quot;HEADER ONLY\&quot;&quot;, &quot;OK&quot;);
+                } else {
+                        usleep(1000);
+                        if (tech_pvt-&gt;unread_sms_msg_id) {
+                                char at_command[256];
</ins><span class="cx"> 
</span><del>-        if (tech_pvt-&gt;no_ucs2 == 0) {
-          res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;UCS2\&quot;&quot;);
-          if (res) {
-            ERRORA
-              (&quot;AT+CSCS=\&quot;UCS2\&quot; (set TE messages to ucs2)  do not got OK from the phone\n&quot;,
-               SKYPIAX_P_LOG);
-            memset(tech_pvt-&gt;sms_message, 0, sizeof(tech_pvt-&gt;sms_message));
-          }
-        }
</del><ins>+                                if (tech_pvt-&gt;no_ucs2 == 0) {
+                                        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;UCS2\&quot;&quot;);
+                                        if (res) {
+                                                ERRORA(&quot;AT+CSCS=\&quot;UCS2\&quot; (set TE messages to ucs2)  do not got OK from the phone\n&quot;, SKYPIAX_P_LOG);
+                                                memset(tech_pvt-&gt;sms_message, 0, sizeof(tech_pvt-&gt;sms_message));
+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-        memset(at_command, 0, sizeof(at_command));
-        sprintf(at_command, &quot;AT+CMGR=%d&quot;, tech_pvt-&gt;unread_sms_msg_id);
-        memset(tech_pvt-&gt;sms_message, 0, sizeof(tech_pvt-&gt;sms_message));
</del><ins>+                                memset(at_command, 0, sizeof(at_command));
+                                sprintf(at_command, &quot;AT+CMGR=%d&quot;, tech_pvt-&gt;unread_sms_msg_id);
+                                memset(tech_pvt-&gt;sms_message, 0, sizeof(tech_pvt-&gt;sms_message));
</ins><span class="cx"> 
</span><del>-        tech_pvt-&gt;reading_sms_msg = 1;
-        res = celliax_serial_write_AT_ack(tech_pvt, at_command);
-        tech_pvt-&gt;reading_sms_msg = 0;
-        if (res) {
-          ERRORA
-            (&quot;AT+CMGR (read SMS) do not got OK from the phone, message sent was:|||%s|||\n&quot;,
-             SKYPIAX_P_LOG, at_command);
-        }
-        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;GSM\&quot;&quot;);
-        if (res) {
-          ERRORA
-            (&quot;AT+CSCS=\&quot;GSM\&quot; (set TE messages to GSM) do not got OK from the phone\n&quot;,
-             SKYPIAX_P_LOG);
-        }
-        memset(at_command, 0, sizeof(at_command));
-        sprintf(at_command, &quot;AT+CMGD=%d&quot;, tech_pvt-&gt;unread_sms_msg_id);    /* delete the message */
-        tech_pvt-&gt;unread_sms_msg_id = 0;
-        res = celliax_serial_write_AT_ack(tech_pvt, at_command);
-        if (res) {
-          ERRORA
-            (&quot;AT+CMGD (Delete SMS) do not got OK from the phone, message sent was:|||%s|||\n&quot;,
-             SKYPIAX_P_LOG, at_command);
-        }
</del><ins>+                                tech_pvt-&gt;reading_sms_msg = 1;
+                                res = celliax_serial_write_AT_ack(tech_pvt, at_command);
+                                tech_pvt-&gt;reading_sms_msg = 0;
+                                if (res) {
+                                        ERRORA(&quot;AT+CMGR (read SMS) do not got OK from the phone, message sent was:|||%s|||\n&quot;, SKYPIAX_P_LOG, at_command);
+                                }
+                                res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CSCS=\&quot;GSM\&quot;&quot;);
+                                if (res) {
+                                        ERRORA(&quot;AT+CSCS=\&quot;GSM\&quot; (set TE messages to GSM) do not got OK from the phone\n&quot;, SKYPIAX_P_LOG);
+                                }
+                                memset(at_command, 0, sizeof(at_command));
+                                sprintf(at_command, &quot;AT+CMGD=%d&quot;, tech_pvt-&gt;unread_sms_msg_id);        /* delete the message */
+                                tech_pvt-&gt;unread_sms_msg_id = 0;
+                                res = celliax_serial_write_AT_ack(tech_pvt, at_command);
+                                if (res) {
+                                        ERRORA(&quot;AT+CMGD (Delete SMS) do not got OK from the phone, message sent was:|||%s|||\n&quot;, SKYPIAX_P_LOG, at_command);
+                                }
</ins><span class="cx"> 
</span><del>-        if (strlen(tech_pvt-&gt;sms_message)) {
</del><ins>+                                if (strlen(tech_pvt-&gt;sms_message)) {
</ins><span class="cx"> 
</span><del>-          manager_event(EVENT_FLAG_SYSTEM, &quot;CELLIAXincomingsms&quot;,
-                        &quot;Interface: %s\r\nSMS_Message: %s\r\n&quot;, tech_pvt-&gt;name, tech_pvt-&gt;sms_message);
</del><ins>+                                        manager_event(EVENT_FLAG_SYSTEM, &quot;CELLIAXincomingsms&quot;, &quot;Interface: %s\r\nSMS_Message: %s\r\n&quot;, tech_pvt-&gt;name, tech_pvt-&gt;sms_message);
</ins><span class="cx"> 
</span><del>-          if (strlen(tech_pvt-&gt;sms_receiving_program)) {
-            int fd1[2];
-            pid_t pid1;
-            char *arg1[] = { tech_pvt-&gt;sms_receiving_program, (char *) NULL };
-            int i;
</del><ins>+                                        if (strlen(tech_pvt-&gt;sms_receiving_program)) {
+                                                int fd1[2];
+                                                pid_t pid1;
+                                                char *arg1[] = { tech_pvt-&gt;sms_receiving_program, (char *) NULL };
+                                                int i;
</ins><span class="cx"> 
</span><del>-            NOTICA(&quot;incoming SMS message:&gt;&gt;&gt;%s&lt;&lt;&lt;\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;sms_message);
-            pipe(fd1);
-            pid1 = fork();
</del><ins>+                                                NOTICA(&quot;incoming SMS message:&gt;&gt;&gt;%s&lt;&lt;&lt;\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;sms_message);
+                                                pipe(fd1);
+                                                pid1 = fork();
</ins><span class="cx"> 
</span><del>-            if (pid1 == 0) {    //child
-              int err;
</del><ins>+                                                if (pid1 == 0) {        //child
+                                                        int err;
</ins><span class="cx"> 
</span><del>-              dup2(fd1[0], 0);  // Connect stdin to pipe output
-              close(fd1[1]);    // close input pipe side
-              setsid();         //session id
-              err = execvp(arg1[0], arg1);  //exec our program, with stdin connected to pipe output
-              if (err) {
-                ERRORA
-                  (&quot;'sms_receiving_program' is set in config file to '%s', and it gave us back this error: %d, (%s). SMS received was:---%s---\n&quot;,
-                   SKYPIAX_P_LOG, tech_pvt-&gt;sms_receiving_program, err, strerror(errno),
-                   tech_pvt-&gt;sms_message);
-              }
-              close(fd1[0]);    // close output pipe side
-            }                   //starting here continue the parent
-            close(fd1[0]);      // close output pipe side
-            // write the msg on the pipe input
-            for (i = 0; i &lt; strlen(tech_pvt-&gt;sms_message); i++) {
-              write(fd1[1], &amp;tech_pvt-&gt;sms_message[i], 1);
-            }
-            close(fd1[1]);      // close pipe input, let our program know we've finished
-          } else {
-            ERRORA
-              (&quot;got SMS incoming message, but 'sms_receiving_program' is not set in config file. SMS received was:---%s---\n&quot;,
-               SKYPIAX_P_LOG, tech_pvt-&gt;sms_message);
-          }
-        }
-#if 1                           //is this one needed? maybe it can interrupt an incoming call that is just to announce itself
-        if (tech_pvt-&gt;phone_callflow == CALLFLOW_CALL_IDLE
-            &amp;&amp; tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner == NULL) {
-          /* we're not in a call, neither calling */
-          res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CKPD=\&quot;EEE\&quot;&quot;);
-          if (res) {
-            ERRORA
-              (&quot;AT+CKPD=\&quot;EEE\&quot; (cellphone screen back to user) do not got OK from the phone\n&quot;,
-               SKYPIAX_P_LOG);
-          }
-        }
</del><ins>+                                                        dup2(fd1[0], 0);        // Connect stdin to pipe output
+                                                        close(fd1[1]);        // close input pipe side
+                                                        setsid();        //session id
+                                                        err = execvp(arg1[0], arg1);        //exec our program, with stdin connected to pipe output
+                                                        if (err) {
+                                                                ERRORA
+                                                                        (&quot;'sms_receiving_program' is set in config file to '%s', and it gave us back this error: %d, (%s). SMS received was:---%s---\n&quot;,
+                                                                         SKYPIAX_P_LOG, tech_pvt-&gt;sms_receiving_program, err, strerror(errno), tech_pvt-&gt;sms_message);
+                                                        }
+                                                        close(fd1[0]);        // close output pipe side
+                                                }                //starting here continue the parent
+                                                close(fd1[0]);        // close output pipe side
+                                                // write the msg on the pipe input
+                                                for (i = 0; i &lt; strlen(tech_pvt-&gt;sms_message); i++) {
+                                                        write(fd1[1], &amp;tech_pvt-&gt;sms_message[i], 1);
+                                                }
+                                                close(fd1[1]);        // close pipe input, let our program know we've finished
+                                        } else {
+                                                ERRORA
+                                                        (&quot;got SMS incoming message, but 'sms_receiving_program' is not set in config file. SMS received was:---%s---\n&quot;,
+                                                         SKYPIAX_P_LOG, tech_pvt-&gt;sms_message);
+                                        }
+                                }
+#if 1                                                        //is this one needed? maybe it can interrupt an incoming call that is just to announce itself
+                                if (tech_pvt-&gt;phone_callflow == CALLFLOW_CALL_IDLE &amp;&amp; tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN &amp;&amp; tech_pvt-&gt;owner == NULL) {
+                                        /* we're not in a call, neither calling */
+                                        res = celliax_serial_write_AT_ack(tech_pvt, &quot;AT+CKPD=\&quot;EEE\&quot;&quot;);
+                                        if (res) {
+                                                ERRORA(&quot;AT+CKPD=\&quot;EEE\&quot; (cellphone screen back to user) do not got OK from the phone\n&quot;, SKYPIAX_P_LOG);
+                                        }
+                                }
</ins><span class="cx"> #endif
</span><del>-      }
-    }
-  }
</del><ins>+                        }
+                }
+        }
</ins><span class="cx"> 
</span><del>-  UNLOCKA(tech_pvt-&gt;controldev_lock);
-  POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
-  return 0;
</del><ins>+        UNLOCKA(tech_pvt-&gt;controldev_lock);
+        POPPA_UNLOCKA(tech_pvt-&gt;controldev_lock);
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> #define SKYPIAX_ALSA
</span><span class="lines">@@ -3843,28 +3658,28 @@
</span><span class="cx">  */
</span><span class="cx"> int alsa_init(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  tech_pvt-&gt;alsac = alsa_open_dev(tech_pvt, SND_PCM_STREAM_CAPTURE);
-  if (!tech_pvt-&gt;alsac) {
-    ERRORA(&quot;Failed opening ALSA capture device: %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;alsacname);
-    if (alsa_shutdown(tech_pvt)) {
-      ERRORA(&quot;alsa_shutdown failed\n&quot;, SKYPIAX_P_LOG);
-      return -1;
-    }
-    return -1;
-  }
-  tech_pvt-&gt;alsap = alsa_open_dev(tech_pvt, SND_PCM_STREAM_PLAYBACK);
-  if (!tech_pvt-&gt;alsap) {
-    ERRORA(&quot;Failed opening ALSA playback device: %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;alsapname);
-    if (alsa_shutdown(tech_pvt)) {
-      ERRORA(&quot;alsa_shutdown failed\n&quot;, SKYPIAX_P_LOG);
-      return -1;
-    }
-    return -1;
-  }
</del><ins>+        tech_pvt-&gt;alsac = alsa_open_dev(tech_pvt, SND_PCM_STREAM_CAPTURE);
+        if (!tech_pvt-&gt;alsac) {
+                ERRORA(&quot;Failed opening ALSA capture device: %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;alsacname);
+                if (alsa_shutdown(tech_pvt)) {
+                        ERRORA(&quot;alsa_shutdown failed\n&quot;, SKYPIAX_P_LOG);
+                        return -1;
+                }
+                return -1;
+        }
+        tech_pvt-&gt;alsap = alsa_open_dev(tech_pvt, SND_PCM_STREAM_PLAYBACK);
+        if (!tech_pvt-&gt;alsap) {
+                ERRORA(&quot;Failed opening ALSA playback device: %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;alsapname);
+                if (alsa_shutdown(tech_pvt)) {
+                        ERRORA(&quot;alsa_shutdown failed\n&quot;, SKYPIAX_P_LOG);
+                        return -1;
+                }
+                return -1;
+        }
</ins><span class="cx"> 
</span><del>-  /* make valgrind very happy */
-  snd_config_update_free_global();
-  return 0;
</del><ins>+        /* make valgrind very happy */
+        snd_config_update_free_global();
+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /*!
</span><span class="lines">@@ -3879,38 +3694,34 @@
</span><span class="cx"> int alsa_shutdown(private_t * tech_pvt)
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-  int err;
</del><ins>+        int err;
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;alsap) {
-    err = snd_pcm_drop(tech_pvt-&gt;alsap);
-    if (err &lt; 0) {
-      ERRORA(&quot;device [%s], snd_pcm_drop failed with error '%s'\n&quot;, SKYPIAX_P_LOG,
-             tech_pvt-&gt;alsapname, snd_strerror(err));
-      return -1;
-    }
-    err = snd_pcm_close(tech_pvt-&gt;alsap);
-    if (err &lt; 0) {
-      ERRORA(&quot;device [%s], snd_pcm_close failed with error '%s'\n&quot;, SKYPIAX_P_LOG,
-             tech_pvt-&gt;alsapname, snd_strerror(err));
-      return -1;
-    }
-  }
-  if (tech_pvt-&gt;alsac) {
-    err = snd_pcm_drop(tech_pvt-&gt;alsac);
-    if (err &lt; 0) {
-      ERRORA(&quot;device [%s], snd_pcm_drop failed with error '%s'\n&quot;, SKYPIAX_P_LOG,
-             tech_pvt-&gt;alsacname, snd_strerror(err));
-      return -1;
-    }
-    err = snd_pcm_close(tech_pvt-&gt;alsac);
-    if (err &lt; 0) {
-      ERRORA(&quot;device [%s], snd_pcm_close failed with error '%s'\n&quot;, SKYPIAX_P_LOG,
-             tech_pvt-&gt;alsacname, snd_strerror(err));
-      return -1;
-    }
-  }
</del><ins>+        if (tech_pvt-&gt;alsap) {
+                err = snd_pcm_drop(tech_pvt-&gt;alsap);
+                if (err &lt; 0) {
+                        ERRORA(&quot;device [%s], snd_pcm_drop failed with error '%s'\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;alsapname, snd_strerror(err));
+                        return -1;
+                }
+                err = snd_pcm_close(tech_pvt-&gt;alsap);
+                if (err &lt; 0) {
+                        ERRORA(&quot;device [%s], snd_pcm_close failed with error '%s'\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;alsapname, snd_strerror(err));
+                        return -1;
+                }
+        }
+        if (tech_pvt-&gt;alsac) {
+                err = snd_pcm_drop(tech_pvt-&gt;alsac);
+                if (err &lt; 0) {
+                        ERRORA(&quot;device [%s], snd_pcm_drop failed with error '%s'\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;alsacname, snd_strerror(err));
+                        return -1;
+                }
+                err = snd_pcm_close(tech_pvt-&gt;alsac);
+                if (err &lt; 0) {
+                        ERRORA(&quot;device [%s], snd_pcm_close failed with error '%s'\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;alsacname, snd_strerror(err));
+                        return -1;
+                }
+        }
</ins><span class="cx"> 
</span><del>-  return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /*!
</span><span class="lines">@@ -3925,328 +3736,320 @@
</span><span class="cx"> snd_pcm_t *alsa_open_dev(private_t * tech_pvt, snd_pcm_stream_t stream)
</span><span class="cx"> {
</span><span class="cx"> 
</span><del>-  snd_pcm_t *handle = NULL;
-  snd_pcm_hw_params_t *params;
-  snd_pcm_sw_params_t *swparams;
-  snd_pcm_uframes_t buffer_size;
-  int err;
-  size_t n;
-  //snd_pcm_uframes_t xfer_align;
-  unsigned int rate;
-  snd_pcm_uframes_t start_threshold, stop_threshold;
-  snd_pcm_uframes_t period_size = 0;
-  snd_pcm_uframes_t chunk_size = 0;
-  int start_delay = 0;
-  int stop_delay = 0;
-  snd_pcm_state_t state;
-  snd_pcm_info_t *info;
</del><ins>+        snd_pcm_t *handle = NULL;
+        snd_pcm_hw_params_t *params;
+        snd_pcm_sw_params_t *swparams;
+        snd_pcm_uframes_t buffer_size;
+        int err;
+        size_t n;
+        //snd_pcm_uframes_t xfer_align;
+        unsigned int rate;
+        snd_pcm_uframes_t start_threshold, stop_threshold;
+        snd_pcm_uframes_t period_size = 0;
+        snd_pcm_uframes_t chunk_size = 0;
+        int start_delay = 0;
+        int stop_delay = 0;
+        snd_pcm_state_t state;
+        snd_pcm_info_t *info;
</ins><span class="cx"> 
</span><del>-  period_size = tech_pvt-&gt;alsa_period_size;
</del><ins>+        period_size = tech_pvt-&gt;alsa_period_size;
</ins><span class="cx"> 
</span><del>-  snd_pcm_hw_params_alloca(&amp;params);
-  snd_pcm_sw_params_alloca(&amp;swparams);
</del><ins>+        snd_pcm_hw_params_alloca(&amp;params);
+        snd_pcm_sw_params_alloca(&amp;swparams);
</ins><span class="cx"> 
</span><del>-  if (stream == SND_PCM_STREAM_CAPTURE) {
-    err = snd_pcm_open(&amp;handle, tech_pvt-&gt;alsacname, stream, 0 | SND_PCM_NONBLOCK);
-  } else {
-    err = snd_pcm_open(&amp;handle, tech_pvt-&gt;alsapname, stream, 0 | SND_PCM_NONBLOCK);
-  }
-  if (err &lt; 0) {
-    ERRORA
-      (&quot;snd_pcm_open failed with error '%s' on device '%s', if you are using a plughw:n device please change it to be a default:n device (so to allow it to be shared with other concurrent programs), or maybe you are using an ALSA voicemodem and slmodemd&quot;
-       &quot; is running?\n&quot;, SKYPIAX_P_LOG, snd_strerror(err),
-       stream == SND_PCM_STREAM_CAPTURE ? tech_pvt-&gt;alsacname : tech_pvt-&gt;alsapname);
-    return NULL;
-  }
</del><ins>+        if (stream == SND_PCM_STREAM_CAPTURE) {
+                err = snd_pcm_open(&amp;handle, tech_pvt-&gt;alsacname, stream, 0 | SND_PCM_NONBLOCK);
+        } else {
+                err = snd_pcm_open(&amp;handle, tech_pvt-&gt;alsapname, stream, 0 | SND_PCM_NONBLOCK);
+        }
+        if (err &lt; 0) {
+                ERRORA
+                        (&quot;snd_pcm_open failed with error '%s' on device '%s', if you are using a plughw:n device please change it to be a default:n device (so to allow it to be shared with other concurrent programs), or maybe you are using an ALSA voicemodem and slmodemd&quot;
+                         &quot; is running?\n&quot;, SKYPIAX_P_LOG, snd_strerror(err), stream == SND_PCM_STREAM_CAPTURE ? tech_pvt-&gt;alsacname : tech_pvt-&gt;alsapname);
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  snd_pcm_info_alloca(&amp;info);
</del><ins>+        snd_pcm_info_alloca(&amp;info);
</ins><span class="cx"> 
</span><del>-  if ((err = snd_pcm_info(handle, info)) &lt; 0) {
-    ERRORA(&quot;info error: %s&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
</del><ins>+        if ((err = snd_pcm_info(handle, info)) &lt; 0) {
+                ERRORA(&quot;info error: %s&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  err = snd_pcm_nonblock(handle, 1);
-  if (err &lt; 0) {
-    ERRORA(&quot;nonblock setting error: %s&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
</del><ins>+        err = snd_pcm_nonblock(handle, 1);
+        if (err &lt; 0) {
+                ERRORA(&quot;nonblock setting error: %s&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  err = snd_pcm_hw_params_any(handle, params);
-  if (err &lt; 0) {
-    ERRORA(&quot;Broken configuration for this PCM, no configurations available: %s\n&quot;,
-           SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
</del><ins>+        err = snd_pcm_hw_params_any(handle, params);
+        if (err &lt; 0) {
+                ERRORA(&quot;Broken configuration for this PCM, no configurations available: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  err = snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
-  if (err &lt; 0) {
-    ERRORA(&quot;Access type not available: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
-  err = snd_pcm_hw_params_set_format(handle, params, celliax_format);
-  if (err &lt; 0) {
-    ERRORA(&quot;Sample format non available: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
-  err = snd_pcm_hw_params_set_channels(handle, params, 1);
-  if (err &lt; 0) {
-    DEBUGA_SKYPE(&quot;Channels count set failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-  }
</del><ins>+        err = snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
+        if (err &lt; 0) {
+                ERRORA(&quot;Access type not available: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
+        err = snd_pcm_hw_params_set_format(handle, params, celliax_format);
+        if (err &lt; 0) {
+                ERRORA(&quot;Sample format non available: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
+        err = snd_pcm_hw_params_set_channels(handle, params, 1);
+        if (err &lt; 0) {
+                DEBUGA_SKYPE(&quot;Channels count set failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx"> #if 1
</span><del>-  unsigned int chan_num;
-  err = snd_pcm_hw_params_get_channels(params, &amp;chan_num);
-  if (err &lt; 0) {
-    ERRORA(&quot;Channels count non available: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
-  if (chan_num &lt; 1 || chan_num &gt; 2) {
-    ERRORA(&quot;Channels count MUST BE 1 or 2, it is: %d\n&quot;, SKYPIAX_P_LOG, chan_num);
-    ERRORA(&quot;Channels count MUST BE 1 or 2, it is: %d on %s %s\n&quot;, SKYPIAX_P_LOG, chan_num,
-           tech_pvt-&gt;alsapname, tech_pvt-&gt;alsacname);
-    return NULL;
-  } else {
-    if (chan_num == 1) {
-      if (stream == SND_PCM_STREAM_CAPTURE)
-        tech_pvt-&gt;alsa_capture_is_mono = 1;
-      else
-        tech_pvt-&gt;alsa_play_is_mono = 1;
-    } else {
-      if (stream == SND_PCM_STREAM_CAPTURE)
-        tech_pvt-&gt;alsa_capture_is_mono = 0;
-      else
-        tech_pvt-&gt;alsa_play_is_mono = 0;
-    }
-  }
</del><ins>+        unsigned int chan_num;
+        err = snd_pcm_hw_params_get_channels(params, &amp;chan_num);
+        if (err &lt; 0) {
+                ERRORA(&quot;Channels count non available: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
+        if (chan_num &lt; 1 || chan_num &gt; 2) {
+                ERRORA(&quot;Channels count MUST BE 1 or 2, it is: %d\n&quot;, SKYPIAX_P_LOG, chan_num);
+                ERRORA(&quot;Channels count MUST BE 1 or 2, it is: %d on %s %s\n&quot;, SKYPIAX_P_LOG, chan_num, tech_pvt-&gt;alsapname, tech_pvt-&gt;alsacname);
+                return NULL;
+        } else {
+                if (chan_num == 1) {
+                        if (stream == SND_PCM_STREAM_CAPTURE)
+                                tech_pvt-&gt;alsa_capture_is_mono = 1;
+                        else
+                                tech_pvt-&gt;alsa_play_is_mono = 1;
+                } else {
+                        if (stream == SND_PCM_STREAM_CAPTURE)
+                                tech_pvt-&gt;alsa_capture_is_mono = 0;
+                        else
+                                tech_pvt-&gt;alsa_play_is_mono = 0;
+                }
+        }
</ins><span class="cx"> #else
</span><del>-  tech_pvt-&gt;alsa_capture_is_mono = 1;
-  tech_pvt-&gt;alsa_play_is_mono = 1;
</del><ins>+        tech_pvt-&gt;alsa_capture_is_mono = 1;
+        tech_pvt-&gt;alsa_play_is_mono = 1;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if 0
</span><del>-  unsigned int buffer_time = 0;
-  unsigned int period_time = 0;
-  snd_pcm_uframes_t period_frames = 0;
-  snd_pcm_uframes_t buffer_frames = 0;
</del><ins>+        unsigned int buffer_time = 0;
+        unsigned int period_time = 0;
+        snd_pcm_uframes_t period_frames = 0;
+        snd_pcm_uframes_t buffer_frames = 0;
</ins><span class="cx"> 
</span><del>-  if (buffer_time == 0 &amp;&amp; buffer_frames == 0) {
-    err = snd_pcm_hw_params_get_buffer_time_max(params, &amp;buffer_time, 0);
-    assert(err &gt;= 0);
-    if (buffer_time &gt; 500000)
-      buffer_time = 500000;
-  }
-  if (period_time == 0 &amp;&amp; period_frames == 0) {
-    if (buffer_time &gt; 0)
-      period_time = buffer_time / 4;
-    else
-      period_frames = buffer_frames / 4;
-  }
-  if (period_time &gt; 0)
-    err = snd_pcm_hw_params_set_period_time_near(handle, params, &amp;period_time, 0);
-  else
-    err = snd_pcm_hw_params_set_period_size_near(handle, params, &amp;period_frames, 0);
-  assert(err &gt;= 0);
-  if (buffer_time &gt; 0) {
-    err = snd_pcm_hw_params_set_buffer_time_near(handle, params, &amp;buffer_time, 0);
-  } else {
-    err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &amp;buffer_frames);
-  }
</del><ins>+        if (buffer_time == 0 &amp;&amp; buffer_frames == 0) {
+                err = snd_pcm_hw_params_get_buffer_time_max(params, &amp;buffer_time, 0);
+                assert(err &gt;= 0);
+                if (buffer_time &gt; 500000)
+                        buffer_time = 500000;
+        }
+        if (period_time == 0 &amp;&amp; period_frames == 0) {
+                if (buffer_time &gt; 0)
+                        period_time = buffer_time / 4;
+                else
+                        period_frames = buffer_frames / 4;
+        }
+        if (period_time &gt; 0)
+                err = snd_pcm_hw_params_set_period_time_near(handle, params, &amp;period_time, 0);
+        else
+                err = snd_pcm_hw_params_set_period_size_near(handle, params, &amp;period_frames, 0);
+        assert(err &gt;= 0);
+        if (buffer_time &gt; 0) {
+                err = snd_pcm_hw_params_set_buffer_time_near(handle, params, &amp;buffer_time, 0);
+        } else {
+                err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &amp;buffer_frames);
+        }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if 1
</span><del>-  rate = tech_pvt-&gt;celliax_sound_rate;
-  err = snd_pcm_hw_params_set_rate_near(handle, params, &amp;rate, 0);
-  if ((float) tech_pvt-&gt;celliax_sound_rate * 1.05 &lt; rate
-      || (float) tech_pvt-&gt;celliax_sound_rate * 0.95 &gt; rate) {
-    WARNINGA(&quot;Rate is not accurate (requested = %iHz, got = %iHz)\n&quot;, SKYPIAX_P_LOG,
-             tech_pvt-&gt;celliax_sound_rate, rate);
-  }
</del><ins>+        rate = tech_pvt-&gt;celliax_sound_rate;
+        err = snd_pcm_hw_params_set_rate_near(handle, params, &amp;rate, 0);
+        if ((float) tech_pvt-&gt;celliax_sound_rate * 1.05 &lt; rate || (float) tech_pvt-&gt;celliax_sound_rate * 0.95 &gt; rate) {
+                WARNINGA(&quot;Rate is not accurate (requested = %iHz, got = %iHz)\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;celliax_sound_rate, rate);
+        }
</ins><span class="cx"> 
</span><del>-  if (err &lt; 0) {
-    ERRORA(&quot;Error setting rate: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
-  tech_pvt-&gt;celliax_sound_rate = rate;
</del><ins>+        if (err &lt; 0) {
+                ERRORA(&quot;Error setting rate: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
+        tech_pvt-&gt;celliax_sound_rate = rate;
</ins><span class="cx"> 
</span><del>-  err = snd_pcm_hw_params_set_period_size_near(handle, params, &amp;period_size, 0);
</del><ins>+        err = snd_pcm_hw_params_set_period_size_near(handle, params, &amp;period_size, 0);
</ins><span class="cx"> 
</span><del>-  if (err &lt; 0) {
-    ERRORA(&quot;Error setting period_size: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
</del><ins>+        if (err &lt; 0) {
+                ERRORA(&quot;Error setting period_size: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  tech_pvt-&gt;alsa_period_size = period_size;
</del><ins>+        tech_pvt-&gt;alsa_period_size = period_size;
</ins><span class="cx"> 
</span><del>-  tech_pvt-&gt;alsa_buffer_size = tech_pvt-&gt;alsa_period_size * tech_pvt-&gt;alsa_periods_in_buffer;
</del><ins>+        tech_pvt-&gt;alsa_buffer_size = tech_pvt-&gt;alsa_period_size * tech_pvt-&gt;alsa_periods_in_buffer;
</ins><span class="cx"> 
</span><del>-  err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &amp;tech_pvt-&gt;alsa_buffer_size);
</del><ins>+        err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &amp;tech_pvt-&gt;alsa_buffer_size);
</ins><span class="cx"> 
</span><del>-  if (err &lt; 0) {
-    ERRORA(&quot;Error setting buffer_size: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
</del><ins>+        if (err &lt; 0) {
+                ERRORA(&quot;Error setting buffer_size: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-  err = snd_pcm_hw_params(handle, params);
-  if (err &lt; 0) {
-    ERRORA(&quot;Unable to install hw params: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
</del><ins>+        err = snd_pcm_hw_params(handle, params);
+        if (err &lt; 0) {
+                ERRORA(&quot;Unable to install hw params: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  snd_pcm_hw_params_get_period_size(params, &amp;chunk_size, 0);
-  snd_pcm_hw_params_get_buffer_size(params, &amp;buffer_size);
-  if (chunk_size == buffer_size) {
-    ERRORA(&quot;Can't use period equal to buffer size (%lu == %lu)\n&quot;, SKYPIAX_P_LOG,
-           chunk_size, buffer_size);
-    return NULL;
-  }
</del><ins>+        snd_pcm_hw_params_get_period_size(params, &amp;chunk_size, 0);
+        snd_pcm_hw_params_get_buffer_size(params, &amp;buffer_size);
+        if (chunk_size == buffer_size) {
+                ERRORA(&quot;Can't use period equal to buffer size (%lu == %lu)\n&quot;, SKYPIAX_P_LOG, chunk_size, buffer_size);
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  snd_pcm_sw_params_current(handle, swparams);
</del><ins>+        snd_pcm_sw_params_current(handle, swparams);
</ins><span class="cx"> 
</span><span class="cx"> #if 0
</span><del>-  err = snd_pcm_sw_params_get_xfer_align(swparams, &amp;xfer_align);
-  if (err &lt; 0) {
-    ERRORA(&quot;Unable to obtain xfer align: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-  }
-  NOTICA(&quot;xfer_align: %d\n&quot;, SKYPIAX_P_LOG, xfer_align);
-  /* for some reason, on some platforms, xfer_align here is zero, that gives a floating point exception later. So, let's try to force it to 160, the frame size used by celliax */
-  xfer_align = tech_pvt-&gt;alsa_period_size;
-  NOTICA(&quot;xfer_align: %d\n&quot;, SKYPIAX_P_LOG, xfer_align);
</del><ins>+        err = snd_pcm_sw_params_get_xfer_align(swparams, &amp;xfer_align);
+        if (err &lt; 0) {
+                ERRORA(&quot;Unable to obtain xfer align: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+        }
+        NOTICA(&quot;xfer_align: %d\n&quot;, SKYPIAX_P_LOG, xfer_align);
+        /* for some reason, on some platforms, xfer_align here is zero, that gives a floating point exception later. So, let's try to force it to 160, the frame size used by celliax */
+        xfer_align = tech_pvt-&gt;alsa_period_size;
+        NOTICA(&quot;xfer_align: %d\n&quot;, SKYPIAX_P_LOG, xfer_align);
</ins><span class="cx"> 
</span><del>-  err = snd_pcm_sw_params_set_xfer_align(handle, swparams, xfer_align);
-  if (err &lt; 0) {
-    ERRORA(&quot;Error setting xfer_align: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-  }
-  NOTICA(&quot;xfer_align: %d\n&quot;, SKYPIAX_P_LOG, xfer_align);
</del><ins>+        err = snd_pcm_sw_params_set_xfer_align(handle, swparams, xfer_align);
+        if (err &lt; 0) {
+                ERRORA(&quot;Error setting xfer_align: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+        }
+        NOTICA(&quot;xfer_align: %d\n&quot;, SKYPIAX_P_LOG, xfer_align);
</ins><span class="cx"> 
</span><del>-  err = snd_pcm_sw_params_get_xfer_align(swparams, &amp;xfer_align);
-  if (err &lt; 0) {
-    ERRORA(&quot;Unable to obtain xfer align: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-  }
-  NOTICA(&quot;xfer_align: %d\n&quot;, SKYPIAX_P_LOG, xfer_align);
</del><ins>+        err = snd_pcm_sw_params_get_xfer_align(swparams, &amp;xfer_align);
+        if (err &lt; 0) {
+                ERRORA(&quot;Unable to obtain xfer align: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+        }
+        NOTICA(&quot;xfer_align: %d\n&quot;, SKYPIAX_P_LOG, xfer_align);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-  /*
-     if (sleep_min)
-     xfer_align = 1;
-     err = snd_pcm_sw_params_set_sleep_min(handle, swparams,
-     0);
</del><ins>+        /*
+           if (sleep_min)
+           xfer_align = 1;
+           err = snd_pcm_sw_params_set_sleep_min(handle, swparams,
+           0);
</ins><span class="cx"> 
</span><del>-     if (err &lt; 0) {
-     ERRORA(&quot;Error setting slep_min: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-     }
-   */
-  n = chunk_size;
-  err = snd_pcm_sw_params_set_avail_min(handle, swparams, n);
-  if (err &lt; 0) {
-    ERRORA(&quot;Error setting avail_min: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-  }
</del><ins>+           if (err &lt; 0) {
+           ERRORA(&quot;Error setting slep_min: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+           }
+         */
+        n = chunk_size;
+        err = snd_pcm_sw_params_set_avail_min(handle, swparams, n);
+        if (err &lt; 0) {
+                ERRORA(&quot;Error setting avail_min: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx"> #if 0
</span><del>-  /* round up to closest transfer boundary */
-  if (xfer_align == 0) {        //so to avoid floating point exception ????
-    xfer_align = 160;
-  }
-  //original n = (buffer_size / xfer_align) * xfer_align;
-  n = (chunk_size / xfer_align) * xfer_align;
</del><ins>+        /* round up to closest transfer boundary */
+        if (xfer_align == 0) {                //so to avoid floating point exception ????
+                xfer_align = 160;
+        }
+        //original n = (buffer_size / xfer_align) * xfer_align;
+        n = (chunk_size / xfer_align) * xfer_align;
</ins><span class="cx"> #endif
</span><del>-  if (stream == SND_PCM_STREAM_CAPTURE) {
-    start_delay = 1;
-  }
-  if (start_delay &lt;= 0) {
-    start_threshold = n + (double) rate *start_delay / 1000000;
-  } else {
-    start_threshold = (double) rate *start_delay / 1000000;
-  }
-  if (start_threshold &lt; 1)
-    start_threshold = 1;
-  if (start_threshold &gt; n)
-    start_threshold = n;
-  err = snd_pcm_sw_params_set_start_threshold(handle, swparams, start_threshold);
-  if (err &lt; 0) {
-    ERRORA(&quot;Error setting start_threshold: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-  }
</del><ins>+        if (stream == SND_PCM_STREAM_CAPTURE) {
+                start_delay = 1;
+        }
+        if (start_delay &lt;= 0) {
+                start_threshold = n + (double) rate *start_delay / 1000000;
+        } else {
+                start_threshold = (double) rate *start_delay / 1000000;
+        }
+        if (start_threshold &lt; 1)
+                start_threshold = 1;
+        if (start_threshold &gt; n)
+                start_threshold = n;
+        err = snd_pcm_sw_params_set_start_threshold(handle, swparams, start_threshold);
+        if (err &lt; 0) {
+                ERRORA(&quot;Error setting start_threshold: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx"> 
</span><del>-  if (stop_delay &lt;= 0)
-    stop_threshold = buffer_size + (double) rate *stop_delay / 1000000;
-  else
-    stop_threshold = (double) rate *stop_delay / 1000000;
</del><ins>+        if (stop_delay &lt;= 0)
+                stop_threshold = buffer_size + (double) rate *stop_delay / 1000000;
+        else
+                stop_threshold = (double) rate *stop_delay / 1000000;
</ins><span class="cx"> 
</span><del>-  if (stream == SND_PCM_STREAM_CAPTURE) {
-    stop_threshold = -1;
-  }
</del><ins>+        if (stream == SND_PCM_STREAM_CAPTURE) {
+                stop_threshold = -1;
+        }
</ins><span class="cx"> 
</span><del>-  err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold);
</del><ins>+        err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold);
</ins><span class="cx"> 
</span><del>-  if (err &lt; 0) {
-    ERRORA(&quot;Error setting stop_threshold: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-  }
</del><ins>+        if (err &lt; 0) {
+                ERRORA(&quot;Error setting stop_threshold: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx"> #if 0
</span><del>-  err = snd_pcm_sw_params_set_xfer_align(handle, swparams, xfer_align);
</del><ins>+        err = snd_pcm_sw_params_set_xfer_align(handle, swparams, xfer_align);
</ins><span class="cx"> 
</span><del>-  if (err &lt; 0) {
-    ERRORA(&quot;Error setting xfer_align: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-  }
</del><ins>+        if (err &lt; 0) {
+                ERRORA(&quot;Error setting xfer_align: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-  if (snd_pcm_sw_params(handle, swparams) &lt; 0) {
-    ERRORA(&quot;Error installing software parameters: %s\n&quot;, SKYPIAX_P_LOG,
-           snd_strerror(err));
-  }
</del><ins>+        if (snd_pcm_sw_params(handle, swparams) &lt; 0) {
+                ERRORA(&quot;Error installing software parameters: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+        }
</ins><span class="cx"> 
</span><del>-  err = snd_pcm_poll_descriptors_count(handle);
-  if (err &lt;= 0) {
-    ERRORA(&quot;Unable to get a poll descriptors count, error is %s\n&quot;, SKYPIAX_P_LOG,
-           snd_strerror(err));
-    return NULL;
-  }
</del><ins>+        err = snd_pcm_poll_descriptors_count(handle);
+        if (err &lt;= 0) {
+                ERRORA(&quot;Unable to get a poll descriptors count, error is %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  if (err != 1) {               //number of poll descriptors
-    DEBUGA_SKYPE(&quot;Can't handle more than one device\n&quot;, SKYPIAX_P_LOG);
-    return NULL;
-  }
</del><ins>+        if (err != 1) {                                //number of poll descriptors
+                DEBUGA_SKYPE(&quot;Can't handle more than one device\n&quot;, SKYPIAX_P_LOG);
+                return NULL;
+        }
</ins><span class="cx"> 
</span><del>-  err = snd_pcm_poll_descriptors(handle, &amp;tech_pvt-&gt;pfd, err);
-  if (err != 1) {
-    ERRORA(&quot;snd_pcm_poll_descriptors failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    return NULL;
-  }
-  DEBUGA_SKYPE(&quot;Acquired fd %d from the poll descriptor\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;pfd.fd);
</del><ins>+        err = snd_pcm_poll_descriptors(handle, &amp;tech_pvt-&gt;pfd, err);
+        if (err != 1) {
+                ERRORA(&quot;snd_pcm_poll_descriptors failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                return NULL;
+        }
+        DEBUGA_SKYPE(&quot;Acquired fd %d from the poll descriptor\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;pfd.fd);
</ins><span class="cx"> 
</span><del>-  if (stream == SND_PCM_STREAM_CAPTURE) {
-    tech_pvt-&gt;celliax_sound_capt_fd = tech_pvt-&gt;pfd.fd;
-  }
</del><ins>+        if (stream == SND_PCM_STREAM_CAPTURE) {
+                tech_pvt-&gt;celliax_sound_capt_fd = tech_pvt-&gt;pfd.fd;
+        }
</ins><span class="cx"> 
</span><del>-  state = snd_pcm_state(handle);
</del><ins>+        state = snd_pcm_state(handle);
</ins><span class="cx"> 
</span><del>-  if (state != SND_PCM_STATE_RUNNING) {
-    if (state != SND_PCM_STATE_PREPARED) {
-      err = snd_pcm_prepare(handle);
-      if (err) {
-        ERRORA(&quot;snd_pcm_prepare failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-        return NULL;
-      }
-      DEBUGA_SKYPE(&quot;prepared!\n&quot;, SKYPIAX_P_LOG);
-    }
-    if (stream == SND_PCM_STREAM_CAPTURE) {
-      err = snd_pcm_start(handle);
-      if (err) {
-        ERRORA(&quot;snd_pcm_start failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-        return NULL;
-      }
-      DEBUGA_SKYPE(&quot;started!\n&quot;, SKYPIAX_P_LOG);
-    }
-  }
-  if (option_debug &gt; 1) {
-    snd_output_t *output = NULL;
-    err = snd_output_stdio_attach(&amp;output, stdout, 0);
-    if (err &lt; 0) {
-      ERRORA(&quot;snd_output_stdio_attach failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
-    }
-    snd_pcm_dump(handle, output);
-  }
-  if (option_debug &gt; 1)
-    DEBUGA_SKYPE(&quot;ALSA handle = %ld\n&quot;, SKYPIAX_P_LOG, (long int) handle);
-  return handle;
</del><ins>+        if (state != SND_PCM_STATE_RUNNING) {
+                if (state != SND_PCM_STATE_PREPARED) {
+                        err = snd_pcm_prepare(handle);
+                        if (err) {
+                                ERRORA(&quot;snd_pcm_prepare failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                                return NULL;
+                        }
+                        DEBUGA_SKYPE(&quot;prepared!\n&quot;, SKYPIAX_P_LOG);
+                }
+                if (stream == SND_PCM_STREAM_CAPTURE) {
+                        err = snd_pcm_start(handle);
+                        if (err) {
+                                ERRORA(&quot;snd_pcm_start failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                                return NULL;
+                        }
+                        DEBUGA_SKYPE(&quot;started!\n&quot;, SKYPIAX_P_LOG);
+                }
+        }
+        if (option_debug &gt; 1) {
+                snd_output_t *output = NULL;
+                err = snd_output_stdio_attach(&amp;output, stdout, 0);
+                if (err &lt; 0) {
+                        ERRORA(&quot;snd_output_stdio_attach failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(err));
+                }
+                snd_pcm_dump(handle, output);
+        }
+        if (option_debug &gt; 1)
+                DEBUGA_SKYPE(&quot;ALSA handle = %ld\n&quot;, SKYPIAX_P_LOG, (long int) handle);
+        return handle;
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4255,343 +4058,339 @@
</span><span class="cx"> 
</span><span class="cx"> struct ast_frame *alsa_read(private_t * tech_pvt)
</span><span class="cx"> {
</span><del>-  static struct ast_frame f;
-  static short __buf[SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
-  static short __buf2[(SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2];
-  short *buf;
-  short *buf2;
-  static int readpos = 0;
-  static int left = SKYPIAX_FRAME_SIZE;
-  snd_pcm_state_t state;
-  int r = 0;
-  int off = 0;
-  int error = 0;
-  //time_t now_timestamp;
</del><ins>+        static struct ast_frame f;
+        static short __buf[SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
+        static short __buf2[(SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2];
+        short *buf;
+        short *buf2;
+        static int readpos = 0;
+        static int left = SKYPIAX_FRAME_SIZE;
+        snd_pcm_state_t state;
+        int r = 0;
+        int off = 0;
+        int error = 0;
+        //time_t now_timestamp;
</ins><span class="cx"> 
</span><del>-  //memset(&amp;f, 0, sizeof(struct ast_frame)); //giova
</del><ins>+        //memset(&amp;f, 0, sizeof(struct ast_frame)); //giova
</ins><span class="cx"> 
</span><del>-  f.frametype = AST_FRAME_NULL;
-  f.subclass = 0;
-  f.samples = 0;
-  f.datalen = 0;
-  f.data = NULL;
-  f.offset = 0;
-  f.src = celliax_type;
-  f.mallocd = 0;
-  f.delivery.tv_sec = 0;
-  f.delivery.tv_usec = 0;
</del><ins>+        f.frametype = AST_FRAME_NULL;
+        f.subclass = 0;
+        f.samples = 0;
+        f.datalen = 0;
+        f.data = NULL;
+        f.offset = 0;
+        f.src = celliax_type;
+        f.mallocd = 0;
+        f.delivery.tv_sec = 0;
+        f.delivery.tv_usec = 0;
</ins><span class="cx"> 
</span><del>-  state = snd_pcm_state(tech_pvt-&gt;alsac);
-  if (state != SND_PCM_STATE_RUNNING) {
-    DEBUGA_SKYPE(&quot;ALSA read state is not SND_PCM_STATE_RUNNING\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        state = snd_pcm_state(tech_pvt-&gt;alsac);
+        if (state != SND_PCM_STATE_RUNNING) {
+                DEBUGA_SKYPE(&quot;ALSA read state is not SND_PCM_STATE_RUNNING\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-    if (state != SND_PCM_STATE_PREPARED) {
-      error = snd_pcm_prepare(tech_pvt-&gt;alsac);
-      if (error) {
-        ERRORA(&quot;snd_pcm_prepare failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(error));
-        return &amp;f;
-      }
-      DEBUGA_SKYPE(&quot;prepared!\n&quot;, SKYPIAX_P_LOG);
-    }
-    usleep(1000);
-    error = snd_pcm_start(tech_pvt-&gt;alsac);
-    if (error) {
-      ERRORA(&quot;snd_pcm_start failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(error));
-      return &amp;f;
-    }
-    DEBUGA_SKYPE(&quot;started!\n&quot;, SKYPIAX_P_LOG);
-    usleep(1000);
-  }
</del><ins>+                if (state != SND_PCM_STATE_PREPARED) {
+                        error = snd_pcm_prepare(tech_pvt-&gt;alsac);
+                        if (error) {
+                                ERRORA(&quot;snd_pcm_prepare failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(error));
+                                return &amp;f;
+                        }
+                        DEBUGA_SKYPE(&quot;prepared!\n&quot;, SKYPIAX_P_LOG);
+                }
+                usleep(1000);
+                error = snd_pcm_start(tech_pvt-&gt;alsac);
+                if (error) {
+                        ERRORA(&quot;snd_pcm_start failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(error));
+                        return &amp;f;
+                }
+                DEBUGA_SKYPE(&quot;started!\n&quot;, SKYPIAX_P_LOG);
+                usleep(1000);
+        }
</ins><span class="cx"> 
</span><del>-  buf = __buf + AST_FRIENDLY_OFFSET / 2;
-  buf2 = __buf2 + ((AST_FRIENDLY_OFFSET / 2) * 2);
</del><ins>+        buf = __buf + AST_FRIENDLY_OFFSET / 2;
+        buf2 = __buf2 + ((AST_FRIENDLY_OFFSET / 2) * 2);
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;alsa_capture_is_mono) {
-    r = snd_pcm_readi(tech_pvt-&gt;alsac, buf + readpos, left);
-  } else {
-    r = snd_pcm_readi(tech_pvt-&gt;alsac, buf2 + (readpos * 2), left);
</del><ins>+        if (tech_pvt-&gt;alsa_capture_is_mono) {
+                r = snd_pcm_readi(tech_pvt-&gt;alsac, buf + readpos, left);
+        } else {
+                r = snd_pcm_readi(tech_pvt-&gt;alsac, buf2 + (readpos * 2), left);
</ins><span class="cx"> 
</span><del>-    int a = 0;
-    int i = 0;
-    for (i = 0; i &lt; (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2;) {
-      __buf[a] = (__buf2[i] + __buf2[i + 1]) / 2;   //comment out this line to use only left
-      //__buf[a] = __buf2[i]; // enable this line to use only left
-      a++;
-      i++;
-      i++;
-    }
-  }
</del><ins>+                int a = 0;
+                int i = 0;
+                for (i = 0; i &lt; (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2;) {
+                        __buf[a] = (__buf2[i] + __buf2[i + 1]) / 2;        //comment out this line to use only left
+                        //__buf[a] = __buf2[i]; // enable this line to use only left
+                        a++;
+                        i++;
+                        i++;
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (r == -EPIPE) {
-    ERRORA(&quot;XRUN read\n\n\n\n\n&quot;, SKYPIAX_P_LOG);
-    return &amp;f;
-  } else if (r == -ESTRPIPE) {
-    ERRORA(&quot;-ESTRPIPE\n&quot;, SKYPIAX_P_LOG);
-    return &amp;f;
</del><ins>+        if (r == -EPIPE) {
+                ERRORA(&quot;XRUN read\n\n\n\n\n&quot;, SKYPIAX_P_LOG);
+                return &amp;f;
+        } else if (r == -ESTRPIPE) {
+                ERRORA(&quot;-ESTRPIPE\n&quot;, SKYPIAX_P_LOG);
+                return &amp;f;
</ins><span class="cx"> 
</span><del>-  } else if (r == -EAGAIN) {
-    DEBUGA_SKYPE(&quot;ALSA read -EAGAIN, the soundcard is not ready to be read by celliax\n&quot;,
-                 SKYPIAX_P_LOG);
-    while (r == -EAGAIN) {
-      usleep(1000);
</del><ins>+        } else if (r == -EAGAIN) {
+                DEBUGA_SKYPE(&quot;ALSA read -EAGAIN, the soundcard is not ready to be read by celliax\n&quot;, SKYPIAX_P_LOG);
+                while (r == -EAGAIN) {
+                        usleep(1000);
</ins><span class="cx"> 
</span><del>-      if (tech_pvt-&gt;alsa_capture_is_mono) {
-        r = snd_pcm_readi(tech_pvt-&gt;alsac, buf + readpos, left);
-      } else {
-        r = snd_pcm_readi(tech_pvt-&gt;alsac, buf2 + (readpos * 2), left);
</del><ins>+                        if (tech_pvt-&gt;alsa_capture_is_mono) {
+                                r = snd_pcm_readi(tech_pvt-&gt;alsac, buf + readpos, left);
+                        } else {
+                                r = snd_pcm_readi(tech_pvt-&gt;alsac, buf2 + (readpos * 2), left);
</ins><span class="cx"> 
</span><del>-        int a = 0;
-        int i = 0;
-        for (i = 0; i &lt; (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2;) {
-          __buf[a] = (__buf2[i] + __buf2[i + 1]) / 2;
-          a++;
-          i++;
-          i++;
-        }
-      }
</del><ins>+                                int a = 0;
+                                int i = 0;
+                                for (i = 0; i &lt; (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2;) {
+                                        __buf[a] = (__buf2[i] + __buf2[i + 1]) / 2;
+                                        a++;
+                                        i++;
+                                        i++;
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-    }
-  } else if (r &lt; 0) {
-    WARNINGA(&quot;ALSA Read error: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(r));
-  } else if (r &gt;= 0) {
-    //DEBUGA_SKYPE(&quot;read: r=%d, readpos=%d, left=%d, off=%d\n&quot;, SKYPIAX_P_LOG, r, readpos, left, off);
-    off -= r;                   //what is the meaning of this? a leftover, probably
-  }
-  /* Update positions */
-  readpos += r;
-  left -= r;
</del><ins>+                }
+        } else if (r &lt; 0) {
+                WARNINGA(&quot;ALSA Read error: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(r));
+        } else if (r &gt;= 0) {
+                //DEBUGA_SKYPE(&quot;read: r=%d, readpos=%d, left=%d, off=%d\n&quot;, SKYPIAX_P_LOG, r, readpos, left, off);
+                off -= r;                                //what is the meaning of this? a leftover, probably
+        }
+        /* Update positions */
+        readpos += r;
+        left -= r;
</ins><span class="cx"> 
</span><del>-  if (readpos &gt;= SKYPIAX_FRAME_SIZE) {
-    /* A real frame */
-    readpos = 0;
-    left = SKYPIAX_FRAME_SIZE;
</del><ins>+        if (readpos &gt;= SKYPIAX_FRAME_SIZE) {
+                /* A real frame */
+                readpos = 0;
+                left = SKYPIAX_FRAME_SIZE;
</ins><span class="cx"> 
</span><del>-    f.frametype = AST_FRAME_VOICE;
-    f.subclass = AST_FORMAT_SLINEAR;
-    f.samples = SKYPIAX_FRAME_SIZE;
-    f.datalen = SKYPIAX_FRAME_SIZE * 2;
-    f.data = buf;
-    f.offset = AST_FRIENDLY_OFFSET;
-    f.src = celliax_type;
-    f.mallocd = 0;
</del><ins>+                f.frametype = AST_FRAME_VOICE;
+                f.subclass = AST_FORMAT_SLINEAR;
+                f.samples = SKYPIAX_FRAME_SIZE;
+                f.datalen = SKYPIAX_FRAME_SIZE * 2;
+                f.data = buf;
+                f.offset = AST_FRIENDLY_OFFSET;
+                f.src = celliax_type;
+                f.mallocd = 0;
</ins><span class="cx"> #ifdef ALSA_MONITOR
</span><del>-    alsa_monitor_read((char *) buf, SKYPIAX_FRAME_SIZE * 2);
</del><ins>+                alsa_monitor_read((char *) buf, SKYPIAX_FRAME_SIZE * 2);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-  }
-  return &amp;f;
</del><ins>+        }
+        return &amp;f;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /*! \brief Write audio frames to interface */
</span><span class="cx"> int alsa_write(private_t * tech_pvt, struct ast_frame *f)
</span><span class="cx"> {
</span><del>-  static char sizbuf[8000];
-  static char sizbuf2[16000];
-  static char silencebuf[8000];
-  static int sizpos = 0;
-  int len = sizpos;
-  int pos;
-  int res = 0;
-  time_t now_timestamp;
-  /* size_t frames = 0; */
-  snd_pcm_state_t state;
-  snd_pcm_sframes_t delayp1;
-  snd_pcm_sframes_t delayp2;
</del><ins>+        static char sizbuf[8000];
+        static char sizbuf2[16000];
+        static char silencebuf[8000];
+        static int sizpos = 0;
+        int len = sizpos;
+        int pos;
+        int res = 0;
+        time_t now_timestamp;
+        /* size_t frames = 0; */
+        snd_pcm_state_t state;
+        snd_pcm_sframes_t delayp1;
+        snd_pcm_sframes_t delayp2;
</ins><span class="cx"> 
</span><del>-  /* We have to digest the frame in 160-byte portions */
-  if (f-&gt;datalen &gt; sizeof(sizbuf) - sizpos) {
-    ERRORA(&quot;Frame too large\n&quot;, SKYPIAX_P_LOG);
-    res = -1;
-  } else {
-    memcpy(sizbuf + sizpos, f-&gt;data, f-&gt;datalen);
-    len += f-&gt;datalen;
-    pos = 0;
</del><ins>+        /* We have to digest the frame in 160-byte portions */
+        if (f-&gt;datalen &gt; sizeof(sizbuf) - sizpos) {
+                ERRORA(&quot;Frame too large\n&quot;, SKYPIAX_P_LOG);
+                res = -1;
+        } else {
+                memcpy(sizbuf + sizpos, f-&gt;data, f-&gt;datalen);
+                len += f-&gt;datalen;
+                pos = 0;
</ins><span class="cx"> #ifdef ALSA_MONITOR
</span><del>-    alsa_monitor_write(sizbuf, len);
</del><ins>+                alsa_monitor_write(sizbuf, len);
</ins><span class="cx"> #endif
</span><del>-    state = snd_pcm_state(tech_pvt-&gt;alsap);
-    if (state == SND_PCM_STATE_XRUN) {
-      int i;
</del><ins>+                state = snd_pcm_state(tech_pvt-&gt;alsap);
+                if (state == SND_PCM_STATE_XRUN) {
+                        int i;
</ins><span class="cx"> 
</span><del>-      DEBUGA_SKYPE
-        (&quot;You've got an ALSA write XRUN in the past (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file\n&quot;,
-         SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer);
-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      } else {
-        res = snd_pcm_format_set_silence(celliax_format, silencebuf, len / 2);
-        if (res &lt; 0) {
-          DEBUGA_SKYPE(&quot;Silence error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-          res = -1;
-        }
-        for (i = 0; i &lt; (tech_pvt-&gt;alsa_periods_in_buffer - 1); i++) {
-          res = snd_pcm_writei(tech_pvt-&gt;alsap, silencebuf, len / 2);
-          if (res != len / 2) {
-            DEBUGA_SKYPE(&quot;Write returned a different quantity: %d\n&quot;, SKYPIAX_P_LOG, res);
-            res = -1;
-          } else if (res &lt; 0) {
-            DEBUGA_SKYPE(&quot;Write error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-            res = -1;
-          }
-        }
-      }
</del><ins>+                        DEBUGA_SKYPE
+                                (&quot;You've got an ALSA write XRUN in the past (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file\n&quot;,
+                                 SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer);
+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        } else {
+                                res = snd_pcm_format_set_silence(celliax_format, silencebuf, len / 2);
+                                if (res &lt; 0) {
+                                        DEBUGA_SKYPE(&quot;Silence error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                                        res = -1;
+                                }
+                                for (i = 0; i &lt; (tech_pvt-&gt;alsa_periods_in_buffer - 1); i++) {
+                                        res = snd_pcm_writei(tech_pvt-&gt;alsap, silencebuf, len / 2);
+                                        if (res != len / 2) {
+                                                DEBUGA_SKYPE(&quot;Write returned a different quantity: %d\n&quot;, SKYPIAX_P_LOG, res);
+                                                res = -1;
+                                        } else if (res &lt; 0) {
+                                                DEBUGA_SKYPE(&quot;Write error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                                                res = -1;
+                                        }
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-    }
</del><ins>+                }
</ins><span class="cx"> 
</span><del>-    res = snd_pcm_delay(tech_pvt-&gt;alsap, &amp;delayp1);
-    if (res &lt; 0) {
-      DEBUGA_SKYPE(&quot;Error %d on snd_pcm_delay: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG, res,
-                   snd_strerror(res));
-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        DEBUGA_SKYPE(&quot;snd_pcm_prepare failed: '%s'\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      res = snd_pcm_delay(tech_pvt-&gt;alsap, &amp;delayp1);
-    }
</del><ins>+                res = snd_pcm_delay(tech_pvt-&gt;alsap, &amp;delayp1);
+                if (res &lt; 0) {
+                        DEBUGA_SKYPE(&quot;Error %d on snd_pcm_delay: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG, res, snd_strerror(res));
+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;snd_pcm_prepare failed: '%s'\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        res = snd_pcm_delay(tech_pvt-&gt;alsap, &amp;delayp1);
+                }
</ins><span class="cx"> 
</span><del>-    delayp2 = snd_pcm_avail_update(tech_pvt-&gt;alsap);
-    if (delayp2 &lt; 0) {
-      DEBUGA_SKYPE(&quot;Error %d on snd_pcm_avail_update: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG,
-                   (int) delayp2, snd_strerror(delayp2));
</del><ins>+                delayp2 = snd_pcm_avail_update(tech_pvt-&gt;alsap);
+                if (delayp2 &lt; 0) {
+                        DEBUGA_SKYPE(&quot;Error %d on snd_pcm_avail_update: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG, (int) delayp2, snd_strerror(delayp2));
</ins><span class="cx"> 
</span><del>-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        DEBUGA_SKYPE(&quot;snd_pcm_prepare failed: '%s'\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      delayp2 = snd_pcm_avail_update(tech_pvt-&gt;alsap);
-    }
</del><ins>+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;snd_pcm_prepare failed: '%s'\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        delayp2 = snd_pcm_avail_update(tech_pvt-&gt;alsap);
+                }
</ins><span class="cx"> 
</span><del>-    if (                        /* delayp1 != 0 &amp;&amp; delayp1 != 160 */
-         delayp1 &lt; 160 || delayp2 &gt; tech_pvt-&gt;alsa_buffer_size) {
</del><ins>+                if (                                        /* delayp1 != 0 &amp;&amp; delayp1 != 160 */
+                           delayp1 &lt; 160 || delayp2 &gt; tech_pvt-&gt;alsa_buffer_size) {
</ins><span class="cx"> 
</span><del>-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        DEBUGA_SKYPE
-          (&quot;snd_pcm_prepare failed while trying to prevent an ALSA write XRUN: %s, delayp1=%d, delayp2=%d\n&quot;,
-           SKYPIAX_P_LOG, snd_strerror(res), (int) delayp1, (int) delayp2);
-      } else {
</del><ins>+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                DEBUGA_SKYPE
+                                        (&quot;snd_pcm_prepare failed while trying to prevent an ALSA write XRUN: %s, delayp1=%d, delayp2=%d\n&quot;,
+                                         SKYPIAX_P_LOG, snd_strerror(res), (int) delayp1, (int) delayp2);
+                        } else {
</ins><span class="cx"> 
</span><del>-        int i;
-        for (i = 0; i &lt; (tech_pvt-&gt;alsa_periods_in_buffer - 1); i++) {
-          res = snd_pcm_format_set_silence(celliax_format, silencebuf, len / 2);
-          if (res &lt; 0) {
-            DEBUGA_SKYPE(&quot;Silence error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-            res = -1;
-          }
-          res = snd_pcm_writei(tech_pvt-&gt;alsap, silencebuf, len / 2);
-          if (res &lt; 0) {
-            DEBUGA_SKYPE(&quot;Write error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-            res = -1;
-          } else if (res != len / 2) {
-            DEBUGA_SKYPE(&quot;Write returned a different quantity: %d\n&quot;, SKYPIAX_P_LOG, res);
-            res = -1;
-          }
-        }
</del><ins>+                                int i;
+                                for (i = 0; i &lt; (tech_pvt-&gt;alsa_periods_in_buffer - 1); i++) {
+                                        res = snd_pcm_format_set_silence(celliax_format, silencebuf, len / 2);
+                                        if (res &lt; 0) {
+                                                DEBUGA_SKYPE(&quot;Silence error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                                                res = -1;
+                                        }
+                                        res = snd_pcm_writei(tech_pvt-&gt;alsap, silencebuf, len / 2);
+                                        if (res &lt; 0) {
+                                                DEBUGA_SKYPE(&quot;Write error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                                                res = -1;
+                                        } else if (res != len / 2) {
+                                                DEBUGA_SKYPE(&quot;Write returned a different quantity: %d\n&quot;, SKYPIAX_P_LOG, res);
+                                                res = -1;
+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-        DEBUGA_SKYPE
-          (&quot;PREVENTING an ALSA write XRUN (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file. delayp1=%d, delayp2=%d\n&quot;,
-           SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer, (int) delayp1, (int) delayp2);
-      }
</del><ins>+                                DEBUGA_SKYPE
+                                        (&quot;PREVENTING an ALSA write XRUN (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file. delayp1=%d, delayp2=%d\n&quot;,
+                                         SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer, (int) delayp1, (int) delayp2);
+                        }
</ins><span class="cx"> 
</span><del>-    }
</del><ins>+                }
</ins><span class="cx"> 
</span><del>-    memset(sizbuf2, 0, sizeof(sizbuf2));
-    if (tech_pvt-&gt;alsa_play_is_mono) {
-    ERRORA(&quot;data=%p, datalen=%d, sizbuf=%p, len/2=%d\n&quot;, SKYPIAX_P_LOG, (void *)data, datalen, (void *)sizbuf, len/2);
-      res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf, len / 2);
-    } else {
-      int a = 0;
-      int i = 0;
-      for (i = 0; i &lt; 8000;) {
-        sizbuf2[a] = sizbuf[i];
-        a++;
-        i++;
-        sizbuf2[a] = sizbuf[i];
-        a++;
-        i--;
-        sizbuf2[a] = sizbuf[i]; // comment out this line to use only left 
-        a++;
-        i++;
-        sizbuf2[a] = sizbuf[i]; // comment out this line to use only left
-        a++;
-        i++;
-      }
-      res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf2, len);
-    }
-    if (res == -EPIPE) {
-      DEBUGA_SKYPE
-        (&quot;ALSA write EPIPE (XRUN) (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file. delayp1=%d, delayp2=%d\n&quot;,
-         SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer, (int) delayp1, (int) delayp2);
-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      } else {
</del><ins>+                memset(sizbuf2, 0, sizeof(sizbuf2));
+                if (tech_pvt-&gt;alsa_play_is_mono) {
+                        ERRORA(&quot;data=%p, datalen=%d, sizbuf=%p, len/2=%d\n&quot;, SKYPIAX_P_LOG, (void *) data, datalen, (void *) sizbuf, len / 2);
+                        res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf, len / 2);
+                } else {
+                        int a = 0;
+                        int i = 0;
+                        for (i = 0; i &lt; 8000;) {
+                                sizbuf2[a] = sizbuf[i];
+                                a++;
+                                i++;
+                                sizbuf2[a] = sizbuf[i];
+                                a++;
+                                i--;
+                                sizbuf2[a] = sizbuf[i];        // comment out this line to use only left 
+                                a++;
+                                i++;
+                                sizbuf2[a] = sizbuf[i];        // comment out this line to use only left
+                                a++;
+                                i++;
+                        }
+                        res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf2, len);
+                }
+                if (res == -EPIPE) {
+                        DEBUGA_SKYPE
+                                (&quot;ALSA write EPIPE (XRUN) (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file. delayp1=%d, delayp2=%d\n&quot;,
+                                 SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer, (int) delayp1, (int) delayp2);
+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        } else {
</ins><span class="cx"> 
</span><del>-        if (tech_pvt-&gt;alsa_play_is_mono) {
-          res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf, len / 2);
-        } else {
-          int a = 0;
-          int i = 0;
-          for (i = 0; i &lt; 8000;) {
-            sizbuf2[a] = sizbuf[i];
-            a++;
-            i++;
-            sizbuf2[a] = sizbuf[i];
-            a++;
-            i--;
-            sizbuf2[a] = sizbuf[i];
-            a++;
-            i++;
-            sizbuf2[a] = sizbuf[i];
-            a++;
-            i++;
-          }
-          res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf2, len);
-        }
</del><ins>+                                if (tech_pvt-&gt;alsa_play_is_mono) {
+                                        res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf, len / 2);
+                                } else {
+                                        int a = 0;
+                                        int i = 0;
+                                        for (i = 0; i &lt; 8000;) {
+                                                sizbuf2[a] = sizbuf[i];
+                                                a++;
+                                                i++;
+                                                sizbuf2[a] = sizbuf[i];
+                                                a++;
+                                                i--;
+                                                sizbuf2[a] = sizbuf[i];
+                                                a++;
+                                                i++;
+                                                sizbuf2[a] = sizbuf[i];
+                                                a++;
+                                                i++;
+                                        }
+                                        res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf2, len);
+                                }
</ins><span class="cx"> 
</span><del>-      }
</del><ins>+                        }
</ins><span class="cx"> 
</span><del>-    } else {
-      if (res == -ESTRPIPE) {
-        ERRORA(&quot;You've got some big problems\n&quot;, SKYPIAX_P_LOG);
-      } else if (res == -EAGAIN) {
-        res = 0;
-      } else if (res &lt; 0) {
-        ERRORA(&quot;Error %d on audio write: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG, res,
-               snd_strerror(res));
-      }
-    }
-  }
</del><ins>+                } else {
+                        if (res == -ESTRPIPE) {
+                                ERRORA(&quot;You've got some big problems\n&quot;, SKYPIAX_P_LOG);
+                        } else if (res == -EAGAIN) {
+                                res = 0;
+                        } else if (res &lt; 0) {
+                                ERRORA(&quot;Error %d on audio write: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG, res, snd_strerror(res));
+                        }
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;audio_play_reset_period) {
-    time(&amp;now_timestamp);
-    if ((now_timestamp - tech_pvt-&gt;audio_play_reset_timestamp) &gt; tech_pvt-&gt;audio_play_reset_period) {
-      if (option_debug)
-        DEBUGA_SKYPE(&quot;reset audio play\n&quot;, SKYPIAX_P_LOG);
-      res = snd_pcm_wait(tech_pvt-&gt;alsap, 1000);
-      if (res &lt; 0) {
-        ERRORA(&quot;audio play wait failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      res = snd_pcm_drop(tech_pvt-&gt;alsap);
-      if (res) {
-        ERRORA(&quot;audio play drop failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      res = snd_pcm_wait(tech_pvt-&gt;alsap, 1000);
-      if (res &lt; 0) {
-        ERRORA(&quot;audio play wait failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      time(&amp;tech_pvt-&gt;audio_play_reset_timestamp);
-    }
-  }
-  res = 0;
-  if (res &gt; 0)
-    res = 0;
-  return res;
</del><ins>+        if (tech_pvt-&gt;audio_play_reset_period) {
+                time(&amp;now_timestamp);
+                if ((now_timestamp - tech_pvt-&gt;audio_play_reset_timestamp) &gt; tech_pvt-&gt;audio_play_reset_period) {
+                        if (option_debug)
+                                DEBUGA_SKYPE(&quot;reset audio play\n&quot;, SKYPIAX_P_LOG);
+                        res = snd_pcm_wait(tech_pvt-&gt;alsap, 1000);
+                        if (res &lt; 0) {
+                                ERRORA(&quot;audio play wait failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        res = snd_pcm_drop(tech_pvt-&gt;alsap);
+                        if (res) {
+                                ERRORA(&quot;audio play drop failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        res = snd_pcm_wait(tech_pvt-&gt;alsap, 1000);
+                        if (res &lt; 0) {
+                                ERRORA(&quot;audio play wait failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        time(&amp;tech_pvt-&gt;audio_play_reset_timestamp);
+                }
+        }
+        res = 0;
+        if (res &gt; 0)
+                res = 0;
+        return res;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif //NOTDEF
</span><span class="lines">@@ -4610,11 +4409,11 @@
</span><span class="cx">         //celliax_signaling_write(tech_pvt, &quot;SET AEC OFF&quot;);
</span><span class="cx">         //celliax_sleep(10000);
</span><span class="cx"> 
</span><del>-celliax_serial_call(tech_pvt, rdest);
</del><ins>+        celliax_serial_call(tech_pvt, rdest);
</ins><span class="cx">         //sprintf(msg_to_skype, &quot;CALL %s&quot;, rdest);
</span><span class="cx">         //if (celliax_signaling_write(tech_pvt, msg_to_skype) &lt; 0) {
</span><del>-                //ERRORA(&quot;failed to communicate with Skype client, now exit\n&quot;, SKYPIAX_P_LOG);
-                //return -1;
</del><ins>+        //ERRORA(&quot;failed to communicate with Skype client, now exit\n&quot;, SKYPIAX_P_LOG);
+        //return -1;
</ins><span class="cx">         //}
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="lines">@@ -4625,305 +4424,302 @@
</span><span class="cx"> 
</span><span class="cx">         DEBUGA_SKYPE(&quot;DIGIT received: %c\n&quot;, SKYPIAX_P_LOG, digit);
</span><span class="cx">         //celliax_signaling_write(tech_pvt, msg_to_skype);
</span><del>-  if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT &amp;&amp; tech_pvt-&gt;at_send_dtmf[0]) {
-    int res = 0;
-    char at_command[256];
</del><ins>+        if (tech_pvt-&gt;controldevprotocol == PROTOCOL_AT &amp;&amp; tech_pvt-&gt;at_send_dtmf[0]) {
+                int res = 0;
+                char at_command[256];
</ins><span class="cx"> 
</span><del>-    memset(at_command, '\0', 256);
-    sprintf(at_command, &quot;%s=\&quot;%c\&quot;&quot;, tech_pvt-&gt;at_send_dtmf, digit);
-    res = celliax_serial_write_AT_ack(tech_pvt, at_command);
-    if (res) {
-      ERRORA(&quot;senddigit command failed, command used: '%s=\&quot;%c\&quot;', giving up\n&quot;,
-             SKYPIAX_P_LOG, tech_pvt-&gt;at_send_dtmf, digit);
-    }
-  }
</del><ins>+                memset(at_command, '\0', 256);
+                sprintf(at_command, &quot;%s=\&quot;%c\&quot;&quot;, tech_pvt-&gt;at_send_dtmf, digit);
+                res = celliax_serial_write_AT_ack(tech_pvt, at_command);
+                if (res) {
+                        ERRORA(&quot;senddigit command failed, command used: '%s=\&quot;%c\&quot;', giving up\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;at_send_dtmf, digit);
+                }
+        }
</ins><span class="cx"> 
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*! \brief Write audio frames to interface */
</span><del>-int alsa_write(private_t * tech_pvt, short * data, int datalen)
</del><ins>+int alsa_write(private_t * tech_pvt, short *data, int datalen)
</ins><span class="cx"> {
</span><del>-  static char sizbuf[8000];
-  static char sizbuf2[16000];
-  static char silencebuf[8000];
-  static int sizpos = 0;
-  int len = sizpos;
-  int pos;
-  int res = 0;
-  time_t now_timestamp;
-  /* size_t frames = 0; */
-  snd_pcm_state_t state;
-  snd_pcm_sframes_t delayp1;
-  snd_pcm_sframes_t delayp2;
</del><ins>+        static char sizbuf[8000];
+        static char sizbuf2[16000];
+        static char silencebuf[8000];
+        static int sizpos = 0;
+        int len = sizpos;
+        int pos;
+        int res = 0;
+        time_t now_timestamp;
+        /* size_t frames = 0; */
+        snd_pcm_state_t state;
+        snd_pcm_sframes_t delayp1;
+        snd_pcm_sframes_t delayp2;
</ins><span class="cx"> 
</span><del>-    //ERRORA(&quot;data=%p, datalen=%d\n&quot;, SKYPIAX_P_LOG, (void *)data, datalen);
-  /* We have to digest the frame in 160-byte portions */
-  if (datalen &gt; sizeof(sizbuf) - sizpos) {
-    ERRORA(&quot;Frame too large\n&quot;, SKYPIAX_P_LOG);
-    res = -1;
-  } else {
-    memcpy(sizbuf + sizpos, data, datalen);
-    len += datalen;
-    pos = 0;
</del><ins>+        //ERRORA(&quot;data=%p, datalen=%d\n&quot;, SKYPIAX_P_LOG, (void *)data, datalen);
+        /* We have to digest the frame in 160-byte portions */
+        if (datalen &gt; sizeof(sizbuf) - sizpos) {
+                ERRORA(&quot;Frame too large\n&quot;, SKYPIAX_P_LOG);
+                res = -1;
+        } else {
+                memcpy(sizbuf + sizpos, data, datalen);
+                len += datalen;
+                pos = 0;
</ins><span class="cx"> #ifdef ALSA_MONITOR
</span><del>-    alsa_monitor_write(sizbuf, len);
</del><ins>+                alsa_monitor_write(sizbuf, len);
</ins><span class="cx"> #endif
</span><del>-    state = snd_pcm_state(tech_pvt-&gt;alsap);
-    if (state == SND_PCM_STATE_XRUN) {
-      int i;
</del><ins>+                state = snd_pcm_state(tech_pvt-&gt;alsap);
+                if (state == SND_PCM_STATE_XRUN) {
+                        int i;
</ins><span class="cx"> 
</span><del>-      DEBUGA_SKYPE
-        (&quot;You've got an ALSA write XRUN in the past (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file\n&quot;,
-         SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer);
-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      } else {
-        res = snd_pcm_format_set_silence(celliax_format, silencebuf, len / 2);
-        if (res &lt; 0) {
-          DEBUGA_SKYPE(&quot;Silence error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-          res = -1;
-        }
-        for (i = 0; i &lt; (tech_pvt-&gt;alsa_periods_in_buffer - 1); i++) {
-          res = snd_pcm_writei(tech_pvt-&gt;alsap, silencebuf, len / 2);
-          if (res != len / 2) {
-            DEBUGA_SKYPE(&quot;Write returned a different quantity: %d\n&quot;, SKYPIAX_P_LOG, res);
-            res = -1;
-          } else if (res &lt; 0) {
-            DEBUGA_SKYPE(&quot;Write error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-            res = -1;
-          }
-        }
-      }
</del><ins>+                        DEBUGA_SKYPE
+                                (&quot;You've got an ALSA write XRUN in the past (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file\n&quot;,
+                                 SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer);
+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        } else {
+                                res = snd_pcm_format_set_silence(celliax_format, silencebuf, len / 2);
+                                if (res &lt; 0) {
+                                        DEBUGA_SKYPE(&quot;Silence error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                                        res = -1;
+                                }
+                                for (i = 0; i &lt; (tech_pvt-&gt;alsa_periods_in_buffer - 1); i++) {
+                                        res = snd_pcm_writei(tech_pvt-&gt;alsap, silencebuf, len / 2);
+                                        if (res != len / 2) {
+                                                DEBUGA_SKYPE(&quot;Write returned a different quantity: %d\n&quot;, SKYPIAX_P_LOG, res);
+                                                res = -1;
+                                        } else if (res &lt; 0) {
+                                                DEBUGA_SKYPE(&quot;Write error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                                                res = -1;
+                                        }
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-    }
</del><ins>+                }
</ins><span class="cx"> 
</span><del>-    res = snd_pcm_delay(tech_pvt-&gt;alsap, &amp;delayp1);
-    if (res &lt; 0) {
-      DEBUGA_SKYPE(&quot;Error %d on snd_pcm_delay: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG, res,
-                   snd_strerror(res));
-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        DEBUGA_SKYPE(&quot;snd_pcm_prepare failed: '%s'\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      res = snd_pcm_delay(tech_pvt-&gt;alsap, &amp;delayp1);
-    }
</del><ins>+                res = snd_pcm_delay(tech_pvt-&gt;alsap, &amp;delayp1);
+                if (res &lt; 0) {
+                        DEBUGA_SKYPE(&quot;Error %d on snd_pcm_delay: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG, res, snd_strerror(res));
+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;snd_pcm_prepare failed: '%s'\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        res = snd_pcm_delay(tech_pvt-&gt;alsap, &amp;delayp1);
+                }
</ins><span class="cx"> 
</span><del>-    delayp2 = snd_pcm_avail_update(tech_pvt-&gt;alsap);
-    if (delayp2 &lt; 0) {
-      DEBUGA_SKYPE(&quot;Error %d on snd_pcm_avail_update: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG,
-                   (int) delayp2, snd_strerror(delayp2));
</del><ins>+                delayp2 = snd_pcm_avail_update(tech_pvt-&gt;alsap);
+                if (delayp2 &lt; 0) {
+                        DEBUGA_SKYPE(&quot;Error %d on snd_pcm_avail_update: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG, (int) delayp2, snd_strerror(delayp2));
</ins><span class="cx"> 
</span><del>-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        DEBUGA_SKYPE(&quot;snd_pcm_prepare failed: '%s'\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      delayp2 = snd_pcm_avail_update(tech_pvt-&gt;alsap);
-    }
</del><ins>+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                DEBUGA_SKYPE(&quot;snd_pcm_prepare failed: '%s'\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        delayp2 = snd_pcm_avail_update(tech_pvt-&gt;alsap);
+                }
</ins><span class="cx"> 
</span><del>-    if (                        /* delayp1 != 0 &amp;&amp; delayp1 != 160 */
-         delayp1 &lt; 160 || delayp2 &gt; tech_pvt-&gt;alsa_buffer_size) {
</del><ins>+                if (                                        /* delayp1 != 0 &amp;&amp; delayp1 != 160 */
+                           delayp1 &lt; 160 || delayp2 &gt; tech_pvt-&gt;alsa_buffer_size) {
</ins><span class="cx"> 
</span><del>-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        DEBUGA_SKYPE
-          (&quot;snd_pcm_prepare failed while trying to prevent an ALSA write XRUN: %s, delayp1=%d, delayp2=%d\n&quot;,
-           SKYPIAX_P_LOG, snd_strerror(res), (int) delayp1, (int) delayp2);
-      } else {
</del><ins>+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                DEBUGA_SKYPE
+                                        (&quot;snd_pcm_prepare failed while trying to prevent an ALSA write XRUN: %s, delayp1=%d, delayp2=%d\n&quot;,
+                                         SKYPIAX_P_LOG, snd_strerror(res), (int) delayp1, (int) delayp2);
+                        } else {
</ins><span class="cx"> 
</span><del>-        int i;
-        for (i = 0; i &lt; (tech_pvt-&gt;alsa_periods_in_buffer - 1); i++) {
-          res = snd_pcm_format_set_silence(celliax_format, silencebuf, len / 2);
-          if (res &lt; 0) {
-            DEBUGA_SKYPE(&quot;Silence error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-            res = -1;
-          }
-          res = snd_pcm_writei(tech_pvt-&gt;alsap, silencebuf, len / 2);
-          if (res &lt; 0) {
-            DEBUGA_SKYPE(&quot;Write error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-            res = -1;
-          } else if (res != len / 2) {
-            DEBUGA_SKYPE(&quot;Write returned a different quantity: %d\n&quot;, SKYPIAX_P_LOG, res);
-            res = -1;
-          }
-        }
</del><ins>+                                int i;
+                                for (i = 0; i &lt; (tech_pvt-&gt;alsa_periods_in_buffer - 1); i++) {
+                                        res = snd_pcm_format_set_silence(celliax_format, silencebuf, len / 2);
+                                        if (res &lt; 0) {
+                                                DEBUGA_SKYPE(&quot;Silence error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                                                res = -1;
+                                        }
+                                        res = snd_pcm_writei(tech_pvt-&gt;alsap, silencebuf, len / 2);
+                                        if (res &lt; 0) {
+                                                DEBUGA_SKYPE(&quot;Write error %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                                                res = -1;
+                                        } else if (res != len / 2) {
+                                                DEBUGA_SKYPE(&quot;Write returned a different quantity: %d\n&quot;, SKYPIAX_P_LOG, res);
+                                                res = -1;
+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-        DEBUGA_SKYPE
-          (&quot;PREVENTING an ALSA write XRUN (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file. delayp1=%d, delayp2=%d\n&quot;,
-           SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer, (int) delayp1, (int) delayp2);
-      }
</del><ins>+                                DEBUGA_SKYPE
+                                        (&quot;PREVENTING an ALSA write XRUN (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file. delayp1=%d, delayp2=%d\n&quot;,
+                                         SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer, (int) delayp1, (int) delayp2);
+                        }
</ins><span class="cx"> 
</span><del>-    }
</del><ins>+                }
</ins><span class="cx"> 
</span><del>-    memset(sizbuf2, 0, sizeof(sizbuf2));
-    if (tech_pvt-&gt;alsa_play_is_mono) {
-      res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf, len / 2);
-    } else {
-      int a = 0;
-      int i = 0;
-      for (i = 0; i &lt; 8000;) {
-        sizbuf2[a] = sizbuf[i];
-        a++;
-        i++;
-        sizbuf2[a] = sizbuf[i];
-        a++;
-        i--;
-        sizbuf2[a] = sizbuf[i]; // comment out this line to use only left 
-        a++;
-        i++;
-        sizbuf2[a] = sizbuf[i]; // comment out this line to use only left
-        a++;
-        i++;
-      }
-      res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf2, len);
-    }
-    if (res == -EPIPE) {
-      DEBUGA_SKYPE
-        (&quot;ALSA write EPIPE (XRUN) (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file. delayp1=%d, delayp2=%d\n&quot;,
-         SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer, (int) delayp1, (int) delayp2);
-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      } else {
</del><ins>+                memset(sizbuf2, 0, sizeof(sizbuf2));
+                if (tech_pvt-&gt;alsa_play_is_mono) {
+                        res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf, len / 2);
+                } else {
+                        int a = 0;
+                        int i = 0;
+                        for (i = 0; i &lt; 8000;) {
+                                sizbuf2[a] = sizbuf[i];
+                                a++;
+                                i++;
+                                sizbuf2[a] = sizbuf[i];
+                                a++;
+                                i--;
+                                sizbuf2[a] = sizbuf[i];        // comment out this line to use only left 
+                                a++;
+                                i++;
+                                sizbuf2[a] = sizbuf[i];        // comment out this line to use only left
+                                a++;
+                                i++;
+                        }
+                        res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf2, len);
+                }
+                if (res == -EPIPE) {
+                        DEBUGA_SKYPE
+                                (&quot;ALSA write EPIPE (XRUN) (celliax can't fill the soundcard buffer fast enough). If this happens often (not after silence or after a pause in the speech, that's OK), and appear to damage the sound quality, first check if you have some IRQ problem, maybe sharing the soundcard IRQ with a broken or heavy loaded ethernet or graphic card. Then consider to increase the alsa_periods_in_buffer (now is set to %d) for this interface in the config file. delayp1=%d, delayp2=%d\n&quot;,
+                                 SKYPIAX_P_LOG, tech_pvt-&gt;alsa_periods_in_buffer, (int) delayp1, (int) delayp2);
+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        } else {
</ins><span class="cx"> 
</span><del>-        if (tech_pvt-&gt;alsa_play_is_mono) {
-          res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf, len / 2);
-        } else {
-          int a = 0;
-          int i = 0;
-          for (i = 0; i &lt; 8000;) {
-            sizbuf2[a] = sizbuf[i];
-            a++;
-            i++;
-            sizbuf2[a] = sizbuf[i];
-            a++;
-            i--;
-            sizbuf2[a] = sizbuf[i];
-            a++;
-            i++;
-            sizbuf2[a] = sizbuf[i];
-            a++;
-            i++;
-          }
-          res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf2, len);
-        }
</del><ins>+                                if (tech_pvt-&gt;alsa_play_is_mono) {
+                                        res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf, len / 2);
+                                } else {
+                                        int a = 0;
+                                        int i = 0;
+                                        for (i = 0; i &lt; 8000;) {
+                                                sizbuf2[a] = sizbuf[i];
+                                                a++;
+                                                i++;
+                                                sizbuf2[a] = sizbuf[i];
+                                                a++;
+                                                i--;
+                                                sizbuf2[a] = sizbuf[i];
+                                                a++;
+                                                i++;
+                                                sizbuf2[a] = sizbuf[i];
+                                                a++;
+                                                i++;
+                                        }
+                                        res = snd_pcm_writei(tech_pvt-&gt;alsap, sizbuf2, len);
+                                }
</ins><span class="cx"> 
</span><del>-      }
</del><ins>+                        }
</ins><span class="cx"> 
</span><del>-    } else {
-      if (res == -ESTRPIPE) {
-        ERRORA(&quot;You've got some big problems\n&quot;, SKYPIAX_P_LOG);
-      } else if (res == -EAGAIN) {
-        res = 0;
-      } else if (res &lt; 0) {
-        ERRORA(&quot;Error %d on audio write: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG, res,
-               snd_strerror(res));
-      }
-    }
-  }
</del><ins>+                } else {
+                        if (res == -ESTRPIPE) {
+                                ERRORA(&quot;You've got some big problems\n&quot;, SKYPIAX_P_LOG);
+                        } else if (res == -EAGAIN) {
+                                res = 0;
+                        } else if (res &lt; 0) {
+                                ERRORA(&quot;Error %d on audio write: \&quot;%s\&quot;\n&quot;, SKYPIAX_P_LOG, res, snd_strerror(res));
+                        }
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;audio_play_reset_period) {
-    time(&amp;now_timestamp);
-    if ((now_timestamp - tech_pvt-&gt;audio_play_reset_timestamp) &gt; tech_pvt-&gt;audio_play_reset_period) {
-      if (option_debug)
-        DEBUGA_SKYPE(&quot;reset audio play\n&quot;, SKYPIAX_P_LOG);
-      res = snd_pcm_wait(tech_pvt-&gt;alsap, 1000);
-      if (res &lt; 0) {
-        ERRORA(&quot;audio play wait failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      res = snd_pcm_drop(tech_pvt-&gt;alsap);
-      if (res) {
-        ERRORA(&quot;audio play drop failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      res = snd_pcm_prepare(tech_pvt-&gt;alsap);
-      if (res) {
-        ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      res = snd_pcm_wait(tech_pvt-&gt;alsap, 1000);
-      if (res &lt; 0) {
-        ERRORA(&quot;audio play wait failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
-      }
-      time(&amp;tech_pvt-&gt;audio_play_reset_timestamp);
-    }
-  }
-  //res = 0;
-  //if (res &gt; 0)
-    //res = 0;
-  return res;
</del><ins>+        if (tech_pvt-&gt;audio_play_reset_period) {
+                time(&amp;now_timestamp);
+                if ((now_timestamp - tech_pvt-&gt;audio_play_reset_timestamp) &gt; tech_pvt-&gt;audio_play_reset_period) {
+                        if (option_debug)
+                                DEBUGA_SKYPE(&quot;reset audio play\n&quot;, SKYPIAX_P_LOG);
+                        res = snd_pcm_wait(tech_pvt-&gt;alsap, 1000);
+                        if (res &lt; 0) {
+                                ERRORA(&quot;audio play wait failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        res = snd_pcm_drop(tech_pvt-&gt;alsap);
+                        if (res) {
+                                ERRORA(&quot;audio play drop failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        res = snd_pcm_prepare(tech_pvt-&gt;alsap);
+                        if (res) {
+                                ERRORA(&quot;audio play prepare failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        res = snd_pcm_wait(tech_pvt-&gt;alsap, 1000);
+                        if (res &lt; 0) {
+                                ERRORA(&quot;audio play wait failed: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(res));
+                        }
+                        time(&amp;tech_pvt-&gt;audio_play_reset_timestamp);
+                }
+        }
+        //res = 0;
+        //if (res &gt; 0)
+        //res = 0;
+        return res;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #define AST_FRIENDLY_OFFSET 0
</span><del>-int alsa_read(private_t * tech_pvt, short * data, int datalen)
</del><ins>+int alsa_read(private_t * tech_pvt, short *data, int datalen)
</ins><span class="cx"> {
</span><del>-  //static struct ast_frame f;
-  static short __buf[SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
-  static short __buf2[(SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2];
-  short *buf;
-  short *buf2;
-  static int readpos = 0;
-  //static int left = SKYPIAX_FRAME_SIZE;
-  static int left;
-  snd_pcm_state_t state;
-  int r = 0;
-  int off = 0;
-  int error = 0;
-  //time_t now_timestamp;
</del><ins>+        //static struct ast_frame f;
+        static short __buf[SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
+        static short __buf2[(SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2];
+        short *buf;
+        short *buf2;
+        static int readpos = 0;
+        //static int left = SKYPIAX_FRAME_SIZE;
+        static int left;
+        snd_pcm_state_t state;
+        int r = 0;
+        int off = 0;
+        int error = 0;
+        //time_t now_timestamp;
</ins><span class="cx"> 
</span><del>-    //DEBUGA_SKYPE(&quot;buf=%p, datalen=%d, left=%d\n&quot;, SKYPIAX_P_LOG, (void *)buf, datalen, left);
-  //memset(&amp;f, 0, sizeof(struct ast_frame)); //giova
</del><ins>+        //DEBUGA_SKYPE(&quot;buf=%p, datalen=%d, left=%d\n&quot;, SKYPIAX_P_LOG, (void *)buf, datalen, left);
+        //memset(&amp;f, 0, sizeof(struct ast_frame)); //giova
</ins><span class="cx"> 
</span><span class="cx"> #ifdef NOTDEF
</span><del>-  f.frametype = AST_FRAME_NULL;
-  f.subclass = 0;
-  f.samples = 0;
-  f.datalen = 0;
-  f.data = NULL;
-  f.offset = 0;
-  f.src = celliax_type;
-  f.mallocd = 0;
-  f.delivery.tv_sec = 0;
-  f.delivery.tv_usec = 0;
-#endif// NOTDEF
</del><ins>+        f.frametype = AST_FRAME_NULL;
+        f.subclass = 0;
+        f.samples = 0;
+        f.datalen = 0;
+        f.data = NULL;
+        f.offset = 0;
+        f.src = celliax_type;
+        f.mallocd = 0;
+        f.delivery.tv_sec = 0;
+        f.delivery.tv_usec = 0;
+#endif // NOTDEF
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-left = datalen;
</del><ins>+        left = datalen;
</ins><span class="cx"> 
</span><del>-  struct timeval to;
-  fd_set rfds;
-int result;
</del><ins>+        struct timeval to;
+        fd_set rfds;
+        int result;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-    FD_ZERO(&amp;rfds);
-    FD_SET(tech_pvt-&gt;celliax_sound_capt_fd, &amp;rfds);
</del><ins>+        FD_ZERO(&amp;rfds);
+        FD_SET(tech_pvt-&gt;celliax_sound_capt_fd, &amp;rfds);
</ins><span class="cx"> 
</span><del>-    /* Wait for something to happen */
-    to.tv_sec = 0;
-    to.tv_usec = 500000;        /* we select with this timeout because under cygwin we avoid the signal usage, so there is no way to end the thread if it is stuck waiting for select */
-    result = select(tech_pvt-&gt;celliax_sound_capt_fd + 1, &amp;rfds, NULL, NULL, &amp;to);
</del><ins>+        /* Wait for something to happen */
+        to.tv_sec = 0;
+        to.tv_usec = 500000;                /* we select with this timeout because under cygwin we avoid the signal usage, so there is no way to end the thread if it is stuck waiting for select */
+        result = select(tech_pvt-&gt;celliax_sound_capt_fd + 1, &amp;rfds, NULL, NULL, &amp;to);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    /* If there are errors...  */
-    if (result &lt; 0) {
-      if (errno == EINTR) {     /* EINTR is just the select
-                                   being interrupted by a SIGURG, or so */
-        ERRORA(&quot;select returned %d: %s\n&quot;, SKYPIAX_P_LOG, result, strerror(errno));
-        usleep(1000);
-        //continue;
-      } else {
-        ERRORA(&quot;select returned %d: %s\n&quot;, SKYPIAX_P_LOG, result, strerror(errno));
</del><ins>+        /* If there are errors...  */
+        if (result &lt; 0) {
+                if (errno == EINTR) {        /* EINTR is just the select
+                                                                   being interrupted by a SIGURG, or so */
+                        ERRORA(&quot;select returned %d: %s\n&quot;, SKYPIAX_P_LOG, result, strerror(errno));
+                        usleep(1000);
+                        //continue;
+                } else {
+                        ERRORA(&quot;select returned %d: %s\n&quot;, SKYPIAX_P_LOG, result, strerror(errno));
</ins><span class="cx"> //FIXME what to do here? is the interface that failed signaled? which interface we have to disable?
</span><del>-        //return NULL;
-      }
-    }
-    /* If there are no file descriptors changed, just continue  */
</del><ins>+                        //return NULL;
+                }
+        }
+        /* If there are no file descriptors changed, just continue  */
</ins><span class="cx"> 
</span><del>-    if (result == 0) {
-      usleep(10000);              //let's breath
-        ERRORA(&quot;select returned %d: %s\n&quot;, SKYPIAX_P_LOG, result, strerror(errno));
-    }
</del><ins>+        if (result == 0) {
+                usleep(10000);                        //let's breath
+                ERRORA(&quot;select returned %d: %s\n&quot;, SKYPIAX_P_LOG, result, strerror(errno));
+        }
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -4943,111 +4739,108 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-  state = snd_pcm_state(tech_pvt-&gt;alsac);
-  if (state != SND_PCM_STATE_RUNNING) {
-    DEBUGA_SKYPE(&quot;ALSA read state is not SND_PCM_STATE_RUNNING\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        state = snd_pcm_state(tech_pvt-&gt;alsac);
+        if (state != SND_PCM_STATE_RUNNING) {
+                DEBUGA_SKYPE(&quot;ALSA read state is not SND_PCM_STATE_RUNNING\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx"> 
</span><del>-    if (state != SND_PCM_STATE_PREPARED) {
-      error = snd_pcm_prepare(tech_pvt-&gt;alsac);
-      if (error) {
-        ERRORA(&quot;snd_pcm_prepare failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(error));
-        return r;
-      }
-      DEBUGA_SKYPE(&quot;prepared!\n&quot;, SKYPIAX_P_LOG);
-    }
-    usleep(1000);
-    error = snd_pcm_start(tech_pvt-&gt;alsac);
-    if (error) {
-      ERRORA(&quot;snd_pcm_start failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(error));
-      return r;
-    }
-    DEBUGA_SKYPE(&quot;started!\n&quot;, SKYPIAX_P_LOG);
-    usleep(1000);
-  }
</del><ins>+                if (state != SND_PCM_STATE_PREPARED) {
+                        error = snd_pcm_prepare(tech_pvt-&gt;alsac);
+                        if (error) {
+                                ERRORA(&quot;snd_pcm_prepare failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(error));
+                                return r;
+                        }
+                        DEBUGA_SKYPE(&quot;prepared!\n&quot;, SKYPIAX_P_LOG);
+                }
+                usleep(1000);
+                error = snd_pcm_start(tech_pvt-&gt;alsac);
+                if (error) {
+                        ERRORA(&quot;snd_pcm_start failed, %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(error));
+                        return r;
+                }
+                DEBUGA_SKYPE(&quot;started!\n&quot;, SKYPIAX_P_LOG);
+                usleep(1000);
+        }
</ins><span class="cx"> 
</span><del>-  buf = __buf + AST_FRIENDLY_OFFSET / 2;
-  buf2 = __buf2 + ((AST_FRIENDLY_OFFSET / 2) * 2);
</del><ins>+        buf = __buf + AST_FRIENDLY_OFFSET / 2;
+        buf2 = __buf2 + ((AST_FRIENDLY_OFFSET / 2) * 2);
</ins><span class="cx"> 
</span><del>-  if (tech_pvt-&gt;alsa_capture_is_mono) {
-    //DEBUGA_SKYPE(&quot;buf=%p, buf+readpos=%p, datalen=%d, left=%d\n&quot;, SKYPIAX_P_LOG, (void *)buf, (void *)(buf + readpos), datalen, left);
-    r = snd_pcm_readi(tech_pvt-&gt;alsac, buf + readpos, left);
-  } else {
-    r = snd_pcm_readi(tech_pvt-&gt;alsac, buf2 + (readpos * 2), left);
</del><ins>+        if (tech_pvt-&gt;alsa_capture_is_mono) {
+                //DEBUGA_SKYPE(&quot;buf=%p, buf+readpos=%p, datalen=%d, left=%d\n&quot;, SKYPIAX_P_LOG, (void *)buf, (void *)(buf + readpos), datalen, left);
+                r = snd_pcm_readi(tech_pvt-&gt;alsac, buf + readpos, left);
+        } else {
+                r = snd_pcm_readi(tech_pvt-&gt;alsac, buf2 + (readpos * 2), left);
</ins><span class="cx"> 
</span><del>-    int a = 0;
-    int i = 0;
-    for (i = 0; i &lt; (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2;) {
-      __buf[a] = (__buf2[i] + __buf2[i + 1]) / 2;   //comment out this line to use only left
-      //__buf[a] = __buf2[i]; // enable this line to use only left
-      a++;
-      i++;
-      i++;
-    }
-  }
</del><ins>+                int a = 0;
+                int i = 0;
+                for (i = 0; i &lt; (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2;) {
+                        __buf[a] = (__buf2[i] + __buf2[i + 1]) / 2;        //comment out this line to use only left
+                        //__buf[a] = __buf2[i]; // enable this line to use only left
+                        a++;
+                        i++;
+                        i++;
+                }
+        }
</ins><span class="cx"> 
</span><del>-  if (r == -EPIPE) {
-    ERRORA(&quot;XRUN read\n\n\n\n\n&quot;, SKYPIAX_P_LOG);
-    return r;
-  } else if (r == -ESTRPIPE) {
-    ERRORA(&quot;-ESTRPIPE\n&quot;, SKYPIAX_P_LOG);
-    return r;
</del><ins>+        if (r == -EPIPE) {
+                ERRORA(&quot;XRUN read\n\n\n\n\n&quot;, SKYPIAX_P_LOG);
+                return r;
+        } else if (r == -ESTRPIPE) {
+                ERRORA(&quot;-ESTRPIPE\n&quot;, SKYPIAX_P_LOG);
+                return r;
</ins><span class="cx"> 
</span><del>-  } else if (r == -EAGAIN) {
-    DEBUGA_SKYPE(&quot;ALSA read -EAGAIN, the soundcard is not ready to be read by celliax\n&quot;,
-                 SKYPIAX_P_LOG);
-    while (r == -EAGAIN) {
-      usleep(1000);
</del><ins>+        } else if (r == -EAGAIN) {
+                DEBUGA_SKYPE(&quot;ALSA read -EAGAIN, the soundcard is not ready to be read by celliax\n&quot;, SKYPIAX_P_LOG);
+                while (r == -EAGAIN) {
+                        usleep(1000);
</ins><span class="cx"> 
</span><del>-      if (tech_pvt-&gt;alsa_capture_is_mono) {
-        r = snd_pcm_readi(tech_pvt-&gt;alsac, buf + readpos, left);
-      } else {
-        r = snd_pcm_readi(tech_pvt-&gt;alsac, buf2 + (readpos * 2), left);
</del><ins>+                        if (tech_pvt-&gt;alsa_capture_is_mono) {
+                                r = snd_pcm_readi(tech_pvt-&gt;alsac, buf + readpos, left);
+                        } else {
+                                r = snd_pcm_readi(tech_pvt-&gt;alsac, buf2 + (readpos * 2), left);
</ins><span class="cx"> 
</span><del>-        int a = 0;
-        int i = 0;
-        for (i = 0; i &lt; (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2;) {
-          __buf[a] = (__buf2[i] + __buf2[i + 1]) / 2;
-          a++;
-          i++;
-          i++;
-        }
-      }
</del><ins>+                                int a = 0;
+                                int i = 0;
+                                for (i = 0; i &lt; (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2) * 2;) {
+                                        __buf[a] = (__buf2[i] + __buf2[i + 1]) / 2;
+                                        a++;
+                                        i++;
+                                        i++;
+                                }
+                        }
</ins><span class="cx"> 
</span><del>-    }
-  } else if (r &lt; 0) {
-    WARNINGA(&quot;ALSA Read error: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(r));
-  } else if (r &gt;= 0) {
-    //DEBUGA_SKYPE(&quot;read: r=%d, readpos=%d, left=%d, off=%d\n&quot;, SKYPIAX_P_LOG, r, readpos, left, off);
-    off -= r;                   //what is the meaning of this? a leftover, probably
-  }
-  /* Update positions */
-  readpos += r;
-  left -= r;
</del><ins>+                }
+        } else if (r &lt; 0) {
+                WARNINGA(&quot;ALSA Read error: %s\n&quot;, SKYPIAX_P_LOG, snd_strerror(r));
+        } else if (r &gt;= 0) {
+                //DEBUGA_SKYPE(&quot;read: r=%d, readpos=%d, left=%d, off=%d\n&quot;, SKYPIAX_P_LOG, r, readpos, left, off);
+                off -= r;                                //what is the meaning of this? a leftover, probably
+        }
+        /* Update positions */
+        readpos += r;
+        left -= r;
</ins><span class="cx"> 
</span><del>-  if (readpos &gt;= SKYPIAX_FRAME_SIZE) {
-    /* A real frame */
-    readpos = 0;
-    left = SKYPIAX_FRAME_SIZE;
-int i;
-for(i=0; i&lt;r; i++)
-data[i] = buf[i];
</del><ins>+        if (readpos &gt;= SKYPIAX_FRAME_SIZE) {
+                /* A real frame */
+                readpos = 0;
+                left = SKYPIAX_FRAME_SIZE;
+                int i;
+                for (i = 0; i &lt; r; i++)
+                        data[i] = buf[i];
</ins><span class="cx"> 
</span><span class="cx"> #ifdef NOTDEF
</span><del>-    f.frametype = AST_FRAME_VOICE;
-    f.subclass = AST_FORMAT_SLINEAR;
-    f.samples = SKYPIAX_FRAME_SIZE;
-    f.datalen = SKYPIAX_FRAME_SIZE * 2;
-    f.data = buf;
-    f.offset = AST_FRIENDLY_OFFSET;
-    f.src = celliax_type;
-    f.mallocd = 0;
</del><ins>+                f.frametype = AST_FRAME_VOICE;
+                f.subclass = AST_FORMAT_SLINEAR;
+                f.samples = SKYPIAX_FRAME_SIZE;
+                f.datalen = SKYPIAX_FRAME_SIZE * 2;
+                f.data = buf;
+                f.offset = AST_FRIENDLY_OFFSET;
+                f.src = celliax_type;
+                f.mallocd = 0;
</ins><span class="cx"> #ifdef ALSA_MONITOR
</span><del>-    alsa_monitor_read((char *) buf, SKYPIAX_FRAME_SIZE * 2);
</del><ins>+                alsa_monitor_read((char *) buf, SKYPIAX_FRAME_SIZE * 2);
</ins><span class="cx"> #endif
</span><span class="cx"> #endif //NOTDEF
</span><span class="cx"> 
</span><del>-  }
-  return r;
</del><ins>+        }
+        return r;
</ins><span class="cx"> }
</span><del>-
-
</del></span></pre></div>
<a id="freeswitchbranchesgmaruzzmod_celliaxmod_celliaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c (14675 => 14676)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c        2009-08-29 13:15:21 UTC (rev 14675)
+++ freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c        2009-08-29 13:24:59 UTC (rev 14676)
</span><span class="lines">@@ -253,28 +253,26 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-int res;
-                                  res = alsa_init(tech_pvt);
-                                  if (res == -1) {
-                                          ERRORA(&quot;Failed initializing sound device\n&quot;, SKYPIAX_P_LOG);
-                                          /* we failed, free the PVT */
-                                          //if (tmp)
-                                                  //free(tmp);
-                                          //return NULL;
-                                  }
</del><ins>+        int res;
+        res = alsa_init(tech_pvt);
+        if (res == -1) {
+                ERRORA(&quot;Failed initializing sound device\n&quot;, SKYPIAX_P_LOG);
+                /* we failed, free the PVT */
+                //if (tmp)
+                //free(tmp);
+                //return NULL;
+        }
+        //teletone_dtmf_detect_init(&amp;tech_pvt-&gt;dtmf_detect, tech_pvt-&gt;read_codec.implementation-&gt;actual_samples_per_second);
+        teletone_dtmf_detect_init(&amp;tech_pvt-&gt;dtmf_detect, 8000);
</ins><span class="cx"> 
</span><del>-
-
-        //teletone_dtmf_detect_init(&amp;tech_pvt-&gt;dtmf_detect, tech_pvt-&gt;read_codec.implementation-&gt;actual_samples_per_second);
-        teletone_dtmf_detect_init(&amp;tech_pvt-&gt;dtmf_detect, 8000);
-
-        if (switch_core_timer_init(&amp;tech_pvt-&gt;timer, &quot;soft&quot;, 20, tech_pvt-&gt;read_codec.implementation-&gt;samples_per_packet, celliax_module_pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_core_timer_init(&amp;tech_pvt-&gt;timer, &quot;soft&quot;, 20, tech_pvt-&gt;read_codec.implementation-&gt;samples_per_packet, celliax_module_pool) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 ERRORA(&quot;setup timer failed\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-switch_clear_flag(tech_pvt, TFLAG_HANGUP);        
</del><ins>+        switch_clear_flag(tech_pvt, TFLAG_HANGUP);
</ins><span class="cx">         DEBUGA_SKYPE(&quot;celliax_codec SUCCESS\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -479,9 +477,9 @@
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;write_codec);
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                        switch_core_timer_destroy(&amp;tech_pvt-&gt;timer);
</del><ins>+                switch_core_timer_destroy(&amp;tech_pvt-&gt;timer);
</ins><span class="cx"> 
</span><del>-alsa_shutdown(tech_pvt);
</del><ins>+                alsa_shutdown(tech_pvt);
</ins><span class="cx"> 
</span><span class="cx">                 *tech_pvt-&gt;session_uuid_str = '\0';
</span><span class="cx">                 tech_pvt-&gt;interface_state = SKYPIAX_STATE_IDLE;
</span><span class="lines">@@ -635,7 +633,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
</del><ins>+static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t * dtmf)
</ins><span class="cx"> {
</span><span class="cx">         private_t *tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="lines">@@ -670,67 +668,62 @@
</span><span class="cx">         tech_pvt-&gt;read_frame.flags = SFF_NONE;
</span><span class="cx">         *frame = NULL;
</span><span class="cx"> 
</span><del>-                if (switch_test_flag(tech_pvt, TFLAG_HANGUP)) {
</del><ins>+        if (switch_test_flag(tech_pvt, TFLAG_HANGUP)) {
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><del>-                }
</del><ins>+        }
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-int samples;
</del><ins>+        int samples;
</ins><span class="cx"> 
</span><del>-                //if ((samples = snd_pcm_readi(tech_pvt-&gt;alsac, tech_pvt-&gt;read_frame.data, tech_pvt-&gt;read_codec.implementation-&gt;samples_per_packet)) &gt; 0) 
-                if ((samples = alsa_read(tech_pvt, tech_pvt-&gt;read_frame.data, tech_pvt-&gt;read_codec.implementation-&gt;samples_per_packet )) &gt; 0) 
</del><ins>+        //if ((samples = snd_pcm_readi(tech_pvt-&gt;alsac, tech_pvt-&gt;read_frame.data, tech_pvt-&gt;read_codec.implementation-&gt;samples_per_packet)) &gt; 0) 
+        if ((samples = alsa_read(tech_pvt, tech_pvt-&gt;read_frame.data, tech_pvt-&gt;read_codec.implementation-&gt;samples_per_packet)) &gt; 0) {
+                tech_pvt-&gt;read_frame.datalen = samples * 2;
+                tech_pvt-&gt;read_frame.samples = samples;
</ins><span class="cx"> 
</span><ins>+                switch_core_timer_check(&amp;tech_pvt-&gt;timer, SWITCH_TRUE);
+                tech_pvt-&gt;read_frame.timestamp = tech_pvt-&gt;timer.samplecount;
+                *frame = &amp;tech_pvt-&gt;read_frame;
</ins><span class="cx"> 
</span><del>-{
-                        tech_pvt-&gt;read_frame.datalen = samples * 2;
-                        tech_pvt-&gt;read_frame.samples = samples;
</del><ins>+                //status = SWITCH_STATUS_SUCCESS;
+                switch_set_flag(tech_pvt, TFLAG_VOICE);
+        }
</ins><span class="cx"> 
</span><del>-                        switch_core_timer_check(&amp;tech_pvt-&gt;timer, SWITCH_TRUE);
-                        tech_pvt-&gt;read_frame.timestamp = tech_pvt-&gt;timer.samplecount;
-                        *frame = &amp;tech_pvt-&gt;read_frame;
-
-                        //status = SWITCH_STATUS_SUCCESS;
-                        switch_set_flag(tech_pvt, TFLAG_VOICE);
-                }
-
-if(samples != 160)
</del><ins>+        if (samples != 160)
</ins><span class="cx">                 ERRORA(&quot;samples=%d\n&quot;, SKYPIAX_P_LOG, samples);
</span><span class="cx"> 
</span><del>-                //WARNINGA(&quot;samples=%d\n&quot;, SKYPIAX_P_LOG, samples);
</del><ins>+        //WARNINGA(&quot;samples=%d\n&quot;, SKYPIAX_P_LOG, samples);
</ins><span class="cx"> 
</span><span class="cx"> //usleep(17000);
</span><span class="cx"> //usleep(17000);
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-        char digit_str[256];
</del><ins>+        char digit_str[256];
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-            memset(digit_str, 0, sizeof(digit_str));
-                teletone_dtmf_detect(&amp;tech_pvt-&gt;dtmf_detect, tech_pvt-&gt;read_frame.data, tech_pvt-&gt;read_frame.samples);
-                teletone_dtmf_get(&amp;tech_pvt-&gt;dtmf_detect, digit_str, sizeof(digit_str));
</del><ins>+        memset(digit_str, 0, sizeof(digit_str));
+        teletone_dtmf_detect(&amp;tech_pvt-&gt;dtmf_detect, tech_pvt-&gt;read_frame.data, tech_pvt-&gt;read_frame.samples);
+        teletone_dtmf_get(&amp;tech_pvt-&gt;dtmf_detect, digit_str, sizeof(digit_str));
</ins><span class="cx"> 
</span><del>-                if (digit_str[0]) {
-                switch_time_t new_dtmf_timestamp = switch_time_now();
-                if((new_dtmf_timestamp - tech_pvt-&gt;old_dtmf_timestamp) &gt; 350000) { //FIXME: make it configurable
-                        char *p = digit_str;
-                            switch_channel_t *channel = switch_core_session_get_channel(session);
</del><ins>+        if (digit_str[0]) {
+                switch_time_t new_dtmf_timestamp = switch_time_now();
+                if ((new_dtmf_timestamp - tech_pvt-&gt;old_dtmf_timestamp) &gt; 350000) {        //FIXME: make it configurable
+                        char *p = digit_str;
+                        switch_channel_t *channel = switch_core_session_get_channel(session);
</ins><span class="cx"> 
</span><del>-                        while(p &amp;&amp; *p) {
-                            switch_dtmf_t dtmf;
-                            dtmf.digit = *p;
-                            dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
-                            switch_channel_queue_dtmf(channel, &amp;dtmf);
-                            p++;
-                        }
-                        NOTICA(&quot;DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n&quot;, SKYPIAX_P_LOG, digit_str, (unsigned int)new_dtmf_timestamp, (unsigned int)(new_dtmf_timestamp - tech_pvt-&gt;old_dtmf_timestamp));
-                    tech_pvt-&gt;old_dtmf_timestamp = new_dtmf_timestamp;
-                    }
-            }
-
-
-
</del><ins>+                        while (p &amp;&amp; *p) {
+                                switch_dtmf_t dtmf;
+                                dtmf.digit = *p;
+                                dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION;
+                                switch_channel_queue_dtmf(channel, &amp;dtmf);
+                                p++;
+                        }
+                        NOTICA(&quot;DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n&quot;, SKYPIAX_P_LOG, digit_str, (unsigned int) new_dtmf_timestamp,
+                                   (unsigned int) (new_dtmf_timestamp - tech_pvt-&gt;old_dtmf_timestamp));
+                        tech_pvt-&gt;old_dtmf_timestamp = new_dtmf_timestamp;
+                }
+        }
</ins><span class="cx"> #ifdef NOTDEF
</span><span class="cx"> 
</span><span class="cx">         if (!celliax_audio_read(tech_pvt)) {
</span><span class="lines">@@ -766,7 +759,7 @@
</span><span class="cx">                                 switch_swap_linear((*frame)-&gt;data, (int) (*frame)-&gt;datalen / 2);
</span><span class="cx">                         }
</span><span class="cx"> #endif
</span><del>-                //WARNINGA(&quot;HERE\n&quot;, SKYPIAX_P_LOG);
</del><ins>+                        //WARNINGA(&quot;HERE\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -815,23 +808,22 @@
</span><span class="cx"> 
</span><span class="cx">         sent = frame-&gt;datalen;
</span><span class="cx"> 
</span><del>-                //ERRORA(&quot;PLAY \n&quot;, SKYPIAX_P_LOG);
-                    //snd_pcm_writei(tech_pvt-&gt;alsap, (short *) frame-&gt;data, (int) (frame-&gt;datalen / 2));
</del><ins>+        //ERRORA(&quot;PLAY \n&quot;, SKYPIAX_P_LOG);
+        //snd_pcm_writei(tech_pvt-&gt;alsap, (short *) frame-&gt;data, (int) (frame-&gt;datalen / 2));
</ins><span class="cx"> 
</span><del>- sent = alsa_write(tech_pvt, frame-&gt;data, (int) (frame-&gt;datalen));
</del><ins>+        sent = alsa_write(tech_pvt, frame-&gt;data, (int) (frame-&gt;datalen));
</ins><span class="cx"> 
</span><del>-#ifdef NOTDEF //FIXME
</del><ins>+#ifdef NOTDEF                                        //FIXME
</ins><span class="cx"> #ifdef WIN32
</span><span class="cx">         switch_file_write(tech_pvt-&gt;audioskypepipe[1], frame-&gt;data, &amp;sent);
</span><span class="cx"> #else /* WIN32 */
</span><span class="cx">         sent = write(tech_pvt-&gt;audioskypepipe[1], frame-&gt;data, sent);
</span><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> #endif //NOTDEF
</span><del>-        if (sent &amp;&amp; sent != frame-&gt;datalen/2 &amp;&amp; sent != -1) {
</del><ins>+        if (sent &amp;&amp; sent != frame-&gt;datalen / 2 &amp;&amp; sent != -1) {
</ins><span class="cx">                 DEBUGA_SKYPE(&quot;sent %d\n&quot;, SKYPIAX_P_LOG, sent);
</span><span class="cx">         }
</span><del>-
-                //NOTICA(&quot;sent=%d\n&quot;, SKYPIAX_P_LOG, sent);
</del><ins>+        //NOTICA(&quot;sent=%d\n&quot;, SKYPIAX_P_LOG, sent);
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1056,7 +1048,7 @@
</span><span class="cx">  *
</span><span class="cx">  */
</span><span class="cx"> #ifdef NOTDEF
</span><del>-static void *SWITCH_THREAD_FUNC celliax_signaling_thread_func(switch_thread_t * thread, void *obj)
</del><ins>+static void *SWITCH_THREAD_FUNC celliax_signaling_thread_func(switch_thread_t *thread, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         private_t *tech_pvt = obj;
</span><span class="cx">         int res;
</span><span class="lines">@@ -1116,7 +1108,7 @@
</span><span class="cx">         }
</span><span class="cx">         return NULL;
</span><span class="cx"> }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx"> 
</span><span class="cx"> /* BEGIN: Changes heres */
</span><span class="cx"> static switch_status_t load_config(int reload_type)
</span><span class="lines">@@ -1302,8 +1294,7 @@
</span><span class="cx">                         if (name) {
</span><span class="cx">                                 DEBUGA_SKYPE(&quot;name=%s\n&quot;, SKYPIAX_P_LOG, name);
</span><span class="cx">                         }
</span><del>-
-#ifdef NOTDEF 
</del><ins>+#ifdef NOTDEF
</ins><span class="cx"> #ifndef WIN32
</span><span class="cx">                         if (!XInitThreads()) {
</span><span class="cx">                                 ERRORA(&quot;Not initialized XInitThreads!\n&quot;, SKYPIAX_P_LOG);
</span><span class="lines">@@ -1313,7 +1304,7 @@
</span><span class="cx">                         switch_sleep(100);
</span><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> 
</span><del>-#endif// NOTDEF 
</del><ins>+#endif // NOTDEF
</ins><span class="cx">                         if (interface_id &amp;&amp; interface_id &lt; SKYPIAX_MAX_INTERFACES) {
</span><span class="cx">                                 private_t newconf;
</span><span class="cx">                                 switch_threadattr_t *celliax_api_thread_attr = NULL;
</span><span class="lines">@@ -1351,109 +1342,109 @@
</span><span class="cx">                                 globals.SKYPIAX_INTERFACES[interface_id].controldevprotocol = controldevprotocol;
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-        switch_mutex_init(&amp;globals.SKYPIAX_INTERFACES[interface_id].controldev_lock, SWITCH_MUTEX_NESTED, celliax_module_pool);
</del><ins>+                                switch_mutex_init(&amp;globals.SKYPIAX_INTERFACES[interface_id].controldev_lock, SWITCH_MUTEX_NESTED, celliax_module_pool);
</ins><span class="cx"> /*********************/
</span><span class="cx"> #ifdef NOTDEF
</span><del>-  .interface_state = SKYPIAX_STATE_DOWN;
-  .phone_callflow = CALLFLOW_CALL_IDLE;
-  .dsp_silence_threshold = 512;
-  .context = &quot;default&quot;;
-  .language = &quot;en&quot;;
-  .exten = &quot;s&quot;;
-  .controldevice_name = &quot;none&quot;;
-  .controldevfd = 0;
-  .next = NULL;
-  .owner = NULL;
-  .dsp = NULL;
-  .fbus2_outgoing_list = NULL;
-  .seqnumfbus = FBUS2_SEQNUM_MAX;
-  .controldev_thread = AST_PTHREADT_NULL;
-  .arraycounter = 0;
</del><ins>+                                .interface_state = SKYPIAX_STATE_DOWN;
+                                .phone_callflow = CALLFLOW_CALL_IDLE;
+                                .dsp_silence_threshold = 512;
+                                .context = &quot;default&quot;;
+                                .language = &quot;en&quot;;
+                                .exten = &quot;s&quot;;
+                                .controldevice_name = &quot;none&quot;;
+                                .controldevfd = 0;
+                                .next = NULL;
+                                .owner = NULL;
+                                .dsp = NULL;
+                                .fbus2_outgoing_list = NULL;
+                                .seqnumfbus = FBUS2_SEQNUM_MAX;
+                                .controldev_thread = AST_PTHREADT_NULL;
+                                .arraycounter = 0;
</ins><span class="cx"> #ifndef GIOVA48
</span><del>-  .celliax_sound_rate = 8000;
</del><ins>+                                .celliax_sound_rate = 8000;
</ins><span class="cx"> #else // GIOVA48
</span><del>-  .celliax_sound_rate = 48000;
</del><ins>+                                .celliax_sound_rate = 48000;
</ins><span class="cx"> #endif // GIOVA48
</span><del>-  .celliax_sound_capt_fd = -1;
-  .need_acoustic_ring = 0;
-  .celliax_serial_synced_timestamp = 0;
-  .celliax_serial_sync_period = 300;
-  .audio_play_reset_timestamp = 0;
-  .audio_capture_reset_timestamp = 0;
-  .controldevice_speed = B38400;
-  .capture_boost = 0;
-  .playback_boost = 0;
-  .stripmsd = 0;
-  .controldev_dead = 0;
-  .dtmf_inited = 0;
-#endif// NOTDEF
-  //at_dial_pre_number = &quot;AT+CKPD=\&quot;&quot;;
-switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_pre_number, &quot;ATD&quot;);
-  //.at_dial_post_number = &quot;S\&quot;&quot;;
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_post_number , &quot;;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_expect , &quot;OK&quot;);
-  globals.SKYPIAX_INTERFACES[interface_id].at_early_audio = 0;
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_hangup , &quot;ATH&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_hangup_expect , &quot;OK&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_answer , &quot;ATA&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_answer_expect , &quot;OK&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_send_dtmf , &quot;AT+VTS&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_1 , &quot;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_1_expect , &quot;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_2 , &quot;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_2_expect , &quot;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_3 , &quot;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_3_expect , &quot;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_4 , &quot;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_4_expect , &quot;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_5 , &quot;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_5_expect , &quot;&quot;);
-  globals.SKYPIAX_INTERFACES[interface_id].at_after_preinit_pause = 500000;
-  globals.SKYPIAX_INTERFACES[interface_id].at_initial_pause = 500000;
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_1 , &quot;at+cmic=0,9&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_1_expect , &quot;OK&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_2 , &quot;AT+CKPD=\&quot;EEE\&quot;&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_2_expect , &quot;OK&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_3 , &quot;AT+CSSN=1,0&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_3_expect , &quot;OK&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_4 , &quot;at+sidet=0&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_4_expect , &quot;OK&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_5 , &quot;at+clvl=99&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_5_expect , &quot;OK&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_battchg , &quot;AT+CBC&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_battchg_expect , &quot;OK&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_signal , &quot;AT+CSQ&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_signal_expect , &quot;OK&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_idle , &quot;+MCST: 1&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_incoming , &quot;+MCST: 2&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_active , &quot;+CSSI: 7&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_failed , &quot;+MCST: 65&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_calling , &quot;+CSSI: 1&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_noservice_string , &quot;CIEV: 2;0&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nosignal_string , &quot;CIEV: 5;0&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_lowsignal_string , &quot;CIEV: 5;1&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_lowbattchg_string , &quot;CIEV: 0;1&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nobattchg_string , &quot;CIEV: 0;0&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callactive_string , &quot;CIEV: 3;1&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nocallactive_string , &quot;CIEV: 3;0&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nocallsetup_string , &quot;CIEV: 6;0&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupincoming_string , &quot;CIEV: 6;1&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupoutgoing_string , &quot;CIEV: 6;2&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupremoteringing_string , &quot;CIEV: 6;3&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].sms_receiving_program , &quot;/usr/local/bin/ciapalo&quot;);
-  globals.SKYPIAX_INTERFACES[interface_id].at_has_clcc = 0;
-  globals.SKYPIAX_INTERFACES[interface_id].at_has_ecam = 0;
</del><ins>+                                .celliax_sound_capt_fd = -1;
+                                .need_acoustic_ring = 0;
+                                .celliax_serial_synced_timestamp = 0;
+                                .celliax_serial_sync_period = 300;
+                                .audio_play_reset_timestamp = 0;
+                                .audio_capture_reset_timestamp = 0;
+                                .controldevice_speed = B38400;
+                                .capture_boost = 0;
+                                .playback_boost = 0;
+                                .stripmsd = 0;
+                                .controldev_dead = 0;
+                                .dtmf_inited = 0;
+#endif // NOTDEF
+                                //at_dial_pre_number = &quot;AT+CKPD=\&quot;&quot;;
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_pre_number, &quot;ATD&quot;);
+                                //.at_dial_post_number = &quot;S\&quot;&quot;;
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_post_number, &quot;;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_dial_expect, &quot;OK&quot;);
+                                globals.SKYPIAX_INTERFACES[interface_id].at_early_audio = 0;
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_hangup, &quot;ATH&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_hangup_expect, &quot;OK&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_answer, &quot;ATA&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_answer_expect, &quot;OK&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_send_dtmf, &quot;AT+VTS&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_1, &quot;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_1_expect, &quot;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_2, &quot;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_2_expect, &quot;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_3, &quot;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_3_expect, &quot;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_4, &quot;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_4_expect, &quot;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_5, &quot;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_preinit_5_expect, &quot;&quot;);
+                                globals.SKYPIAX_INTERFACES[interface_id].at_after_preinit_pause = 500000;
+                                globals.SKYPIAX_INTERFACES[interface_id].at_initial_pause = 500000;
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_1, &quot;at+cmic=0,9&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_1_expect, &quot;OK&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_2, &quot;AT+CKPD=\&quot;EEE\&quot;&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_2_expect, &quot;OK&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_3, &quot;AT+CSSN=1,0&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_3_expect, &quot;OK&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_4, &quot;at+sidet=0&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_4_expect, &quot;OK&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_5, &quot;at+clvl=99&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_postinit_5_expect, &quot;OK&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_battchg, &quot;AT+CBC&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_battchg_expect, &quot;OK&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_signal, &quot;AT+CSQ&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_query_signal_expect, &quot;OK&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_idle, &quot;+MCST: 1&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_incoming, &quot;+MCST: 2&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_active, &quot;+CSSI: 7&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_failed, &quot;+MCST: 65&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_call_calling, &quot;+CSSI: 1&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_noservice_string, &quot;CIEV: 2;0&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nosignal_string, &quot;CIEV: 5;0&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_lowsignal_string, &quot;CIEV: 5;1&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_lowbattchg_string, &quot;CIEV: 0;1&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nobattchg_string, &quot;CIEV: 0;0&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callactive_string, &quot;CIEV: 3;1&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nocallactive_string, &quot;CIEV: 3;0&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_nocallsetup_string, &quot;CIEV: 6;0&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupincoming_string, &quot;CIEV: 6;1&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupoutgoing_string, &quot;CIEV: 6;2&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].at_indicator_callsetupremoteringing_string, &quot;CIEV: 6;3&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].sms_receiving_program, &quot;/usr/local/bin/ciapalo&quot;);
+                                globals.SKYPIAX_INTERFACES[interface_id].at_has_clcc = 0;
+                                globals.SKYPIAX_INTERFACES[interface_id].at_has_ecam = 0;
</ins><span class="cx"> 
</span><del>-  globals.SKYPIAX_INTERFACES[interface_id].alsa_period_size = 160;
-  globals.SKYPIAX_INTERFACES[interface_id].alsa_periods_in_buffer = 4;
-  globals.SKYPIAX_INTERFACES[interface_id].celliax_sound_rate = 8000;
</del><ins>+                                globals.SKYPIAX_INTERFACES[interface_id].alsa_period_size = 160;
+                                globals.SKYPIAX_INTERFACES[interface_id].alsa_periods_in_buffer = 4;
+                                globals.SKYPIAX_INTERFACES[interface_id].celliax_sound_rate = 8000;
</ins><span class="cx"> 
</span><del>-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].alsacname , &quot;plughw:1&quot;);
-  switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].alsapname , &quot;plughw:1&quot;);
</del><ins>+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].alsacname, &quot;plughw:1&quot;);
+                                switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].alsapname, &quot;plughw:1&quot;);
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-  globals.SKYPIAX_INTERFACES[interface_id].alsa_play_is_mono = 1;
-  globals.SKYPIAX_INTERFACES[interface_id].alsa_capture_is_mono = 1;
</del><ins>+                                globals.SKYPIAX_INTERFACES[interface_id].alsa_play_is_mono = 1;
+                                globals.SKYPIAX_INTERFACES[interface_id].alsa_capture_is_mono = 1;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1486,54 +1477,57 @@
</span><span class="cx">                                          SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
</span><span class="cx">                                 WARNINGA(&quot;STARTING interface_id=%d\n&quot;, SKYPIAX_P_LOG, interface_id);
</span><span class="cx"> 
</span><del>-                                int res=0;
</del><ins>+                                int res = 0;
</ins><span class="cx"> 
</span><del>-  /* init the serial port */
-  if (globals.SKYPIAX_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
-    globals.SKYPIAX_INTERFACES[interface_id].controldevfd = celliax_serial_init(&amp;globals.SKYPIAX_INTERFACES[interface_id], globals.SKYPIAX_INTERFACES[interface_id].controldevice_speed);
-    if (globals.SKYPIAX_INTERFACES[interface_id].controldevfd &lt; 1) {
-      ERRORA(&quot;celliax_serial_init failed\n&quot;, SKYPIAX_P_LOG);
-      //celliax_sound_shutdown(tmp);
-      //if (tmp)
-        //free(tmp);
-      //return NULL;
-    }
-  }
</del><ins>+                                /* init the serial port */
+                                if (globals.SKYPIAX_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
+                                        globals.SKYPIAX_INTERFACES[interface_id].controldevfd =
+                                                celliax_serial_init(&amp;globals.SKYPIAX_INTERFACES[interface_id], globals.SKYPIAX_INTERFACES[interface_id].controldevice_speed);
+                                        if (globals.SKYPIAX_INTERFACES[interface_id].controldevfd &lt; 1) {
+                                                ERRORA(&quot;celliax_serial_init failed\n&quot;, SKYPIAX_P_LOG);
+                                                //celliax_sound_shutdown(tmp);
+                                                //if (tmp)
+                                                //free(tmp);
+                                                //return NULL;
+                                        }
+                                }
</ins><span class="cx"> 
</span><del>-  /* config the phone/modem on the serial port */
-  if (globals.SKYPIAX_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
-    //int res;
-    res = celliax_serial_config(&amp;globals.SKYPIAX_INTERFACES[interface_id]);
-    if (res) {
-      ERRORA(&quot;celliax_serial_config failed\n&quot;, SKYPIAX_P_LOG);
-      //celliax_sound_shutdown(tmp);
-      //if (tmp)
-        //free(tmp);
-      //return NULL;
-    }
-  }
</del><ins>+                                /* config the phone/modem on the serial port */
+                                if (globals.SKYPIAX_INTERFACES[interface_id].controldevprotocol != PROTOCOL_NO_SERIAL) {
+                                        //int res;
+                                        res = celliax_serial_config(&amp;globals.SKYPIAX_INTERFACES[interface_id]);
+                                        if (res) {
+                                                ERRORA(&quot;celliax_serial_config failed\n&quot;, SKYPIAX_P_LOG);
+                                                //celliax_sound_shutdown(tmp);
+                                                //if (tmp)
+                                                //free(tmp);
+                                                //return NULL;
+                                        }
+                                }
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">                                 switch_sleep(100000);
</span><span class="cx">                                 switch_threadattr_create(&amp;celliax_api_thread_attr, celliax_module_pool);
</span><span class="cx">                                 switch_threadattr_stacksize_set(celliax_api_thread_attr, SWITCH_THREAD_STACKSIZE);
</span><del>-                                switch_thread_create(&amp;globals.SKYPIAX_INTERFACES[interface_id].celliax_api_thread, celliax_api_thread_attr, celliax_do_skypeapi_thread, &amp;globals.SKYPIAX_INTERFACES[interface_id], celliax_module_pool);
</del><ins>+                                switch_thread_create(&amp;globals.SKYPIAX_INTERFACES[interface_id].celliax_api_thread, celliax_api_thread_attr, celliax_do_skypeapi_thread,
+                                                                         &amp;globals.SKYPIAX_INTERFACES[interface_id], celliax_module_pool);
</ins><span class="cx"> 
</span><span class="cx">                                 switch_sleep(100000);
</span><span class="cx"> 
</span><del>-#ifdef NOTDEF 
-                                  res = alsa_init(&amp;globals.SKYPIAX_INTERFACES[interface_id]);
-                                  if (res == -1) {
-                                          ERRORA(&quot;Failed initializing sound device\n&quot;, SKYPIAX_P_LOG);
-                                          /* we failed, free the PVT */
-                                          //if (tmp)
-                                                  //free(tmp);
-                                          //return NULL;
-                                  }
</del><ins>+#ifdef NOTDEF
+                                res = alsa_init(&amp;globals.SKYPIAX_INTERFACES[interface_id]);
+                                if (res == -1) {
+                                        ERRORA(&quot;Failed initializing sound device\n&quot;, SKYPIAX_P_LOG);
+                                        /* we failed, free the PVT */
+                                        //if (tmp)
+                                        //free(tmp);
+                                        //return NULL;
+                                }
</ins><span class="cx"> 
</span><span class="cx">                                 switch_threadattr_create(&amp;celliax_signaling_thread_attr, celliax_module_pool);
</span><span class="cx">                                 switch_threadattr_stacksize_set(celliax_signaling_thread_attr, SWITCH_THREAD_STACKSIZE);
</span><del>-                                switch_thread_create(&amp;globals.SKYPIAX_INTERFACES[interface_id].celliax_signaling_thread, celliax_signaling_thread_attr, celliax_signaling_thread_func, &amp;globals.SKYPIAX_INTERFACES[interface_id], celliax_module_pool);
</del><ins>+                                switch_thread_create(&amp;globals.SKYPIAX_INTERFACES[interface_id].celliax_signaling_thread, celliax_signaling_thread_attr,
+                                                                         celliax_signaling_thread_func, &amp;globals.SKYPIAX_INTERFACES[interface_id], celliax_module_pool);
</ins><span class="cx"> 
</span><span class="cx">                                 switch_sleep(100000);
</span><span class="cx"> 
</span><span class="lines">@@ -1582,7 +1576,7 @@
</span><span class="cx">                                         switch_xml_free(xml);
</span><span class="cx">                                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                                 }
</span><del>-#endif// NOTDEF 
</del><ins>+#endif // NOTDEF
</ins><span class="cx"> 
</span><span class="cx">                         } else {
</span><span class="cx">                                 ERRORA(&quot;interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n&quot;, SKYPIAX_P_LOG, interface_id, SKYPIAX_MAX_INTERFACES);
</span><span class="lines">@@ -1667,7 +1661,6 @@
</span><span class="cx">                                 howmany = write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], &quot;sciutati&quot;, howmany);
</span><span class="cx"> #endif /* WIN32 */
</span><span class="cx">                         }
</span><del>-
</del><span class="cx"> #ifdef NOTDEF
</span><span class="cx">                         if (globals.SKYPIAX_INTERFACES[interface_id].celliax_api_thread) {
</span><span class="cx"> #ifdef WIN32
</span><span class="lines">@@ -1690,7 +1683,7 @@
</span><span class="cx">                                 XSync(tech_pvt-&gt;SkypiaxHandles.disp, False);
</span><span class="cx"> #endif
</span><span class="cx">                         }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx">                         x = 10;
</span><span class="cx">                         while (x) {                        //FIXME 0.5 seconds?
</span><span class="cx">                                 x--;
</span><span class="lines">@@ -1730,18 +1723,18 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #ifdef NOTDEF
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_tcp_srv_thread(switch_thread_t * thread, void *obj)
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_tcp_srv_thread(switch_thread_t *thread, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         return celliax_do_tcp_srv_thread_func(obj);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_tcp_cli_thread(switch_thread_t * thread, void *obj)
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_tcp_cli_thread(switch_thread_t *thread, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         return celliax_do_tcp_cli_thread_func(obj);
</span><span class="cx"> }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx"> 
</span><del>-void *SWITCH_THREAD_FUNC celliax_do_skypeapi_thread(switch_thread_t * thread, void *obj)
</del><ins>+void *SWITCH_THREAD_FUNC celliax_do_skypeapi_thread(switch_thread_t *thread, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         return celliax_do_skypeapi_thread_func(obj);
</span><span class="cx"> }
</span><span class="lines">@@ -1810,7 +1803,7 @@
</span><span class="cx"> 
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx"> 
</span><span class="cx"> int new_inbound_channel(private_t * tech_pvt)
</span><span class="cx"> {
</span><span class="lines">@@ -1941,8 +1934,8 @@
</span><span class="cx">         }
</span><span class="cx">         if (channel) {
</span><span class="cx">                 switch_channel_mark_answered(channel);
</span><del>-tech_pvt-&gt;phone_callflow = SKYPIAX_STATE_UP;
-tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
</del><ins>+                tech_pvt-&gt;phone_callflow = SKYPIAX_STATE_UP;
+                tech_pvt-&gt;interface_state = SKYPIAX_STATE_UP;
</ins><span class="cx">                 //DEBUGA_SKYPE(&quot;skype_call: %s, answered\n&quot;, SKYPIAX_P_LOG, id);
</span><span class="cx">         } else {
</span><span class="cx">                 ERRORA(&quot;No channel???\n&quot;, SKYPIAX_P_LOG);
</span><span class="lines">@@ -2062,8 +2055,7 @@
</span><span class="cx">                                 if (strlen(globals.SKYPIAX_INTERFACES[i].name)
</span><span class="cx">                                         &amp;&amp; (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[1], strlen(argv[1])) == 0)) {
</span><span class="cx">                                         globals.sk_console = &amp;globals.SKYPIAX_INTERFACES[i];
</span><del>-                                        stream-&gt;write_function(stream,
-                                                                                   &quot;sk console is now: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;, i, globals.SKYPIAX_INTERFACES[i].name);
</del><ins>+                                        stream-&gt;write_function(stream, &quot;sk console is now: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n&quot;, i, globals.SKYPIAX_INTERFACES[i].name);
</ins><span class="cx">                                         stream-&gt;write_function(stream, &quot;sk console is: |||%s|||\n&quot;, globals.sk_console-&gt;name);
</span><span class="cx">                                         found = 1;
</span><span class="cx">                                         break;
</span><span class="lines">@@ -2190,8 +2182,7 @@
</span><span class="cx">                                 found = 1;
</span><span class="cx">                                 DEBUGA_SKYPE
</span><span class="cx">                                         (&quot;FOUND  (name=%s, giovatech-&gt;interface_state=%d != SKYPIAX_STATE_DOWN) &amp;&amp; (giovatech-&gt;skype_user=%s == tech_pvt-&gt;skype_user=%s) &amp;&amp; (giovatech-&gt;callid_number=%s == value=%s)\n&quot;,
</span><del>-                                         SKYPIAX_P_LOG, giovatech-&gt;name, giovatech-&gt;interface_state,
-                                         giovatech-&gt;skype_user, tech_pvt-&gt;skype_user, giovatech-&gt;callid_number, value)
</del><ins>+                                         SKYPIAX_P_LOG, giovatech-&gt;name, giovatech-&gt;interface_state, giovatech-&gt;skype_user, tech_pvt-&gt;skype_user, giovatech-&gt;callid_number, value)
</ins><span class="cx">                                         if (tech_pvt-&gt;interface_state == SKYPIAX_STATE_PRERING) {
</span><span class="cx">                                         tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
</span><span class="cx">                                 } else if (tech_pvt-&gt;interface_state != 0 &amp;&amp; tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN) {
</span><span class="lines">@@ -2245,7 +2236,7 @@
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><del>-#endif// NOTDEF
</del><ins>+#endif // NOTDEF
</ins><span class="cx"> int celliax_transfer(private_t * tech_pvt, char *id, char *value)
</span><span class="cx"> {
</span><span class="cx">         char msg_to_skype[1024];
</span><span class="lines">@@ -2267,8 +2258,7 @@
</span><span class="cx">                                 found = 1;
</span><span class="cx">                                 DEBUGA_SKYPE
</span><span class="cx">                                         (&quot;FOUND  (name=%s, giovatech-&gt;interface_state=%d != SKYPIAX_STATE_DOWN) &amp;&amp; (giovatech-&gt;skype_user=%s == tech_pvt-&gt;skype_user=%s) &amp;&amp; (giovatech-&gt;callid_number=%s == value=%s)\n&quot;,
</span><del>-                                         SKYPIAX_P_LOG, giovatech-&gt;name, giovatech-&gt;interface_state,
-                                         giovatech-&gt;skype_user, tech_pvt-&gt;skype_user, giovatech-&gt;callid_number, value)
</del><ins>+                                         SKYPIAX_P_LOG, giovatech-&gt;name, giovatech-&gt;interface_state, giovatech-&gt;skype_user, tech_pvt-&gt;skype_user, giovatech-&gt;callid_number, value)
</ins><span class="cx">                                         break;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -2376,28 +2366,26 @@
</span><span class="cx">                         int res;
</span><span class="cx">                         //celliax_sleep(1000000); //1 sec
</span><span class="cx">                         //DEBUGA_SKYPE(&quot;ciao!\n&quot;, SKYPIAX_P_LOG);
</span><del>-                        res=celliax_serial_read(tech_pvt);
-            if (res == -1) {    //manage the graceful interface shutdown
-              tech_pvt-&gt;controldev_dead = 1;
-              close(tech_pvt-&gt;controldevfd);
-              ERRORA(&quot;celliax_serial_monitor failed, declaring %s dead\n&quot;, SKYPIAX_P_LOG,
-                     tech_pvt-&gt;controldevice_name);
-            } else if (tech_pvt-&gt;controldevprotocol != PROTOCOL_NO_SERIAL
-                       &amp;&amp; tech_pvt-&gt;interface_state == SKYPIAX_STATE_RING) {
-                WARNINGA(&quot;INCOMING RING, let's take the incoming call\n&quot;, SKYPIAX_P_LOG);
</del><ins>+                        res = celliax_serial_read(tech_pvt);
+                        if (res == -1) {        //manage the graceful interface shutdown
+                                tech_pvt-&gt;controldev_dead = 1;
+                                close(tech_pvt-&gt;controldevfd);
+                                ERRORA(&quot;celliax_serial_monitor failed, declaring %s dead\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;controldevice_name);
+                        } else if (tech_pvt-&gt;controldevprotocol != PROTOCOL_NO_SERIAL &amp;&amp; tech_pvt-&gt;interface_state == SKYPIAX_STATE_RING) {
+                                WARNINGA(&quot;INCOMING RING, let's take the incoming call\n&quot;, SKYPIAX_P_LOG);
</ins><span class="cx">                                 celliax_answer(tech_pvt);
</span><span class="cx">                                 //new_inbound_channel(tech_pvt);
</span><del>-              //FIXME if (!celliax_new(p, AST_STATE_RING, tech_pvt-&gt;context)) {
-                //FIXME ERRORA(&quot;celliax_new failed! BAD BAD BAD\n&quot;, CELLIAX_P_LOG);
-              //FIXME }
-            } else if (tech_pvt-&gt;interface_state == CALLFLOW_CALL_REMOTEANSWER) {
-                WARNINGA(&quot;REMOTE PARTY ANSWERED\n&quot;, SKYPIAX_P_LOG);
-outbound_channel_answered(tech_pvt);
</del><ins>+                                //FIXME if (!celliax_new(p, AST_STATE_RING, tech_pvt-&gt;context)) {
+                                //FIXME ERRORA(&quot;celliax_new failed! BAD BAD BAD\n&quot;, CELLIAX_P_LOG);
+                                //FIXME }
+                        } else if (tech_pvt-&gt;interface_state == CALLFLOW_CALL_REMOTEANSWER) {
+                                WARNINGA(&quot;REMOTE PARTY ANSWERED\n&quot;, SKYPIAX_P_LOG);
+                                outbound_channel_answered(tech_pvt);
</ins><span class="cx">                                 //new_inbound_channel(tech_pvt);
</span><del>-              //FIXME if (!celliax_new(p, AST_STATE_RING, tech_pvt-&gt;context)) {
-                //FIXME ERRORA(&quot;celliax_new failed! BAD BAD BAD\n&quot;, CELLIAX_P_LOG);
-              //FIXME }
-            }
</del><ins>+                                //FIXME if (!celliax_new(p, AST_STATE_RING, tech_pvt-&gt;context)) {
+                                //FIXME ERRORA(&quot;celliax_new failed! BAD BAD BAD\n&quot;, CELLIAX_P_LOG);
+                                //FIXME }
+                        }
</ins><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="cx">                 ERRORA(&quot;Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n&quot;, SKYPIAX_P_LOG);
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>