7 A Linux/Unix toolset and driver for Nokia mobile phones.
9 Copyright (C) 1999, 2000 Hugh Blemings & Pavel JanÃk ml.
11 Released under the terms of the GNU GPL, see file COPYING for more details.
13 Provides a generic API for accessing functions on the phone, wherever
14 possible hiding the model specific details.
16 The underlying code should run in it's own thread to allow communications to
17 the phone to be run independantly of mailing code that calls these API
20 Unless otherwise noted, all functions herein block until they complete. The
21 functions themselves are defined in a structure in gsm-common.h.
24 Revision 1.1.1.5 2002/04/03 00:07:54 short
25 Found in "gnokii-working" directory, some November-patches version
27 Revision 1.31 2001/11/08 16:45:58 pkot
28 Obsolete old structure, kill treads where possible and make shared library
30 Revision 1.30 2001/08/09 11:51:38 pkot
31 Generic AT support updates and cleanup (Manfred Jonsson)
33 Revision 1.29 2001/07/27 00:02:20 pkot
34 Generic AT support for the new structure (Manfred Jonsson)
36 Revision 1.28 2001/06/06 09:05:56 machek
37 Convert Grab/Release display to new structure.
39 Revision 1.27 2001/05/07 14:13:06 machek
40 nokia-2110 module converted to suit new API better. --identify now works.
42 Revision 1.26 2001/04/25 12:54:47 machek
43 Partly converted nokia 2110 to "new" form, and moved it to phone
46 Revision 1.25 2001/03/26 23:39:21 pkot
48 - Windows INLINE patch (Manfred Jonsson)
49 - patch to configure.in to compile under FreeBSD (Panagiotis Astithas)
59 #include "gsm-common.h"
60 #include "data/rlp-common.h"
61 #include "gsm-statemachine.h"
62 #include "phones/nk7110.h"
63 #include "phones/nk6100.h"
64 #include "phones/nk3110.h"
65 #include "phones/nk2110.h"
68 /* GSM_LinkOK is set to true once normal communications with the phone have
72 bool LinkAlwaysOK = true;
74 /* Define pointer to the GSM_Functions structure used by external code to call
75 relevant API functions. This structure is defined in gsm-common.h. */
79 /* Define pointer to the GSM_Information structure used by external code to
80 obtain information that varies from model to model. This structure is also
81 defined in gsm-common.h */
83 GSM_Information *GSM_Info;
87 /* From here starts the ugly compatibility cludge to complete WIPE OUT the
88 * insane "Sorry, phone has not yet been converted to new style.
89 * Phone.Functions == NULL!" message out of the Earth surface to make the world
90 * a happy place back again! Wiping out, wiping out, wiping out!
91 * The most World's evil GSM_Error code: GE_NOTIMPLEMENTED
92 * Completely non-systematic naming is not my souvenir - it is just copied
93 * from the existing include files. (Jan Kratochvil)
96 static GSM_Statemachine *compat_Functions_Statemachine;
98 #define INVOKE_COMPAT_FUNCTIONS_SM(gop) \
99 (compat_Functions_Statemachine->Phone.Functions((gop),&data,compat_Functions_Statemachine))
100 #define RETURN_COMPAT_FUNCTIONS_SM(gop) \
101 return((INVOKE_COMPAT_FUNCTIONS_SM((gop))))
102 #define BODY_COMPAT_FUNCTIONS_SM_CORE(core,gop) \
105 RETURN_COMPAT_FUNCTIONS_SM((gop));
106 #define BODY_COMPAT_FUNCTIONS_SM0(gop) \
107 BODY_COMPAT_FUNCTIONS_SM_CORE( ,(gop))
108 #define BODY_COMPAT_FUNCTIONS_SM1(field1,arg1,gop) \
109 BODY_COMPAT_FUNCTIONS_SM_CORE( data.field1=(arg1); ,(gop))
110 #define BODY_COMPAT_FUNCTIONS_SM2(field1,arg1,field2,arg2,gop) \
111 BODY_COMPAT_FUNCTIONS_SM_CORE( data.field1=(arg1);data.field2=(arg2); ,(gop))
112 #define BODY_COMPAT_FUNCTIONS_SM3(field1,arg1,field2,arg2,field3,arg3,gop) \
113 BODY_COMPAT_FUNCTIONS_SM_CORE( data.field1=(arg1);data.field2=(arg2);data.field3=(arg3); ,(gop))
115 static GSM_Error compat_Functions_Initialise
116 (char *port_device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame))
118 fprintf(stderr,"FATAL: GSM->Initialise called for new style phone implementation!\n");
119 return(GE_NOTIMPLEMENTED);
122 static void compat_Functions_Terminate(void)
124 GSM_Data data; /* void */
126 INVOKE_COMPAT_FUNCTIONS_SM(GOP_Terminate);
129 static GSM_Error compat_Functions_GetMemoryLocation( GSM_PhonebookEntry *entry )
131 BODY_COMPAT_FUNCTIONS_SM1(PhonebookEntry,entry,GOP_ReadPhonebook);
134 static GSM_Error compat_Functions_WritePhonebookLocation( GSM_PhonebookEntry *entry )
136 BODY_COMPAT_FUNCTIONS_SM1(PhonebookEntry,entry,GOP_WritePhonebook);
139 static GSM_Error compat_Functions_GetSpeedDial( GSM_SpeedDial *entry )
141 BODY_COMPAT_FUNCTIONS_SM1(SpeedDial,entry,GOP_GetSpeedDial);
144 static GSM_Error compat_Functions_SetSpeedDial( GSM_SpeedDial *entry )
146 BODY_COMPAT_FUNCTIONS_SM1(SpeedDial,entry,GOP_SetSpeedDial);
149 static GSM_Error compat_Functions_GetMemoryStatus( GSM_MemoryStatus *Status )
151 BODY_COMPAT_FUNCTIONS_SM1(MemoryStatus,Status,GOP_GetMemoryStatus);
154 static GSM_Error compat_Functions_GetSMSStatus( GSM_SMSStatus *Status )
156 BODY_COMPAT_FUNCTIONS_SM1(SMSStatus,Status,GOP_GetSMSStatus);
159 static GSM_Error compat_Functions_GetSMSCenter( GSM_MessageCenter *MessageCenter )
161 BODY_COMPAT_FUNCTIONS_SM1(MessageCenter,MessageCenter,GOP_GetSMSCenter);
164 static GSM_Error compat_Functions_SetSMSCenter( GSM_MessageCenter *MessageCenter )
166 BODY_COMPAT_FUNCTIONS_SM1(MessageCenter,MessageCenter,GOP_SetSMSCenter);
169 static GSM_Error compat_Functions_GetSMSMessage( GSM_SMSMessage *Message )
171 BODY_COMPAT_FUNCTIONS_SM1(SMSMessage,Message,GOP_GetSMS);
174 static GSM_Error compat_Functions_DeleteSMSMessage( GSM_SMSMessage *Message )
176 BODY_COMPAT_FUNCTIONS_SM1(SMSMessage,Message,GOP_DeleteSMS);
179 static GSM_Error compat_Functions_SendSMSMessage( GSM_SMSMessage *Message )
181 BODY_COMPAT_FUNCTIONS_SM1(SMSMessage,Message,GOP_SendSMS);
184 static GSM_Error compat_Functions_SaveSMSMessage( GSM_SMSMessage *Message )
186 BODY_COMPAT_FUNCTIONS_SM1(SMSMessage,Message,GOP_SaveSMS);
189 static GSM_Error compat_Functions_GetRFLevel( GSM_RFUnits *units, float *level )
191 BODY_COMPAT_FUNCTIONS_SM2(RFUnits,units,RFLevel,level,GOP_GetRFLevel);
194 static GSM_Error compat_Functions_GetBatteryLevel( GSM_BatteryUnits *units, float *level )
196 BODY_COMPAT_FUNCTIONS_SM2(BatteryUnits,units,BatteryLevel,level,GOP_GetBatteryLevel);
199 static GSM_Error compat_Functions_GetPowerSource( GSM_PowerSource *source )
201 BODY_COMPAT_FUNCTIONS_SM1(PowerSource,source,GOP_GetPowersource);
204 static GSM_Error compat_Functions_GetDisplayStatus( int *Status )
206 BODY_COMPAT_FUNCTIONS_SM1(DisplayStatus,Status,GOP_GetDisplayStatus);
209 static GSM_Error compat_Functions_EnterSecurityCode( GSM_SecurityCode Code )
211 BODY_COMPAT_FUNCTIONS_SM1(SecurityCode,&Code,GOP_EnterSecurityCode);
214 /* FIXME: GetSecurityCodeStatus() should have GSM_SecurityCodeType as its argument!
216 static GSM_Error compat_Functions_GetSecurityCodeStatus( int *Status )
218 GSM_SecurityCodeType status_local;
222 data.SecurityCodeStatus=&status_local;
223 err=INVOKE_COMPAT_FUNCTIONS_SM(GOP_GetSecurityCodeStatus);
224 *Status=status_local;
228 static GSM_Error compat_Functions_GetIMEI( char *imei )
230 BODY_COMPAT_FUNCTIONS_SM1(Imei,imei,GOP_GetImei);
233 static GSM_Error compat_Functions_GetRevision( char *revision )
235 BODY_COMPAT_FUNCTIONS_SM1(Revision,revision,GOP_GetRevision);
238 static GSM_Error compat_Functions_GetModel( char *model )
240 BODY_COMPAT_FUNCTIONS_SM1(Model,model,GOP_GetModel);
243 static GSM_Error compat_Functions_GetManufacturer( char *manufacturer )
245 BODY_COMPAT_FUNCTIONS_SM1(Manufacturer,manufacturer,GOP_GetManufacturer);
248 static GSM_Error compat_Functions_GetDateTime( GSM_DateTime *date_time)
250 BODY_COMPAT_FUNCTIONS_SM1(DateTime,date_time,GOP_GetDateTime);
253 static GSM_Error compat_Functions_SetDateTime( GSM_DateTime *date_time)
255 BODY_COMPAT_FUNCTIONS_SM1(DateTime,date_time,GOP_SetDateTime);
258 static GSM_Error compat_Functions_GetAlarm( int alarm_number, GSM_DateTime *date_time )
260 BODY_COMPAT_FUNCTIONS_SM2(AlarmNumber,&alarm_number,AlarmDateTime,date_time,GOP_GetAlarm);
263 static GSM_Error compat_Functions_SetAlarm( int alarm_number, GSM_DateTime *date_time )
265 BODY_COMPAT_FUNCTIONS_SM2(AlarmNumber,&alarm_number,AlarmDateTime,date_time,GOP_SetAlarm);
268 static GSM_Error compat_Functions_DialVoice( char *Number )
270 BODY_COMPAT_FUNCTIONS_SM1(VoiceNumber,Number,GOP_DialVoice);
273 static GSM_Error compat_Functions_DialData( char *Number, char type, void (* callpassup)(char c) )
275 BODY_COMPAT_FUNCTIONS_SM3(DataNumber,Number,DataType,&type,DataCallPassUp,callpassup,GOP_DialData);
278 static GSM_Error compat_Functions_GetIncomingCallNr( char *Number )
280 BODY_COMPAT_FUNCTIONS_SM1(IncomingCallNr,Number,GOP_GetIncomingCallNr);
283 static GSM_Error compat_Functions_GetNetworkInfo ( GSM_NetworkInfo *NetworkInfo )
285 BODY_COMPAT_FUNCTIONS_SM1(NetworkInfo,NetworkInfo,GOP_GetNetworkInfo);
288 static GSM_Error compat_Functions_GetCalendarNote ( GSM_CalendarNote *CalendarNote)
290 BODY_COMPAT_FUNCTIONS_SM1(CalendarNote,CalendarNote,GOP_GetCalendarNote);
293 static GSM_Error compat_Functions_WriteCalendarNote ( GSM_CalendarNote *CalendarNote)
295 BODY_COMPAT_FUNCTIONS_SM1(CalendarNote,CalendarNote,GOP_WriteCalendarNote);
298 static GSM_Error compat_Functions_DeleteCalendarNote ( GSM_CalendarNote *CalendarNote)
300 BODY_COMPAT_FUNCTIONS_SM1(CalendarNote,CalendarNote,GOP_DeleteCalendarNote);
303 static GSM_Error compat_Functions_NetMonitor ( unsigned char mode, char *Screen )
305 BODY_COMPAT_FUNCTIONS_SM2(NetMonitorMode,&mode,NetMonitorScreen,Screen,GOP_NetMonitor);
308 static GSM_Error compat_Functions_SendDTMF ( char *String )
310 BODY_COMPAT_FUNCTIONS_SM1(DTMF,String,GOP_SendDTMF);
313 static GSM_Error compat_Functions_GetBitmap ( GSM_Bitmap *Bitmap )
315 BODY_COMPAT_FUNCTIONS_SM1(Bitmap,Bitmap,GOP_GetBitmap);
318 static GSM_Error compat_Functions_SetBitmap ( GSM_Bitmap *Bitmap )
320 BODY_COMPAT_FUNCTIONS_SM1(Bitmap,Bitmap,GOP_SetBitmap);
323 static GSM_Error compat_Functions_SetRingtone ( GSM_Ringtone *ringtone )
325 BODY_COMPAT_FUNCTIONS_SM1(Ringtone,ringtone,GOP_SetRingtone);
328 static GSM_Error compat_Functions_Reset ( unsigned char type )
330 BODY_COMPAT_FUNCTIONS_SM1(ResetType,&type,GOP_Reset);
333 static GSM_Error compat_Functions_GetProfile ( GSM_Profile *Profile )
335 BODY_COMPAT_FUNCTIONS_SM1(Profile,Profile,GOP_GetProfile);
338 static GSM_Error compat_Functions_SetProfile ( GSM_Profile *Profile )
340 BODY_COMPAT_FUNCTIONS_SM1(Profile,Profile,GOP_SetProfile);
343 /* return type "bool" is fortunately compatible with "GSM_Error"
345 static bool compat_Functions_SendRLPFrame ( RLP_F96Frame *frame, bool out_dtx )
347 BODY_COMPAT_FUNCTIONS_SM2(RLPFrame,frame,RLPFrame_out_dtx,&out_dtx,GOP_SendRLPFrame);
350 static GSM_Error compat_Functions_CancelCall ( void )
352 BODY_COMPAT_FUNCTIONS_SM0(GOP_CancelCall);
355 static GSM_Error compat_Functions_EnableDisplayOutput ( void )
357 BODY_COMPAT_FUNCTIONS_SM0(GOP_EnableDisplayOutput);
360 static GSM_Error compat_Functions_DisableDisplayOutput ( void )
362 BODY_COMPAT_FUNCTIONS_SM0(GOP_DisableDisplayOutput);
365 static GSM_Error compat_Functions_EnableCellBroadcast ( void )
367 BODY_COMPAT_FUNCTIONS_SM0(GOP_EnableCellBroadcast);
370 static GSM_Error compat_Functions_DisableCellBroadcast ( void )
372 BODY_COMPAT_FUNCTIONS_SM0(GOP_DisableCellBroadcast);
375 static GSM_Error compat_Functions_ReadCellBroadcast ( GSM_CBMessage *Message )
377 BODY_COMPAT_FUNCTIONS_SM1(CBMessage,Message,GOP_ReadCellBroadcast);
380 static GSM_Error compat_Functions_SetKey (int c, int up)
382 BODY_COMPAT_FUNCTIONS_SM2(SetKeyKey,&c,SetKeyUp,&up,GOP_SetKey);
385 static GSM_Error compat_Functions_HandleString (char *s)
387 BODY_COMPAT_FUNCTIONS_SM1(HandleString,s,GOP_HandleString);
390 static GSM_Error compat_Functions_AnswerCall (char s)
392 BODY_COMPAT_FUNCTIONS_SM1(CallNo,&s,GOP_AnswerCall);
395 static GSM_Functions compat_Functions={
396 compat_Functions_Initialise,
397 compat_Functions_Terminate,
398 compat_Functions_GetMemoryLocation,
399 compat_Functions_WritePhonebookLocation,
400 compat_Functions_GetSpeedDial,
401 compat_Functions_SetSpeedDial,
402 compat_Functions_GetMemoryStatus,
403 compat_Functions_GetSMSStatus,
404 compat_Functions_GetSMSCenter,
405 compat_Functions_SetSMSCenter,
406 compat_Functions_GetSMSMessage,
407 compat_Functions_DeleteSMSMessage,
408 compat_Functions_SendSMSMessage,
409 compat_Functions_SaveSMSMessage,
410 compat_Functions_GetRFLevel,
411 compat_Functions_GetBatteryLevel,
412 compat_Functions_GetPowerSource,
413 compat_Functions_GetDisplayStatus,
414 compat_Functions_EnterSecurityCode,
415 compat_Functions_GetSecurityCodeStatus,
416 compat_Functions_GetIMEI,
417 compat_Functions_GetRevision,
418 compat_Functions_GetModel,
419 compat_Functions_GetManufacturer,
420 compat_Functions_GetDateTime,
421 compat_Functions_SetDateTime,
422 compat_Functions_GetAlarm,
423 compat_Functions_SetAlarm,
424 compat_Functions_DialVoice,
425 compat_Functions_DialData,
426 compat_Functions_GetIncomingCallNr,
427 compat_Functions_GetNetworkInfo,
428 compat_Functions_GetCalendarNote,
429 compat_Functions_WriteCalendarNote,
430 compat_Functions_DeleteCalendarNote,
431 compat_Functions_NetMonitor,
432 compat_Functions_SendDTMF,
433 compat_Functions_GetBitmap,
434 compat_Functions_SetBitmap,
435 compat_Functions_SetRingtone,
436 compat_Functions_Reset,
437 compat_Functions_GetProfile,
438 compat_Functions_SetProfile,
439 compat_Functions_SendRLPFrame,
440 compat_Functions_CancelCall,
441 compat_Functions_EnableDisplayOutput,
442 compat_Functions_DisableDisplayOutput,
443 compat_Functions_EnableCellBroadcast,
444 compat_Functions_DisableCellBroadcast,
445 compat_Functions_ReadCellBroadcast,
446 compat_Functions_SetKey,
447 compat_Functions_HandleString,
448 compat_Functions_AnswerCall,
451 GSM_Error compat_Phone_Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state)
456 fprintf(stderr,"FATAL: compat_Phone_Functions(GOP_Init) called for old style phone implementation!\n");
457 return(GE_NOTIMPLEMENTED);
463 case GOP_ReadPhonebook:
464 return(GSM->GetMemoryLocation(data->PhonebookEntry/*entry*/));
466 case GOP_WritePhonebook:
467 return(GSM->WritePhonebookLocation(data->PhonebookEntry/*entry*/));
469 case GOP_GetSpeedDial:
470 return(GSM->GetSpeedDial(data->SpeedDial/*entry*/));
472 case GOP_SetSpeedDial:
473 return(GSM->SetSpeedDial(data->SpeedDial/*entry*/));
475 case GOP_GetMemoryStatus:
476 return(GSM->GetMemoryStatus(data->MemoryStatus/*Status*/));
478 case GOP_GetSMSStatus:
479 return(GSM->GetSMSStatus(data->SMSStatus/*Status*/));
481 case GOP_GetSMSCenter:
482 return(GSM->GetSMSCenter(data->MessageCenter/*MessageCenter*/));
484 case GOP_SetSMSCenter:
485 return(GSM->SetSMSCenter(data->MessageCenter/*MessageCenter*/));
488 return(GSM->GetSMSMessage(data->SMSMessage/*Message*/));
491 return(GSM->DeleteSMSMessage(data->SMSMessage/*Message*/));
494 return(GSM->SendSMSMessage(data->SMSMessage/*Message*/));
497 return(GSM->SaveSMSMessage(data->SMSMessage/*Message*/));
500 return(GSM->GetRFLevel(data->RFUnits/*units*/,data->RFLevel/*level*/));
502 case GOP_GetBatteryLevel:
503 return(GSM->GetBatteryLevel(data->BatteryUnits/*units*/,data->BatteryLevel/*level*/));
505 case GOP_GetPowersource:
506 return(GSM->GetPowerSource(data->PowerSource/*source*/));
508 case GOP_GetDisplayStatus:
509 return(GSM->GetDisplayStatus(data->DisplayStatus/*Status*/));
511 case GOP_EnterSecurityCode:
512 return(GSM->EnterSecurityCode(*data->SecurityCode/*Code*/));
514 case GOP_GetSecurityCodeStatus: {
515 int status_local=*data->SecurityCodeStatus;
518 err=GSM->GetSecurityCodeStatus(&status_local);
519 *data->SecurityCodeStatus=status_local;
524 return(GSM->GetIMEI(data->Imei/*imei*/));
526 case GOP_GetRevision:
527 return(GSM->GetRevision(data->Revision/*revision*/));
530 return(GSM->GetModel(data->Model/*model*/));
532 case GOP_GetManufacturer:
533 return(GSM->GetManufacturer(data->Manufacturer/*manufacturer*/));
535 case GOP_GetDateTime:
536 return(GSM->GetDateTime(data->DateTime/*date_time*/));
538 case GOP_SetDateTime:
539 return(GSM->SetDateTime(data->DateTime/*date_time*/));
542 return(GSM->GetAlarm((!data->AlarmNumber ? 0 : *data->AlarmNumber)/*alarm_number*/,
543 data->AlarmDateTime/*date_time*/));
546 return(GSM->SetAlarm((!data->AlarmNumber ? 0 : *data->AlarmNumber)/*alarm_number*/,
547 data->AlarmDateTime/*date_time*/));
550 return(GSM->DialVoice(data->VoiceNumber/*Number*/));
553 return(GSM->DialData(data->DataNumber/*Number*/,
554 (!data->DataType ? -1 : *data->DataType)/*type*/,
555 data->DataCallPassUp/*callpassup*/));
557 case GOP_GetIncomingCallNr:
558 return(GSM->GetIncomingCallNr(data->IncomingCallNr/*Number*/));
560 case GOP_GetNetworkInfo:
561 return(GSM->GetNetworkInfo(data->NetworkInfo/*NetworkInfo*/));
563 case GOP_GetCalendarNote:
564 return(GSM->GetCalendarNote(data->CalendarNote/*CalendarNote*/));
566 case GOP_WriteCalendarNote:
567 return(GSM->WriteCalendarNote(data->CalendarNote/*CalendarNote*/));
569 case GOP_DeleteCalendarNote:
570 return(GSM->DeleteCalendarNote(data->CalendarNote/*CalendarNote*/));
573 return(GSM->NetMonitor((!data->NetMonitorMode ? 0 : *data->NetMonitorMode)/*mode*/,
574 data->NetMonitorScreen/*Screen*/));
577 return(GSM->SendDTMF(data->DTMF/*String*/));
580 return(GSM->GetBitmap(data->Bitmap/*Bitmap*/));
583 return(GSM->SetBitmap(data->Bitmap/*Bitmap*/));
585 case GOP_SetRingtone:
586 return(GSM->SetRingtone(data->Ringtone/*ringtone*/));
589 return(GSM->Reset((!data->ResetType ? 0x03 : *data->ResetType)/*type*/));
592 return(GSM->GetProfile(data->Profile/*Profile*/));
595 return(GSM->SetProfile(data->Profile/*Profile*/));
597 /* return type "bool" is fortunately compatible with "GSM_Error"
599 case GOP_SendRLPFrame:
600 return(GSM->SendRLPFrame(data->RLPFrame/*frame*/,
601 (!data->RLPFrame_out_dtx ? 0 : *data->RLPFrame_out_dtx)/*out_dtx*/));
604 return(GSM->CancelCall());
606 case GOP_EnableDisplayOutput:
607 return(GSM->EnableDisplayOutput());
609 case GOP_DisableDisplayOutput:
610 return(GSM->DisableDisplayOutput());
612 case GOP_EnableCellBroadcast:
613 return(GSM->EnableCellBroadcast());
615 case GOP_DisableCellBroadcast:
616 return(GSM->DisableCellBroadcast());
618 case GOP_ReadCellBroadcast:
619 return(GSM->ReadCellBroadcast(data->CBMessage/*Message*/));
622 return(GSM->SetKey(*data->SetKeyKey/*c*/,
623 (!data->SetKeyUp ? 0 : *data->SetKeyUp)/*up*/));
625 case GOP_HandleString:
626 return(GSM->HandleString(data->HandleString/*s*/));
629 return(GSM->AnswerCall((!data->CallNo ? 0 : *data->CallNo)/*s*/));
633 return(GE_NOTIMPLEMENTED);
637 /* Initialise interface to the phone. Model number should be a string such as
638 3810, 5110, 6110 etc. Device is the serial port to use e.g. /dev/ttyS0, the
639 user must have write permission to the device. */
641 static GSM_Error register_phone(GSM_Phone *phone, char *model, char *setupmodel, GSM_Statemachine *sm)
646 GSM_DataClear(&data);
647 data.Model = setupmodel;
653 if (strstr(phone->Info.Models, model) != NULL)
654 return phone->Functions(GOP_Init, p_data, sm);
655 return GE_UNKNOWNMODEL;
658 #define MODULE(x) { \
659 extern GSM_Functions x##_Functions; \
660 extern GSM_Information x##_Information; \
661 extern bool x##_LinkOK; \
662 if (strstr(x##_Information.Models, model) != NULL) { \
663 GSM = & x##_Functions; \
664 GSM_Info = & x##_Information; \
665 GSM_LinkOK = & x##_LinkOK; \
666 return (GSM->Initialise(device, initlength, connection, rlp_callback)); \
670 #define REGISTER_PHONE(x, y) { \
671 extern GSM_Phone phone_##x; \
672 if ((ret = register_phone(&phone_##x, model, y, sm)) != GE_UNKNOWNMODEL) \
676 GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), GSM_Statemachine *sm)
679 compat_Functions_Statemachine=sm;
680 #ifndef WIN32 /* MB21 not supported in win32 */
681 if (strstr("2110", model)) {
682 extern GSM_Phone phone_nokia_2110;
683 memcpy(&(sm->Phone), &phone_nokia_2110, sizeof(GSM_Phone));
684 sm->Phone.Functions(GOP_Init, NULL, sm);
688 GSM_LinkOK = &LinkAlwaysOK;
689 sm->Link.ConnectionType=connection;
690 sm->Link.InitLength=atoi(initlength);
691 strcpy(sm->Link.PortDevice,device);
692 GSM=&compat_Functions;
694 REGISTER_PHONE(nokia_7110, NULL);
695 REGISTER_PHONE(at_hw, model); /* FIXME: why 7110 does not to set sm->Model? */
696 REGISTER_PHONE(cimd, model); /* FIXME: why 7110 does not to set sm->Model? */
698 REGISTER_PHONE(nokia_3110, NULL);
702 return (GE_UNKNOWNMODEL);