Ejemplo n.º 1
0
static int Multitech_2834_voice_mode_on(void)
{
	char buffer[VOICE_BUF_LEN];

	if (voice_command(voice_modem->ask_mode_cmnd, "") != OK)
		return FAIL;

	do {
		if (voice_read(mode_save) != OK)
			return FAIL;
	} while (strlen(mode_save) == 0);

	if (strncmp(mode_save, "+FCLASS=", 8) == 0)
        	memmove(mode_save, mode_save + 8, strlen(mode_save) - 8 + 1);

	if ((voice_command("", voice_modem->ask_mode_answr) & VMA_USER) != VMA_USER)
		return FAIL;

	sprintf(buffer, "%s%s", voice_modem->switch_mode_cmnd,
		voice_modem->voice_mode_id);

	if ((voice_command(buffer, voice_modem->switch_mode_answr) & VMA_USER) !=
	    VMA_USER)
		return FAIL;

	Multitech_2834_fix_modem(0);

	return OK;
}
Ejemplo n.º 2
0
void Multitech_2834_fix_modem(int expect_error)
{
	char buffer[VOICE_BUF_LEN];
	int result = VMA_FAIL;

        if (!cvd.enable_command_echo.d.i) {
  	   /* Multitech 2834 ZDXV modem (ROM 0416A NORTH AMERICAN) 
            * -- [email protected]
            *    As I understand the problem -- some Multitech 2834 ZDXv
            *    modems garble the command echo at certain points. To counter
            *    this, a dummy command is sent at those points (just AT)
            *    and the echo is ignored: this is the purpose of
            *    Multitech_2834_fix_modem(). If echo is off, there is
            *    no need to prevent garbled commands echos, and thus no need
            *    for Multitech_2834_fix_modem() (in fact, it would fail).
            */

           return; 
        }

	/* my ZDXv with 0416A firmware seems to exhibit a bug here -
	 * if you send the modem 'AT', it echos 'TA'.  If you send it
	 * 'ATI', it echos 'TIA'!
	 */
	voice_write("AT");
	do {
		if (voice_read(buffer) != OK) {
			voice_flush(1);
			break;
		}

		result = voice_analyze(buffer, "AT", TRUE);

		if (result == VMA_FAIL) {
			voice_flush(1);
			break;
		}

		if (result == VMA_ERROR) {
			lprintf(L_WARN, "%s: Modem returned ERROR",
	        		program_name);
			voice_flush(1);
			break;
		}
	} while (result != VMA_USER_1);

	if (result == VMA_USER_1 && expect_error)
        	lprintf(L_WARN, "%s: Modem answered correctly - mail [email protected]",
        		program_name);
        if (result != VMA_USER_1 && !expect_error)
        	lprintf(L_WARN, "%s: Modem answered incorrectly - mail [email protected]",
			program_name); 
}
Ejemplo n.º 3
0
int Cirrus_Logic_init (void)
     {
     char buffer[VOICE_BUF_LEN];
     range play_range = {0, 0};
     range rec_range = {0, 0};
     range rec_silence_threshold = {0, 0};

     reset_watchdog();
     lprintf(L_MESG, "Initializing Cirrus Logic voice modem");
     voice_modem_state = INITIALIZING;

     /* Get the record volume range available from modem */
     voice_command("AT#VRL=?", "");
     voice_read(cirrus_logic_ans);
     voice_flush(1);
     get_range(cirrus_logic_ans, &rec_range);

     if (cvd.receive_gain.d.i == -1)
          cvd.receive_gain.d.i = (rec_range.max + rec_range.min) / 2;

     sprintf(buffer, "AT#VRL=%.0f", rec_range.min + ((rec_range.max -
      rec_range.min) * cvd.receive_gain.d.i / 100.0));

     if (voice_command(buffer, "OK") != VMA_USER_1)
          lprintf(L_WARN, "can't set recording volume");

     /* Get the play volume range available from modem */
     voice_command("AT#VPL=?", "");
     voice_read(cirrus_logic_ans);
     voice_flush(1);
     get_range(cirrus_logic_ans, &play_range);

     if (cvd.transmit_gain.d.i == -1)
          cvd.transmit_gain.d.i = (play_range.max + play_range.min) / 2;

     sprintf(buffer, "AT#VPL=%.0f", play_range.min + ((play_range.max -
      play_range.min) * cvd.transmit_gain.d.i / 100.0));

     if (voice_command(buffer, "OK") != VMA_USER_1)
          lprintf(L_WARN, "can't set play volume");

     if ((cvd.rec_silence_threshold.d.i > 100) ||
        (cvd.rec_silence_threshold.d.i < 0))
          {
          lprintf(L_WARN, "Invalid threshold value.");
          return(ERROR);
          }

     /* Get the silence threshold range from modem */
     voice_command("AT#VSL=?", "");
     voice_read(cirrus_logic_ans);
     voice_flush(1);
     get_range(cirrus_logic_ans, &rec_silence_threshold);

     sprintf(buffer, "AT#VSL=%.0f", rec_silence_threshold.min +
      ((rec_silence_threshold.max - rec_silence_threshold.min) *
      cvd.rec_silence_threshold.d.i / 100.0));

     if (voice_command(buffer, "OK") != VMA_USER_1)
          lprintf(L_WARN, "can't set silence threshold");

     sprintf(buffer, "AT#VSQT=%1u", (int)cvd.rec_silence_len.d.i);

     if (voice_command(buffer, "OK") != VMA_USER_1)
          lprintf(L_WARN, "can't set silence period record mode");

     sprintf(buffer, "AT#VSST=%1u", (int)cvd.rec_silence_len.d.i);

     if (voice_command(buffer, "OK") != VMA_USER_1)
          lprintf(L_WARN, "can't set silence period record and command mode");

     if (voice_command("AT\\Q3", "OK") == VMA_USER_1)
          {
          TIO tio;
          tio_get(voice_fd, &tio);
          tio_set_flow_control(voice_fd, &tio, FLOW_HARD);
          tio_set(voice_fd, &tio);
          }
     else
          lprintf(L_WARN, "can't turn on hardware flow control");

     voice_modem_state = IDLE;
     return(OK);
     }
