view src/aci2/aci/ati_omcompat.c @ 701:35e7f9d0379f

targets: add TARGET_HAS_BUZZER to c11x, c139 and dsample This new target config preprocessor symbol was introduced in Tourmaline in connection with the new approach to playing buzzer melodies via PWT, properly omitting the responsible code on targets where BU output controls the vibrator instead. That code is not present in Magnetite and we have no plans to backport it here, but target header files should be kept consistent between the two trees, especially given that we plan to support FC Venus target in Magnetite.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 26 Mar 2022 19:51:34 +0000
parents 1badec9097de
children
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 "dar/dar_api.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)
{
	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;

	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 : @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");

	dar_reset_system();

	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 logic is broken - hence
 * we are NOT reimplementing this bogon in FreeCalypso.
 *
 * If you feel like changing your modem's IMEI, you can do it
 * through the RVTMUX interface with our fc-fsio utility's
 * set-imeisv command.
 */

/*
 * 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 */