Home
GSM Library
Contents
1. SSM Library Version 3 0 User Manual Imtrod ctid fie ene ere een er ee 3 Q ck Start meere nee re tee E ee re eee re ee ee ene ee ee ee ee ee 4 Routines and MPSA Stn fleece eennpdh vibe ple nbs se ives fetta cascada dec pdb peablbeai abs bela bdlanniabai toa 8 UN EV rite MechaniS it calla ian Sn dred vlad lacie 8 E ae er eee enenenenemenetodtatennenednacden 9 Date Time e Heen ergeet 9 Eer 10 Kee E 10 ET Ee 11 Network Te E 11 HE e E 11 EIST 12 Mic eege eebe eege 13 EE tistiteotentiniesiniiastintontiminadinaietndutin inten ite tindeutini tintin iengindeainaiaintintiniiatininntetenayt 13 M ltiple EC 17 GIRDI CIS 18 FEDS aU un E 19 www dizzy co za Page 2 of 19 Introduction GSM modules have made it easy for embedded developers to add hardware capable of connecting to cellular networks to their project These GSM modules communicate via simple AT commands Whilst the AT commands are easy to understand and use writing reliable embedded code for interfacing with them can be challenging We have spent hundreds of hours developing and testing our GSM Library It is designed to be easy to use fast and reliable with failsafes and retry mechanisms built in at every step Functionality provided by the library includes Base Library v Read write the GSM modules RTCC real time calendar and clock Since most GSM modules have a facility for connecting a small backup battery to maintain the RTCC this can be a convenient
2. it then TMROH TMROL RODE DLE end if lt Timer0 end sub sub procedure gsm ODL 0x20 gsmlmsPing m cim GSM star as te er RBO m GSM Start Dir as Soit em TRISEO olt sub procedure interrupt Interrupt gt Ims Clim GSM Pwe key es Sbit aie JH OLC GSM Pune EE ENEE O bit MES ISON 0 Clear interrupt flag iMESicieVjor gt Event dim GsmEventType as char www dizzy co za Page 6 of 19 Handle GSM Library events here end sub main UART1 Init 9600 GSM Lib is designed to work at 9600 baud gsmiInit gsm MS rair gsm Meg Imit Only ir GSM Meg extension is availaole gem GPRS Iniel Only it GSM GPRS extension is available TOCON 10001000 Set up interrupt timer GIS bit 1 Global interro enable mOra birt 1 mnable TimerQ overilow interrupts while true gsmPoll 1 Acel your Coce here wend enel mikroPascal var GSM Pwr key 3 fo ar IWAWE2 Dite var GSM Pyr key Dir 3 goirt t WRISE2 OLL var GSM Stat 8 Soiu ar REO oity var GSM strat Dir g Soire at TRISHO boire procedure interrupt begin lt Timer0 Interrupt gt if OIF bit then begim lms Tnterrwpt TMROH OxD1 TMROL 0x20 gsmlmsPing TOTP bit s 0p Clear interrupt ilag end ff lt Timer0 Interrupt gt end procedu
3. server returns a result code other than 200 e g 404 Page not found then the www dizzy co za Page 12 of 19 gsmevntGprsHttpResultErr event will occur H the GPRS operation fails for any other reason e g no signal then the gsmevntGprsFailed event will occur Routines mikroC void gsmGprsHttpGet char url WO tement eener Cac wil Char joosiecksica char gsmGprsPending void gsmGprsCancel mikroBasic sub procedure gsmGprsHttpGet dim byref url as string sub procedure gsmGprsHttpPost dim byref url as string dim byref postdata as string sub function gsmGprsPending as char sub procedure gsmGprsCancel mikroPascal procedure gsmGprsHttpGet var url string procedure gsmGprsHttpPost var url string var postdata string function gsmGprsPending char procedure gsmGprsCancel Events gsmevntGprsHttpResponse ine This event will occur for each line of the HTTP response received request initiated by gsmGprsHttpGet or gsmGprsHttpPost L pstrGsmEventData points to a string containing the line of data gsmevntGprsHttpResultErr Occurs if the HTTP server returned a result code other than 200 e g 404 Page not found as a result of an HTTP GET or POST operation initiated by gsmGprsHttpGet or gsmGprsHttpPost pstrGsmEventData points to a string containing the result code returned from the HTTP server gsmev
4. 0 overflow interrupts while 1 Ops IIL ir Add your code here mikroBasic Claim GISME Pye rer eis let gle JD loilic Claim GIS ye reese ua Sloalie aie TSEZ Jee Clim GSM Swar as Sole ene RAN lowe Clim GSM Siete Dee e ice gle IMAISI0 JE dim wrdDelayTmr as word sub procedure interrupt www dizzy co za Page 14 of 19 IT lt TimerO Interrupt gt die WOLF ole Cam Ims Limiesiewuysic TMROH OxD1 TMROL 0x20 gsmimsPing Inc wrdDelayTmr ODT louie D H Clee wiesisnbjore seller end if lt TimerO Interrupt gt end sub sub procedure do delay dim delaytime_ms as word Delay for a certain amount of time whilst still allowing the GSM Library to operate wrdDelayTmr 0 while wrdDelayTmr lt delaytime ms gsmPol11 wend end sub sub procedure gsmEvent dim GsmEventType as char Handle GSM Library events here end sub main DARTI Tane W600 CSM lib is desugned co work ae J00 baud gsmiInit gsm MS Init gem Mag Tmel Y Only Li CSN Msg Germain as eivelallleloile gem CIPS Tmel Only LE GSM CERS extension is sivelullalolle TOCON 10001000 Set up interrupt timer Gia lowe 1 Y leet larcerrvot snelle WOE gae 1 Y Maisie mimert ovario alinieeicicuisics while true gsmPoll Add your code here wend end mikroPascal var GSM Pwr key 8 Sbit at IWAWE2 Jeer var GSM Pwr key Dir 3 Soit aic WRISEZ OLL va
5. TDateTime mikroBasic structure DateTime dim Year Month Day Hour Minute Second as char end structure typedef TDateTime as DateTime mikroPascal type TDateTime record Year Month Day Hour Minute Second char end If you are not familiar with structures then please see the mikroC mikroBasic mikroPascal help file for detailed information For mikroBasic mikroPascal users not familiar with pointers these can be thought of as function parameters passed by reference byref Pointers can in fact be passed to a function which requires parameters by reference and this can be an easy way to work around the pointer mikroBasic sub procedure gsmMissedCall dim byref OriginatorID as string TI OriginatorID is a string and pointers can be forgotten about z LCD _Cmd _LCD Clear ICD One eerste ILD CD Out 2 1 Missed Cal end sub sub procedure gsmEvent dim GsmEventType as char select case GsmEventType www dizzy co za Page 8 of 19 case gsmevntMissedCall pstrGsmEventOriginatorID is a string pointer pstrGsmEventOriginatorID carat symbol at end defers to the string pointed to by pstrGsmEventOriginatorID See the mikroBasic help file for more information gsmMissedCall pstrGsmEventOriginatorID enc select end sub mikroPascal procedure gsmMis
6. an be used to send a text message gsmMsgSendPending can be used to determine if the operation has been processed yet and gsmMsgSendCancel can be used to cancel the operation Messages are first drafted into the SIM card memory before being sent This is done in order to maximise reliability and also allows multiple messages to be qued up in the SIM card memory before being sent Once gsmMsgSend has been called then the message and DestinationID parameters should not be changed until the message has been drafted gsmevntMsgDrafted event gsmMsgSendPending will return false Q as these parameters are passed as pointers by reference gsmMsguJustArrived can be called during a gsmevntMsgRevd event in order to determine if the message just arrived If gsmMsgJustArrived returns false then the message was read from the SIM card memory and could possibly be old but not definitely Routines mikroC void gsmMsgSend char Message char DestinationID char gsmMsgSendPending www dizzy co za Page 11 of 19 void gsmMsgSendCancel char gsmMsgJustArrived mikroBasic sub procedure gsmMsgSend dim byref Message as string dim byref DestinationID as string sub function gsmMsgSendPending as char sub procedure gsmMsgSendCancel sub function gsmMsgJustArrived as char mikroPascal procedure gsmMsgSend var Message stri
7. as a unique identifier Events gsmevntiIMEl_Read pstrGsmEventData points to the read IMEI PIN Code GSM library can optionally enter a PIN code for the SIM card Events gsmevntPIN_Request pstrGsmEventData should be pointed to the PIN code If the event is ignored or pstrGsmEventData is pointed to a blank string then a PIN code will not be entered gsmevntPI IN_Fail The entered pin code was incorrect www dizzy co za Page 10 of 19 Missed Call Events gsmevntMissedCall pstrGsmEventOriginatorlID points to a string containing the Caller ID from which the missed call originated Network Registration The gsmReady routine can be used to determine if the GSM module is registered on the GSM network Routines mikroC void gsmReady mikroBasic sub procedure gsmReady mikroPascal procedure gsmReady Text Messaging Text Messaging routines and events require the GSM_Msg extension Warning GSM Library uses the SIM card memory for drafting and reading messages This is done in order to maximise reliability If the SIM card message memory is not currently empty then any messages stored on the SIM card will be processed and deleted and any drafts saved on the SIM card will be sent Please check that this will not cause any problems before using GSM Library with your SIM card Perhaps copy any relevant messages from SIM card memory to phone memory gsmMsgSend c
8. d do delay unsigned int delaytime ms Delay for a certain amount o we time whilst still allowing the GSM Library to operate unsigned int ctr tor Cce Opccrr lt celaycime msp Ctr q raume 1 37 delay ms 1 mikroBasic sub procedure do delay dim delaytime ms as word Delay for a certain amount of time whilst still allowing the GSM Library to operate dim ctr as word for ctr 0 to delaytime ms www dizzy co za Page 16 of 19 gsmPoll delay ms 1 next ctr end sub mikroPascal proccaur co klasse me ms O z begin Delay for a certain amount of time whilst still allowing the GSM Library to operate wee EES 8 woreels Ow GLE 0 to delaycime me Eo begim gsmPoll delay ms 1 end end Multiple UARTs GSM Library uses the last UART which was initialised or set active UART_Set_Active please see the compiler help file in order to communicate If you wish to use multiple UARTS in your project then you may need to set the UART function pointers to the correct functions before calling gsmPoll or gsm1msPing mikroC UART Rd Ptr amp UART1 Read UART We Per amp UARTI Weites UART Rdy Ptr amp UART1 Data Ready UART Tx Idle Ptr amp UART1 Tx Idle 3 el Basic UART Rd Ptr QUARTI Read UART Wr Ptr UART1 Write UART R
9. dure gsmEvent dim GsmEventType as char Handle GSM Library events here end sub mikroPascal procedure gsmEvent GsmEventType char begin Handle GSM Library events here end www dizzy co za Page 5 of 19 That s it The basic program structure should now be something like the following mikroC ff lt er A sbit GSM Pwr Key at LAT soilt GSM Pur key Dir ar TR 20 bite Solt GSM Srat at PORT 1 Be void interrupt Jee eprer TOIF bit if cu Olina bit TMROH OxD1 TMROL 0x20 gsmlmsPing lt Timer0 ff Ime SEO bit Solt GSM Steere Dir ar TRISEZ ie Torero Do Clear interrupt ileg void main ARTI Imit gsmInit void gsmEvent char Gsm Handle GSM Library events here Interrupt gt EventType 9600 GSM Lib is designed to work at 9600 baud gsm Me init gsm Msg Imith gsm GPRS_Init Only if GSM _ GPRS extension is available Only ii GSM Msg extension is available et up interrupt timer nterrupt enable TO CON GiSit gglpgn S GTR bit 1 Global i TOTE bit 1 Bmebi Wiles il 4 GSwM2O lL Ib Add your code here TimerO overflow interrupts mikroBasic di di IT Lre O ig TOIF b
10. dy Ptr QUARTI Data Ready UART Tx Idle Ptr UART1 Tx Idle mikroPascal UART Rd Ptr UART1 Read UART Wr Ptr UART1 Write UART Rey Per s QUARTI Deta Reech UART Tx Idle Ptr UART1 Tx Idle www dizzy co za Page 17 of 19 Various examples of how to use the GSM Library are included with the library package Once the package has been installed these examples can be found in the compilers packages GSM Examples folder or by right clicking on the GSM Library in Library Manager and then clicking Examples The examples are also downloadable from our E GSM_Msg website at www dizzy co za H GSM_GPRS_SIMCom C GSM_GPRS_SIMCom y www dizzy co za Page 18 of 19 W i je1l laa e This part says that you cannot sue us because we accept no responsibility for any damages whatsoever that may be caused in connection with our products We ve designed them the best we can but please use your common sense www dizzy co za Page 19 of 19
11. e date time from the GSM network if it does then the GSM module will set its RTCC using the data obtained from the network Tip When the event gsmevntMsgRcvd occurs please see the Text Messaging section for more www dizzy co za Page 9 of 19 information the gsmMsguustArrived routine can be used to determine if the text message has just arrived the message could also possibly be an old one retrieved from the SIM card memory in which case gsmMsguustArrived will return false 0 If a text message has just arrived then its date time stamp are probably current and can be used to set the GSM modules RTCC this must be initiated manually using gsmDateTimeWrite J Routines mikroG void gsmDateTimeRead void gsmDateTimeWrite mikroBasic sub procedure gsmDateTimeRead sub procedure gsmDateTimeWrite mikroPascal procedure gsmDateTimeRead procedure gsmDateTimeWrite Events gsmevntDateTimeRead This event occurs after a read of the GSM modules RTCC initiated by the gsmDateTimeRead routine is completed dtmGsmEvent contains the date time read gsmevntDateTimeWrite This event occurs just before a write to the GSM modules RTCC initiated by the gsmDateTimeWrite routine dtmGsmEvent should be loaded with the date time to be written IMEI Code GSM library will automatically read the modules IMEI code This can be used
12. feature for keeping track of the date and time in the event of power loss v Receive the date time from the GSM network Most GSM networks can send the current date time to the GSM module upon registration on the network The module can use this information to set its own internal RTCC This feature is currently available for SiMCom Telit and Quectel modules v Read the modules unique IMEI code The IMEI can be used to uniquely identify the unit v Enter SIM card PIN code optional v Detect a missed call including the caller ID Text Messaging SMS Extension v Receive text messages v Send text messages GPRS Extension v HTTP GET This feature is currently only available for SiMCom modules HTTP POST This feature is currently only available for GM o modules www dizzy co za Page 3 of 19 The GSM Library and extensions are provided as mikroElektronika compiler library packages Assuming that the relevant mikroElektronika compiler is already installed the library can be easily added to it by using the Package Manager http www mikroe com package manager Once installed the library and extensions if applicable will be listed within Library Manager in the compiler Library Manager di Se HOF ZE use CG GSM a GSM _ GSM_MS_Quectel a M GSM_MS_SIMCom _ GSM_MS_Telit m M Str GSM_Msg m GSM_Msg GSM_GPRS_SIMCom V GSM_GPRS_SIMCom v GSM Library requires
13. kroBasic ARTI Taie 260 0 9 GSM Iie ie glkeztemecl ee vork awr J600 bewei gsmInit EE ett gsm Msg Imit Only it GSM Meg extension is eywelallelole gsm GPRS Init Only if GSM GPRS extension is available mikroPascal UART1 Init 9600 GSM Lib is designed to work at 9600 baud gem imak i gem MS Tmel z gsm Msg Init Only if GSM Msg extension is available gsm GPRS Init Only if GSM GPRS extension is available 4 Set up a 1ms timer interrupt and call gsm1msPing from within the interrupt Timer Calculator www mikroe com timer calculator can be very helpful for setting up the interrupt mikroC gesmlmsPing e Call from virthin lms cimer interruot mikroBasic gsmlmsPing Call from within lms timer interrupt mikroPascal gsmimseing gt Call from within ime timer anterrupt D Call gsmPoll from within your main program loop as often as possible mikroC gsmPoll Call from within lms timer interrupt mikroBasic gsmPoll Call from within lms timer interrupt mikroPascal gsmPoll Call from within lms timer interrupt D Create a routine called gsmEvent to handle events from the GSM Library mikroC void gsmEvent char GsmEventType Handle GSM Library events here mikroBasic sub proce
14. ng var DestinationID string function gsmMsgSendPending char procedure gsmMsgSendCancel function gsmMsgJustArrived char Events gsmevntMsgRcecvd Occurs when a GSM message is received pstrGsmEventData points to a string containing the message text pstrGsmEventOriginatorID points to a string containing the Caller ID from which the message originated gsmevntMsgDrafted Occurs after a message to be sent has been drafted to the SIM card memory initiated by gsmMsgSend L pstrGsmEventData points to a string containing the message ID gsmevntMsgDiscarded Occurs if drafting of a message to the SIM card memory initiated by gsmMsgSend has failed This could possibly occur if the SIM card memory is full gsmevntMsgSent Occurs when sending of a message is completed pstrGsmEventData points to a string containing the message ID gsmevntMsgSendFailed Occurs if sending of a message has failed This could possibly occur if there is no credit airtime loaded on the SIM card pstrGsmEventData points to a string containing the message ID GPRS GPRS routines and events require the GSM_GPRS extension Currently only HTTP GET and POST operations are supported and only for SiMCom modules gsmGprsHttpGet and gsmGprsHttpPost can be used to initiate an HTTP GET or POST operation respectively The result is returned via one or more gsmevntGprsHttpResponseLine events one event for each line of the response If the HTTP
15. ntGprsFailed Occurs if the GPRS operation failed e g no signal Delays gsmPoll should be called as often as possible This means that the use of delay_ms or similar in your code should be avoided There are however ways to work around this Example 1 Recommended Use a timer variable incremented during the 1ms timer interrupt to time the delay mikroC www dizzy co za Page 13 of 19 SE SIM Eine Nei elie IWAIGO Jealie f sbit GSM Pwr Key Dir at TRISEO bit sbit Eil eng np PORTE B2 sort CHN stat Dir et TRISh bat unsigned int wrdDelayTmr void interrupt Tmerr Iimnternup t LE TOTE oe 7 ime ner eo TMROH OxD1 TMROM I0s lt 20 gsmimsPing wrdDelayTmr TOIF bit 0 Clear interrupt flag lt TimerO Interrupt gt void do delay unsigned int delaytime ms Delay for a certain amount of time whilst still allowing the GSM Library to operate wrdDelayTmr 0 while wrdDelayTmr lt delaytime ms gsmPoll1 void gsmEvent char GsmEventType Handle GSM Library events here WiOsGee meade ie 4 UART1 Init 9600 GSM Lib is designed to work at 9600 baud SEET rem Jeer Tote ur gsm Mag Init Only if GSM Msg extension is available gsm GPRS Init Only if GSM GPRS extension is available TOCON 0610001000 Set up interrupt timer GIE bit 1 Global interrupt enable TOIE bit 1 Enable Timer
16. r GSM Start sOit ar REO ce var GSM Start Dir g goir ar ELSE bite var wrdDelayTmr word procedure interrupt begin lt Timer0 Interrupt gt if YOT bit then begim lms Interrupt TMROH OxD1 TMROL 0x20 gsmlmsPing Inc wrdDelayTmr WOW Joie s Of Clear interrot ilag www dizzy co za Page 15 of 19 end lt TimerO Interrupt gt end procedure do delay delaytime ms word begin Delay for a certain amount of time whilst still allowing the GSM Library to operate wrdDelayTmr 0 while wrdDelayTmr lt delaytime ms do begin gsmPoll1 end end procedure gsmEvent GsmEventType char begin Handle GSM Library events here end procedure main begin UART1 Init 9600 GSM Lib is designed to work at 9600 baud gsminit gsm MS Init EE 7 Only if GEM Msg extension is available gsm GPRS Init Only if GSM GPRS extension is available TOCON 10001000 Set up interrupt timer GIE bit 1 Global interrupt enable TOL bit s l Enable Timer 0 overs low interrupts while 1 do begin Gismboulnii Gr Add your code here end end Example 2 Break the delay up into smaller pieces calling gsmPoll between each piece This could result in the delay being slightly longer than desired mikroC voi
17. re gsmEvent GsmEventType char begin Handle GSM Library events here end procedure main begin UART1 Init 9600 GSM Lib is designed to work at 9600 baud gsminit gsm Ms malt gsm Msg Init Only if GSM Msg extension is available gem GERS Init Only if GSM_GPRS extension is available TOCON 10001000 Set up interrupt timer GIE bit 1 Global interrupt enable TOMES EE while 1 do begin Srami eoil 13 Add your code here end end www dizzy co za Page 7 of 19 Routines and Events The Event Mechanism GSM Library uses the gsmEvent routine to both report and request information The GsmEventType parameter contains the event type please see the sections below for details on the various types of events There are 3 global variables which are used to pass data back and forth with the GSM Library Variable Type pstrGsmEventData Pointer to a string char pstrGsmEventOriginatorID Pointer to a string char dtmGsmEvent DateTime Structure more information below The use of these variables is event specific details in the sections below Not all of the variables are used by all of the events and some events may use no variables at all dtmGsmEvent consists of the following structure mikroC typedef struct DateTime char Year Month Day Hour Minute Second
18. sedCall var OriginatorID string begin OriginatorID is a string and pointers can be forgotten about LCD Cmd _LCD Clear LED Out 1 1 OriginatorInD s LCD Out 2 1 Missed call s end procedure gsmEvent GsmEventType char begin ce Case Cemaventiiype O gsmevntMissedCall begin pstrGsmEventOriginatorID is a string pointer pstrGsmEventOriginatorID carat symbol at end defers to the string pointed to by pstrGsmEventOriginatorID See the mikroBasic help file for more information gsmMissedCall pstrGsmEventOriginatorID end euler Power The gsmPowerSetOnOff routine can be used to instruct the GSM Library to power the GSM module on or off GSM Library will power the module on by default Routines mikroC void gsmPowerSetOnOff char power on mikroBasic sub procedure gsmPowerSetOnOff dim power on as char mikroPascal procedure gsmPowerSetOnOff power on char Date Time RTCC The date time routines can be used to read from write to the GSM modules internal RTCC real time calendar and clock Since most GSM modules have a facility for connecting a small backup battery to maintain the RTCC this can be a convenient feature for keeping track of the date and time in the event of power loss Additionally GSM Library will automatically try to obtain th
19. the following in order to operate 1 Select deselect the relevant library components in the Library Manager GSM Required Main GSM Library component Str Required GSM Library string support functions GSM_MS_x Optional required Manufacturer specific code select appropriate for some modules GSM module manufacturer Required for Telit modules GSM_Msg Optional Text message SMS functionality GSM_GPRS_x Optional GPRS functionality Declare alias for the GSM modules Power_Key Reset on Telit modules as well as Status pins mikroC soit GSM Pwr key atc ATEZ loilicg Soit GSM Pwr key Dir aie TRISE2 Oit soit GSM Stat at PORTI BOZ solt GSM Start Dir at MATSAO OLES mikroBasic Chim GSM Zort e aS oO Chim GSM Pwr key Dir as Sbit en TRISB2 OLT chim GSM Sac aS stoe eu BIO O chim GSM cocar Dir as obit aie RIO tg mikroPascal var GSM Pwr Key 83 Soit ar ATEZ ete var GSM Pwr Key Dir g Soir ar TRISEZ olte woare M Stace g Sisi at E www dizzy co za Page 4 of 19 var GSM Star Dir s goir ae WRISHO irs 3 Call initialisation routines at startup mikroC UART1 Init 9600 GSM Lib is designed to work at 9600 baud gsmimike gem MS Wiaalie p gsm Msg Init Only if GSM Msg extension is available gsm GPRS Init Only if GSM GPRS extension is available mi
Download Pdf Manuals
Related Search
Related Contents
Samsung Galaxy S6 und S6 edge – Die verständliche Operating instructions GAM v2-03_english 簡易取り扱い説明書 - MakeShop Owner`s Manual Samsung Samsung SGH-L170 Käyttöopas Kustom V100 User's Manual Rexel Eyelets 2014-15 - 2 - La Bible Communiqué de presse - INPES et InVS "Noyades - le Copyright © All rights reserved.
Failed to retrieve file