Ejemplo n.º 4
0
static int ISDN4Linux_init(void)
     {
     static char buffer[VOICE_BUF_LEN] = "";
     unsigned reg_content;

     voice_modem_state = INITIALIZING;
     lprintf(L_MESG, "initializing ISDN4Linux voice mode");
     reset_watchdog();

     /* Enable voice calls (set bit 1 in register S18) */

     if (voice_command("ATS18?", "") != OK)
          return(FAIL);

     if (voice_read(buffer) != OK)
          return(FAIL);

     if (voice_command("", "OK") != VMA_USER_1)
          return(FAIL);

     reg_content=atoi(buffer);

     sprintf(buffer, "ATS18=%u", reg_content | 1);

     if (voice_command(buffer, "OK") != VMA_USER_1)
          return(FAIL);

     /* Enable CALLER NUMBER after first RING (set bit 4 in register S13) */

     if (voice_command("ATS13?", "") != OK)
          return(FAIL);

     if (voice_read(buffer) != OK)
          return(FAIL);

     if (voice_command("", "OK") != VMA_USER_1)
          return(FAIL);

     reg_content=atoi(buffer);

     sprintf(buffer, "ATS13=%u", reg_content | (1 << 4));

     if (voice_command(buffer, "OK") != VMA_USER_1)
          return(FAIL);

#if ISDN_FUTURE
     {
     char buffer[VOICE_BUF_LEN];

     /*
      * ATS40.3=1 - Enable distincitve ring type 1 (RING)
      * ATS40.4=1 - Enable distincitve ring type 2 (RING 1)
      * ATS40.5=1 - Enable distincitve ring type 3 (RING 2)
      * ATS40.6=1 - Enable distincitve ring type 4 (RING 3)
      */

     /*
      * AT+VSD=x,y - Set silence threshold and duration.
      */

     sprintf(buffer, "AT+VSD=%d,%d", cvd.rec_silence_threshold.d.i * 31 / 100,
      cvd.rec_silence_len.d.i);

     if (voice_command(buffer, "OK") != VMA_USER_1)
          lprintf(L_WARN, "setting recording preferences didn't work");

     }
#endif /* ISDN_FUTURE */

     voice_modem_state = IDLE;
     return(OK);
     }
Ejemplo n.º 5
0
void V253_querry_compressions() {
     char buffer[VOICE_BUF_LEN];
     memset( buffer, '\0', sizeof(buffer) );

     if (!cvd.enable_compression_mapping_querry.d.i) {
       lprintf(L_NOISE, "voice compression querry disabled");
       return;
     }
     if (voice_command("AT+VSM=?", "") != OK)
       {
	 lprintf(L_WARN, "voice compression querry failed");
	 return;
       }
     do {
       if (voice_read(buffer) != OK)
	 {
	   lprintf(L_WARN, "voice compression querry failed");
	   break;
	  }
#ifndef NO_STRSTR
       // now check, if the line contains a supported compression method
       if(mSTRSTR(buffer,"\"SIGNED PCM\",8")) {
	 // The leading number in buffer contains the modem compression id
	 Kompressiontable[9]= strtol(buffer, NULL, 10);
	 lprintf(L_NOISE, "Mapped signed PCM, 9 -> %d",Kompressiontable[9]);
       } else if(mSTRSTR(buffer,"\"SIGNED PCM\",16")) {
	 // The leading number in buffer contains the modem compression id
	 Kompressiontable[12]= strtol(buffer, NULL, 10);
	 lprintf(L_NOISE, "Mapped signed PCM, 12 -> %d",Kompressiontable[12]);
       } else if(mSTRSTR(buffer,"UNSIGNED PCM\",8")) {
	 // The leading number in buffer contains the modem compression id
	 Kompressiontable[0]= 
	   Kompressiontable[1]= 
	   Kompressiontable[8]= strtol(buffer, NULL, 10);
	 lprintf(L_NOISE, "Mapped default (8 bit linear), 0 -> %d",Kompressiontable[0]);
	 lprintf(L_NOISE, "Mapped unsigned PCM, 1 -> %d",Kompressiontable[1]);
	 lprintf(L_NOISE, "Mapped 8 bit linear, 8 -> %d",Kompressiontable[8]);
       } else if(mSTRSTR(buffer,"8-BIT LINEAR")) {
	 // The leading number in buffer contains the modem compression id
	 Kompressiontable[0]= 
	   Kompressiontable[1]= 
	   Kompressiontable[8]= strtol(buffer, NULL, 10);
	 lprintf(L_NOISE, "Mapped default (8 bit linear), 0 -> %d",Kompressiontable[0]);
	 lprintf(L_NOISE, "Mapped unsigned PCM, 1 -> %d",Kompressiontable[1]);
	 lprintf(L_NOISE, "Mapped 8 bit linear, 8 -> %d",Kompressiontable[8]);
       } else if(mSTRSTR(buffer,"IMA ADPCM\",4")) {
	 // The leading number in buffer contains the modem compression id
	 Kompressiontable[5]= strtol(buffer, NULL, 10);
	 lprintf(L_NOISE, "Mapped 4 bit IMA ADPCM, 5 -> %d",Kompressiontable[5]);
       } else if(mSTRSTR(buffer,"4-BIT ADPCM")) {
	 // The leading number in buffer contains the modem compression id
	 Kompressiontable[5]= strtol(buffer, NULL, 10);
	 lprintf(L_NOISE, "Mapped 4 bit IMA ADPCM, 5 -> %d",Kompressiontable[5]);
       } else if(mSTRSTR(buffer,"ULAW")) {
	 // The leading number in buffer contains the modem compression id
	 Kompressiontable[10]= strtol(buffer, NULL, 10);
	 lprintf(L_NOISE, "Mapped ulaw, 10 -> %d",Kompressiontable[10]);
       } else if(mSTRSTR(buffer,"ALAW")) {
	 // The leading number in buffer contains the modem compression id
	 Kompressiontable[11]= strtol(buffer, NULL, 10);
	 lprintf(L_NOISE, "Mapped alaw, 11 -> %d",Kompressiontable[11]);
       } else if(mSTRSTR(buffer,"16-BIT LINEAR")) {
	 // The leading number in buffer contains the modem compression id
	 Kompressiontable[13]= strtol(buffer, NULL, 10);
	 lprintf(L_NOISE, "Mapped 16 bit linear, 13 -> %d",Kompressiontable[13]);
       } else 
#endif
	 {
	   lprintf(L_NOISE, "Unknown: %s",buffer);
	 }
       
     } while (strncmp("OK",buffer,2)); //search for the terminating "OK"
}