Appendix A. Controlling the COM111 Power Supply and resetting the modem
A-3
'Set port 1 to 1 (ON) (use writeio as in slowsequence)
WriteIO (&B00000001,1)
Delay(1,20,sec) 'Allow 20s seconds for the modem to power on and re-register
'If using a PPP connection, restart the PPP session
PPPOpen 'No checks of success in this example
EndIf
'5 minutes later turn the modem off if it is not online
'First set a variable to indicate the 5 min time has passed
If TimeIntoInterval (5,60,Min) Then timetogooff=true
'If time to go off also check we are offline OR that 15 mins has not passed
'i.e. shutdown at 15 mins anyway
If(timetogooff AND (NOT ComPortIsActive (Modemport)))OR TimeIntoInterval(15,60,min) Then
'If using an IP connection shutdown the PPP session
PPPClose
'Open the serial port to allow commands to be sent
SerialOpen (Modemport,Modembaud,0,0,100)
'Send the command to log off the network and shutdown cleanly,
'wait up to 3 sec.
'First send the +++ sequence to get the modem in command mode - in case
'online
SerialOut (Modemport,"+++","OK"+CHR(13),1,150)
SerialOut (Modemport,"AT+CFUN=0"+CHR(13),"OK"+CHR(13),1,300)
'Delay to allow deregistration
Delay (1,5,sec)
'Turn the SW12 off if using it
SW12 (0)
'OR
'Set port 1 to 0 (LOW) (use WriteIO As in SlowSequence)
WriteIO (&B00000001,0)
'Closing the serial port saves power too.
SerialClose(Modemport)
timetogooff=false
EndIf
'--------------------------------------------------------------------
NextScan
EndProg
A.2 Performing a soft reset
To perform a “soft” reset the modem the command AT+CFUN=1<CR> is sent to
the modem without controlling the power to the modem. This attempts to
disconnect the modem from the network, fully resets the module to a power up
state and then reconnects it to the network. This entire process can take up to 30
seconds, although the module will accept non-network related commands within a
few seconds of receiving the reset command.
Performing a “soft” reset only cause a short break in communications and is
almost as effective as a full power cycle reset.
A.2.1 A CRBasic Program Example of a soft reset
This example can be used on the CR6, CR300, CR800 series, CR1000 and
CR3000 dataloggers. It uses the standard CRBasic serialopen, serialout and
serialclose commands to send out configuration commands to the modem. The
example shows using a slow sequence to reset the modem every 12 hours, using
the command AT+CFUN=1.
'CR1000 Series Datalogger
'Example program showing how to regularly reset the GSM/GPRS modem
'The modem control is done in a slow sequence to avoid interference with measurements
'Declare Public Variables
'Example:
Public PTemp, batt_volt