view src/aci2/aci/ati_omcompat.c @ 175:bca0f7237ecd

fad.lib compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 12 Oct 2016 17:27:19 +0000
parents 93999a60b835
children b16d79c550a2
line wrap: on
line source

/*
 * This module has been added to the Leonardo GSM firmware source by
 * Spacefalcon the Outlaw.  It contains the implementation of the AT@
 * commands which were invented by Openmoko.  The addition of this code
 * to the present leo2moko source tree allows our fw to serve as a
 * compatible and fully functional replacement for the closed original
 * mokoN firmware.
 */

#ifndef ATI_OMCOMPAT_C
#define ATI_OMCOMPAT_C

#include "aci_all.h"

#include <ctype.h>
#include <string.h>

#include "aci_cmh.h"
#include "ati_cmd.h"
#include "aci_cmd.h"
#include "aci_io.h"
#include "aci_cmd.h"
#include "l4_tim.h"
#include "line_edit.h"
#include "aci_lst.h"

#include "pcm.h"
#include "audio.h"
#include "aci.h"
#include "rx.h"
#include "pwr.h"
#include "l4_tim.h"

#ifdef GPRS
#ifdef DTI
#include "dti.h"
#include "dti_conn_mng.h"
#include "dti_cntrl_mng.h"
#endif /* DTI */
#include "gaci.h"
#include "gaci_cmh.h"
#include "gaci_cmd.h"
#endif  /* GPRS */

#include "aci_mem.h"
#include "aci_prs.h"

#include "ati_int.h"

#ifndef _SIMULATION_
#include "ffs\ffs.h"
#endif

#ifdef FF_ATI_BAT

#include "typedefs.h"
#include "gdd.h"
#include "bat.h"

#include "ati_bat.h"

#endif /*FF_ATI_BAT*/

#include "audio\audio_api.h"
#include "abb.h"
#include "..\drivers\drv_app\power\power.h"

#ifdef GPRS
#include "p_mph.h"
#include "p_mphc.h"
#include "..\alr\alr_gprs.h"
#endif
#include "p_tb.h"
#include "..\alr\alr.h"

/*
 * PURPOSE : @ST command (Configure the sidetone level)
 */
GLOBAL T_ATI_RSLT atAtST (char *cl, UBYTE srcId)
{
	T_ACI_RETURN ret = AT_FAIL;  
	char tmp[8]={0};
	INT8 gain = -26;
	TRACE_FUNCTION("atAtST()");

	/*
	 * input functionality
	 */
	cl = parse(cl,"s", (LONG)8, tmp);

	gain = atoi(tmp);

	if ( cl )
	{
		if ( gain == -23 || gain == -20 || gain == -17 || gain == -14 || gain == -11 || gain == -8 || gain == -5 || gain == -2 || gain == 1 || gain == -26 )
		{
			Side_Tone_Write(gain);
			return (ATI_CMPL);
		}
		else
		{     
			cmdCmsError(CMS_ERR_OpNotAllowed);
			return (ATI_FAIL);
		}
	} 
}

GLOBAL T_ATI_RSLT queatAtST (char *cl, UBYTE srcId)
{
	char *me="+ST: ";
	INT8 ST1;
	T_ACI_RETURN ret = AT_FAIL;  

	TRACE_FUNCTION("queatAtST()");

	ST1 = Side_Tone_Read();

	sprintf(g_sa,"%s%d",me,ST1);

	io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);

	return (ATI_CMPL);

}

/*
 * PURPOSE : @AUL command (Audio table load)
 */

static char tmp[8]={0};

GLOBAL T_ATI_RSLT atAtAUL (char *cl, UBYTE srcId)
{
	T_ACI_RETURN ret = AT_FAIL;    
	T_AUDIO_MODE_LOAD audio_mode_load_parameter;  
	T_RV_RETURN return_path;

	/* initalize the return path, for this test the return path is an message */
	return_path.callback_func = NULL;
	return_path.addr_id = rvf_get_taskid();

	TRACE_FUNCTION("atAtAUL()"); 

	/*
	 * input functionality
	 */
	cl = parse(cl,"s", (LONG)8, tmp);   

	sprintf(audio_mode_load_parameter.audio_mode_filename, "para%s", tmp);
	
	if ( audio_mode_load(&audio_mode_load_parameter, return_path) == AUDIO_ERROR )
		return (ATI_FAIL);
	else
		return (ATI_CMPL);

}

GLOBAL T_ATI_RSLT queatAtAUL (char *cl, UBYTE srcId)
{
	char *me="@AUL: ";  
	T_ACI_RETURN ret = AT_FAIL;  

	TRACE_FUNCTION("queatAtAUL()");  

	if (strlen(tmp))
		sprintf(g_sa,"%s/aud/para%s.cfg",me, tmp);
	else
		sprintf(g_sa,"%s",me);  		

	io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);

	return (ATI_CMPL);

}

/*
 * PURPOSE : @POFF command (Power Off GSM Modem)
 */
 
GLOBAL T_ATI_RSLT atAtPOFF (char *cl, UBYTE srcId)
{		
	TRACE_FUNCTION("atAtPOFF");
	
	sprintf(g_sa,"%s","OK");  		
	io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);

	ABB_Power_Off();
	
	return (ATI_CMPL);	
}

/*
 * PURPOSE : @RST command (Reset GSM Modem)
 */
 
GLOBAL T_ATI_RSLT atAtRST (char *cl, UBYTE srcId)
{		
	TRACE_FUNCTION("atAtRST");			
	
	Power_OFF_Button();  
	
	return (ATI_CMPL);	
}

/*
 * Openmoko's firmware contains an undocumented AT@SC command that
 * sets/changes the IMEI of the modem.  However, it takes the IMEI
 * input in an obfuscated form, and the implementation code is
 * rather ugly - hence I don't feel like reimplementing it here.
 *
 * If you feel like changing your modem's IMEI, you can do it quite
 * easily with FreeCalypso tools: use fc-loadtool to read the FFS
 * sectors out of flash, then mpffs-edit to change the /pcm/IMEI file
 * in the FFS image, then fc-loadtool again to program the modified
 * FFS image back into flash.
 */

GLOBAL T_ATI_RSLT atAtSC (char *cl, UBYTE srcId)
{		
	TRACE_FUNCTION("atAtSC");			

	return (ATI_FAIL);	
}

/*
 * PURPOSE : @BAND command (Get RF band)
 */

GLOBAL T_ATI_RSLT atAtBAND (char *cl, UBYTE srcId)
{		
    char szDummy[32]; // to produce the exact same assembler code
    char szBand[32];    
    UBYTE band_sc = get_band (alr_data->serving_cell); // to produce the exact same assembler code

	TRACE_FUNCTION("atAtBAND");			
	band_sc = alr_data->sc_band;
    switch(band_sc)
    {
    case BAND_GSM_900:
      strcpy(szBand, "GSM 900");
      break;
    case BAND_DCS_1800:
      strcpy(szBand, "DCS 1800");
      break;
    case BAND_PCS_1900:
      strcpy(szBand, "PCS 1900");
      break;
    case BAND_E_GSM:
      strcpy(szBand, "EGSM");
      break;
    case BAND_GSM_850:
      strcpy(szBand, "GSM 850");
      break;
    default:
      strcpy(szBand, "Unknown");
      break;
    }
	sprintf(g_sa,"%s", szBand);  		
	io_sendMessage(srcId, g_sa, ATI_NORMAL_OUTPUT);
		
	return (ATI_CMPL);	
}

#endif /* ATI_OMCOMPAT_C */