API  2.3.0
TSmarT Software Library
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
cellular_2g_sms.c

This is an example about how to send SMS using the GPRS device.

/* @file main.c
* @author TST
* @version 0.1
* @date 28/01/2013
* @brief This is an example of how to send a SMS using the cellular 2g device.
*
* The Cellular 2G in use is a SL6087 2G manufactured by Sierra wireless.
* This example show the user how to send a SMS (GSM network).
*
* @note To run this application it's necessary to set some network parameters:
* - PIN code -------> Personal identification number.
* - Phone number ---> Destination phone number.
*
* @note To run this application it's necessary to set the PIN SIM card and
* the destination phone number. Do this changing specific defines.
*
*/
/* Platform headers */
#include "tsmart.h"
/* Specific configuration for cellular 2g device, Set defintions */
#define PIN_CODE "<SET PIN CODE>" /* Set SIM configuration */
#define PHONE_NUMBER "<SET DESTINATION PHONE NUMBER>" /* Destination phone number */
/* @brief vCEL2G_SMS task
*
* This task turns on the cellular 2g device, after that sends a SMS.
*
* @param pvParameters
*/
void vCEL2G_SMS(void *pvParameters) {
/* Variables */
/* Turn On */
if(TSMART_CELLULAR_2G_TurnOn(&tsmart_cellular_2g, PIN_CODE) != TSMART_PASS){
for(;;);
}
/* Configure module */
if( TSMART_CELLULAR_2G_ConfigDevice(&tsmart_cellular_2g, &device_config) != TSMART_PASS){
for(;;);
}
do{
/* Wait to register in GSM network */
/* Wait for 1 second to try again */
vTaskDelay(1000/portTICK_RATE_MS);
/* Debug message */
/* Send confirmation */
if(TSMART_CELLULAR_2G_SendSms(&tsmart_cellular_2g, PHONE_NUMBER, "Hello World", strlen("Hello World")) != TSMART_PASS){
for(;;);
}
/* Wait forever */
while(1);
}
/* @brief "Init()" function.
*
* This is the first thing that the user must do for using TSmarT.
* It initializes specific hardware resources (GPRS, GPS, AI, DIO, MODBUS, MSA...)
* and software resources (queues, mutex, tasks...) for the user application.
*
* The way to fill in this function properly is to initialize first
* hardware resources and after that software resources.
*
* This function must return: TSMART_PASS when every thing is OK or
* TSMART_FAIL when a failure happened.
*
* @return
* @arg TSMART_PASS
* @arg TSMART_FAIL
*/
int32_t init() {
/* Variables */
portBASE_TYPE xReturn;
/* ************************************************************************* */
/* Debug Mode */
/* ************************************************************************* */
/* ************************************************************************* */
/* Initialize resources */
/* ************************************************************************* */
/* The specific hardware for this application: cellular 2g
*/
return TSMART_FAIL;
}
/* ************************************************************************* */
/* Application task */
/* ************************************************************************* */
/* This examples will need one task:
*
* - CELLULAR_2G_SMS task: This task turn on the cellular 2g and sends a SMS.
*
*/
/* Create CEL2G_SMS Task */
xReturn = xTaskCreate(vCEL2G_SMS, "CEL2G_SMS", 512, NULL, 7, NULL);
if (xReturn != pdPASS) {
return TSMART_FAIL;
}
/* Everything OK */
return TSMART_PASS;
}