See README for more details on supported mobile phones.
$Log$
- Revision 1.1.1.1 2001/11/25 21:59:12 short
- :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
-
- Revision 1.8 2001/11/17 20:19:29 pkot
- smslib cleanups, fixes and debugging
-
- Revision 1.7 2001/11/17 16:44:07 pkot
- Cleanup. Reading SMS for 6100 series. Not that it has some bugs more and does not support UDH yet
-
- Revision 1.6 2001/11/15 12:15:04 pkot
- smslib updates. begin work on sms in 6100 series
-
- Revision 1.5 2001/11/15 12:12:34 pkot
- 7110 and 6110 series phones introduce as Nokia
-
- Revision 1.4 2001/11/15 12:04:06 pkot
- Faster initialization for 6100 series (don't check for dlr3 cable)
+ 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)
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));
- 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(" 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);
+ 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....
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));
-
- /* These offsets are 6210/7110 series specific */
- /* Short Message status */
- data->SMSMessage->Status = message[4];
- dprintf("\tStatus: ");
- switch (data->SMSMessage->Status) {
- case SMS_Read:
- dprintf("READ\n");
- break;
- case SMS_Unread:
- dprintf("UNREAD\n");
- break;
- case SMS_Sent:
- dprintf("SENT\n");
- break;
- case SMS_Unsent:
- dprintf("UNSENT\n");
- break;
- default:
- dprintf("UNKNOWN\n");
- break;
- }
-
- DecodePDUSMS(message + 5, 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;
-}