1 /** 2 * \file gammu-info.h 3 * \author Michal Čihař 4 * 5 * Phone information. 6 */ 7 #ifndef __gammu_info_h 8 #define __gammu_info_h 9 10 /** 11 * \defgroup Info Info 12 * Phone information. 13 */ 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 #include <gammu-types.h> 20 #include <gammu-error.h> 21 #include <gammu-limits.h> 22 23 /** 24 * Find network name from given network code. 25 * 26 * \ingroup Info 27 */ 28 const unsigned char *GSM_GetNetworkName(const char *NetworkCode); 29 30 /** 31 * Find country name from given country code. 32 * 33 * \ingroup Info 34 */ 35 const unsigned char *GSM_GetCountryName(const char *CountryCode); 36 37 /** 38 * Structure for defining code-name mappings. 39 * 40 * \ingroup Info 41 */ 42 typedef struct { 43 const char Code[8]; 44 const char Name[64]; 45 } GSM_CodeName; 46 47 /** 48 * List of network codes, terminated by empty name/code. 49 * 50 * \ingroup Info 51 */ 52 extern const GSM_CodeName GSM_Networks[]; 53 54 /** 55 * List of country codes, terminated by empty name/code. 56 * 57 * \ingroup Info 58 */ 59 extern const GSM_CodeName GSM_Countries[]; 60 61 /** 62 * Status of network logging 63 * 64 * \ingroup Info 65 */ 66 typedef enum { 67 /** 68 * Home network for used SIM card. 69 */ 70 GSM_HomeNetwork = 1, 71 /** 72 * No network available for used SIM card. 73 */ 74 GSM_NoNetwork, 75 /** 76 * SIM card uses roaming. 77 */ 78 GSM_RoamingNetwork, 79 /** 80 * Network registration denied - card blocked or expired or disabled. 81 */ 82 GSM_RegistrationDenied, 83 /** 84 * Unknown network status. 85 */ 86 GSM_NetworkStatusUnknown, 87 /** 88 * Network explicitely requested by user. 89 */ 90 GSM_RequestingNetwork 91 } GSM_NetworkInfo_State; 92 93 /** 94 * Status of GPRS connection. 95 * 96 * \ingroup Info 97 */ 98 typedef enum { 99 /** 100 * GRPS is detached. 101 */ 102 GSM_GPRS_Detached = 1, 103 /** 104 * GRPS is attached. 105 */ 106 GSM_GPRS_Attached 107 } GSM_GPRS_State; 108 109 /** 110 * Structure for getting the current network info. 111 * 112 * \ingroup Info 113 */ 114 typedef struct { 115 /** 116 * Cell ID (CID) 117 */ 118 char CID[10]; 119 /** 120 * GSM network code. 121 */ 122 char NetworkCode[10]; 123 /** 124 * Status of network logging. If phone is not logged into any network, 125 * some values are not filled 126 */ 127 GSM_NetworkInfo_State State; 128 /** 129 * LAC (Local Area Code). 130 */ 131 char LAC[10]; 132 /** 133 * Name of current network returned from phone (or empty). 134 * The buffer needs to have twice the capacity of the longest supported 135 * network name to account for decoding. 136 */ 137 unsigned char NetworkName[20 * 2]; 138 /** 139 * GPRS state. 140 */ 141 GSM_GPRS_State GPRS; 142 /** 143 * Cell ID (CID) for packet network 144 */ 145 char PacketCID[10]; 146 /** 147 * Status of network logging for packet data. If phone is not logged into any network, 148 * some values are not filled 149 */ 150 GSM_NetworkInfo_State PacketState; 151 /** 152 * LAC (Local Area Code) for packet data. 153 */ 154 char PacketLAC[10]; 155 } GSM_NetworkInfo; 156 157 /** 158 * Information about signal quality, all these should be -1 when unknown. 159 * 160 * \ingroup Info 161 */ 162 typedef struct { 163 /* 164 * Signal strength in dBm 165 */ 166 int SignalStrength; 167 /** 168 * Signal strength in percent. 169 */ 170 int SignalPercent; 171 /** 172 * Bit error rate in percent. 173 */ 174 int BitErrorRate; 175 } GSM_SignalQuality; 176 177 /** 178 * Power source 179 * 180 * \ingroup Info 181 */ 182 typedef enum { 183 /** 184 * Powered from battery 185 */ 186 GSM_BatteryPowered = 1, 187 /** 188 * Powered from AC, battery connected 189 */ 190 GSM_BatteryConnected, 191 /** 192 * Powered from AC, battery is charging 193 */ 194 GSM_BatteryCharging, 195 /** 196 * Powered from AC, no battery 197 */ 198 GSM_BatteryNotConnected, 199 /** 200 * Powered from AC, battery is fully charged 201 */ 202 GSM_BatteryFull, 203 /** 204 * Power failure 205 */ 206 GSM_PowerFault 207 } GSM_ChargeState; 208 209 /** 210 * Power source 211 * 212 * \ingroup Info 213 */ 214 typedef enum { 215 /** 216 * Unknown battery 217 */ 218 GSM_BatteryUnknown = 0, 219 /** 220 * NiMH battery 221 */ 222 GSM_BatteryNiMH = 1, 223 /** 224 * Lithium Ion battery 225 */ 226 GSM_BatteryLiIon, 227 /** 228 * Lithium Polymer battery 229 */ 230 GSM_BatteryLiPol 231 } GSM_BatteryType; 232 233 /** 234 * Battery status 235 * 236 * \ingroup Info 237 */ 238 typedef struct { 239 /** 240 * Signal strength in percent, -1 = unknown 241 */ 242 int BatteryPercent; 243 /** 244 * Charge state 245 */ 246 GSM_ChargeState ChargeState; 247 /** 248 * Current battery voltage (in mV). 249 */ 250 int BatteryVoltage; 251 /** 252 * Voltage from charger (in mV) 253 */ 254 int ChargeVoltage; 255 /** 256 * Current from charger (in mA) 257 */ 258 int ChargeCurrent; 259 /** 260 * Phone current consumption (in mA) 261 */ 262 int PhoneCurrent; 263 /** 264 * Battery temperature (in degrees Celsius) 265 */ 266 int BatteryTemperature; 267 /** 268 * Phone temperature (in degrees Celsius) 269 */ 270 int PhoneTemperature; 271 /** 272 * Remaining battery capacity (in mAh) 273 */ 274 int BatteryCapacity; 275 /** 276 * Battery type 277 */ 278 GSM_BatteryType BatteryType; 279 } GSM_BatteryCharge; 280 281 /** 282 * Display feature 283 * 284 * \ingroup Info 285 */ 286 typedef enum { 287 GSM_CallActive = 1, 288 /** 289 * blinking envelope 290 */ 291 GSM_SMSMemoryFull, 292 GSM_FaxCall, 293 GSM_UnreadSMS, 294 GSM_DataCall, 295 GSM_VoiceCall, 296 GSM_KeypadLocked 297 } GSM_DisplayFeature; 298 299 /** 300 * Display features 301 * 302 * \ingroup Info 303 */ 304 typedef struct { 305 int Number; 306 GSM_DisplayFeature Feature[7]; 307 } GSM_DisplayFeatures; 308 309 /** 310 * Phone features definition. This is usually used for things, which can not 311 * be determined on run time. 312 * 313 * \ingroup Info 314 */ 315 typedef enum { 316 /* n6110.c */ 317 /** 318 * Calendar,3310 style - 10 reminders, Unicode, 3 coding types 319 */ 320 F_CAL33 = 1, 321 /** 322 * Calendar,5210 style - full Unicode, etc. 323 */ 324 F_CAL52, 325 /** 326 * Calendar,8250 style - "normal", but with Unicode 327 */ 328 F_CAL82, 329 /** 330 * Ringtones returned in SM format - 33xx 331 */ 332 F_RING_SM, 333 /** 334 * No ringtones 335 */ 336 F_NORING, 337 /** 338 * No phonebook in Unicode 339 */ 340 F_NOPBKUNICODE, 341 /** 342 * No WAP 343 */ 344 F_NOWAP, 345 /** 346 * No caller groups 347 */ 348 F_NOCALLER, 349 /** 350 * No Picture Images 351 */ 352 F_NOPICTURE, 353 /** 354 * No Picture Images text in Unicode 355 */ 356 F_NOPICTUREUNI, 357 /** 358 * No startup logo 359 */ 360 F_NOSTARTUP, 361 /** 362 * No calendar 363 */ 364 F_NOCALENDAR, 365 /** 366 * Startup logo is not animated 367 */ 368 F_NOSTARTANI, 369 /** 370 * Network and battery level get from netmonitor 371 */ 372 F_POWER_BATT, 373 /** 374 * Phone profiles in 3310 style 375 */ 376 F_PROFILES33, 377 /** 378 * Phone profiles in 5110 style 379 */ 380 F_PROFILES51, 381 /** 382 * Phone can make authentication with magic bytes 383 */ 384 F_MAGICBYTES, 385 /** 386 * Phone can't send DTMF 387 */ 388 F_NODTMF, 389 /** 390 * Phone return display status 391 */ 392 F_DISPSTATUS, 393 /** 394 * Phone does not return call info 395 */ 396 F_NOCALLINFO, 397 398 /* n3320.c */ 399 /** 400 * Day and month reversed in pbk, when compare to GSM models 401 */ 402 F_DAYMONTH, 403 404 /* n6510.c */ 405 /** 406 * Phonebook in 3510 style with ringtones ID 407 */ 408 F_PBK35, 409 /** 410 * Phonebook in 7250 style with picture ID 411 */ 412 F_PBKIMG, 413 /** 414 * Phonebook with selecting ringtones from gallery 415 */ 416 F_PBKTONEGAL, 417 /** 418 * Phonebook with SMS list 419 */ 420 F_PBKSMSLIST, 421 /** 422 * Phonebook with user ID 423 */ 424 F_PBKUSER, 425 /** 426 * Caller groups like in 6230i 427 */ 428 F_6230iCALLER, 429 /** 430 * Phone with FM radio 431 */ 432 F_RADIO, 433 /** 434 * ToDo in 6310 style - 0x55 msg type 435 */ 436 F_TODO63, 437 /** 438 * ToDo in 6610 style - like calendar, with date and other 439 */ 440 F_TODO66, 441 /** 442 * No ringtones in MIDI 443 */ 444 F_NOMIDI, 445 /** 446 * Bluetooth support 447 */ 448 F_BLUETOOTH, 449 /** 450 * No images, ringtones, java saved in special filesystem 451 */ 452 F_NOFILESYSTEM, 453 /** 454 * No MMS sets in phone 455 */ 456 F_NOMMS, 457 /** 458 * GPRS point are not useable 459 */ 460 F_NOGPRSPOINT, 461 /** 462 * Calendar,3510 style - Reminder,Call,Birthday 463 */ 464 F_CAL35, 465 /** 466 * Calendar,6510 style - CBMM, method 3 467 */ 468 F_CAL65, 469 /** 470 * WAP & MMS settings contains first & second proxy 471 */ 472 F_WAPMMSPROXY, 473 /** 474 * Phone with Chat settings 475 */ 476 F_CHAT, 477 /** 478 * Phone with SyncML settings 479 */ 480 F_SYNCML, 481 /** 482 * Filesystem version 2 483 */ 484 F_FILES2, 485 /** 486 * No filesystem version 1 487 */ 488 F_NOFILE1, 489 /** 490 * WAP, MMS, etc. settings like in 6230i - unknown now 491 */ 492 F_6230iWAP, 493 /** 494 * Profiles support available 495 */ 496 F_PROFILES, 497 /** 498 * Series 40 3.0 499 */ 500 F_SERIES40_30, 501 /** 502 * SMS are read from filesystem files like in Series 40 3.0 503 */ 504 F_SMS_FILES, 505 /** 506 * MMS storage as in 3320 507 */ 508 F_3220_MMS, 509 510 /* n6510.c && n7110.c */ 511 /** 512 * Voice tags available 513 */ 514 F_VOICETAGS, 515 /** 516 * Calendar,6210 style - Call,Birthday,Memo,Meeting 517 */ 518 F_CAL62, 519 /** 520 * Notes supported 521 */ 522 F_NOTES, 523 524 /* AT modules */ 525 /** 526 * Phone supports only sent/unsent messages 527 */ 528 F_SMSONLYSENT, 529 /** 530 * CPBS on some memories can hang phone 531 */ 532 F_BROKENCPBS, 533 /** 534 * Siemens M20 like SMS handling 535 */ 536 F_M20SMS, 537 /** 538 * Use slower writing which some phone need 539 */ 540 F_SLOWWRITE, 541 /** 542 * SMS in ME start from location 900 - case of Sagem 543 */ 544 F_SMSME900, 545 /** 546 * Phone supports Alcatel protocol 547 */ 548 F_ALCATEL, 549 /** 550 * Phone can switch to OBEX protocol from AT mode 551 */ 552 F_OBEX, 553 /** 554 * Phone supports IrMC level 2 even if it doesn't report it 555 */ 556 F_IRMC_LEVEL_2, 557 /** 558 * Switching to OBEX mode is done using AT+MODE=22 559 */ 560 F_MODE22, 561 /** 562 * Locations of SMS memories start from 0 563 */ 564 F_SMS_LOCATION_0, 565 /** 566 * Phone does not support UCS2 even if it reports it. 567 */ 568 F_NO_UCS2, 569 /** 570 * Phone returns strings in utf-8 even if it reports GSM. 571 */ 572 F_FORCE_UTF8, 573 /** 574 * Phone supports SM storage for SMS even if it does not report 575 * so. 576 */ 577 F_SMS_SM, 578 /** 579 * Phone supports ME storage for SMS even if it does not report 580 * so. 581 */ 582 F_SMS_ME, 583 /** 584 * Switching to OBEX mode is done using AT+XLNK. 585 */ 586 F_XLNK, 587 /** 588 * Submit messages can be saved on SM memory only. 589 */ 590 F_SUBMIT_SIM_ONLY, 591 /** 592 * Prefer Unicode for phone book manipulations. 593 */ 594 F_PBK_UNICODE, 595 /** 596 * Switching to OBEX mode using AT^SQWE=3. 597 */ 598 F_SQWE, 599 /** 600 * Do not use OBEX/AT switching even if available. 601 */ 602 F_NO_ATOBEX, 603 /** 604 * Length of text for contact is in bytes and not chars. 605 */ 606 F_LENGTH_BYTES, 607 /** 608 * CMGL does not list real locations for CMGR, these should be 609 * sequential. 610 */ 611 F_BROKEN_CMGL, 612 /** 613 * Phonebook has extra numeric field at the end. 614 */ 615 F_EXTRA_PBK_FIELD, 616 /** 617 * Key presses can not be in unicode. 618 */ 619 F_CKPD_NO_UNICODE, 620 /** 621 * OBEX switching using AT+CPROT even if phone does not report 622 * it properly. 623 */ 624 F_CPROT, 625 /** 626 * Phonebook with favorite messaging numbers 627 */ 628 F_PBKFAVORITEMESSAGE, 629 /** 630 * No support for postal entry in phonebook. 631 */ 632 F_PBKNOPOSTAL, 633 /** 634 * Encode number in HEX charset. 635 */ 636 F_PBK_ENCODENUMBER, 637 /** 638 * Do not use CLIP (phone hangs on it). 639 */ 640 F_NO_CLIP, 641 /** 642 * USSD propmts and responses are encoded like PDU in SMS 643 * (packed 7-bit GSM encoding). 644 */ 645 F_ENCODED_USSD, 646 /** 647 * Phone has better support for SMS text mode (rather than PDU mode) 648 */ 649 F_USE_SMSTEXTMODE, 650 /** 651 * Phone does not end CPIN reply with OK/ERROR. 652 */ 653 F_CPIN_NO_OK, 654 /** 655 * Phone require four digit year in time. 656 */ 657 F_FOUR_DIGIT_YEAR, 658 /** 659 * Phone does not have a phone SMS memory even if it reports so. 660 */ 661 F_SMS_NO_ME, 662 /** 663 * Phone does not have a SIM SMS memory even if it reports so. 664 */ 665 F_SMS_NO_SM, 666 /** 667 * Phone supports Siemens style phonebook even if it does not 668 * tell so. 669 */ 670 F_SIEMENS_PBK, 671 /** 672 * Disable AT+SYNCML probing. 673 */ 674 F_NO_ATSYNCML, 675 /** 676 * Phone supports m-obex (usually Samsung phones). 677 */ 678 F_MOBEX, 679 /** 680 * Phone supports m-obex (usually Samsung phones) using AT$TSSPCSW=1. 681 */ 682 F_TSSPCSW, 683 /** 684 * Disable GetNext* operations on the dummy phone. 685 */ 686 F_DISABLE_GETNEXT, 687 /** 688 * Disable GetNextSMS operations on the dummy phone. 689 */ 690 F_DISABLE_GETNEXTSMS, 691 /** 692 * CMGL hangs, so should not be used. 693 */ 694 F_DISABLE_CMGL, 695 /** 696 * Phone does not support UTF8 even if it reports it. 697 */ 698 F_NO_UTF8, 699 /** 700 * Samsung B2100 in UCS-2 mode provides a garbled UTF-8 instead. 701 */ 702 F_SAMSUNG_UTF8, 703 /** 704 * SMS text is always UTF-8 encoded. 705 */ 706 F_SMS_UTF8_ENCODED, 707 /** 708 * Avoid forcibly stopping CUSD session. 709 */ 710 F_NO_STOP_CUSD, 711 /** 712 * Reading og SMSes in text mode. 713 */ 714 F_READ_SMSTEXTMODE, 715 /** 716 * Reset phone after timeout. 717 */ 718 F_RESET_AFTER_TIMEOUT, 719 /** 720 * Huawei style init. 721 */ 722 F_HUAWEI_INIT, 723 /** 724 * ZTE style init. 725 */ 726 F_ZTE_INIT, 727 /** 728 * Prefer GSM charset for USSD (default is unicode). 729 */ 730 F_USSD_GSM_CHARSET, 731 /** 732 * Phone supports SR storage even if it does not report 733 * so. 734 */ 735 F_SMS_SR, 736 /** 737 * Phone does not have a SR memory even if it reports so. 738 */ 739 F_SMS_NO_SR, 740 741 /** 742 * Just marker of highest feature code, should not be used. 743 */ 744 F_LAST_VALUE 745 } GSM_Feature; 746 747 /** 748 * Converts feature value to string. 749 * 750 * \ingroup Info 751 * 752 * \param feature GSM_Feature to convert. 753 * 754 * \return Pointer to static string with string for specified feature, 755 * NULL on failure. 756 */ 757 const char *GSM_FeatureToString(GSM_Feature feature); 758 759 /** 760 * Converts feature string to value. 761 * 762 * \ingroup Info 763 * 764 * \param feature GSM_Feature string to convert. 765 * 766 * \return GSM_Feature value, 0 on failure. 767 */ 768 GSM_Feature GSM_FeatureFromString(const char *feature); 769 770 /** 771 * Model identification, used for finding phone features. 772 * 773 * \ingroup Info 774 */ 775 typedef struct { 776 /** 777 * Model as returned by phone 778 */ 779 const char *model; 780 /** 781 * Identification by Gammu 782 */ 783 const char *number; 784 /** 785 * Model as used over IrDA 786 */ 787 const char *irdamodel; 788 /** 789 * List of supported features 790 */ 791 GSM_Feature features[GSM_MAX_PHONE_FEATURES + 1]; 792 } GSM_PhoneModel; 793 794 /** 795 * Checks whether phone supports features. 796 * 797 * \param model Model information (you can get it using \ref GSM_GetModelInfo). 798 * \param feature GSM_Feature to check for. 799 * 800 * \return True if phone has defined this feature. 801 * 802 * \ingroup Info 803 */ 804 gboolean GSM_IsPhoneFeatureAvailable(GSM_PhoneModel * model, GSM_Feature feature); 805 806 /** 807 * Adds feature to phone configuration. 808 * 809 * \param model Model information (you can get it using \ref GSM_GetModelInfo). 810 * \param feature GSM_Feature to check for. 811 * 812 * \return True if phone has defined this feature. 813 * 814 * \ingroup Info 815 */ 816 gboolean GSM_AddPhoneFeature(GSM_PhoneModel * model, GSM_Feature feature); 817 818 #include <gammu-statemachine.h> 819 820 /** 821 * Reads manufacturer from phone. 822 * 823 * \param s State machine pointer. 824 * \param value Pointer where to store manufacturer name 825 * 826 * \return Error code. 827 * 828 * \ingroup Info 829 */ 830 GSM_Error GSM_GetManufacturer(GSM_StateMachine * s, char *value); 831 832 /** 833 * Reads model from phone. 834 * 835 * \param s State machine pointer. 836 * \param value Pointer where to store model name 837 * 838 * \return Error code. 839 * 840 * \ingroup Info 841 */ 842 GSM_Error GSM_GetModel(GSM_StateMachine * s, char *value); 843 844 /** 845 * Reads model info from state machine. 846 * 847 * \param s State machine pointer. 848 * 849 * \return Pointer to phone information structure. 850 * 851 * \ingroup Info 852 */ 853 GSM_PhoneModel *GSM_GetModelInfo(GSM_StateMachine * s); 854 855 /** 856 * Reads firmware information from phone. 857 * 858 * \param s State machine pointer. 859 * \param value Pointer where to store revision text 860 * \param date Pointer where to store revision date 861 * \param num Pointer where to store revision number 862 * 863 * \return Error code. 864 * 865 * \ingroup Info 866 */ 867 GSM_Error GSM_GetFirmware(GSM_StateMachine * s, char *value, char *date, 868 double *num); 869 870 /** 871 * Reads IMEI/serial number from phone. 872 * 873 * \param s State machine pointer. 874 * \param value Pointer where to store IMEI, NULL to ignore. 875 * 876 * \return Error code. 877 * 878 * \ingroup Info 879 */ 880 GSM_Error GSM_GetIMEI(GSM_StateMachine * s, char *value); 881 882 /** 883 * Gets date and time from phone. 884 * 885 * \ingroup Info 886 */ 887 GSM_Error GSM_GetOriginalIMEI(GSM_StateMachine * s, char *value); 888 889 /** 890 * Gets month when device was manufactured. 891 * 892 * \ingroup Info 893 */ 894 GSM_Error GSM_GetManufactureMonth(GSM_StateMachine * s, char *value); 895 896 /** 897 * Gets product code of device. 898 * 899 * \ingroup Info 900 */ 901 GSM_Error GSM_GetProductCode(GSM_StateMachine * s, char *value); 902 903 /** 904 * Gets hardware information about device. 905 * 906 * \ingroup Info 907 */ 908 GSM_Error GSM_GetHardware(GSM_StateMachine * s, char *value); 909 910 /** 911 * Gets PPM (Post Programmable Memory) info from phone 912 * (in other words for Nokia get, which language pack is in phone) 913 * 914 * \ingroup Info 915 */ 916 GSM_Error GSM_GetPPM(GSM_StateMachine * s, char *value); 917 918 /** 919 * Gets SIM IMSI from phone. 920 * 921 * \ingroup Info 922 */ 923 GSM_Error GSM_GetSIMIMSI(GSM_StateMachine * s, char *IMSI); 924 925 /** 926 * Gets information about batery charge and phone charging state. 927 * 928 * \ingroup Info 929 */ 930 GSM_Error GSM_GetBatteryCharge(GSM_StateMachine * s, GSM_BatteryCharge * bat); 931 932 /** 933 * Reads signal quality (strength and error rate). 934 * 935 * \ingroup Info 936 */ 937 GSM_Error GSM_GetSignalQuality(GSM_StateMachine * s, GSM_SignalQuality * sig); 938 939 /** 940 * Gets network information. 941 * 942 * \ingroup Info 943 */ 944 GSM_Error GSM_GetNetworkInfo(GSM_StateMachine * s, GSM_NetworkInfo * netinfo); 945 946 /** 947 * Acquired display status. 948 * 949 * \ingroup Info 950 */ 951 GSM_Error GSM_GetDisplayStatus(GSM_StateMachine * s, 952 GSM_DisplayFeatures * features); 953 #ifdef __cplusplus 954 } 955 #endif 956 #endif 957 958 /* Editor configuration 959 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: 960 */ 961