/* smsDemo.c: send and receive sms message demo Compiler: BC++ 3.1, Turbo C++ 1.01 (3.01) MSVC 1.52 Compile mode: Large Project: smsDemo.c ..\..\lib\uPAC5000.Lib ..\..\lib\OS7_COM.lib ..\lib\GSM.lib Hardware: uPAC-5000 Note The OS7_COM.lib library is required for using the GSM member functions. [Nov 11, 2011] Create by Malo */ #include #include #include #include #include #include "..\..\lib\uPAC5000.h" #include "..\..\lib\OS7_COM.h" #include "..\lib\GSM.h" void printMsg(strEncode_Msg RecMsg) { int i; if(RecMsg.mode == 0) { Print("\r\n------------------\r\n"); Print("phone number = %s\r\n", RecMsg.phoneNumber); Print("receive time = %s\r\n", RecMsg.time); Print("mode = %d\r\n", RecMsg.mode); Print("message length = %d\r\n", RecMsg.dataLen); Print("message = %s\r\n", RecMsg.msg); Print("\r\n------------------\r\n"); }else { Print("\r\n------------------\r\n"); Print("phone number = %s\r\n", RecMsg.phoneNumber); Print("receive time = %s\r\n", RecMsg.time); Print("mode = %d\r\n", RecMsg.mode); Print("message length = %d\r\n", RecMsg.dataLen); Print("message = \r\n"); for(i=0; i>8, libVer&0xff, libDate); //-- print GSM lib. version GM_SYS_GetLibDate(libDate); libVer = GM_SYS_GetLibVersion(); Print("GSM LIB vesion %X.%02X, Date:%s\r\n", libVer>>8, libVer&0xff, libDate); //---- init modem strcpy(sysProfile.PINCode, "0000"); //The pin code of SIM card, ex: "0000" sysProfile.modemPort = 11; //modem port number. G-4500 = 4, uP-5000 = 11 sysProfile.hardware = 2; //hardware type. 1: G-4500, 2: uPAC-5000, 3: iP-8000, 0: GTM-201 if( (Result = GM_SYS_InitModem(sysProfile)) == GM_NOERROR) Print("init_modem success!!\r\n"); else{ Print("init_modem fail!! return value is %d\r\n", Result); return 1; } //--check Could the modem service? while(GM_SYS_CheckModemStatus() != GM_NOERROR) { Print("wait modem register...\r\n"); DelayMs(1000); } Print("modem registered!!\r\n"); while(iAction!=0) { iAction=0; quit=0; Print("\r\n"); Print("1) Send ASCII messages\r\n"); Print("2) check signal quality\r\n"); Print("3) check registered?\r\n"); Print("\r\n"); Print("0) Quits demo program\r\n"); Print("Choose an option and press [Enter]: "); Scanf("%d", &iAction); Print("\r\n"); switch(iAction) { case 1://Send ASCII messages Print("Send ASCII messages\r\n"); Print("Please Input Phone Number ="); Scanf("%s", sendNumber); Print("How many message do you want to send?\r\n"); Scanf("%d", &send_n); i = 0; Print("== start to send sms, please press to exit ==\r\n"); while(1) { // press "ESC" to exit if(Kbhit()) { tmp = Getch(); if( tmp == 27 || tmp == 'q') break; } //--(1) check that could the modem service, if it can't, skip operating the modem below if(GM_SYS_CheckModemStatus() != GM_NOERROR) continue; //--(2) send messages, when the modem can service if(i