1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
|
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Gammu internals</title>
</head>
<body>
<h2> Gammu internals</h2>
<h3> gammurc Configuration file</h3>
When started, Gammu looks for the file gammurc, which contains
startup definitions in a Windows INI manner. For a 6210 on COM1, the
file may looks like this:
<p><tt>[gammu]</tt> <br>
<tt>model = 6210</tt> <br>
<tt>port=com1:</tt> <br>
<tt>connection=dlr3</tt> </p>
<p>Though Gammu has support for automatically identifying the connected
device, still port number and connection type need to be specified.
Including the model definition speeds up things since the identifying
process is skipped. </p>
<p>These are the currently possible values for connection: <br>
<table border="1">
<tbody>
<tr>
<td><b>Connection</b></td>
<td><b>Details</b></td>
</tr>
<tr>
<td><tt>at19200</tt> <br>
<tt>at115200</tt></td>
<td>AT commands over serial ports</td>
</tr>
<tr>
<td><tt>fbus</tt> <br>
<tt>mbus</tt></td>
<td>Nokias proprietary wiring and protocols</td>
</tr>
<tr>
<td><tt>dlr3</tt></td>
<td>Nokia fbus protocol over DLR3 cable</td>
</tr>
<tr>
<td><tt>Irda</tt> <br>
<tt>infrared</tt></td>
<td>Infrared with irDA standard or Nokia fbus</td>
</tr>
<tr>
<td><tt>atblue</tt></td>
<td>AT over Bluetooth</td>
</tr>
<tr>
<td><tt>dlr3blue</tt></td>
<td>Nokia fbus over Bluetooth (init using method from DLR3 cable)</td>
</tr>
</tbody>
</table>
</p>
<h3> Architecture</h3>
Marcin Wiacek, author of Gammu, did a very good job at abstracting the
various levels he uses, enabling developers to add new features very
quickly. We could, for example, add definitions for a new phone and
for the most part it wouldnt matter whether its connected locally,
via infrared, or (evolving) via Bluetooth.
<p>These are the different abstraction levels: <br>
<table border="1">
<tbody>
<tr>
<td><b>Title</b></td>
<td><b>Description</b></td>
<td><b>Defined in</b></td>
</tr>
<tr>
<td>Configuration parser</td>
<td>Parses gammurc file</td>
<td>cfg</td>
</tr>
<tr>
<td>Connections</td>
<td>Provides interfaces for serial, infrared and Bluetooth
communications</td>
<td>common\device</td>
</tr>
<tr>
<td>Protocols</td>
<td>Defines protocols for Nokia, AT and Alcatel phones</td>
<td>common\protocol</td>
</tr>
<tr>
<td>Phones</td>
<td>Specific and general implementations for the supported phone
series</td>
<td>common\phone</td>
</tr>
<tr>
<td>Service</td>
<td>Provides access to the phone functions main point of
interest for application development</td>
<td>common\service</td>
</tr>
</tbody>
</table>
</p>
<h3> Phone function reference</h3>
The following phone functions are possible, support varies by phone: <br>
<table border="1">
<tbody>
<tr>
<td><b>Name</b></td>
<td><b>Description</b></td>
</tr>
<tr>
<td>AnswerCall</td>
<td>Accept currently incoming call</td>
</tr>
<tr>
<td>CancelCall</td>
<td>Deny currently incoming call</td>
</tr>
<tr>
<td>DialVoice</td>
<td>Call number and establish voice call</td>
</tr>
<tr>
<td>EnterSecurityCode</td>
<td>Allow to "enter" pin/puk/pin2/puk2, when phone prompts for it
on screen</td>
</tr>
<tr>
<td>Get/Set/DeleteWAPBookmark</td>
<td>Obvious</td>
</tr>
<tr>
<td>Get/Set/SendSMSMessage GetNextSMSMessage DeleteSMS</td>
<td>Obvious</td>
</tr>
<tr>
<td>Get/SetAlarm</td>
<td>Obvious</td>
</tr>
<tr>
<td>Get/SetBitmap</td>
<td>Obvious</td>
</tr>
<tr>
<td>Get/SetCalendarNote DeleteCalendarNote</td>
<td>Obvious</td>
</tr>
<tr>
<td>Get/SetDateTime</td>
<td>Obvious</td>
</tr>
<tr>
<td>Get/SetMemory</td>
<td>Retrieve and set various telephone numbers, like phonebook
entries in the internal memory and on the SIM card,
dialed/missed/received logs as well as the phones own number</td>
</tr>
<tr>
<td>Get/SetProfile</td>
<td>Profile data such as ringtone volume, key sound etc.</td>
</tr>
<tr>
<td>Get/SetRingtone</td>
<td>Obvious</td>
</tr>
<tr>
<td>Get/SetSMSC</td>
<td>Get/Set the number of the SMS Service Center</td>
</tr>
<tr>
<td>Get/SetSpeedDial</td>
<td>a.k.a. dialing shortcuts</td>
</tr>
<tr>
<td>Get/SetTodo DeleteAllTodo</td>
<td>Obvious</td>
</tr>
<tr>
<td>Get/SetWAPSettings</td>
<td>Dial-up settings</td>
</tr>
<tr>
<td>GetBatteryLevel</td>
<td>Obvious</td>
</tr>
<tr>
<td>GetDisplayStatus</td>
<td>See on-screen notification icons (new SMS etc.)</td>
</tr>
<tr>
<td>GetHardware</td>
<td>Get hardware info</td>
</tr>
<tr>
<td>GetIMEI</td>
<td>Retrieve the International Mobile Equipment Identity number</td>
</tr>
<tr>
<td>GetManufactureMonth</td>
<td>Obvious</td>
</tr>
<tr>
<td>GetManufacturer</td>
<td>Obvious</td>
</tr>
<tr>
<td>GetMemoryStatus</td>
<td>Retrieve information about capacity and usage of specific
memory</td>
</tr>
<tr>
<td>GetNetworkInfo</td>
<td>Retrieve network name, code, current cell, location area
code, net status (home/roaming/searching network/no network)</td>
</tr>
<tr>
<td>GetNetworkLevel</td>
<td>Network signal strength</td>
</tr>
<tr>
<td>GetOriginalIMEI</td>
<td>Obvious</td>
</tr>
<tr>
<td>GetPPM</td>
<td>Get name of phones language package (Nokia)</td>
</tr>
<tr>
<td>GetProductCode</td>
<td>Manufacturer-specific</td>
</tr>
<tr>
<td>GetRingtonesInfo</td>
<td>Get ringtone names</td>
</tr>
<tr>
<td>GetSecurityStatus</td>
<td>Figure out what code (PIN, Security Code, PIN2, PUK, PUK2),
is being prompted by the phone, if any</td>
</tr>
<tr>
<td>GetSIMIMSI</td>
<td>International Mobile Subscriber Identity number assigned to
SIM card</td>
</tr>
<tr>
<td>GetSMSFolders</td>
<td>Retrieve names of SMS folders</td>
</tr>
<tr>
<td>GetSMSStatus</td>
<td>Statistics about SMS memory usage</td>
</tr>
<tr>
<td>PlayTone</td>
<td>Play tone on phone</td>
</tr>
<tr>
<td>PressKey</td>
<td>Simulate any key push to phone!</td>
</tr>
<tr>
<td>Reset</td>
<td>Soft/hard phone reset</td>
</tr>
<tr>
<td>ResetPhoneSettings</td>
<td>Obvious</td>
</tr>
<tr>
<td>SendDTMF</td>
<td>Numeric key tones</td>
</tr>
<tr>
<td>SetAutoNetworkLogin</td>
<td>Obvious</td>
</tr>
<tr>
<td>SetIncomingCall</td>
<td>Trigger notification for incoming calls</td>
</tr>
<tr>
<td>SetIncomingCB</td>
<td>Trigger notification for incoming CB messages</td>
</tr>
<tr>
<td>SetIncomingSMS</td>
<td>Trigger notification for incoming SMS messages</td>
</tr>
</tbody>
</table>
<h3> Services</h3>
Furthermore, Gammu offers the following services (see first table): <br>
<table border="1">
<tbody>
<tr>
<td><b>Title</b></td>
<td><b>Description</b></td>
<td><b>Defined in</b></td>
</tr>
<tr>
<td>Backup</td>
<td>Complete backup/restore of phone data</td>
<td>gsmbackup.c</td>
</tr>
<tr>
<td>Logo</td>
<td>Functions to read, write, resize and convert bitmaps and
operator logos and animations</td>
<td>gsmlogo.c</td>
</tr>
<tr>
<td>Networks</td>
<td>Pretty extensive table to link GSM operator network codes to
the actual operator names</td>
<td>gsmnet.c</td>
</tr>
<tr>
<td>Phonebook</td>
<td>VCard support (currently minimal)</td>
<td>gsmpbk.c</td>
</tr>
<tr>
<td>Calendar</td>
<td>VCalendar support</td>
<td>gsmcal.c</td>
</tr>
<tr>
<td>Ringtones</td>
<td>Functions to read, write and convert ringtone data in various
formats</td>
<td>gsmring.c</td>
</tr>
<tr>
<td>SMS</td>
<td>Encode and decode various SMS formats, including multi-part
messages</td>
<td>gsmsms.c</td>
</tr>
<tr>
<td>WAP bookmarks</td>
<td>Encoding support for Nokia WAP bookmarks</td>
<td>gsmwap.c</td>
</tr>
</tbody>
</table>
<p>Be sure to also take a look at gammu.c, which offers additional
functionality such as data message composition/sending (wap settings
no gprs/syncml; vcards, calendar items, ringtones, logos, sms center
settings, bookmarks). Check out the Readme in the docs/ directory. </p>
<h2> Writing code based on Gammu</h2>
Though Gammu is meant to be a single application, one can simply import
all its classes and headers and make use of them. The easiest way to do
this is to copy all the includes and global variables (s, *Phone, etc.,
see below for details) from the main class gammu.c. into ones own main
class. When using Gammu in a C++ project, it is mandatory to use extern
C when including its files:
<p><tt>extern "C" {</tt> </p>
<p><tt>#include "gammu/gammu/gammu.h"</tt> </p>
<p><tt>..............</tt> </p>
<p><tt>}</tt> </p>
<h3> Global variables</h3>
gammu.c uses the following global variables, I recommend their
adoption:
<table border="1">
<tbody>
<tr>
<td><b>Variable</b></td>
<td><b>Details</b></td>
</tr>
<tr>
<td>GSM_StateMachine s</td>
<td>Basic layer to the phone connection</td>
</tr>
<tr>
<td>GSM_Phone_Functions *Phone</td>
<td>Interface to the phone (see phone functions above)</td>
</tr>
<tr>
<td>static CFG_Header *cfg</td>
<td>Configuration settings retrieved from gammurc</td>
</tr>
<tr>
<td>GSM_Error error</td>
<td>Current errorlevel. Important values are GE_NONE=1 and
GE_NOTIMPLEMENTED=19</td>
</tr>
</tbody>
</table>
<h3> Basic procedure</h3>
In order to work with Gammu, follow the following procedure observed in
gammu.c: <br>
<table border="1">
<tbody>
<tr>
<td><b>Step</b></td>
<td><b>Description</b></td>
<td><b>Command</b></td>
</tr>
<tr>
<td>1</td>
<td>(optional): Find and parse out the gammurc configuration
file</td>
<td>cfg=CFG_FindGammuRC();</td>
</tr>
<tr>
<td>2</td>
<td>Load configuration settings</td>
<td>CFG_ReadConfig(cfg, &s.Config);</td>
</tr>
<tr>
<td>3</td>
<td>Connect to phone</td>
<td>GSM_Init(false);</td>
</tr>
<tr>
<td colspan="3">
<center>....</center>
</td>
</tr>
<tr>
<td>4</td>
<td>Interface phone</td>
<td>For example: error=Phone->GetRingtone(&s,
&ringtonebin,0);</td>
</tr>
<tr>
<td colspan="3">
<center>....</center>
</td>
</tr>
<tr>
<td>5</td>
<td>Terminate connection</td>
<td>GSM_Terminate();</td>
</tr>
</tbody>
</table>
<p>Note: The functions GSM_Init and GSM_Terminate are located in
gammu.c. </p>
<h3> Working without a gammurc</h3>
When Gammu cant find the gammurc, it will fall back to its defaults
which are entered in the function CFG_ReadConfig in common/gsmring.c.
<h3> DLL or not?</h3>
Starting with release 0.64, there is a DLL version of Gammu included in
the distribution. As of now, it mostly acts as a demonstration on how
to use Gammu routines in other environments (Delphi) and encapsulates
only a few of its functions, none of the ones I needed (which were
functions for ringtone, contact, calendar, wap data access).
<p>Thus, the DLL would have to be adjusted with every new release of
Gammu in the same manner as with the current implementation, defying
the independent nature of a DLL, so I decided not to use this DLL as a
base for now. Still, I assume that the DLL will soon encapsulate all
Gammu functions, making it an interesting option for the future. </p>
</body>
</html>
|