Gammu internals  1.38.0
Generic phone functions
Collaboration diagram for Generic phone functions:

Functions

GSM_Error PHONE_GetSMSFolders (GSM_StateMachine *s, GSM_SMSFolders *folders)
 
void GSM_CreateFirmwareNumber (GSM_StateMachine *s)
 
GSM_Error PHONE_Terminate (GSM_StateMachine *s)
 
GSM_Error NoneReply (GSM_Protocol_Message *msg, GSM_StateMachine *s)
 
GSM_Error PHONE_FindDataFile (GSM_StateMachine *s, GSM_File *File, const char *ExtraPath, const char *filename)
 
GSM_Error PHONE_UploadFile (GSM_StateMachine *s, GSM_File *File)
 

Detailed Description

Function Documentation

§ GSM_CreateFirmwareNumber()

void GSM_CreateFirmwareNumber ( GSM_StateMachine s)

Parses string firmware number into numeric.

Definition at line 52 of file pfunc.c.

References GSM_Phone::Data, _GSM_StateMachine::Phone, smprintf(), StringToDouble(), GSM_Phone_Data::VerNum, and GSM_Phone_Data::Version.

Referenced by DUMMY_GetFirmware(), and NOKIA_EncodeDateTime().

53 {
55  smprintf(s, "Number version is \"%f\"\n", s->Phone.Data.VerNum);
56 }
char Version[GSM_MAX_VERSION_LENGTH+1]
Definition: gsmstate.h:454
void StringToDouble(char *text, double *d)
Definition: coding.c:1731
GSM_Phone Phone
Definition: gsmstate.h:1431
GSM_Phone_Data Data
Definition: gsmstate.h:1369
double VerNum
Definition: gsmstate.h:462
int smprintf(GSM_StateMachine *s, const char *format,...)
Definition: debug.c:261

§ NoneReply()

GSM_Error NoneReply ( GSM_Protocol_Message msg,
GSM_StateMachine s 
)

Generic reply function when no reply is requested.

§ PHONE_FindDataFile()

GSM_Error PHONE_FindDataFile ( GSM_StateMachine s,
GSM_File File,
const char *  ExtraPath,
const char *  filename 
)

Definition at line 141 of file pfunc.c.

References EncodeUnicode(), ERR_MOREMEMORY, ERR_NONE, GAMMU_DATA_PATH, GSM_ReadFile(), MAX, GSM_File::Name, and smprintf().

142 {
143  char *path;
144  GSM_Error error;
145 
146  EncodeUnicode(File->Name, filename, strlen(filename));
147 
148  path = malloc(MAX(strlen(GAMMU_DATA_PATH), ExtraPath == NULL ? 0 : strlen(ExtraPath)) + 50);
149  if (path == NULL) {
150  return ERR_MOREMEMORY;
151  }
152 
153  if (ExtraPath != NULL) {
154  sprintf(path, "%s/%s", ExtraPath, filename);
155  smprintf(s, "Trying to load from extra path: %s\n", path);
156 
157  error = GSM_ReadFile(path, File);
158  if (error == ERR_NONE) {
159  free(path);
160  return error;
161  }
162  }
163 
164  sprintf(path, "%s/%s", GAMMU_DATA_PATH, filename);
165  smprintf(s, "Trying to load from data path: %s\n", path);
166 
167  error = GSM_ReadFile(path, File);
168  free(path);
169 
170  return error;
171 }
unsigned char Name[2 *(GSM_MAX_FILENAME_LENGTH+1)]
Definition: gammu-file.h:74
#define MAX(a, b)
Definition: gammu-misc.h:68
GSM_Error
Definition: gammu-error.h:23
void EncodeUnicode(unsigned char *dest, const char *src, size_t len)
Definition: coding.c:301
GSM_Error GSM_ReadFile(const char *FileName, GSM_File *File)
Definition: gsmmisc.c:74
#define GAMMU_DATA_PATH
Definition: gammu-config.h:380
int smprintf(GSM_StateMachine *s, const char *format,...)
Definition: debug.c:261

§ PHONE_GetSMSFolders()

GSM_Error PHONE_GetSMSFolders ( GSM_StateMachine s,
GSM_SMSFolders folders 
)

§ PHONE_Terminate()

GSM_Error PHONE_Terminate ( GSM_StateMachine s)

Generic function for terminating phone connection. Can be used if phone does not require any special actions.

Definition at line 79 of file pfunc.c.

References GSM_Phone::Data, GSM_Phone_Data::EnableIncomingCB, GSM_Phone_Data::EnableIncomingSMS, ERR_NONE, FALSE, GSM_Phone::Functions, _GSM_StateMachine::Phone, GSM_Phone_Functions::SetIncomingCB, GSM_Phone_Functions::SetIncomingSMS, and TRUE.

80 {
81  GSM_Error error;
82 
83  if (s->Phone.Data.EnableIncomingCB==TRUE) {
84  error=s->Phone.Functions->SetIncomingCB(s,FALSE);
85  if (error!=ERR_NONE) return error;
86  }
87  if (s->Phone.Data.EnableIncomingSMS==TRUE) {
88  error=s->Phone.Functions->SetIncomingSMS(s,FALSE);
89  if (error!=ERR_NONE) return error;
90  }
91  return ERR_NONE;
92 }
GSM_Error(* SetIncomingSMS)(GSM_StateMachine *s, gboolean enable)
Definition: gsmstate.h:975
gboolean EnableIncomingCB
Definition: gsmstate.h:667
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define FALSE
Definition: gammu-types.h:25
GSM_Error(* SetIncomingCB)(GSM_StateMachine *s, gboolean enable)
Definition: gsmstate.h:979
GSM_Phone_Data Data
Definition: gsmstate.h:1369
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
#define TRUE
Definition: gammu-types.h:28
gboolean EnableIncomingSMS
Definition: gsmstate.h:663

§ PHONE_UploadFile()

GSM_Error PHONE_UploadFile ( GSM_StateMachine s,
GSM_File File 
)

Definition at line 173 of file pfunc.c.

References ERR_EMPTY, ERR_NONE, and GSM_SendFilePart().

174 {
175  size_t Pos = 0;
176  int Handle = 0;
177  GSM_Error error = ERR_NONE;;
178 
179  while (error == ERR_NONE) {
180  error = GSM_SendFilePart(s, File, &Pos, &Handle);
181  }
182  if (error == ERR_EMPTY) {
183  return ERR_NONE;
184  }
185  return error;
186 }
GSM_Error GSM_SendFilePart(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle)
Definition: api.c:1778
GSM_Error
Definition: gammu-error.h:23