Send SMS Flyport GPRS

From openPicus Wiki
Jump to: navigation, search

Contents

What you are going to learn

This tutorial shows how to send an SMS using Flyport GPRS.

Introduction to SMS

Flyport GPRS can send SMS (Short Message System) messages. Up to 160 characters can be written on a single message, on ASCII format.

How to use it

Substitute recipient phone number on the char phonenumber[25] = "PUT_HERE_PHONE_NUMBER"; definition.
Open the Serial Monitor utility on the IDE where you can insert text of the message and press ENTER to send it.

Code example

Source code for taskFlyport.c:

#include "taskFlyport.h"
 
char phonenumber[25] = "PUT_HERE_PHONE_NUMBER"; // Remember to use INTERNATIONAL PREFIX
char smsTextBuff[161];
 
void FlyportTask()
{
    vTaskDelay(20);
    UARTWrite(1,"Flyport Task Started...\r\n");
 
    //Wait for GSM Connection successfull
    do
    {
	UpdateConnStatus();
	while(LastExecStat() == OP_EXECUTION);
    }while((LastConnStatus() != REG_SUCCESS)&&(LastConnStatus() != ROAMING));
 
    vTaskDelay(20);
    UARTWrite(1,"Flyport registered on network!\r\n");
 
    while(1)
    {
        // Check for Serial commands
	if(UARTBufferSize(1) > 0)
	{	
            vTaskDelay(20);
	    int len = UARTBufferSize(1);
	    if(len > 160)
		len = 160;
	    UARTRead(1, smsTextBuff, len);
	    smsTextBuff[len] = '\0';
 
            UARTWrite(1, "Sending SMS...");
	    // Send SMS:
	    SMSSend(phonenumber, smsTextBuff, FALSE);
 
	    while(LastExecStat() == OP_EXECUTION)
		vTaskDelay(1);
 
	    if(LastExecStat() == OP_SUCCESS)
		UARTWrite(1, "SMS sent!\r\n");
	    else
		UARTWrite(1, "SMS NOT sent!\r\n");
	}
    }
}
Personal tools
Namespaces

Variants
Actions
START HERE
DEVELOPMENT
HARDWARE INFO
RESOURCES
PHASED OUT
Toolbox