Help for sending SMS via GSM modem using an IRIS mote (atmega128)

Status
Not open for further replies.

bharti

New Member
Hi,

I am currently trying to send an SMS via a GSM module ADH8066 (by sparksfun) using an IRIS mote. The GSM works via UART. I have managed to get the IRIS mote to communicate with the PC via the hyperterminal using UART. Also the GSM modem works when I send AT commands to it via the PC. However when I connect the GSM modem and the IRIS mote, it does not work. Can anyone help me resolve this problem? My code is as follows :

Code:
#include "printf.h"

module GSMmodemC @safe()
{
  uses interface Boot;
  uses interface Init as UartInit;
  uses interface StdControl as UartControl;
  uses interface UartStream; 
  uses interface Leds;
  uses interface Timer<TMilli>;  
  uses interface GeneralIO as TriggerPin;
 
}
implementation
{

enum {
    UART_BUF_MAXLEN = 15
};
   
char* uartsendBuf1 = "AT\n\r";
char* uartsendBuf2 = "AT+CMGF=1\n\r";
char* uartsendBuf3 = "AT+CMGS=";
char* uartsendBuf4 = "+6590140252";
char* newline = "\n\r"; 
char* msg = "Hello";
uint8_t recevedByte;
uint8_t stage = 0;
uint8_t flag = 0;
uint8_t uartBuf[UART_BUF_MAXLEN];
/** Count of bytes read into #uartBuf during a reading. */
uint8_t uartBufCount;
  
  event void Boot.booted() {
	
	call TriggerPin.clr();
	call TriggerPin.set();
	call UartInit.init();
	call Timer.startPeriodic(3000);
    call UartControl.start();
	//call Timer.startPeriodic(2000);
    
  }  
  
  	
	event void Timer.fired() {
	

	switch (stage) {
		case 0:	
		call UartControl.start();
		call UartStream.send(uartsendBuf1, 4);
		break;
		case 1:
		call UartControl.start();
		call UartStream.send(uartsendBuf2, 11);  //at+cmgf=1
		break;
		case 2:
		call UartControl.start();
		call UartStream.send(uartsendBuf3, 8); // at+cmgs=
			break;
		case 3:
		call UartControl.start();		
		call UartStream.send(0x22,1);   // "
		break; 
		case 4:
		call UartControl.start();		
		call UartStream.send(uartsendBuf4,11);  //phone number
		break;
		case 5:
		call UartControl.start();		
		call UartStream.send(0x22,1);  // " ""
		break;
		case 6:
		call UartControl.start();		
		call UartStream.send(newline,2); //newline
		break;
		case 7:
		call UartControl.start();		
		call UartStream.send(msg,5);  //message
		break;
		
		case 8:
		call UartControl.start();		
		call UartStream.send(0x1A, 1);   //comtrol z
		break; 
	
	
	}
	
	}
  

  async event void UartStream.sendDone( uint8_t* buf, uint16_t len, error_t error )
  {      
	call Leds.led2Toggle();
	stage++;
	if (stage > 8)
	{
	stage = 0;
	}	

	call UartControl.stop();
	
  }
  
  async event void UartStream.receivedByte( uint8_t byte )
  {     
   }

  
  async event void UartStream.receiveDone( uint8_t* buf, uint16_t len, error_t error )
  {
  }

}
 
Last edited by a moderator:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…