X-Git-Url: https://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Fnewmodules%2Fn6110.c;h=a4599617afb7f741ca170d2edf309bbdf681f6f0;hp=481c92e593f772ee0e1a2752aab5ada0417df81b;hb=82bcbc2300f764bcb3551b152a0a961f4fef5e66;hpb=c7dcdfd34d2bed9cc64c5c9603e51ef8c8271951 diff --git a/common/newmodules/n6110.c b/common/newmodules/n6110.c index 481c92e..a459961 100644 --- a/common/newmodules/n6110.c +++ b/common/newmodules/n6110.c @@ -41,11 +41,6 @@ supported by this model of phone. */ - - - - - /* Here we initialise model specific functions. */ GSM_Functions N6110_Functions = { N6110_Initialise, @@ -54,13 +49,8 @@ GSM_Functions N6110_Functions = { NULL_KeepAlive, N6110_GetMemoryLocation, N6110_WritePhonebookLocation, -#ifndef UCLINUX N6110_GetSpeedDial, N6110_SetSpeedDial, -#else /* UCLINUX */ - NULL, - NULL, -#endif /* UCLINUX */ N6110_GetMemoryStatus, #ifndef UCLINUX N6110_GetSMSStatus, @@ -87,9 +77,16 @@ GSM_Functions N6110_Functions = { N6110_EnterSecurityCode, N6110_GetSecurityCodeStatus, N6110_GetSecurityCode, +#else /* UCLINUX */ + NULL, + NULL, + NULL, + NULL, +#endif /* UCLINUX */ N6110_GetIMEI, N6110_GetRevision, N6110_GetModel, +#ifndef UCLINUX N6110_GetDateTime, N6110_SetDateTime, N6110_GetAlarm, @@ -101,13 +98,6 @@ GSM_Functions N6110_Functions = { NULL, NULL, NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, #endif /* UCLINUX */ N6110_DialData, #ifndef UCLINUX @@ -141,12 +131,11 @@ GSM_Functions N6110_Functions = { #ifndef UCLINUX N6110_GetProfile, N6110_SetProfile, - N6110_SendRLPFrame, #else /* UCLINUX */ NULL, NULL, - NULL, #endif /* UCLINUX */ + N6110_SendRLPFrame, N6110_CancelCall, #ifndef UCLINUX N6110_PressKey, @@ -201,7 +190,7 @@ GSM_Functions N6110_Functions = { GSM_Information N6110_Information = { "3210|3310|3330|5110|5130|5190|6110|6130|6150|6190|8210|8850", /* Supported models in FBUS */ - "3210|3310|3330|5110|5130|5190|6110|6130|6150|6190|8210|8850", + "3210|3310|3330|5110|5130|5190|6110|6130|6150|6190|8210|8850|9210", /* Supported models in MBUS */ "6110|6130|6150|8210|8850", /* Supported models in FBUS over infrared */ @@ -212,7 +201,7 @@ GSM_Information N6110_Information = { "8210|8850", /* infrared sockets */ "6110|6130|6150|8210|8850", - /* Supported models in FBUS over infrared with Tekram device */ + /* Supported models in FBUS over infrared with Tekram device */ "", 4, /* Max RF Level */ 0, /* Min RF Level */ GRF_Arbitrary, /* RF level units */ @@ -442,6 +431,8 @@ GSM_Error N6110_SendStatusRequest(void) static void N6110_ReplyGetAuthentication(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { + LIVE; + #if defined WIN32 || !defined HAVE_SNPRINTF sprintf(Current_IMEI, "%s", MessageBuffer+9); sprintf(Current_Model, "%s", MessageBuffer+25); @@ -605,6 +596,14 @@ static GSM_Error N6110_Authentication() 0x00, 0x00, 0x00, 0x00}; + unsigned char req3_55[] = { N6110_FRAME_HEADER, 0x42,0x05,0x01, + 0x07,0xa2,0x88,0x81,0x21,0x55,0x63,0xa8,0x00,0x00, + 0x07,0xa3,0xb8,0x81,0x20,0x15,0x63,0x80 }; + unsigned char req3[] = { N6110_FRAME_HEADER, 0x42,0x05,0x01, + 0x07,0xa2,0x88,0x81,0x21,0x15,0x63,0xa8,0x00,0x00, + 0x07,0xa3,0xb8,0x81,0x20,0x15,0x63,0x80 }; + unsigned char unknown_05[] = {N6110_FRAME_HEADER, 0x05}; + #ifdef DEBUG fprintf(stdout,_("Making authentication!\n")); #endif @@ -613,15 +612,23 @@ static GSM_Error N6110_Authentication() usleep(100); Protocol->SendMessage(5, 0x02, connect2); usleep(100); Protocol->SendMessage(7, 0x02, connect3); + usleep(100); Protocol->SendMessage(sizeof(req3_55), 0x01, req3_55); /* Lace */ + CurrentMagicError = GE_BUSY; usleep(100); Protocol->SendMessage(4, 0x64, connect4); + + usleep(100); Protocol->SendMessage(sizeof(req3_55), 0x01, req3_55); /* Lace */ + usleep(100); Protocol->SendMessage(sizeof(req3), 0x01, req3); /* Lace */ + if (NULL_WaitUntil(50,&CurrentMagicError)!=GE_NONE) return GE_TIMEOUT; N6110_GetNokiaAuth(Current_IMEI, MagicBytes, magic_connect+4); Protocol->SendMessage(45, 0x64, magic_connect); + usleep(100); Protocol->SendMessage(4, 0x04, unknown_05); /* Lace */ + #ifdef DEBUG fprintf(stdout,_("End of authentication!\n")); #endif @@ -732,7 +739,12 @@ GSM_Error N6110_Initialise(char *port_device, char *initlength, After making it phone display "Accessory connected" and probably give access to some function (I'm not too sure about it !) Anyway, I make it now for N51xx/61xx */ - if (GetModelFeature (FN_AUTHENTICATION)!=0) { +#if 1 + if (GetModelFeature (FN_AUTHENTICATION)!=0) +#else + if (0/*Lace-hack:GetModelFeature (FN_AUTHENTICATION)!=0*/) +#endif + { if (N6110_Authentication()!=GE_NONE) return GE_TIMEOUT; } else { /* No authentication */ if (N6110_SendIMEIFrame()!=GE_NONE) return GE_TIMEOUT; @@ -814,34 +826,35 @@ void N6110_ReplyCallDivert(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) fprintf(stdout, _(" Status : deactivated\n")); } #endif /* DEBUG */ - - switch (MessageBuffer[6]) { - case 0x43: CurrentCallDivert->DType=GSM_CDV_Busy;break; - case 0x3d: CurrentCallDivert->DType=GSM_CDV_NoAnswer;break; - case 0x3e: CurrentCallDivert->DType=GSM_CDV_OutOfReach;break; - case 0x15: CurrentCallDivert->DType=GSM_CDV_AllTypes;break; //? - case 0x02: CurrentCallDivert->DType=GSM_CDV_AllTypes;break; //? - } - if (MessageBuffer[6]==0x02) //? - CurrentCallDivert->CType=GSM_CDV_AllCalls; - else { - switch (MessageBuffer[8]) { - case 0x0b: CurrentCallDivert->CType=GSM_CDV_VoiceCalls;break; - case 0x0d: CurrentCallDivert->CType=GSM_CDV_FaxCalls; break; - case 0x19: CurrentCallDivert->CType=GSM_CDV_DataCalls; break; + if (CurrentCallDivert!=NULL) { + switch (MessageBuffer[6]) { + case 0x43: CurrentCallDivert->DType=GSM_CDV_Busy;break; + case 0x3d: CurrentCallDivert->DType=GSM_CDV_NoAnswer;break; + case 0x3e: CurrentCallDivert->DType=GSM_CDV_OutOfReach;break; + case 0x15: CurrentCallDivert->DType=GSM_CDV_AllTypes;break; //? + case 0x02: CurrentCallDivert->DType=GSM_CDV_AllTypes;break; //? } - } - if (MessageBuffer[10]==0x01) { - CurrentCallDivert->Enabled=true; - CurrentCallDivert->Timeout=MessageBuffer[45]; - strcpy(CurrentCallDivert->Number,GSM_UnpackSemiOctetNumber(MessageBuffer+12,true)); - } else { - CurrentCallDivert->Enabled=false; - } + if (MessageBuffer[6]==0x02) //? + CurrentCallDivert->CType=GSM_CDV_AllCalls; + else { + switch (MessageBuffer[8]) { + case 0x0b: CurrentCallDivert->CType=GSM_CDV_VoiceCalls;break; + case 0x0d: CurrentCallDivert->CType=GSM_CDV_FaxCalls; break; + case 0x19: CurrentCallDivert->CType=GSM_CDV_DataCalls; break; + } + } - CurrentCallDivertError=GE_NONE; + if (MessageBuffer[10]==0x01) { + CurrentCallDivert->Enabled=true; + CurrentCallDivert->Timeout=MessageBuffer[45]; + strcpy(CurrentCallDivert->Number,GSM_UnpackSemiOctetNumber(MessageBuffer+12,true)); + } else { + CurrentCallDivert->Enabled=false; + } + CurrentCallDivertError=GE_NONE; + } break; case 0x03: @@ -1903,6 +1916,8 @@ GSM_Error N6110_SetProfile(GSM_Profile *Profile) return (GE_NONE); } +#endif /* UCLINUX */ + bool N6110_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx) { u8 req[60] = { 0x00, 0xd9 }; @@ -1918,6 +1933,8 @@ bool N6110_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx) return (Protocol->SendFrame(32, 0xf0, req)); } +#ifndef UCLINUX + void N6110_ReplyGetCalendarNote(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { int i, j; @@ -2564,9 +2581,11 @@ GSM_Error N6110_DialData(char *Number, char type, void (* callpassup)(char c)) 0x02,0x01,0x05,0x81,0x01,0x00,0x00,0x01,0x02,0x0a, 0x07,0xa1,0x88,0x89,0x21,0x15,0x63,0xa0,0x00,0x06, 0x88,0x90,0x21,0x48,0x40,0xbb }; +#if 0 unsigned char req2[] = { N6110_FRAME_HEADER, 0x42,0x05,0x01, 0x07,0xa2,0xc8,0x81,0x21,0x15,0x63,0xa8,0x00,0x00, 0x07,0xa3,0xb8,0x81,0x20,0x15,0x63,0x80,0x01,0x60 }; +#endif unsigned char req3[] = { N6110_FRAME_HEADER, 0x42,0x05,0x01, 0x07,0xa2,0x88,0x81,0x21,0x15,0x63,0xa8,0x00,0x00, 0x07,0xa3,0xb8,0x81,0x20,0x15,0x63,0x80 }; @@ -2582,12 +2601,16 @@ GSM_Error N6110_DialData(char *Number, char type, void (* callpassup)(char c)) switch (type) { case 0: + usleep(100); Protocol->SendMessage(sizeof(req3), 0x01, req3); /* Lace */ + usleep(100); req_end = req_end0; size = sizeof(req_end0); break; case 1: Protocol->SendMessage(sizeof(req3), 0x01, req3); + usleep(1000000); Protocol->SendMessage(sizeof(req4), 0x01, req4); + usleep(1000000); req_end = req_end1; size = sizeof(req_end1); break; @@ -2608,7 +2631,14 @@ GSM_Error N6110_DialData(char *Number, char type, void (* callpassup)(char c)) memcpy(req + 5 + strlen(Number), req_end, size); Protocol->SendMessage(5 + size + strlen(Number), 0x01, req); - if (type != 1) Protocol->SendMessage(26, 0x01, req2); + usleep(1000000); + +#if 0 + if (type != 1) { + Protocol->SendMessage(26, 0x01, req2); + usleep(1000000); + } +#endif return (GE_NONE); } @@ -3108,6 +3138,8 @@ GSM_Error N6110_GetSMSFolders ( GSM_SMSFolders *folders) return GE_NONE; } +#endif /* UCLINUX */ + GSM_Error N6110_GetIMEI(char *imei) { if (strlen(Current_IMEI)>0) { @@ -3129,8 +3161,6 @@ GSM_Error N6110_GetRevision(char *revision) return (GE_TRYAGAIN); } -#endif /* UCLINUX */ - static GSM_Error N6110_GetModel(char *model) { if (strlen(Current_Model)>0) { @@ -3267,9 +3297,15 @@ static void N6110_ReplyGetMemoryLocation(u16 MessageLength, u8 *MessageBuffer, u while (N6110_GetModel(model) != GE_NONE) sleep(1); - if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) {//pbk with Unicode + if (GetModelFeature (FN_PHONEBOOK)==F_PBK33SIM || + GetModelFeature (FN_PHONEBOOK)==F_PBK33INT) {//pbk with Unicode +#ifndef UCLINUX DecodeUnicode (CurrentPhonebookEntry->Name, MessageBuffer+6, count/2); CurrentPhonebookEntry->Name[count/2] = 0x00; +#else /* UCLINUX */ + fprintf(stderr,"FATAL ERROR: DecodeUnicode disabled!\n"); + exit(1); +#endif /* UCLINUX */ } else { memcpy(CurrentPhonebookEntry->Name, MessageBuffer + 6, count); CurrentPhonebookEntry->Name[count] = 0x00; @@ -3279,7 +3315,8 @@ static void N6110_ReplyGetMemoryLocation(u16 MessageLength, u8 *MessageBuffer, u for (tmp=0; tmp Name[tmp/2]='~'; //enables/disables blinking if (tmp%2!=0 && MessageBuffer[6+tmp]==0) CurrentPhonebookEntry->Name[tmp/2]='`'; //hides rest ot contents @@ -3436,7 +3473,9 @@ GSM_Error N6110_WritePhonebookLocation(GSM_PhonebookEntry *entry) current=7; - if (GetModelFeature (FN_PHONEBOOK)==F_PBK33) { + if (GetModelFeature (FN_PHONEBOOK)==F_PBK33INT || + GetModelFeature (FN_PHONEBOOK)==F_PBK33SIM) { +#ifndef UCLINUX req[6] = strlen(entry->Name)*2; @@ -3450,6 +3489,13 @@ GSM_Error N6110_WritePhonebookLocation(GSM_PhonebookEntry *entry) } current+=strlen(entry->Name)*2; + +#else /* UCLINUX */ + + fprintf(stderr,"FATAL ERROR: EncodeUnicode disabled!\n"); + exit(1); + +#endif /* UCLINUX */ } else { req[6] = strlen(entry->Name); @@ -3546,7 +3592,9 @@ GSM_Error N6110_SendDTMF(char *String) (20, &CurrentSendDTMFError, 5+length, 0x01, req); } -void N6110_ReplyGetSpeedDial(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { +#endif /* UCLINUX */ + +static void N6110_ReplyGetSpeedDial(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { switch (MessageBuffer[3]) { @@ -3596,7 +3644,7 @@ GSM_Error N6110_GetSpeedDial(GSM_SpeedDial *entry) (20, &CurrentSpeedDialError, 5, 0x03, req); } -void N6110_ReplySetSpeedDial(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { +static void N6110_ReplySetSpeedDial(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { switch (MessageBuffer[3]) { @@ -3642,6 +3690,8 @@ GSM_Error N6110_SetSpeedDial(GSM_SpeedDial *entry) (20, &CurrentSpeedDialError, 7, 0x03, req); } +#ifndef UCLINUX + /* This function finds parts of SMS in frame used in new Nokia phones in internal protocols (they're coded according to GSM 03.40), copies them to GSM_ETSISMSMessage and calls GSM_DecodeETSISMS to decode @@ -3801,14 +3851,10 @@ void N6110_ReplyGetSMSMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageTy fprintf(stdout, _("Message: SMS reading failed\n")); switch (MessageBuffer[4]) { - case 0x02: - fprintf(stdout, _(" Invalid location!\n"));break; - case 0x07: - fprintf(stdout, _(" Empty SMS location.\n"));break; - case 0x0c: - fprintf(stdout, _(" No access to memory (no PIN on card ?)\n"));break; - default: - fprintf(stdout, _(" Error code %i - please report it \n"),MessageBuffer[4]);break; + case 0x02:fprintf(stdout, _(" Invalid location!\n"));break; + case 0x07:fprintf(stdout, _(" Empty SMS location.\n"));break; + case 0x0c:fprintf(stdout, _(" No access to memory (no PIN on card ?)\n"));break; + default :fprintf(stdout, _(" Error code %i - please report it \n"),MessageBuffer[4]);break; } #endif /* DEBUG */ @@ -3895,8 +3941,7 @@ GSM_Error GSM_EncodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int * switch (PDU) { case SMS_Submit: offset=5; - for (i=0;i<((ETSI.Number[0]+1)/2+1)+1;i++) - req[i+12+offset]=ETSI.Number[i]; + for (i=0;i<((ETSI.Number[0]+1)/2+1)+1;i++) req[i+12+offset]=ETSI.Number[i]; req[10+offset]=ETSI.TPDCS; req[11+offset]=ETSI.TPUDL; req[24+offset]=ETSI.TPVP; @@ -3906,21 +3951,17 @@ GSM_Error GSM_EncodeNokiaSMSFrame(GSM_SMSMessage *SMS, unsigned char *req, int * // fprintf(stdout,_(" TP-DCS: %02x\n"),ETSI.TPDCS); #endif // req[]=ETSI.TPPID; - for(i=0;i<*length;i++) - req[i+31+offset]=ETSI.MessageText[i]; + for(i=0;i<*length;i++) req[i+31+offset]=ETSI.MessageText[i]; break; case SMS_Deliver: offset=4; - for (i=0;i<((ETSI.Number[0]+1)/2+1)+1;i++) - req[i+12+offset]=ETSI.Number[i]; + for (i=0;i<((ETSI.Number[0]+1)/2+1)+1;i++) req[i+12+offset]=ETSI.Number[i]; req[10+offset]=ETSI.TPDCS; req[11+offset]=ETSI.TPUDL; // req[]=ETSI.TPPID; - for(i=0;i<*length;i++) - req[i+31+offset]=ETSI.MessageText[i]; - for (i=0;i<7;i++) - req[24+offset+i]=ETSI.DeliveryDateTime[i]; + for(i=0;i<*length;i++) req[i+31+offset]=ETSI.MessageText[i]; + for (i=0;i<7;i++) req[24+offset+i]=ETSI.DeliveryDateTime[i]; break; default: break; @@ -4939,7 +4980,7 @@ static void N6110_Dispatch0x03Message(u16 MessageLength, u8 *MessageBuffer, u8 M CurrentGetBitmap->width=MessageBuffer[count++]; CurrentGetBitmap->height=MessageBuffer[count++]; count++; - tmp=CurrentGetBitmap->height*CurrentGetBitmap->width/8; + tmp=GSM_GetBitmapSize(CurrentGetBitmap); if (CurrentGetBitmap->size>tmp) CurrentGetBitmap->size=tmp; memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,CurrentGetBitmap->size); CurrentGetBitmapError=GE_NONE; @@ -5023,10 +5064,11 @@ static void N6110_Dispatch0x05Message(u16 MessageLength, u8 *MessageBuffer, u8 M if (CurrentGetBitmap->type==GSM_StartupLogo) { CurrentGetBitmap->height=MessageBuffer[count++]; CurrentGetBitmap->width=MessageBuffer[count++]; - CurrentGetBitmap->size=CurrentGetBitmap->height*CurrentGetBitmap->width/8; + CurrentGetBitmap->size=GSM_GetBitmapSize(CurrentGetBitmap); length=CurrentGetBitmap->size; memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,length); } else { + //bitmap size length=MessageBuffer[count++]; length=length*MessageBuffer[count++]/8; } @@ -5141,7 +5183,7 @@ static void N6110_Dispatch0x05Message(u16 MessageLength, u8 *MessageBuffer, u8 M CurrentGetBitmap->width=MessageBuffer[count++]; CurrentGetBitmap->height=MessageBuffer[count++]; count++; - tmp=CurrentGetBitmap->height*CurrentGetBitmap->width/8; + tmp=GSM_GetBitmapSize(CurrentGetBitmap); if (CurrentGetBitmap->size>tmp) CurrentGetBitmap->size=tmp; memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count,CurrentGetBitmap->size); CurrentGetBitmapError=GE_NONE; @@ -5220,8 +5262,6 @@ static void N6110_Dispatch0x06Message(u16 MessageLength, u8 *MessageBuffer, u8 M } } -#endif /* UCLINUX */ - static void N6110_Dispatch0x09Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { switch (MessageBuffer[3]) { @@ -5247,8 +5287,6 @@ static void N6110_Dispatch0x09Message(u16 MessageLength, u8 *MessageBuffer, u8 M } } -#ifndef UCLINUX - static void N6110_Dispatch0x13Message(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) { switch(MessageBuffer[3]) { @@ -5395,7 +5433,7 @@ static void N6110_Dispatch0x47Message(u16 MessageLength, u8 *MessageBuffer, u8 M CurrentGetBitmap->width=MessageBuffer[count+1]; CurrentGetBitmap->height=MessageBuffer[count+2]; - CurrentGetBitmap->size=CurrentGetBitmap->height*CurrentGetBitmap->width/8; + CurrentGetBitmap->size=GSM_GetBitmapSize(CurrentGetBitmap); memcpy(CurrentGetBitmap->bitmap,MessageBuffer+count+4,CurrentGetBitmap->size); @@ -5584,11 +5622,11 @@ void N6110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) case 0x06:N6110_ReplyWritePhonebookLocation(MessageLength,MessageBuffer,MessageType);break; case 0x08: case 0x09:N6110_ReplyGetMemoryStatus(MessageLength,MessageBuffer,MessageType);break; -#ifndef UCLINUX case 0x17: case 0x18:N6110_ReplyGetSpeedDial(MessageLength,MessageBuffer,MessageType);break; case 0x1a: case 0x1b:N6110_ReplySetSpeedDial(MessageLength,MessageBuffer,MessageType);break; +#ifndef UCLINUX default :N6110_Dispatch0x03Message(MessageLength,MessageBuffer,MessageType);break; #endif /* UCLINUX */ } @@ -5634,7 +5672,6 @@ void N6110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) default :N6110_ReplyEnterSecurityCode (MessageLength,MessageBuffer,MessageType);break; } break; -#endif /* UCLINUX */ /* SIM login */ case 0x09: @@ -5642,7 +5679,6 @@ void N6110_DispatchMessage(u16 MessageLength, u8 *MessageBuffer, u8 MessageType) N6110_Dispatch0x09Message(MessageLength, MessageBuffer, MessageType); break; -#ifndef UCLINUX /* Network info */ case 0x0a: switch (MessageBuffer[3]) {