From 88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22 Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 07 Aug 2004 17:24:40 +0000 Subject: Initial revision --- (limited to 'gammu/emb/common/protocol/symbian') diff --git a/gammu/emb/common/protocol/symbian/mrouter.c b/gammu/emb/common/protocol/symbian/mrouter.c new file mode 100644 index 0000000..2ca7af1 --- a/dev/null +++ b/gammu/emb/common/protocol/symbian/mrouter.c @@ -0,0 +1,110 @@ +/* (c) 2003 by Marcin Wiacek */ + +#include "../../gsmstate.h" + +#if defined(GSM_ENABLE_MROUTERBLUE) + +#include +#include + +#include "../../gsmcomon.h" +#include "mrouter.h" + +static GSM_Error MROUTER_WriteMessage (GSM_StateMachine *s, unsigned char *buffer, + int length, unsigned char type) +{ + unsigned char *out_buffer; + int current=0,sent; + + out_buffer = (unsigned char *)malloc(length+1); + + memcpy(out_buffer,buffer,length); + out_buffer[length]=0x7E; + + GSM_DumpMessageLevel2(s, out_buffer, length, type); + GSM_DumpMessageLevel3(s, out_buffer, length, type); + + /* Send it out... */ + sent = s->Device.Functions->WriteDevice(s,out_buffer,length+1); + + free(out_buffer); + + if (sent!=current) return ERR_DEVICEWRITEERROR; + return ERR_NONE; +} + +static GSM_Error MROUTER_StateMachine(GSM_StateMachine *s, unsigned char rx_char) +{ + GSM_Phone_Functions *Phone = s->Phone.Functions; + GSM_Protocol_MROUTERData *d = &s->Protocol.Data.MROUTER; + + switch (d->MsgRXState) { + case RX_Sync: + if (rx_char == 0x7E) { + d->MsgRXState = RX_GetMessage; + d->Msg.Count = 0; + d->Msg.Length = 0; + } else smprintf(s,"Sync error: %02x\n",rx_char); + break; + case RX_GetMessage: + if (rx_char == 0x7E) { + s->Phone.Data.RequestMsg = &d->Msg; + s->Phone.Data.DispatchError = Phone->DispatchMessage(s); + d->Msg.Count = 0; + d->Msg.Length = 0; + } else { + d->Msg.BufferUsed = d->Msg.Length+1; + d->Msg.Buffer = (unsigned char *)realloc(d->Msg.Buffer,d->Msg.BufferUsed); + + d->Msg.Buffer[d->Msg.Count] = rx_char; + d->Msg.Count++; + d->Msg.Length++; + } + break; + } + + return ERR_NONE; +} + +static GSM_Error MROUTER_Initialise(GSM_StateMachine *s) +{ + GSM_Protocol_MROUTERData *d = &s->Protocol.Data.MROUTER; +GSM_Error error; + + d->Msg.BufferUsed = 0; + d->Msg.Buffer = NULL; + d->Msg.Length = 0; + + d->MsgRXState = RX_Sync; + +// error=s->Device.Functions->DeviceSetDtrRts(s,false,false); +// if (error!=ERR_NONE) return error; + + error=s->Device.Functions->DeviceSetSpeed(s,115200); + if (error!=ERR_NONE) return error; + + +// error=s->Device.Functions->DeviceSetSpeed(s,115200); +// if (error!=ERR_NONE) return error; + + return ERR_NONE; +} + +static GSM_Error MROUTER_Terminate(GSM_StateMachine *s) +{ + free(s->Protocol.Data.MROUTER.Msg.Buffer); + return ERR_NONE; +} + +GSM_Protocol_Functions MROUTERProtocol = { + MROUTER_WriteMessage, + MROUTER_StateMachine, + MROUTER_Initialise, + MROUTER_Terminate +}; + +#endif + +/* How should editor hadle tabs in this file? Add editor commands here. + * vim: noexpandtab sw=8 ts=8 sts=8: + */ diff --git a/gammu/emb/common/protocol/symbian/mrouter.h b/gammu/emb/common/protocol/symbian/mrouter.h new file mode 100644 index 0000000..7d72cdd --- a/dev/null +++ b/gammu/emb/common/protocol/symbian/mrouter.h @@ -0,0 +1,31 @@ +/* (c) 2003 by Marcin Wiacek */ + +#ifndef mrouter_h +#define mrouter_h + +#include "../protocol.h" + +typedef struct { + int MsgRXState; + GSM_Protocol_Message Msg; +} GSM_Protocol_MROUTERData; + +#ifndef GSM_USED_SERIALDEVICE +# define GSM_USED_SERIALDEVICE +#endif +//#if defined(GSM_ENABLE_BLUEOBEX) +//# ifndef GSM_USED_BLUETOOTHDEVICE +//# define GSM_USED_BLUETOOTHDEVICE +//# endif +//#endif +//#if defined(GSM_ENABLE_IRDAOBEX) +//# ifndef GSM_USED_IRDADEVICE +//# define GSM_USED_IRDADEVICE +//# endif +//#endif + +#endif + +/* How should editor hadle tabs in this file? Add editor commands here. + * vim: noexpandtab sw=8 ts=8 sts=8: + */ -- cgit v0.9.0.2