X-Git-Url: http://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Fnewmodules%2Fnewat.c;h=01e051f47f27e481591a1c64af64a695e6fe6e59;hp=985eb8cf76a175fa1edcfad0caf889fbd729321d;hb=refs%2Ftags%2Fbp_uc;hpb=5d49fe8eea4e11457b4f9904eb0d5db435679841 diff --git a/common/newmodules/newat.c b/common/newmodules/newat.c index 985eb8c..01e051f 100644 --- a/common/newmodules/newat.c +++ b/common/newmodules/newat.c @@ -132,6 +132,7 @@ GSM_Information Nat_Information = { "at", /* Supported models in AT commands mode */ "", "", + "", 4, /* Max RF Level */ 0, /* Min RF Level */ GRF_Arbitrary, /* RF level units */ @@ -237,20 +238,30 @@ void Nat_ReplyGetID(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { fprintf(stdout, _(" Model: RAE-3\n")); #endif strcpy(Current_Model,"RAE-3"); - - } else { - while (MessageBuffer[i]!=0x0d && MessageBuffer[i]!=0x0a) { - Current_Model[i-10]=MessageBuffer[i]; - i++; - } - Current_Model[i-9]=0; - + CurrentMagicError=GE_NONE; + return; + } + if (strncmp("Nokia 6210",MessageBuffer+i,10)==0) { #ifdef DEBUG fprintf(stdout, _("Message: Mobile phone model identification received:\n")); - fprintf(stdout, _(" Model: %s\n"),Current_Model); + fprintf(stdout, _(" Model: NPE-3\n")); #endif + strcpy(Current_Model,"NPE-3"); + CurrentMagicError=GE_NONE; + return; } + while (MessageBuffer[i]!=0x0d && MessageBuffer[i]!=0x0a) { + Current_Model[i-10]=MessageBuffer[i]; + i++; + } + Current_Model[i-9]=0; + +#ifdef DEBUG + fprintf(stdout, _("Message: Mobile phone model identification received:\n")); + fprintf(stdout, _(" Model: %s\n"),Current_Model); +#endif + CurrentMagicError=GE_NONE; } @@ -277,7 +288,7 @@ void Nat_ReplyGetHW(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { for (i=12;i<17;i++) fprintf(stdout,_("%c"),MessageBuffer[i]); fprintf(stdout, _("\n")); /* Some Nokia phones like 9210 return only firmware */ - if (MessageLength>22) { + if (MessageLength>24) { fprintf(stdout, _(" Hardware: ")); for (i=21;i<25;i++) fprintf(stdout,_("%c"),MessageBuffer[i]); fprintf(stdout, _("\n")); @@ -290,7 +301,7 @@ void Nat_ReplyGetHW(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { Current_Revision[current++]=' '; Current_Revision[current++]='H'; Current_Revision[current++]='W'; - if (MessageLength>22) { + if (MessageLength>24) { for (i=21;i<25;i++) Current_Revision[current++]=MessageBuffer[i]; } else { /* Some Nokia phones like 9210 return only firmware */ @@ -385,10 +396,10 @@ GSM_Error Nat_Initialise(char *port_device, char *initlength, if (Nat_SendIMEIFrame()!=GE_NONE) return GE_TIMEOUT; - if (Nat_SendHWFrame()!=GE_NONE) return GE_TIMEOUT; - if (Nat_SendIDFrame()!=GE_NONE) return GE_TIMEOUT; + if (Nat_SendHWFrame()!=GE_NONE) return GE_TIMEOUT; + /* In AT doesn't have any init strings, etc. Phone answered with frame, so connection should be enabled ;-) */ CurrentLinkOK = true; @@ -407,6 +418,15 @@ GSM_Error Nat_GetManufacturer(char* manufacturer) return GE_NONE; } +void Nat_ReplyPBKSetMemoryTypeError(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { + +#ifdef DEBUG + fprintf(stdout, _("Message: memory setting error\n")); +#endif + + CurrentPhonebookError=GE_UNKNOWN; +} + void Nat_ReplyPBKSetMemoryType(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { #ifdef DEBUG @@ -469,6 +489,15 @@ GSM_Error SetCharset() return error; } +void Nat_ReplyGetMemoryLocationError(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { + +#ifdef DEBUG + fprintf(stdout, _("Message: phonebook entry receiving error\n")); +#endif + + CurrentPhonebookError=GE_UNKNOWN; +} + /* FIXME: M20 can have " inside name. We can't get endpos by finding first " */ void Nat_ReplyGetMemoryLocation(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { @@ -620,6 +649,13 @@ void Nat_ReplyGetMemoryStatusCPBS(u16 MessageLength, u8 *MessageBuffer, u8 Messa } else CurrentMemoryStatusError=GE_UNKNOWN; } +void Nat_ReplyGetMemoryStatusCPBSError(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { +#ifdef DEBUG + fprintf(stdout, _("Message: memory status receiving error\n")); +#endif + CurrentMemoryStatusError=GE_UNKNOWN; +} + void Nat_ReplyGetMemoryStatusCPBR(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { char *start; @@ -735,6 +771,8 @@ void Nat_ReplyGetNetworkInfo(u16 MessageLength, u8 *MessageBuffer, u8 MessageTyp int i,current; GSM_NetworkInfo NullNetworkInfo; + if (!strncmp(MessageBuffer,"AT+CREG=",8)) return; + /* TODO: checking if phone really registered to network */ current=23; @@ -771,6 +809,26 @@ void Nat_ReplyGetNetworkInfo(u16 MessageLength, u8 *MessageBuffer, u8 MessageTyp CurrentNetworkInfoError = GE_NONE; } +void Nat_ReplyGetNetworkInfoCOPS(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { + /* Make sure we are expecting NetworkInfo frame */ + if (CurrentNetworkInfo && CurrentNetworkInfoError == GE_BUSY) { +#ifdef DEBUG + fprintf(stdout, _("Message: network info received\n")); +#endif + if (MessageBuffer[20]=='2') { + CurrentNetworkInfo->NetworkCode[0]=MessageBuffer[23]; + CurrentNetworkInfo->NetworkCode[1]=MessageBuffer[24]; + CurrentNetworkInfo->NetworkCode[2]=MessageBuffer[25]; + CurrentNetworkInfo->NetworkCode[3]=' '; + CurrentNetworkInfo->NetworkCode[4]=MessageBuffer[26]; + CurrentNetworkInfo->NetworkCode[5]=MessageBuffer[27]; + CurrentNetworkInfo->NetworkCode[6]=0; + + CurrentNetworkInfoError = GE_NONE; + } + } +} + GSM_Error Nat_GetNetworkInfo(GSM_NetworkInfo *NetworkInfo) { GSM_Error error; @@ -781,6 +839,10 @@ GSM_Error Nat_GetNetworkInfo(GSM_NetworkInfo *NetworkInfo) error=NULL_SendMessageSequence (20, &CurrentNetworkInfoError, 9, 0x00, "AT+CREG?\r"); + if (error!=GE_NONE) return error; + + error=NULL_SendMessageSequence + (20, &CurrentNetworkInfoError, 9, 0x00, "AT+COPS?\r"); CurrentNetworkInfo = NULL; @@ -912,10 +974,11 @@ GSM_Error Nat_PressKey(int key, int event) { char req[128]; - sprintf(req, "AT+CKPD=?\r"); + sprintf(req, "AT+CKPD=\"1\",\"20\"\r"); return NULL_SendMessageSequence (50, &CurrentPressKeyError, strlen(req), 0x00, req); +// return GE_NOTSUPPORTED; } GSM_Error Nat_DialVoice(char *Number) { @@ -1055,6 +1118,14 @@ void Nat_ReplySetDateTime(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) CurrentSetDateTimeError=GE_NONE; } +void Nat_ReplyDateTimeError(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { +#ifdef DEBUG + fprintf(stdout,_("Message: date & time functions error\n")); +#endif + CurrentSetDateTimeError=GE_UNKNOWN; + CurrentDateTimeError=GE_UNKNOWN; +} + GSM_Error Nat_SetDateTime(GSM_DateTime *date_time) { char req[128]; @@ -1114,35 +1185,45 @@ GSM_Error Nat_SetAlarm(int alarm_number, GSM_DateTime *date_time) (50, &CurrentSetAlarmError, strlen(req), 0x00, req); } +void Nat_ReplyAlarmError(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { +#ifdef DEBUG + fprintf(stdout,_("Message: alarm functions error\n")); +#endif + CurrentSetAlarmError=GE_UNKNOWN; + CurrentAlarmError=GE_UNKNOWN; +} + void Nat_ReplyGetSMSCenter(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { int i,start; unsigned char buffer[300]; start=18; +#ifdef DEBUG + fprintf(stdout, _("Message: SMSC data received\n")); +#endif + /* FIXME: support for all formats */ start+=ExtractOneParameter(MessageBuffer+start, buffer); for (i=1;iNumber,buffer); + if (buffer[0]==0) CurrentMessageCenterError=GE_EMPTYSMSC; + else { + strcpy(CurrentMessageCenter->Number,buffer); - /* Some default values. Is it possible to get them ? */ - CurrentMessageCenter->Name[0]=0; - CurrentMessageCenter->DefaultRecipient[0]=0; - CurrentMessageCenter->Format=GSMF_Text; - CurrentMessageCenter->Validity=GSMV_Max_Time; + /* Some default values. Is it possible to get them ? */ + CurrentMessageCenter->Name[0]=0; + CurrentMessageCenter->DefaultRecipient[0]=0; + CurrentMessageCenter->Format=GSMF_Text; + CurrentMessageCenter->Validity=GSMV_Max_Time; #ifdef DEBUG - fprintf(stdout, _("Message: SMSC number received\n Number: '%s'\n"),buffer); + fprintf(stdout, _(" Number: '%s'\n"),buffer); #endif - CurrentMessageCenterError=GE_NONE; + CurrentMessageCenterError=GE_NONE; + } } /* We only get SMSC number */ @@ -1232,6 +1313,7 @@ GSM_Error GSM_DecodeETSISMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int le SMS_MessageType PDU=SMS_Deliver; GSM_ETSISMSMessage ETSI; int i,current=0,current2=0; + GSM_Error error; for(i=0;i