diff -ur --exclude=CVS gnokii/common/gsm-statemachine.c gnokii_new/common/gsm-statemachine.c --- gnokii/common/gsm-statemachine.c Tue Sep 7 12:37:28 2004 +++ gnokii_new/common/gsm-statemachine.c Tue Dec 14 01:08:23 2004 @@ -129,8 +129,12 @@ dprintf("Unsolicited frame, skipping...\n"); free(edata); return; - } else if (res == GN_ERR_UNHANDLEDFRAME) + } else if (res == GN_ERR_UNHANDLEDFRAME) { sm_unhandled_frame_dump(messagetype, message, messagesize, state); + } else if (res == GN_ERR_WAITING) { + free(edata); + return; + } if (temp != 0) { dprintf("Unknown Frame Type %02x\n", messagetype); state->driver.default_function(messagetype, message, messagesize, state); diff -ur --exclude=CVS gnokii/common/misc.c gnokii_new/common/misc.c --- gnokii/common/misc.c Mon Oct 11 08:42:04 2004 +++ gnokii_new/common/misc.c Tue Dec 14 01:05:59 2004 @@ -235,7 +235,7 @@ {"7210", "NHL-4", PM_CALLERGROUP | PM_CALENDAR | PM_SPEEDDIAL | PM_EXTPBK | PM_SMS | PM_FOLDERS }, {"7250", "NHL-4J", PM_CALLERGROUP | PM_CALENDAR | PM_SPEEDDIAL | PM_EXTPBK | PM_SMS | PM_FOLDERS }, {"7250i", "NHL-4JX", PM_CALLERGROUP | PM_CALENDAR | PM_SPEEDDIAL | PM_EXTPBK | PM_SMS | PM_FOLDERS }, - {"7600", "NMM-3", 0 }, + {"7600", "NMM-3", PM_CALLERGROUP | PM_EXTPBK | PM_SMS | PM_FOLDERS | PM_SPEEDDIAL | PM_CALENDAR | PM_DTMF }, {"7650", "NHL-2NA", PM_CALLERGROUP | PM_CALENDAR | PM_SPEEDDIAL | PM_EXTPBK | PM_SMS | PM_FOLDERS }, {"8110", "0423" , PM_SMS | PM_DTMF | PM_DATA }, /* NHE-6BX */ {"8110", "2501", PM_SMS | PM_DTMF | PM_DATA }, diff -ur --exclude=CVS gnokii/common/nokia-decoding.c gnokii_new/common/nokia-decoding.c --- gnokii/common/nokia-decoding.c Tue Feb 17 20:29:51 2004 +++ gnokii_new/common/nokia-decoding.c Tue Dec 14 01:05:59 2004 @@ -38,7 +38,7 @@ gn_error phonebook_decode(unsigned char *blockstart, int length, gn_data *data, int blocks, int memtype, int speeddial_pos) { - int subblock_count = 0, i; + int subblock_count = 0, i,j; gn_phonebook_subentry* subentry = NULL; @@ -51,6 +51,7 @@ blockstart[0] != GN_PHONEBOOK_ENTRY_LogoSwitch && blockstart[0] != GN_PHONEBOOK_ENTRY_Group && blockstart[0] != GN_PHONEBOOK_ENTRY_Pointer && + blockstart[0] != GN_PHONEBOOK_ENTRY_RingtoneAdv && /* the last one can be the case of the bitmap name -- we * don't have phonebook entry allocated then, but a bitmap; * we handle this later on @@ -187,6 +188,22 @@ if (data->bitmap) data->bitmap->number = blockstart[5] - 1; dprintf(" Group: %d\n", blockstart[5] - 1); + break; + case GN_PHONEBOOK_ENTRY_RingtoneAdv: /* Newer ringtones */ + switch(blockstart[15]) { + case 0x01: + memcpy(data->bitmap->ringtone_id,blockstart+6,6); + dprintf(" Gallery ringtone id: %02x %02x %02x %02x %02x %02x\n",blockstart[6],blockstart[7],blockstart[8],blockstart[9],blockstart[10],blockstart[11]); + data->bitmap->ringtone = -1; + break; + case 0x07: + data->bitmap->ringtone = blockstart[11]; + dprintf(" Standard ringtone: %d\n", blockstart[11]); + break; + default: + dprintf(" Unknown ringtone entry!\n"); + break; + } break; default: dprintf("Unknown phonebook block %02x\n", blockstart[0]); diff -ur --exclude=CVS gnokii/common/phones/nk6510.c gnokii_new/common/phones/nk6510.c --- gnokii/common/phones/nk6510.c Sun Oct 31 15:03:10 2004 +++ gnokii_new/common/phones/nk6510.c Tue Dec 14 01:05:59 2004 @@ -137,6 +137,14 @@ static gn_error NK6510_CancelCall(gn_data *data, struct gn_statemachine *state); static gn_error NK6510_AnswerCall(gn_data *data, struct gn_statemachine *state); +static gn_error NK6510_Reset(gn_data *data, struct gn_statemachine *state); + +static gn_error NK6510_GetFileList(gn_data *data, struct gn_statemachine *state); +static gn_error NK6510_GetFileId(gn_data *data, struct gn_statemachine *state); +static gn_error NK6510_GetFile(gn_data *data, struct gn_statemachine *state); +static gn_error NK6510_PutFile(gn_data *data, struct gn_statemachine *state); +static gn_error NK6510_DeleteFile(gn_data *data, struct gn_statemachine *state); + #ifdef SECURITY static gn_error NK6510_GetSecurityCodeStatus(gn_data *data, struct gn_statemachine *state); static gn_error NK6510_EnterSecurityCode(gn_data *data, struct gn_statemachine *state); @@ -167,12 +175,14 @@ static gn_error NK6510_IncomingWAP(int messagetype, unsigned char *message, int length, gn_data *data, struct gn_statemachine *state); static gn_error NK6510_IncomingToDo(int messagetype, unsigned char *message, int length, gn_data *data, struct gn_statemachine *state); static gn_error NK6510_IncomingSound(int messagetype, unsigned char *message, int length, gn_data *data, struct gn_statemachine *state); +static gn_error NK6510_IncomingReset(int messagetype, unsigned char *message, int length, gn_data *data, struct gn_statemachine *state); +static gn_error NK6510_IncomingRadio(int messagetype, unsigned char *message, int length, gn_data *data, struct gn_statemachine *state); +static gn_error NK6510_IncomingFile(int messagetype, unsigned char *message, int length, gn_data *data, struct gn_statemachine *state); #ifdef SECURITY static gn_error NK6510_IncomingSecurity(int messagetype, unsigned char *message, int length, gn_data *data, struct gn_statemachine *state); #endif - static int sms_encode(gn_data *data, struct gn_statemachine *state, unsigned char *req); static int get_memory_type(gn_memory_type memory_type); @@ -182,6 +192,7 @@ static bool new_sms = false; /* Do we have a new SMS? */ static gn_incoming_function_type nk6510_incoming_functions[] = { + { NK6510_MSG_RESET, NK6510_IncomingReset }, { NK6510_MSG_FOLDER, NK6510_IncomingFolder }, { NK6510_MSG_SMS, NK6510_IncomingSMS }, { NK6510_MSG_PHONEBOOK, NK6510_IncomingPhonebook }, @@ -205,6 +216,8 @@ { NK6510_MSG_WAP, NK6510_IncomingWAP }, { NK6510_MSG_TODO, NK6510_IncomingToDo }, { NK6510_MSG_SOUND, NK6510_IncomingSound }, + { NK6510_MSG_RADIO, NK6510_IncomingRadio }, + { NK6510_MSG_FILE, NK6510_IncomingFile }, { 0, NULL } }; @@ -213,7 +226,7 @@ pgen_incoming_default, /* Mobile phone information */ { - "6510|6310|8310|6310i|6360|6610|6100|5100|3510|3510i|3595|6800|6810|6820|6820b|6610i|6230|6650|7210|7250|7250i", /* Supported models */ + "6510|6310|8310|6310i|6360|6610|6100|5100|3510|3510i|3595|6800|6810|6820|6820b|6610i|6230|6650|7210|7250|7250i|7600", /* Supported models */ 7, /* Max RF Level */ 0, /* Min RF Level */ GN_RF_Percentage, /* RF level units */ @@ -384,6 +397,18 @@ return NK6510_DeleteRingtone(data, state); case GN_OP_PlayTone: return NK6510_PlayTone(data, state); + case GN_OP_Reset: + return NK6510_Reset(data, state); + case GN_OP_GetFileList: + return NK6510_GetFileList(data, state); + case GN_OP_GetFileId: + return NK6510_GetFileId(data, state); + case GN_OP_GetFile: + return NK6510_GetFile(data, state); + case GN_OP_PutFile: + return NK6510_PutFile(data, state); + case GN_OP_DeleteFile: + return NK6510_DeleteFile(data, state); default: return GN_ERR_NOTIMPLEMENTED; } @@ -450,6 +475,7 @@ */ state->config.rfcomm_cn = 14; case GN_CT_Infrared: + case GN_CT_DKU2: case GN_CT_Irda: err = phonet_initialise(state); /* Don't loop forever */ @@ -495,6 +521,16 @@ state->driver.phone.startup_logo_height = 48; state->driver.phone.max_battery_level = 4; } + + if (!strncmp(data.model, "NMM-3", 5)) { + state->driver.phone.max_battery_level=4; + state->driver.phone.operator_logo_width = 0; + state->driver.phone.operator_logo_height = 0; + state->driver.phone.startup_logo_width = 0; + state->driver.phone.startup_logo_height = 0; + state->driver.phone.max_battery_level = 4; + } + } if (!connected) return err; return GN_ERR_NONE; @@ -1477,6 +1513,242 @@ return error; } +/*****************/ +/* FILE HANDLING */ +/*****************/ + +static gn_error NK6510_GetFileList(gn_data *data, struct gn_statemachine *state) +{ + unsigned char req[512] = {FBUS_FRAME_HEADER, 0x68, 0x00}; + int i; + + if(!data->file_list) return GN_ERR_INTERNALERROR; + data->file_list->file_count=0; + + i=strlen(data->file_list->path); + req[5]=char_unicode_encode(req+6,data->file_list->path,i); + + if (sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state)) return GN_ERR_NOTREADY; + return sm_block(NK6510_MSG_FILE, data, state); +} + +static gn_error NK6510_GetFileId(gn_data *data, struct gn_statemachine *state) +{ + unsigned char req[512] = {FBUS_FRAME_HEADER, 0x82, 0x00}; + int i; + + if(!data->file) return GN_ERR_INTERNALERROR; + + i=strlen(data->file->name); + req[5]=char_unicode_encode(req+6,data->file->name,i); + + if (sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state)) return GN_ERR_NOTREADY; + return sm_block(NK6510_MSG_FILE, data, state); +} + +static gn_error NK6510_GetFile(gn_data *data, struct gn_statemachine *state) +{ + unsigned char req[512] = {FBUS_FRAME_HEADER, 0x68, 0x00}; + unsigned char req2[512] = {FBUS_FRAME_HEADER, 0x72, 0x00, 0x00, 0x00}; + unsigned char req3[] = {FBUS_FRAME_HEADER, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, // Start position + 0x00, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x00, 0x00}; // Size + unsigned char req4[] = {FBUS_FRAME_HEADER, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}; + gn_error err; + int i; + + if(!data->file) return GN_ERR_INTERNALERROR; + i=strlen(data->file->name); + + /* Get the file size */ + req[5]=char_unicode_encode(req+6,data->file->name,i); + if (sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state)) return GN_ERR_NOTREADY; + err=sm_block(NK6510_MSG_FILE, data, state); + if(err!=GN_ERR_NONE) return err; + data->file->file=malloc(data->file->file_length); + if(!data->file->file) return GN_ERR_INTERNALERROR; + + /* Start the transfer */ + req2[7]=char_unicode_encode(req2+8,data->file->name,i); + data->file->togo=0; + if (sm_message_send(req2[7]+12, NK6510_MSG_FILE, req2, state)) return GN_ERR_NOTREADY; + err=sm_block(NK6510_MSG_FILE, data, state); + if(err!=GN_ERR_NONE) return err; + if(data->file->togo!=data->file->file_length) return GN_ERR_INTERNALERROR; + + /* Get the data */ + while(data->file->togo>0) { + i=data->file->file_length-data->file->togo; + req3[11]=(i&0xff0000)>>16; + req3[12]=(i&0xff00)>>8; + req3[13]=i&0xff; + if(data->file->togo>0x100) { + req3[20]=0x01; + } else { + req3[19]=(data->file->togo&0xff0000)>>16; + req3[20]=(data->file->togo&0xff00)>>8; + req3[21]=data->file->togo&0xff; + } + if (sm_message_send(sizeof(req3), NK6510_MSG_FILE, req3, state)) return GN_ERR_NOTREADY; + err=sm_block(NK6510_MSG_FILE, data, state); + if(err!=GN_ERR_NONE) return err; + } + + /* Finish the transfer */ + if (sm_message_send(sizeof(req4), NK6510_MSG_FILE, req4, state)) return GN_ERR_NOTREADY; + return sm_block(NK6510_MSG_FILE, data, state); +} + +static gn_error NK6510_PutFile(gn_data *data, struct gn_statemachine *state) +{ + unsigned char req1[512] = {FBUS_FRAME_HEADER, 0x72, 0x11, 0x00, 0x00}; + unsigned char req2[512] = {FBUS_FRAME_HEADER, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00}; // Size + unsigned char req3[] = {FBUS_FRAME_HEADER, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}; + gn_error err; + int i; + + if(!data->file) return GN_ERR_INTERNALERROR; + i=strlen(data->file->name); + + /* Start the transfer */ + req1[7]=char_unicode_encode(req1+8,data->file->name,i); + data->file->togo=0; + if (sm_message_send(req1[7]+12, NK6510_MSG_FILE, req1, state)) return GN_ERR_NOTREADY; + err=sm_block(NK6510_MSG_FILE, data, state); + if(err!=GN_ERR_NONE) return err; + if(data->file->togo!=data->file->file_length) return GN_ERR_INTERNALERROR; + + /* Put the data */ + while(data->file->togo>0) { + i=data->file->togo; + if(data->file->togo>0x100) { + req2[12]=0x01; + data->file->just_sent=0x100; + } else { + req2[11]=(data->file->togo&0xff0000)>>16; + req2[12]=(data->file->togo&0xff00)>>8; + req2[13]=data->file->togo&0xff; + data->file->just_sent=data->file->togo; + } + memcpy(req2+14,data->file->file+data->file->file_length-data->file->togo,data->file->just_sent); + if (sm_message_send(14+data->file->just_sent,NK6510_MSG_FILE,req2,state)) return GN_ERR_NOTREADY; + err=sm_block(NK6510_MSG_FILE, data, state); + if(err!=GN_ERR_NONE) return err; + if(data->file->togo!=i-data->file->just_sent) return GN_ERR_INTERNALERROR; + } + + /* Finish the transfer */ + if (sm_message_send(sizeof(req3), NK6510_MSG_FILE, req3, state)) return GN_ERR_NOTREADY; + return sm_block(NK6510_MSG_FILE, data, state); +} + +static gn_error NK6510_DeleteFile(gn_data *data, struct gn_statemachine *state) +{ + unsigned char req[512] = {FBUS_FRAME_HEADER, 0x62, 0x00}; + gn_error err; + int i; + + if(!data->file) return GN_ERR_INTERNALERROR; + i=strlen(data->file->name); + + req[5]=char_unicode_encode(req+6,data->file->name,i); + if (sm_message_send(req[5]+9, NK6510_MSG_FILE, req, state)) return GN_ERR_NOTREADY; + return sm_block(NK6510_MSG_FILE, data, state); +} + + +static gn_error NK6510_IncomingFile(int messagetype, unsigned char *message, int length, gn_data *data, struct gn_statemachine *state) { + int i; + char string[300]; + gn_file *file; + + switch (message[3]) { + case 0x59: + // Sent a block of file ok + if(data->file) { + data->file->togo-=data->file->just_sent; + return GN_ERR_NONE; + } + break; + case 0x5f: + // Recv a block of file + if(data->file) { + i=(message[8]<<8)+message[9]; + memcpy(data->file->file+data->file->file_length-data->file->togo,message+10,i); + data->file->togo-=i; + return GN_ERR_NONE; + } + break; + case 0x63: + // Deleted ok + if(message[4]==0x06) { + dprintf("Invalid path\n"); + return GN_ERR_INVALIDLOCATION; + } + return GN_ERR_NONE; + break; + case 0x6d: + case 0x69: + if(message[04]==0x06) { + dprintf("Invalid path\n"); + return GN_ERR_INVALIDLOCATION; + } + if(message[04]==0x0e) { + dprintf("Empty directory\n"); + return GN_ERR_NONE; + } + if(data->file) { + file=data->file; + } else if(data->file_list) { + data->file_list->files[data->file_list->file_count]=malloc(sizeof(gn_file)); + file=data->file_list->files[data->file_list->file_count]; + data->file_list->file_count++; + i=message[31]*2; + char_unicode_decode(file->name, message+32, i); + } + if(!file) return GN_ERR_INTERNALERROR; + dprintf("Filename: %s\n",file->name); + dprintf(" Status bytes: %02x %02x %02x\n",message[8],message[9],message[29]); + file->file_length=(message[11]<<16)+(message[12]<<8)+message[13]; + dprintf(" Filesize: %d\n",file->file_length); + file->year=(message[14]<<8)+message[15]; + file->month=message[16]; + file->day=message[17]; + file->hour=message[18]; + file->minute=message[19]; + file->second=message[20]; + dprintf(" Date: %04u.%02u.%02u\n",file->year,file->month,file->day); + dprintf(" Time: %02u:%02u:%02u\n",file->hour,file->minute,file->second); + if(message[4]==0x0d) return GN_ERR_WAITING; + break; + case 0x73: + if(data->file) { + if(message[4]==0x0c) { + data->file->togo=-1; + } else if(message[4]==0x00) { + data->file->togo=data->file->file_length; + } + } + break; + case 0x75: + // file transfer complete ok + return GN_ERR_NONE; + break; + case 0x83: + if(data->file) { + memcpy(data->file->id,message+4,6); + } + break; + default: + break; + } + return GN_ERR_NONE; +} + + + /**********************/ /* PHONEBOOK HANDLING */ /**********************/ @@ -1651,13 +1923,14 @@ static gn_error SetCallerBitmap(gn_data *data, struct gn_statemachine *state) { - unsigned char req[200] = {FBUS_FRAME_HEADER, 0x0B, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10, + unsigned char req[400] = {FBUS_FRAME_HEADER, 0x0B, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10, 0xFF, 0x10, 0x00, 0x06, /* number */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; /* blocks */ unsigned int count = 22, block = 0; char string[150]; + int i; /* 00 01 00 0B 00 01 01 00 00 10 @@ -1679,7 +1952,7 @@ string[0] = data->bitmap->number + 1; string[1] = 0; string[2] = 0x55; - count += PackBlock(0x1e, 3, block++, string, req + count, 200 - count); + count += PackBlock(0x1e, 3, block++, string, req + count, 400 - count); /* Logo */ string[0] = data->bitmap->width; @@ -1687,37 +1960,36 @@ string[2] = string[3] = 0x00; string[4] = 0x7e; memcpy(string + 5, data->bitmap->bitmap, data->bitmap->size); - count += PackBlock(0x1b, data->bitmap->size + 5, block++, string, req + count, 200 - count); + count += PackBlock(0x1b, data->bitmap->size + 5, block++, string, req + count, 400 - count); -#if 0 /* Name */ - switch (data->bitmap->number) { - case 0: - string[0] = 0x0d; - char_unicode_encode(string + 1, "Family", 6); - break; - case 1: - string[0] = 0x07; - char_unicode_encode(string + 1, "VIP", 3); - break; - case 2: - string[0] = 0x0f; - char_unicode_encode(string + 1, "Friends", 7); - break; - case 3: - string[0] = 0x15; - char_unicode_encode(string + 1, "Colleagues", 10); - break; - case 4: - string[0] = 0x0d; - char_unicode_encode(string + 1, "Others", 6); - break; - default: - string[0] = 0x00; - break; + i = strlen(data->bitmap->text); + i = char_unicode_encode((string + 1), data->bitmap->text, i); + string[0] = i; + count += PackBlock(0x07, i + 1, block++, string, req + count, 400 - count); + + /* Ringtone */ + if(data->bitmap->ringtone<0) { + string[0]=0x00; + string[7]=0x00; + string[8]=0x00; + string[9]=0x00; + string[10]=0x01; + memcpy(string+1,data->bitmap->ringtone_id,6); + } else { + string[0]=0x00; + string[1]=0x00; + string[2]=0x00; + string[3]=0x00; + string[4]=0x00; + string[5]=(data->bitmap->ringtone&0xff00)>>8; + string[6]=(data->bitmap->ringtone&0x00ff); + string[7]=0x00; + string[8]=0x00; + string[9]=0x00; + string[10]=0x07; } - if (string[0]) count += PackBlock(0x07, string[0], block++, string, req + count, 200 - count); -#endif + count += PackBlock(0x37, 11, block++, string, req + count, 400-count); req[21] = block; SEND_MESSAGE_BLOCK(NK6510_MSG_PHONEBOOK, count); @@ -2516,13 +2788,15 @@ static gn_error SetOperatorBitmap(gn_data *data, struct gn_statemachine *state) { - unsigned char req[300] = {FBUS_FRAME_HEADER, 0x25, 0x01, 0x55, 0x00, 0x00, 0x55, + //unsigned char req[1000] = {FBUS_FRAME_HEADER, 0x25, 0x01, 0x55, 0x00, 0x00, 0x55, + unsigned char req[1000] = {FBUS_FRAME_HEADER, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, /* Blocks */ 0x0c, 0x08, /* type, length */ - 0x62, 0xf2, 0x20, 0x03, 0x55, 0x55, - 0x1a}; + //0x62, 0xf2, 0x20, 0x03, 0x55, 0x55, + 0x62, 0xf2, 0x20, 0x03, 0x00, 0x00, + 0x1a}; - memset(req + 19, 0, 281); + memset(req + 19, 0, 881); /* 00 01 00 25 01 55 00 00 55 02 0C 08 62 F2 20 03 55 55 @@ -2544,11 +2818,10 @@ req[20] = data->bitmap->width; req[21] = data->bitmap->height; req[23] = req[25] = data->bitmap->size; - req[19] = req[23] + 8; memcpy(req + 26, data->bitmap->bitmap, data->bitmap->size); } dprintf("Setting op logo...\n"); - SEND_MESSAGE_BLOCK(NK6510_MSG_NETSTATUS, req[19] + req[11] + 10); + SEND_MESSAGE_BLOCK(NK6510_MSG_NETSTATUS, req[19] + req[11] + 14); } /*********************/ @@ -2561,7 +2834,7 @@ case 0x0B: if (!data->battery_level) return GN_ERR_INTERNALERROR; *(data->battery_unit) = GN_BU_Percentage; - *(data->battery_level) = message[9] * 100 / 7; + *(data->battery_level) = message[9] * 100 / state->driver.phone.max_battery_level; dprintf("Battery level %f\n\n", *(data->battery_level)); break; default: @@ -3212,6 +3485,16 @@ 00 01 00 05 00 00 00 2C 00 02 00 00 00 01 00 00 */ + + switch(message[3]) { + case 0x02: + /* Hard reset ok */ + return GN_ERR_NONE; + break; + default: + break; + } + return GN_ERR_NOTIMPLEMENTED; } @@ -3378,10 +3661,40 @@ SEND_MESSAGE_BLOCK(NK6510_MSG_SUBSCRIBE, 39); } +/*************/ +/*** RESET ***/ +/*************/ -/*****************/ +static gn_error NK6510_IncomingReset(int messagetype, unsigned char *message, int length, gn_data *data, struct gn_statemachine *state) +{ + switch (message[3]) { + default: + dprintf("Incoming Reset\n"); + return GN_ERR_UNHANDLEDFRAME; + break; + } + return GN_ERR_NONE; +} + +static gn_error NK6510_Reset(gn_data *data, struct gn_statemachine *state) +{ + unsigned char req[] = {FBUS_FRAME_HEADER,0x05,0x80,0x00}; + unsigned char req2[] = {FBUS_FRAME_HEADER,0x01,0,0,0,0,0,0x01}; + + if (data->reset_type == 0x03) { + printf("Soft resetting....\n"); + SEND_MESSAGE_BLOCK(NK6510_MSG_RESET, 6); + } + else if (data->reset_type == 0x04) { + printf("Hard resetting....\n"); + if (sm_message_send(10, NK6510_MSG_RADIO, req2, state)) return GN_ERR_NOTREADY; + return sm_block(NK6510_MSG_RADIO, data, state); + } else return GN_ERR_INTERNALERROR; +} + +/******************/ /*** COMMSTATUS ***/ -/*****************/ +/******************/ static gn_error NK6510_IncomingCommStatus(int messagetype, unsigned char *message, int length, gn_data *data, struct gn_statemachine *state) { diff -ur --exclude=CVS gnokii/gnokii/gnokii.c gnokii_new/gnokii/gnokii.c --- gnokii/gnokii/gnokii.c Sun Oct 31 15:05:52 2004 +++ gnokii_new/gnokii/gnokii.c Tue Dec 14 01:05:59 2004 @@ -88,6 +88,7 @@ #include "gnokii-app.h" #include "gnokii.h" +#include #define MAX_INPUT_LINE_LEN 512 @@ -177,6 +178,12 @@ OPT_GETRINGTONELIST, OPT_DELETERINGTONE, OPT_SHOWSMSFOLDERSTATUS, + OPT_GETFILELIST, + OPT_GETFILEID, + OPT_GETFILE, + OPT_GETALLFILES, + OPT_PUTFILE, + OPT_DELETEFILE } opt_index; static FILE *logfile = NULL; @@ -373,6 +380,14 @@ " gnokii --changesecuritycode PIN|PIN2|PUK|PUK2\n" )); #endif + fprintf(f, _("File options:\n" + " gnokii --getfilelist remote_path\n" + " gnokii --getfileid remote_filename\n" + " gnokii --getfile remote_filename [local_filename]\n" + " gnokii --getallfiles remote_path\n" + " gnokii --putfile local_filename remote_filename\n" + " gnokii --deletefile remote_filename\n" + )); fprintf(f, _("Misc options:\n" " gnokii --keysequence\n" " gnokii --enterchar\n" @@ -4901,11 +4916,199 @@ return 0; } +/* Get file list. */ +static int getfilelist(char *path) +{ + gn_file_list fi; + gn_error error; + int i; + + memset(&fi, 0, sizeof(fi)); + snprintf(fi.path, sizeof(fi.path), "%s", path); + + gn_data_clear(&data); + data.file_list = &fi; + + if ((error = gn_sm_functions(GN_OP_GetFileList, &data, &state)) != GN_ERR_NONE) + fprintf(stderr, _("Failed to get info for %s: %s\n"), path, gn_error_print(error)); + else { + fprintf(stdout, _("Filelist for path %s:\n"), path); + for(i=0;iname); + free(fi.files[i]); + } + } + return error; +} + +/* Get file id */ +static int getfileid(char *filename) +{ + gn_file fi; + gn_error error; + int i; + + memset(&fi, 0, sizeof(fi)); + snprintf(fi.name, 512, "%s", filename); + + gn_data_clear(&data); + data.file = &fi; + + if ((error = gn_sm_functions(GN_OP_GetFileId, &data, &state)) != GN_ERR_NONE) + fprintf(stderr, _("Failed to get info for %s: %s\n"),filename, gn_error_print(error)); + else { + fprintf(stdout, _("Fileid for file %s is %02x %02x %02x %02x %02x %02x\n"), filename, fi.id[0],fi.id[1],fi.id[2],fi.id[3],fi.id[4],fi.id[5]); + } + return error; +} + +/* Delete file */ +static int deletefile(char *filename) +{ + gn_file fi; + gn_error error; + int i; + + memset(&fi, 0, sizeof(fi)); + snprintf(fi.name, 512, "%s", filename); + + gn_data_clear(&data); + data.file = &fi; + + if ((error = gn_sm_functions(GN_OP_DeleteFile, &data, &state)) != GN_ERR_NONE) + fprintf(stderr, _("Failed to delete %s: %s\n"),filename, gn_error_print(error)); + else { + fprintf(stdout, _("Deleted: %s\n"), filename); + } + return error; +} + +/* Get file */ +static int getfile(int nargc, char *nargv[]) +{ + gn_file fi; + gn_error error; + int i; + FILE *f; + char filename2[512]; + + if (nargc<1) usage(stderr, -1); + + memset(&fi, 0, sizeof(fi)); + snprintf(fi.name, 512, "%s", nargv[0]); + + gn_data_clear(&data); + data.file = &fi; + + if ((error = gn_sm_functions(GN_OP_GetFile, &data, &state)) != GN_ERR_NONE) + fprintf(stderr, _("Failed to get file %s: %s\n"), nargv[0], gn_error_print(error)); + else { + if (nargc==1) { + strncpy(filename2,strrchr(nargv[0],'/')+1,512); + fprintf(stdout,_("Got file %s. Save to [%s]: "),nargv[0],filename2); + gn_line_get(stdin,filename2,512); + if(filename2[0]==0) strncpy(filename2,strrchr(nargv[0],'/')+1,512); + f =fopen(filename2,"w"); + } else { + f=fopen(nargv[1],"w"); + } + if (!f) { + fprintf(stderr, _("Cannot open file %s\n"), filename2); + return GN_ERR_FAILED; + } + fwrite(fi.file,fi.file_length,1,f); + fclose(f); + free(fi.file); + } + return error; +} + +/* Get all files */ +static int getallfiles(char *path) +{ + gn_file_list fi; + gn_error error; + int i; + FILE *f; + char filename2[512]; + + memset(&fi, 0, sizeof(fi)); + snprintf(fi.path, sizeof(fi.path), "%s", path); + + gn_data_clear(&data); + data.file_list = &fi; + + if ((error = gn_sm_functions(GN_OP_GetFileList, &data, &state)) != GN_ERR_NONE) + fprintf(stderr, _("Failed to get info for %s: %s\n"), path, gn_error_print(error)); + else { + *(strrchr(path,'/')+1)=0; + for(i=0;iname,512); + snprintf(fi.files[i]->name,512,"%s%s",path,filename2); + if ((error = gn_sm_functions(GN_OP_GetFile, &data, &state)) != GN_ERR_NONE) + fprintf(stderr, _("Failed to get file %s: %s\n"), data.file->name, gn_error_print(error)); + else { + fprintf(stdout, _("Got file %s.\n"),filename2); + f = fopen(filename2, "w"); + if (!f) { + fprintf(stderr, _("Cannot open file %s\n"), filename2); + return GN_ERR_FAILED; + } + fwrite(data.file->file,data.file->file_length,1,f); + fclose(f); + free(data.file->file); + } + free(fi.files[i]); + } + } + return error; +} + +/* Put file */ +static int putfile(int nargc, char *nargv[]) +{ + gn_file fi; + gn_error error; + int i; + FILE *f; + + if (nargc != 2) usage(stderr, -1); + + memset(&fi, 0, sizeof(fi)); + snprintf(fi.name, 512, "%s", nargv[1]); + + gn_data_clear(&data); + data.file = &fi; + + f=fopen(nargv[0],"r"); + if(!f || fseek(f,0,SEEK_END)) { + fprintf(stderr,_("Cannot open file %s\n"),nargv[0]); + return GN_ERR_FAILED; + } + fi.file_length=ftell(f); + rewind(f); + fi.file=malloc(fi.file_length); + if(fread(fi.file,1,fi.file_length,f)!=fi.file_length) { + fprintf(stderr,_("Cannot read file %s\n"),nargv[0]); + return GN_ERR_FAILED; + } + + if ((error = gn_sm_functions(GN_OP_PutFile, &data, &state)) != GN_ERR_NONE) + fprintf(stderr, _("Failed to put file to %s: %s\n"), nargv[1], gn_error_print(error)); + + free(fi.file); + + return error; +} + + + /* This is a "convenience" function to allow quick test of new API stuff which doesn't warrant a "proper" command line function. */ #ifndef WIN32 static int foogle(char *argv[]) -{ +{ /* Fill in what you would like to test here... */ return 0; } @@ -5104,7 +5307,7 @@ { "senddtmf", required_argument, NULL, OPT_SENDDTMF }, /* Resets the phone */ - { "reset", optional_argument, NULL, OPT_RESET }, + { "reset", required_argument, NULL, OPT_RESET }, /* Set logo */ { "setlogo", optional_argument, NULL, OPT_SETLOGO }, @@ -5174,6 +5377,18 @@ /* Get (sim)lock info */ { "getlocksinfo", no_argument, NULL, OPT_GETLOCKSINFO }, + /* Get file list */ + { "getfilelist", required_argument, NULL, OPT_GETFILELIST }, + /* Get file id */ + { "getfileid", required_argument, NULL, OPT_GETFILEID }, + /* Get file */ + { "getfile", required_argument, NULL, OPT_GETFILE }, + /* Get all files */ + { "getallfiles", required_argument, NULL, OPT_GETALLFILES }, + /* Put a file */ + { "putfile", required_argument, NULL, OPT_PUTFILE }, + /* Delete a file */ + { "deletefile", required_argument, NULL, OPT_DELETEFILE }, { 0, 0, 0, 0}, }; @@ -5231,7 +5446,12 @@ { OPT_GETWAPSETTING, 1, 2, 0 }, { OPT_ACTIVATEWAPSETTING,1, 1, 0 }, { OPT_MONITOR, 0, 1, 0 }, - + { OPT_GETFILELIST, 1, 1, 0 }, + { OPT_GETFILEID, 1, 1, 0 }, + { OPT_GETFILE, 1, 2, 0 }, + { OPT_GETALLFILES, 1, 1, 0 }, + { OPT_PUTFILE, 2, 2, 0 }, + { OPT_DELETEFILE, 1, 1, 0 }, { 0, 0, 0, 0 }, }; @@ -5502,6 +5722,24 @@ break; case OPT_GETLOCKSINFO: rc = getlocksinfo(); + break; + case OPT_GETFILELIST: + rc = getfilelist(optarg); + break; + case OPT_GETFILEID: + rc = getfileid(optarg); + break; + case OPT_GETFILE: + rc = getfile(nargc, nargv); + break; + case OPT_GETALLFILES: + rc = getallfiles(optarg); + break; + case OPT_PUTFILE: + rc = putfile(nargc, nargv); + break; + case OPT_DELETEFILE: + rc = deletefile(optarg); break; #ifndef WIN32 case OPT_FOOGLE: diff -ur --exclude=CVS gnokii/include/gnokii/bitmaps.h gnokii_new/include/gnokii/bitmaps.h --- gnokii/include/gnokii/bitmaps.h Tue Jan 6 00:32:34 2004 +++ gnokii_new/include/gnokii/bitmaps.h Tue Dec 14 01:05:59 2004 @@ -69,6 +69,7 @@ unsigned char bitmap[GN_BMP_MAX_SIZE]; /* Actual Bitmap */ char number; /* Caller group number */ int ringtone; /* Ringtone no sent with caller group */ + unsigned char ringtone_id[6]; } gn_bmp; API gn_error gn_file_bitmap_read(char *filename, gn_bmp *bitmap, gn_phone *info); diff -ur --exclude=CVS gnokii/include/gnokii/common.h gnokii_new/include/gnokii/common.h --- gnokii/include/gnokii/common.h Tue Dec 14 01:02:56 2004 +++ gnokii_new/include/gnokii/common.h Tue Dec 14 01:05:59 2004 @@ -185,6 +185,7 @@ GN_PHONEBOOK_ENTRY_LogoSwitch = 0x1c, GN_PHONEBOOK_ENTRY_Group = 0x1e, GN_PHONEBOOK_ENTRY_URL = 0x2c, + GN_PHONEBOOK_ENTRY_RingtoneAdv= 0x37, } gn_phonebook_entry_type; typedef struct { @@ -666,5 +667,28 @@ GN_LOG_T_NONE = 0, GN_LOG_T_STDERR = 1 } gn_log_target; + +typedef struct { + unsigned char id[6]; + char name[512]; + int year; + int month; + int day; + int hour; + int minute; + int second; + int file_length; + int togo; + int just_sent; + unsigned char *file; +} gn_file; + +#define GN_FILES_MAX_COUNT 100 + +typedef struct { + char path[512]; + gn_file *files[GN_FILES_MAX_COUNT]; + int file_count; +} gn_file_list; #endif /* _gnokii_common_h */ diff -ur --exclude=CVS gnokii/include/gnokii/data.h gnokii_new/include/gnokii/data.h --- gnokii/include/gnokii/data.h Sun Jan 25 22:25:19 2004 +++ gnokii_new/include/gnokii/data.h Tue Dec 14 01:05:59 2004 @@ -100,6 +100,9 @@ gn_tone *tone; gn_ringtone_list *ringtone_list; gn_call_active *call_active; + gn_file_list *file_list; + gn_file *file; + } gn_data; /* @@ -228,6 +231,11 @@ GN_OP_GetRingtoneList, GN_OP_DeleteRingtone, GN_OP_GetActiveCalls, + GN_OP_GetFileList, + GN_OP_GetFileId, + GN_OP_GetFile, + GN_OP_PutFile, + GN_OP_DeleteFile, GN_OP_Max, /* don't append anything after this entry */ } gn_operation; diff -ur --exclude=CVS gnokii/include/phones/nk6510.h gnokii_new/include/phones/nk6510.h --- gnokii/include/phones/nk6510.h Wed Feb 18 21:49:43 2004 +++ gnokii_new/include/phones/nk6510.h Tue Dec 14 01:05:59 2004 @@ -56,6 +56,7 @@ #define NK6510_MSG_SUBSCRIBE 0x10 /* subscribe to channels */ #define NK6510_MSG_CALENDAR 0x13 /* Calendar notes */ #define NK6510_MSG_FOLDER 0x14 /* Folders handling */ +#define NK6510_MSG_RESET 0x15 /* Reset */ #define NK6510_MSG_BATTERY 0x17 /* Battery info */ #define NK6510_MSG_CLOCK 0x19 /* Date & alarm */ #define NK6510_MSG_IDENTITY 0x1b /* Brief product info */ @@ -63,8 +64,9 @@ #define NK6510_MSG_PROFILE 0x39 /* Profiles */ #define NK6510_MSG_NOTKNOWN 0x3E /* */ #define NK6510_MSG_WAP 0x3F /* WAP */ -#define NK6510_MSG_RADIO 0x43 /* Radio (6510/8310) */ +#define NK6510_MSG_RADIO 0x43 /* Radio (6510/8310) + hard reset */ #define NK6510_MSG_TODO 0x55 /* ToDo */ +#define NK6510_MSG_FILE 0x6d /* File Handling */ #define NK6510_MSG_STLOGO 0x7a /* Startup logo */ /* SMS handling message subtypes (send) */