예제 #1
0
bool MySkype::SetupAudioDevices(uint micIdx, uint spkIdx){

  SEStringList spkHandles, spkNames, spkProductIDs;
  SEStringList micHandles, micNames, micProductIDs;

  if (!GetAvailableOutputDevices (spkHandles, spkNames,  spkProductIDs)) throw SkypeException("Can't obtain available output devices.\n");
  if (!GetAvailableRecordingDevices (micHandles, micNames, micProductIDs)) throw SkypeException("Can't obtain available recording revices.\n");

  if (micIdx > (micHandles.size() + 1))
  {
    printf("[SKYPE]: Invalid mic device no. (%d) passed to MySkype::SetupAudioDevices\n", micIdx);
    throw SkypeException("Invalid mic device passed to MySkype::SetupAudioDevices.\n");
  };

  if (spkIdx > (spkHandles.size() + 1))
  {
    printf("[SKYPE]: Invalid speaker device no. (%d) passed to MySkype::SetupAudioDevices\n", spkIdx);
    throw SkypeException("Invalid speaker device passed to MySkype::SetupAudioDevices.\n");
  };

  printf("[SKYPE]: Setting mic to %s\n", (const char*)micNames[micIdx]);
  printf("[SKYPE]: Setting speakers to %s\n", (const char*)spkNames[spkIdx]);

  if (!SelectSoundDevices(micHandles[micIdx], spkHandles[spkIdx], spkHandles[spkIdx])) throw SkypeException("Can't select sound devices.\n");
  if (!SetSpeakerVolume(100)) throw SkypeException("Can't set speker volume.\n");
  return true;
}
예제 #2
0
/**********************************************************
Method decreases speaker volume

return: 
        ERROR ret. val:
        ---------------
        -1 - comm. line to the GSM module is not free
        -2 - GSM module did not answer in timeout
        -3 - GSM module has answered "ERROR" string

        OK ret val:
        -----------
        0..100 current speaker volume 
**********************************************************/
char GSM::DecSpeakerVolume(void)
{
  char ret_val;
  byte current_speaker_value;

  current_speaker_value = last_speaker_volume;
  if (current_speaker_value > 0) {
    current_speaker_value--;
    ret_val = SetSpeakerVolume(current_speaker_value);
  }
  else ret_val = 0;

  return (ret_val);
}
예제 #3
0
/**********************************************************
Method increases speaker volume

return: 
        ERROR ret. val:
        ---------------
        -1 - comm. line to the GSM module is not free
        -2 - GSM module did not answer in timeout
        -3 - GSM module has answered "ERROR" string

        OK ret val:
        -----------
        0..100 current speaker volume 
**********************************************************/
char GSM::IncSpeakerVolume(void)
{
  char ret_val;
  byte current_speaker_value;

  current_speaker_value = last_speaker_volume;
  if (current_speaker_value < 100) {
    current_speaker_value++;
    ret_val = SetSpeakerVolume(current_speaker_value);
  }
  else ret_val = 100;

  return (ret_val);
}
예제 #4
0
/**********************************************************
  Sends parameters for initialization of GSM module

  group:  0 - parameters of group 0 - not necessary to be registered in the GSM
          1 - parameters of group 1 - it is necessary to be registered
**********************************************************/
void GSM::InitParam(byte group)
{

  switch (group) {
    case PARAM_SET_0:
      // check comm line
      if (CLS_FREE != GetCommLineStatus()) return;
      SetCommLineStatus(CLS_ATCMD);

      // Reset to the factory settings
      SendATCmdWaitResp("AT&F1", 1000, 20, "OK", 5);      
      // switch off echo
      SendATCmdWaitResp("ATE0", 500, 20, "OK", 5);
      // setup fixed baud rate
      SendATCmdWaitResp("AT+IPR=115200", 500, 20, "OK", 5);
      // setup mode
      SendATCmdWaitResp("AT#SELINT=1", 500, 20, "OK", 5);
      // Switch ON User LED - just as signalization we are here
      SendATCmdWaitResp("AT#GPIO=8,1,1", 500, 20, "OK", 5);
      // Sets GPIO9 as an input = user button
      SendATCmdWaitResp("AT#GPIO=9,0,0", 500, 20, "OK", 5);
      // allow audio amplifier control
      SendATCmdWaitResp("AT#GPIO=5,0,2", 500, 20, "OK", 5);
      // Switch OFF User LED- just as signalization we are finished
      SendATCmdWaitResp("AT#GPIO=8,0,1", 500, 20, "OK", 5);
      SetCommLineStatus(CLS_FREE);
      break;

    case PARAM_SET_1:
      // check comm line
      if (CLS_FREE != GetCommLineStatus()) return;
      SetCommLineStatus(CLS_ATCMD);

      // Audio codec - Full Rate (for DTMF usage)
      SendATCmdWaitResp("AT#CODEC=1", 500, 20, "OK", 5);
      // Hands free audio path
      SendATCmdWaitResp("AT#CAP=1", 500, 20, "OK", 5);
      // Echo canceller enabled 
      SendATCmdWaitResp("AT#SHFEC=1", 500, 20, "OK", 5);
      // Ringer tone select (0 to 32)
      SendATCmdWaitResp("AT#SRS=26,0", 500, 20, "OK", 5);
      // Microphone gain (0 to 7) - response here sometimes takes 
      // more than 500msec. so 1000msec. is more safety
      SendATCmdWaitResp("AT#HFMICG=7", 1000, 20, "OK", 5);
      // set the SMS mode to text 
      SendATCmdWaitResp("AT+CMGF=1", 500, 20, "OK", 5);
      // Auto answer after first ring enabled
      // auto answer is not used
      //SendATCmdWaitResp("ATS0=1", 500, 20, "OK", 5);

      // select ringer path to handsfree
      SendATCmdWaitResp("AT#SRP=1", 500, 20, "OK", 5);
      // select ringer sound level
      SendATCmdWaitResp("AT+CRSL=2", 500, 20, "OK", 5);
      // we must release comm line because SetSpeakerVolume()
      // checks comm line if it is free
      SetCommLineStatus(CLS_FREE);
      // select speaker volume (0 to 14)
      SetSpeakerVolume(9);
      // init SMS storage
      InitSMSMemory();
      // select phonebook memory storage
      SendATCmdWaitResp("AT+CPBS=\"SM\"", 1000, 20, "OK", 5);
      break;
  }
  
}