Exemple #1
0
void cmd_audiohw_speaker_vol(int argc, char** argv)
{
	if(argc < 2)
	{
#ifdef CONFIG_3G
		bufferPrintf("%s <loudspeaker volume> (between 0 and 100)\r\n", argv[0]);
#else
		bufferPrintf("%s <loudspeaker volume> [speaker volume] (between 0 and 100... 'speaker' is the one next to your ear)\r\n", argv[0]);
#endif
		return;
	}

	int vol = parseNumber(argv[1]);

#ifdef CONFIG_3G
	audiohw_set_speaker_vol(vol);
	bufferPrintf("Set speaker volume to: %d\r\n", vol);
#else
	loudspeaker_vol(vol);

	bufferPrintf("Set loudspeaker volume to: %d\r\n", vol);

	if(argc > 2)
	{
		vol = parseNumber(argv[2]);
		speaker_vol(vol);

		bufferPrintf("Set speaker volume to: %d\r\n", vol);
	}
#endif
}
Exemple #2
0
int speaker_setup()
{
	// something set at the very beginning
	radio_cmd("at+xdrv=0,41,25\r\n", 10);

#ifdef CONFIG_IPHONE
	bufferPrintf("radio: enabling internal speaker\r\n");

	// mute everything?
	radio_cmd("at+xdrv=0,1,0,0\r\n", 10);
	radio_cmd("at+xdrv=0,1,0,1\r\n", 10);
	radio_cmd("at+xdrv=0,1,0,2\r\n", 10);
	radio_cmd("at+xdrv=0,1,0,6\r\n", 10);

	// I really don't know
	radio_cmd("at+xdrv=0,24,1,1\r\n", 10);
	radio_cmd("at+xdrv=0,0,2,2\r\n", 10);

	loudspeaker_vol(100);
	speaker_vol(68);

	// clock
	// In general, lower is slower and higher is faster, but at some point it loops around.
	// This may mean the value is a bitset, e.g., at+xdrv=0,2,2,29 will set it to half speed
	radio_cmd("at+xdrv=0,2,2,10\r\n", 10);

	// channels?
	radio_cmd("at+xdrv=0,9,2\r\n", 10);

	// enable i2s?
	radio_cmd("at+xdrv=0,20,1\r\n", 10);

	// unmute?
	radio_cmd("at+xdrv=0,3,0\r\n", 10);

	bufferPrintf("radio: internal speaker enabled\r\n");
#endif
	return 0;
}
Exemple #3
0
void cmd_audiohw_speaker_vol(int argc, char** argv)
{
	if(argc < 2)
	{
		bufferPrintf("%s <loudspeaker volume> [speaker volume] (between 0 and 100... 'speaker' is the one next to your ear)\r\n", argv[0]);
		return;
	}

	int vol = parseNumber(argv[1]);
	
	loudspeaker_vol(vol);

	bufferPrintf("Set loudspeaker volume to: %d\r\n", vol);

	if(argc > 2)
	{
		vol = parseNumber(argv[2]);
		speaker_vol(vol);

		bufferPrintf("Set speaker volume to: %d\r\n", vol);
	}
}
Exemple #4
0
void radio_call(const char* number)
{
	char buf[256];

	bufferPrintf("radio: Setting up audio\r\n");

	audiohw_switch_normal_call(TRUE);

#ifdef CONFIG_3G
	radio_cmd("at+xdrv=0,8,0,0\r\n", 10);
#else
	radio_cmd("at+xdrv=0,4\r\n", 10);
	radio_cmd("at+xdrv=0,20,0\r\n", 10);
#endif

	// mute everything?
	radio_cmd("at+xdrv=0,1,0,0\r\n", 10);
	radio_cmd("at+xdrv=0,1,0,1\r\n", 10);
	radio_cmd("at+xdrv=0,1,0,2\r\n", 10);
	radio_cmd("at+xdrv=0,1,0,6\r\n", 10);

	// I really don't know
	radio_cmd("at+xdrv=0,24,1,1\r\n", 10);

	// note this is different from before
	radio_cmd("at+xdrv=0,0,1,1\r\n", 10);

	// microphone volume?
	radio_cmd("at+xdrv=0,1,100,1\r\n", 10);

	loudspeaker_vol(40);

#ifdef CONFIG_3G
	radio_cmd("at+xdrv=0,8,1,0\r\n", 10);
#endif

	speaker_vol(68);

	// clock
	// In general, lower is slower and higher is faster, but at some point it loops around.
	// This may mean the value is a bitset, e.g., at+xdrv=0,2,2,29 will set it to half speed
	radio_cmd("at+xdrv=0,2,2,10\r\n", 10);

	// channels?
	radio_cmd("at+xdrv=0,9,2\r\n", 10);

	// enable i2s?
	radio_cmd("at+xdrv=0,20,1\r\n", 10);

	// unmute?
	radio_cmd("at+xdrv=0,3,0\r\n", 10);

	// get notifications
	radio_cmd("at+xcallstat=1\r\n", 10);

	bufferPrintf("radio: Dialing\r\n");

	sprintf(buf, "atd%s;\r\n", number);

	radio_cmd(buf, 10);
	radio_cmd("at+cmut=0\r\n", 10);

#ifndef CONFIG_3G
	radio_cmd("at+xdrv=4,0,0,0,0,0\r\n", 10);

	speaker_vol(68);

	radio_cmd("at+xdrv=4,0,0,0,0,0\r\n", 10);
#endif

	// we now need to wait for +XCALLSTAT to indicate 0 or active status. This code is less
	// complex than it seems. The whole point is just to wait until we have a line that says
	// +XCALLSTAT: *,0. That's it.
	while(TRUE)
	{
		buf[0] = '\0';

		radio_read(buf, sizeof(buf));

		char* pos = buf;
		int len = strlen(buf);
		int callstat = -1;

		while(len >= (sizeof("+XCALLSTAT: ") - 1))
		{

			while(((int)(pos - buf)) <= (len - sizeof("+XCALLSTAT: ") + 1) && memcmp(pos, "+XCALLSTAT: ", sizeof("+XCALLSTAT: ") - 1) != 0)
				++pos;

			if(memcmp(pos, "+XCALLSTAT: ", sizeof("+XCALLSTAT: ") - 1) != 0)
				break;

			while(*pos != ',')
				++pos;

			++pos;

			if(*pos == '0')
			{
				bufferPrintf("radio: Call answered\r\n");
				callstat = 0;
				break;
			}

			++pos;
		}

		if(callstat == 0)
			break;
	}

#ifndef CONFIG_3G
	// do the rest
	radio_cmd("at+xdrv=4,0,0,0,0,0\r\n", 10);
#endif

	// why the same thing again?
	radio_cmd("at+xdrv=0,4\r\n", 10);
	radio_cmd("at+xdrv=0,20,0\r\n", 10);

	radio_cmd("at+xcallstat=0\r\n", 10);
}