public class sender extends MIDlet
{
public TextMessage txtMessage = null;
public MessageConnection smsconn = null;
public void send() {
try {
//Set the message text.
txtMessage.setPayloadText("Alarm trigger");
//Send the message.
smsconn.send(txtMessage);
log("Message sending completed");
} catch (Exception e) {}
}
//To start the MIDlet
protected void startApp () throws MIDletStateChangeException
{
//Start the timer
log("timer started");
WatchdogTimer wd = new WatchdogTimer();
//After start, count towards 0, nokia12 reset after reached 0
wd.setTimeout(30 * 60); // 30 minutes
//Set the correct target address
String targetAddress = "sms://+0180555555:5678";//send a sms to +0180555555 using port 5678
String targetAddress1 = "sms://+0123456789:5678";//send a sms to +0123456789 using port 5678
String url = "sms://:5678";
int counter = 0;
log("Send SMS Program");
try {
while (counter <= 4) {
//Open the message connection.
smsconn = (MessageConnection)Connector.open(url);
//Creating a text message to be send.
txtMessage = (TextMessage)smsconn.newMessage(MessageConnection.TEXT_MESSAGE);
txtMessage.setAddress(targetAddress);
send();
txtMessage.setAddress(targetAddress1);
send();
smsconn.close();
log("Go to reply message");
//replyMessage();
Thread.sleep(30000);
++counter;
}
log("sent 5 times");
//use watchdog to restart if there is no action taken by owner!!!
} catch(Exception e) {/* handle error */ }
}
//A required method
public void destroyApp (boolean unconditional) throws MIDletStateChangeException
{
}
//A required method
public void pauseApp () {}
private void log(String msg) {
SerialPortLogger.getInstance().write(msg);
}
}
Hi.. I'm adding a watchdog into my program.. Above is the program codes that I have written to send a sms.. I need a watchdog to reset everything if there is no reply message by the user after sending 5 times.. so what code shall I add in after the line [log("sent 5 times")] in order to restart after the watchdog count down to 0
And in between of the program when it is running,I need to check whether there is any error with the program and are they running in the right order..I believed that I can use watchdog to do all theses right..but I'm not sure at which interval I must insert the watchdog to make sure the program is running ok
And can also tell me how to write the code or is there any website where it will provide me a clear understanding on how to implement watchdog into the program..thanks