Diffstat (limited to 'gammu/emb/gammu/depend/nokia/dct4.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/gammu/depend/nokia/dct4.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gammu/emb/gammu/depend/nokia/dct4.c b/gammu/emb/gammu/depend/nokia/dct4.c index f4ed305..4bf958d 100644 --- a/gammu/emb/gammu/depend/nokia/dct4.c +++ b/gammu/emb/gammu/depend/nokia/dct4.c @@ -14,49 +14,50 @@ #include "../../../common/misc/coding/coding.h" extern GSM_Reply_Function UserReplyFunctions4[]; /* ------- some usefull functions ----------------------------------------- */ GSM_Error CheckDCT4Only() { bool found = false; /* Checking if phone is DCT4 */ #ifdef GSM_ENABLE_NOKIA3650 if (strstr(N3650Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; #endif #ifdef GSM_ENABLE_NOKIA6510 if (strstr(N6510Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; #endif #ifdef GSM_ENABLE_NOKIA3320 if (strstr(N3320Phone.models, s.Phone.Data.ModelInfo->model) != NULL) found = true; #endif if (!found) return ERR_NOTSUPPORTED; if (s.ConnectionType!=GCT_MBUS2 && s.ConnectionType!=GCT_FBUS2 && s.ConnectionType!=GCT_FBUS2DLR3 && s.ConnectionType!=GCT_PHONETBLUE && - s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET) { + s.ConnectionType!=GCT_IRDAPHONET && s.ConnectionType!=GCT_BLUEPHONET && + s.ConnectionType!=GCT_FBUS2DKU5) { return ERR_OTHERCONNECTIONREQUIRED; } return ERR_NONE; } static void CheckDCT4() { GSM_Error error; error = CheckDCT4Only(); switch (error) { case ERR_NOTSUPPORTED: Print_Error(ERR_NOTSUPPORTED); break; case ERR_OTHERCONNECTIONREQUIRED: printf("Can't do it with current phone protocol\n"); GSM_TerminateConnection(&s); exit(-1); default: break; } } static bool answer_yes2(char *text) @@ -864,84 +865,87 @@ void DCT4GetT9(int argc, char *argv[]) i = 0; while (1) { req[12] = i / 256; req[13] = i % 256; if (i != 0) { if (T9Dictionary - i < req[16]*256+req[17]) { req[16] = (T9Dictionary - i) / 256; req[17] = (T9Dictionary - i) % 256; } if (T9Dictionary - i == 0) break; } error=GSM_WaitFor (&s, req, 18, 0x23, 4, ID_User3); Print_Error(error); if (i==0) { T9Dictionary = T9FullSize; dbgprintf("T9 dictionary size is %i\n",T9Dictionary); } i+=T9Size; } fclose(T9File); } +#ifdef GSM_ENABLE_NOKIA6510 + extern GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable); void DCT4SetLight(int argc, char *argv[]) { int i; N6510_PHONE_LIGHTS type; bool enable; if (mystrncasecmp(argv[2],"display",0)) { type = N6510_LIGHT_DISPLAY; } else if (mystrncasecmp(argv[2],"keypad",0)) { type = N6510_LIGHT_KEYPAD; } else if (mystrncasecmp(argv[2],"torch",0)) { type = N6510_LIGHT_TORCH; } else { printf("What lights should I enable (\"%s\") ?\n",argv[2]); exit(-1); } if (mystrncasecmp(argv[3],"on",0)) { enable = true; } else if (mystrncasecmp(argv[3],"off",0)) { enable = false; } else { printf("What should I do (\"%s\") ?\n",argv[3]); exit(-1); } for (i=0;i<s.ConfigNum;i++) { s.Config[i].StartInfo = "false"; } GSM_Init(true); CheckDCT4(); error=N6510_SetLight(&s, type, enable); Print_Error(error); GSM_Terminate(); } +#endif void DCT4DisplayTest(int argc, char *argv[]) { unsigned char ans[200]; unsigned char req0[] = {0x00, 0x08, 0x0D, 0x00, 0x0F, 0x00}; unsigned char req[] = {0x00, 0x08, 0x0E, 0x00, 0x12, 0x01, 0x00, 0x04, 0x09, /* test number */ 0x00}; if (CheckDCT4Only()!=ERR_NONE) return; s.User.UserReplyFunctions=UserReplyFunctions4; DCT4_SetPhoneMode(&s, DCT4_MODE_TEST); s.Protocol.Functions->WriteMessage(&s, req0, 6, 0x40); req[8] = atoi(argv[2]); s.Protocol.Functions->WriteMessage(&s, req, 10, 0x40); printf("Press any key to continue...\n"); GetLine(stdin, ans, 99); DCT4_SetPhoneMode(&s, DCT4_MODE_NORMAL); @@ -1000,48 +1004,50 @@ void DCT4GetADC(int argc, char *argv[]) 0x01}; unsigned char GetUnit[] = {N6110_FRAME_HEADER, 0x11, 0x00, /* Test number */ 0x01}; if (CheckDCT4Only()!=ERR_NONE) return; s.User.UserReplyFunctions=UserReplyFunctions4; while (1) { printf(" %30s ",DCT4ADC[i].name); GetRaw[4] = i; error=GSM_WaitFor (&s, GetRaw, 6, 0x17, 4, ID_User3); Print_Error(error); GetUnit[4] = i; ADC = DCT4ADC[i].x; error=GSM_WaitFor (&s, GetUnit, 6, 0x17, 4, ID_User3); Print_Error(error); printf("%s\n",DCT4ADC[i].unit); i++; if (DCT4ADC[i].name[0] == 0x00) break; } } +#ifdef GSM_ENABLE_NOKIA6510 + static double RadioFreq; static unsigned char RadioName[100]; static GSM_Error DCT4_ReplyTuneRadio(GSM_Protocol_Message msg, GSM_StateMachine *s) { int length; unsigned char name[100]; switch (msg.Buffer[3]) { case 0x09: N6510_DecodeFMFrequency(&RadioFreq, msg.Buffer+16); length = msg.Buffer[8]; memcpy(name,msg.Buffer+18,length*2); name[length*2] = 0x00; name[length*2+1] = 0x00; CopyUnicodeString(RadioName,name); smprintf(s,"Station name: \"%s\"\n",DecodeUnicodeString(RadioName)); return ERR_NONE; case 0x15: case 0x16: smprintf(s,"Response for enabling radio/headset status received\n"); if (msg.Buffer[5] == 0) { smprintf(s,"Connected\n"); @@ -1153,48 +1159,49 @@ void DCT4TuneRadio(int argc, char *argv[]) fprintf(stderr,"%.1f MHz - \"%s\" \n", FMStation[i].Frequency, DecodeUnicodeString(FMStation[i].StationName)); } if (answer_yes2("Do you want to save found stations")) { fprintf(stderr,"Deleting old FM stations: "); error=Phone->ClearFMStations(&s); Print_Error(error); fprintf(stderr,"Done\n"); for (i=0;i<num;i++) { FMStation[i].Location = i+1; error=Phone->SetFMStation(&s,&FMStation[i]); Print_Error(error); fprintf(stderr,"%cWriting: %i percent",13,(i+1)*100/num); } fprintf(stderr,"\n"); } error=GSM_WaitFor (&s, Disable, 6, 0x3E, 4, ID_User3); Print_Error(error); GSM_Terminate(); } +#endif void DCT4PlaySavedRingtone(int argc, char *argv[]) { unsigned char req[] = {N6110_FRAME_HEADER, 0x01, 0x00,0x64, //id 0x01, //group 0x01,0x00,0x00, 0x0A, //volume 0x00,0x00,0x00,0x00,0x00,0x00,0x00}; GSM_AllRingtonesInfo Info; GSM_Init(true); CheckDCT4(); s.User.UserReplyFunctions=UserReplyFunctions4; error=Phone->GetRingtonesInfo(&s,&Info); Print_Error(error); if (atoi(argv[2]) > Info.Number-1) { GSM_Terminate(); return; @@ -1292,50 +1299,52 @@ static GSM_Reply_Function UserReplyFunctions4[] = { {DCT4_ReplyGetScreenDump, "\x0E",0x00,0x00,ID_IncomingFrame}, {DCT4_ReplyGetADC, "\x17",0x03,0x10,ID_User3 }, {DCT4_ReplyGetADC, "\x17",0x03,0x12,ID_User3 }, {DCT4_ReplySetPPS, "\x1b",0x03,0x05,ID_User1 }, {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_User6 }, {DCT4_ReplyVibra, "\x1C",0x03,0x0D,ID_User3 }, {DCT4_ReplyVibra, "\x1C",0x03,0x0F,ID_User3 }, {NoneReply, "\x1F",0x03,0x02,ID_User3 }, {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x05,ID_User1 }, {DCT4_ReplyGetT9, "\x23",0x03,0x05,ID_User3 }, {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x05,ID_User4 }, {DCT4_ReplyGetVoiceRecord, "\x23",0x03,0x0D,ID_User4 }, {DCT4_ReplyGetSecurityCode, "\x23",0x03,0x0D,ID_User1 }, {DCT4_ReplyTestsStartup, "\x35",0x02,0x01,ID_User3 }, {DCT4_ReplyTestsStartup, "\x35",0x02,0x02,ID_User3 }, {DCT4_ReplyTestsNames, "\x35",0x02,0x03,ID_User1 }, {DCT4_ReplyTestsStatus, "\x35",0x02,0x04,ID_User2 }, +#ifdef GSM_ENABLE_NOKIA6510 {DCT4_ReplyTuneRadio, "\x3E",0x03,0x09,ID_User3 }, {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_User3 }, {DCT4_ReplyTuneRadio, "\x3E",0x03,0x15,ID_SetFMStation}, {DCT4_ReplyTuneRadio, "\x3E",0x03,0x16,ID_User3 }, +#endif {DCT4_ReplyGetVoiceRecord, "\x4A",0x03,0x31,ID_User4 }, {DCT4_ReplyGetSimlock, "\x53",0x03,0x0D,ID_User6 }, {DCT4_ReplyGetSimlock, "\x53",0x03,0x13,ID_User6 }, {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x03,ID_User3 }, {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x07,ID_User3 }, {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x08,ID_User3 }, {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0x0A,ID_User3 }, {DCT4_ReplyMakeCameraShoot, "\x61",0x03,0xF0,ID_User3 }, {DCT4_ReplyGetBTInfo, "\xD7",0x03,0x0A,ID_User6 }, {NULL, "\x00",0x00,0x00,ID_None } }; #endif /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ |