/*
-
$Id$
G N O K I I
This file provides functions specific to the 6100 series.
See README for more details on supported mobile phones.
+ $Log$
+ Revision 1.1.1.3 2002/04/03 00:08:09 short
+ Found in "gnokii-working" directory, some November-patches version
+
+ Revision 1.3 2001/08/17 00:01:53 pkot
+ Fixed a typo in 6100.c (me)
+
+ Revision 1.2 2001/08/09 12:34:34 pkot
+ 3330 and 6250 support - I have no idea if it does work (mygnokii)
+
+ Revision 1.1 2001/07/09 23:55:35 pkot
+ Initial support for 6100 series in the new structure (me)
+
*/
#include <string.h>
/* Some globals */
-static const SMSMessage_Layout nk6100_deliver = {
- true,
- 0, 11, 0, 0, 6, 0, 0, -1, 23, 22, 0, 20,
- 8, true, 24, true, 36, -1,
- 5, 4,
- 43, true
-};
-
-static const SMSMessage_Layout nk6100_submit = {
- true,
- -1, 20, 20, 20, 6, 21, 22, -1, 24, 23, 20, 20,
- 8, true, 25, true, 37, -1,
- -1, -1,
- 44, true
-};
-
-static const SMSMessage_Layout nk6100_delivery_report = {
- true,
- 0, 0, 0, 0, 6, 0, 0, 0, 22, 21, -1, 20,
- 8, true, 24, true, 35, 42,
- 5, 4,
- 22, true
-};
-
-static const SMSMessage_Layout nk6100_picture = {
- false,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, true, 0, true, 0, 0,
- 0, 0,
- 0, true
-};
-
-static SMSMessage_PhoneLayout nk6100_layout;
-
static unsigned char MagicBytes[4] = { 0x00, 0x00, 0x00, 0x00 };
static GSM_IncomingFunctionType IncomingFunctions[] = {
{ 0x64, IncomingPhoneInfo },
{ 0xd2, IncomingModelInfo },
- { 0x14, IncomingSMS },
{ 0x03, Incoming0x03 },
{ 0x0a, Incoming0x0a },
{ 0x17, Incoming0x17 },
switch (op) {
case GOP_Init:
return Initialise(state);
+ break;
case GOP_GetModel:
return GetModelName(data, state);
+ break;
case GOP_GetRevision:
return GetRevision(data, state);
+ break;
case GOP_GetImei:
return GetIMEI(data, state);
+ break;
case GOP_Identify:
return Identify(data, state);
+ break;
case GOP_GetBatteryLevel:
return GetBatteryLevel(data, state);
+ break;
case GOP_GetRFLevel:
return GetRFLevel(data, state);
+ break;
case GOP_GetMemoryStatus:
return GetMemoryStatus(data, state);
- case GOP_GetSMS:
- return GetSMSMessage(data, state);
+ break;
default:
return GE_NOTIMPLEMENTED;
+ break;
}
}
-/* static bool LinkOK = true; */
+static bool LinkOK = true;
/* Initialise is the only function allowed to 'use' state */
static GSM_Error Initialise(GSM_Statemachine *state)
GSM_Data data;
char model[10];
GSM_Error err;
+ int try = 0, connected = 0;
/* Copy in the phone info */
memcpy(&(state->Phone), &phone_nokia_6100, sizeof(GSM_Phone));
- /* SMS Layout */
- nk6100_layout.Type = 7;
- nk6100_layout.Deliver = nk6100_deliver;
- nk6100_layout.Submit = nk6100_submit;
- nk6100_layout.DeliveryReport = nk6100_delivery_report;
- nk6100_layout.Picture = nk6100_picture;
- layout = nk6100_layout;
-
- switch (state->Link.ConnectionType) {
- case GCT_Serial:
- err = FBUS_Initialise(&(state->Link), state, 0);
- break;
- case GCT_Infrared:
- err = PHONET_Initialise(&(state->Link), state);
- break;
- default:
- return GE_NOTSUPPORTED;
- }
+ while (!connected) {
+ switch (state->Link.ConnectionType) {
+ case GCT_Serial:
+ if (try > 1) return GE_NOTSUPPORTED;
+ err = FBUS_Initialise(&(state->Link), state);
+ break;
+ case GCT_Infrared:
+ if (try > 0) return GE_NOTSUPPORTED;
+ err = PHONET_Initialise(&(state->Link), state);
+ break;
+ default:
+ return GE_NOTSUPPORTED;
+ break;
+ }
- if (err != GE_NONE) {
- dprintf("Error in link initialisation\n");
- return GE_NOTSUPPORTED;
- }
-
- SM_Initialise(state);
+ if (err != GE_NONE) {
+ dprintf("Error in link initialisation\n");
+ try++;
+ continue;
+ }
+
+ SM_Initialise(state);
- /* Now test the link and get the model */
- GSM_DataClear(&data);
- data.Model = model;
- if (state->Phone.Functions(GOP_GetModel, &data, state) != GE_NONE) return GE_NOTSUPPORTED;
+ /* Now test the link and get the model */
+ GSM_DataClear(&data);
+ data.Model = model;
+ if (state->Phone.Functions(GOP_GetModel, &data, state) != GE_NONE) try++;
+ else connected = 1;
+ }
return GE_NONE;
}
if (message[5] != 0xff) {
data->MemoryStatus->Used = (message[16] << 8) + message[17];
data->MemoryStatus->Free = ((message[14] << 8) + message[15]) - data->MemoryStatus->Used;
- dprintf("Memory status - location = %d\n", (message[8] << 8) + message[9]);
+ dprintf(_("Memory status - location = %d\n"), (message[8] << 8) + message[9]);
return GE_NONE;
} else {
dprintf("Unknown error getting mem status\n");
static GSM_Error Identify(GSM_Data *data, GSM_Statemachine *state)
{
unsigned char req[] = { FBUS_FRAME_HEADER, 0x10 };
-
+
dprintf("Identifying...\n");
- PNOK_GetManufacturer(data->Manufacturer);
if (SM_SendMessage(state, 4, 0x64, req) != GE_NONE) return GE_NOTREADY;
SM_WaitFor(state, data, 0x64);
SM_Block(state, data, 0x64); /* waits for all requests */
dprintf("Received revision %s\n", data->Revision);
}
- dprintf("Message: Mobile phone identification received:\n");
- dprintf("\tIMEI: %s\n", data->Imei);
- dprintf("\tModel: %s\n", data->Model);
- dprintf("\tProduction Code: %s\n", message + 31);
- dprintf("\tHW: %s\n", message + 39);
- dprintf("\tFirmware: %s\n", message + 44);
+ dprintf(_("Message: Mobile phone identification received:\n"));
+ dprintf(_(" IMEI: %s\n"), data->Imei);
+ dprintf(_(" Model: %s\n"), data->Model);
+ dprintf(_(" Production Code: %s\n"), message + 31);
+ dprintf(_(" HW: %s\n"), message + 39);
+ dprintf(_(" Firmware: %s\n"), message + 44);
/* These bytes are probably the source of the "Accessory not connected"
messages on the phone when trying to emulate NCDS... I hope....
UPDATE: of course, now we have the authentication algorithm. */
- dprintf("\tMagic bytes: %02x %02x %02x %02x\n", message[50], message[51], message[52], message[53]);
+ dprintf(_(" Magic bytes: %02x %02x %02x %02x\n"), message[50], message[51], message[52], message[53]);
MagicBytes[0] = message[50];
MagicBytes[1] = message[51];
data->Revision[GSM_MAX_REVISION_LENGTH - 1] = 0;
}
#endif
- dprintf("Phone info:\n%s\n", message + 4);
+ dprintf(_("Phone info:\n%s\n"), message + 4);
return GE_NONE;
}
}
return (result);
}
-
-static GSM_Error GetSMSMessage(GSM_Data *data, GSM_Statemachine *state)
-{
- unsigned char req[] = { FBUS_FRAME_HEADER, 0x07, 0x02 /* Unknown */, 0x00 /* Location */, 0x01, 0x64};
-
- req[5] = data->SMSMessage->Number;
-
- if (SM_SendMessage(state, 8, 0x02, req) != GE_NONE) return GE_NOTREADY;
- return SM_Block(state, data, 0x14);
-}
-
-static GSM_Error IncomingSMS(int messagetype, unsigned char *message, int length, GSM_Data *data)
-{
- int i;
-
- switch (message[3]) {
- /* save sms succeeded */
- case 0x05:
- dprintf("Message stored at %d\n", message[5]);
- break;
- /* save sms failed */
- case 0x06:
- dprintf("SMS saving failed:\n");
- switch (message[4]) {
- case 0x02:
- dprintf("\tAll locations busy.\n");
- return GE_MEMORYFULL;
- case 0x03:
- dprintf("\tInvalid location!\n");
- return GE_INVALIDSMSLOCATION;
- default:
- dprintf("\tUnknown reason.\n");
- return GE_UNKNOWN;
- }
- /* read sms */
- case 0x08:
- for (i = 0; i < length; i ++)
- if (isprint(message[i]))
- dprintf("[%02x%c]", message[i], message[i]);
- else
- dprintf("[%02x ]", message[i]);
- dprintf("\n");
-
- memset(data->SMSMessage, 0, sizeof(GSM_SMSMessage));
-
- /* Short Message status */
- DecodePDUSMS(message, data->SMSMessage, length);
-
- break;
- /* read sms failed */
- case 0x09:
- dprintf("SMS reading failed:\n");
- switch (message[4]) {
- case 0x02:
- dprintf("\tInvalid location!\n");
- return GE_INVALIDSMSLOCATION;
- case 0x07:
- dprintf("\tEmpty SMS location.\n");
- return GE_EMPTYSMSLOCATION;
- default:
- dprintf("\tUnknown reason.\n");
- return GE_UNKNOWN;
- }
- /* delete sms succeeded */
- case 0x0b:
- dprintf("Message: SMS deleted successfully.\n");
- break;
- /* sms status succeded */
- case 0x37:
- dprintf("Message: SMS Status Received\n");
- dprintf("\tThe number of messages: %d\n", message[10]);
- dprintf("\tUnread messages: %d\n", message[11]);
- data->SMSStatus->Unread = message[11];
- data->SMSStatus->Number = message[10];
- break;
- /* sms status failed */
- case 0x38:
- dprintf("Message: SMS Status error, probably not authorized by PIN\n");
- return GE_INTERNALERROR;
- /* unknown */
- default:
- dprintf("Unknown message.\n");
- return GE_UNKNOWN;
- }
- return GE_NONE;
-}