Now you can compile and upload your code supporting highier buffered serial input data. */



Similar documents
GM862 Arduino Shield

Bluetooth for device discovery. Networking Guide

Yun Shield Quick Start Guide VERSION: 1.0 Version Description Date 1.0 Release 2014-Jul-08 Yun Shield Quick Start Guide 1 / 14

SUDT AccessPort TM Advanced Terminal / Monitor / Debugger Version 1.37 User Manual

ADL User Guide for Open AT V4.10

MeshBee Open Source ZigBee RF Module CookBook

MT-350 SMS. Operation Manual. PORTech Communications Inc.

Arduino Lesson 5. The Serial Monitor

IPRS-7 IP/GPRS PC Receiver Software Quick Start V1.2

Web Site: Forums: forums.parallax.com Sales: Technical:

LCD I 2 C/Serial RX Backpack. Data Sheet. LCD to I2C/Serial RX Backpack I2C or Serial RX communication with Standard 16 Pin LCD modules

ezvsp User's Manual ( Version 2.1d ) Sollae Systems Co., Ltd.

SITRANS RD500 Configuring the RD500 with PSTN or GSM modems and Windows-based servers and clients for communication Objective:

GSM Click - Cross-Platform Development Quick Start Guide

Telit AppZone Programming Tips

WA Manager Alarming System Management Software Windows 98, NT, XP, 2000 User Guide

Technical Document. NiagaraAX SMS Users Guide. January 4, 2007

SMTP-32 Library. Simple Mail Transfer Protocol Dynamic Link Library for Microsoft Windows. Version 5.2

Arduino Lesson 1. Blink

SIM808 V2.2.5 user manual V1.2. Electrodragon.com

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification

FaxFinder V.34 Fax Server. Configuration Guide for Inter-Operation with Altigen AltiServ Phone Systems

2014 GSM SHIELD COMPATIBLE WITH ARDUINO GSM SHIELD USING SIMCOMM (SIM900A)

GPRS Shield. Introduction

MPLAB Harmony System Service Libraries Help

GSC/VRC IP Converter. Installation and Operation Manual

Virtual Integrated Design Getting started with RS232 Hex Com Tool v6.0

1. Make sure that no client accounts are open. 2. Click on Setup, then click Modem. The Modem Setup window will appear.

Configuration Guide. SafeNet Authentication Service. SAS Agent for Microsoft Internet Information Services (IIS)

Jorix kernel: real-time scheduling

Overview. Internet Connection Requirement: The working GPRS connection required for the application properly work.

Illustration 1: Diagram of program function and data flow

Device Management API for Windows* and Linux* Operating Systems

Talk2M ewon Internet Connection How To

TUTORIAL FOR INITIALIZING BLUETOOTH COMMUNICATION BETWEEN ANDROID AND ARDUINO

Keil C51 Cross Compiler

RN-131-PICTAIL & RN-171-PICTAIL Evaluation Boards

Virtuozzo Virtualization SDK

AN601 I2C 2.8 Communication Protocol. SM130 SM130 - Mini APPLICATION NOTE

µtasker Document FTP Client

OfficeServ Link. User Guide. Version 2.1 June 2005

MS Active Sync: Sync with External Memory Files

SACO 16D_ modules for SMS 010 User s Guide SMS 010 SACO library

XPort Universal Demo Board User Guide

Agent Configuration Guide

NortechCommander Software Operating Manual MAN R6

Wireless Communication With Arduino

Configuration Guide for Ascom Communications Server, Remote Management Package

VEHICLE TRACKING AND ACCIDENT ALERT SYSTEM.

Using Xbee in Serial Communication

Modbus Communications for PanelView Terminals

An Introduction To Simple Scheduling (Primarily targeted at Arduino Platform)

Chapter 5 Real time clock by John Leung

Temperature & Humidity SMS Alert Controller

Installation and Operation Manual TAP Application on the Open Java Server

Low Speed Modems for Dial and Leased Circuits 2400E-2 (Stand Alone) 2400R-2 (Rack Mount) 2400E-4 (Stand Alone) 2400R-4 (Rack Mount)

How To Fix An Lmx9838 Bluetooth Serial Port Module With Bluetooth (Bluetooth 2) From A Bluetooth Bluetooth 4.2 Device With A Bluembee 2.2 Module

SSL-Manager (SNMP-SSL Management Software)

SMS Alarm Messenger. Setup Software Guide. SMSPro_Setup. Revision [Version 2.2]

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

ONE-TOUCH MAIL V 2.3 MANUAL

Implementing SPI Master and Slave Functionality Using the Z8 Encore! F083A

Lab 6 Introduction to Serial and Wireless Communication

Identikey Server Getting Started Guide 3.1

CelluLine CGW-TS GSM Cellular Gateway. Installation and Programming Manual

RouteFinder SOHO. Quick Start Guide. SOHO Security Appliance. EDGE Models RF825-E, RF825-E-AP CDMA Models RF825-C-Nx, RF825-C-Nx-AP

Application Note: AN00141 xcore-xa - Application Development

Using Logix5000 Controllers as Masters or Slaves on Modbus

OpenVox GSM Gateway Function Manual

Verint GI2. Gi2 Features Verint Systems Inc. All rights reserved.

Firmware version: 1.10 Issue: 7 AUTODIALER GD30.2. Instruction Manual

CipherLab 5100 Time Attendance Utility Manual

Ethernet Interface Manual Thermal / Label Printer. Rev Metapace T-1. Metapace T-2 Metapace L-1 Metapace L-2

App Note. VoxStack GSM Gateway API

BS860 IP Auto-dialer User s Manual

Application Note. Receiving Analog In-Band CPID with the Dialogic 1000 Media Gateway Series

Unique Micro Design Advanced Thinking Products. Model S151 UMD Transfer Utility for the Nippondenso BHT Series User Manual

Backup Exec Cloud Storage for Nirvanix Installation Guide. Release 2.0

VPN Direct connection How To

Nokia for Business. Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

A REST API for Arduino & the CC3000 WiFi Chip

Introduction. How does FTP work?

APPLICATION. Using the PB-100 to Make Calls and Announcements From a Database. Using the PB-100 for All-Call Dialing

Online HTTP Information Server and SMS Alerts System for Mobile Weather Station through GSM Wireless Communication

Green Telnet. Making the Client/Server Model Green

Configuring and Monitoring FTP Servers

Design and Implementation of Home Monitoring System Using RF Technology

Quectel Cellular Engine

NEC Express5800 Series NEC ESMPRO AlertManager User's Guide

ALTIRIS Software Delivery Solution for Windows 6.1 SP3 Product Guide

APR-PRT3 Printer Module: C-Bus Programming Instructions

Issue 2EN. Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation

Upgrading Intel AMT 5.0 drivers to Linux kernel v2.6.31

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Qt Signals and Slots. Olivier Goffart. October 2013

Transcription:

SMS_SS - a-gsm 2.064 send/read/list SMS example utility COPYRIGHT (c) 2014 Dragos Iosub / R&D Software Solutions srl You are legaly entitled to use this SOFTWARE ONLY IN CONJUNCTION WITH a-gsm DEVICES USAGE. Modifications, derivates and redistribution of this software must include unmodified this COPYRIGHT NOTICE. You can redistribute this SOFTWARE and/or modify it under the terms of this COPYRIGHT NOTICE. Any other usage may be permited only after written notice of Dragos Iosub / R&D Software Solutions srl. This SOFTWARE is distributed is provide "AS IS" in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Dragos Iosub, Bucharest 2014. http://itbrainpower.net In order to make your Arduino serial communication reliable (especially for Arduino Uno) with a-gsm shield, you must edit: C:\Program Files\Arduino\libraries\SoftwareSerial\SoftwareSerial.cpp comment the line 42 #define _SS_MAX_RX_BUFF 64 this, will look after that like: //#define _SS_MAX_RX_BUFF 64 and add bellow the next line: #define _SS_MAX_RX_BUFF 128 You just increased the RX buffer size for UNO and other "snails". Now you can compile and upload your code supporting highier buffered serial input data. //#define atdebug //uncomment this line if you want to catch OK/ERROR/TIMEOUT modem response //modify the next 2 line to be convenient for you char message[]="hi!\r\nthis message has been sent from a-gsm v2.064 Arduino shield connected with my Arduino board."; //no more than 160 chars -text SMS maximum lenght char destinationnumber[]="+40123456789"; //usually phone number with International prefix eg. +40 for Romania - in some networks you must use domestic numbers #define powerpin //#define resetpin #define statuspin 7//Arduino Digital pin used to power up / power down the modem 6//Arduino Digital pin used to reset the modem 5//Arduino Digital pin used to monitor if modem is powered #define RXSoft 2 //RX soft -used for software communication #define TXSoft 3 //TX soft -used for software communication #include <SoftwareSerial.h> typedef struct { -1-

int nosms; int totsms; simmsms; simmsms SSMS = {0,0; int sendsms(char* phno, char* phtype, char* message); void readsimm(void); void setupmodemforsmsusage(void); void listsmsstatus(void); do not change under this line! Insteed, make one copy for playing with. int state=0, i=0, powerstate = 0; char ch; char buffd[256]; char IMEI[18]; unsigned long offsettime; int totalchars = 0; SoftwareSerial SSerial(RXSoft, TXSoft); //setup software serial for modem communication utility for sending SMS phno - destination phone number, international format eg.:+40123456789 - char* phtype - destination phone number type 129 (international)/ 147(domestic) - char* message -...what you want to transmit in your SMS :)) - max. 160 chars - char* returns 1 for SUCCESS 0 for FAILURE int sendsms(char* phno, char* phtype, char* message){ return SUCCESSorFAILURE; setupmodemforsmsusage() -utility to set up the modem for SMS (text mode) usage void setupmodemforsmsusage(){ utility for listing SMS (received) from memmory store into SSMS the used/total SMSs SSMS.noSMS --- used SMS (locations)... if >0, we have something to read :) SSMS.totSMS --- total SMS (locations) void listsmsstatus(){ clear buffd preparing it for writing void clearbuffd(void){//just clear the data buffer memset(buffd, 0x00, sizeof(buffd)); -2-

send command -cmd to themodem, waiting Delay_mS msecs after that size_t agsmcmd(char* cmd, int Delay_mS){ send string -str to the modem, NOT ADDING \r\n to the line end size_t agsmwrite(char* str){ return read char from the modem inline char agsmread(void){ Receive data from serial until event: SUCCESS string - 1'st argument FAILURE string - second argument TIMEOUT - third argument in secconds! return: int -1 TIMEOUT 0 FAILURE 1 SUCCESS the string collected from modem => buffd int recuartdata( char* ok, char* err, int to){ return(cmdsuccescode); send AT command, looking for SUCCES STRING(1'st) or FAILURE STRING(second), and TIMEOUT(third) return 1 for succes, 2 for failure, -1 for timeout modem response is loaded in buffd int sendatcommand(char* outstr, char* ok, char* err, int to){ res = recuartdata( ok, err, to); return(res); bool TXavailable(){ return(charsavailableforread); just print debug to Serial void printdebugln(char* what){ Serial.println(what); utility that load into IMEI var the modem IMEI void getimei(){//at+gsn -3-

Arduino hardware setup utility void setup(){ here is the main code void loop(){ char somebuffer[161]; int SMSindex = 1; char * pch0; char * pch1; int res; int i; switch(state){ case 0://check modem status, power it if necessary if(!digitalread(statuspin)) restartmodem(); else i=0; res= 0; while(res!= 1){ res = sendatcommand("at","ok","error",2); if (res!= 1) { if(i++ >= 10) restartmodem(); delay(500); sendatcommand("at+ipr=19200;&w","ok","error",2); delay(2000); case 1://next some init strings... agsmcmd("at+qimode=0",200); agsmcmd("at+qindi=0",200); agsmcmd("at+qimux=0",200); agsmcmd("at+qidnsip=0",200); offsettime=0; case 2://stop if PIN is requested printdebugln("try CPIN..."); if(!offsettime) if ((millis() - offsettime) > 20000) restartmodem(); agsmcmd("at+cpin?",200); i = 0; while(txavailable()){ ch = agsmread(); buffd[i] = ch; i++; -4-

//printdebugln(buffd); delay(100); if(strstr(buffd,"ready")) { offsettime=0; printdebugln("ready"); else { delay(100); case 3: //is the modem registered? getimei();//just for fun if(!offsettime) if ((millis() - offsettime) > 30000) restartmodem(); printdebugln("query GSM registration?"); agsmcmd("at+creg?",1000);//gsm network registration i = 0; while(txavailable()){ ch = agsmread(); buffd[i] = ch; i++; //printdebugln(buffd); delay(100); if(strstr(buffd,"0,1")) { offsettime=0; printdebugln("ready"); else { case 4: //it is SIM/MODEM full initialised? printdebugln("query State of Initialization"); agsmcmd("at+qinistat",200); i = 0; while(txavailable()){ ch = agsmread(); buffd[i] = ch; i++; if(strstr(buffd,"3")) { offsettime=0; printdebugln("ready"); delay(100); else {printdebugln("not yet..."); delay(1000); delay(100); -5-

case 5://Initialize the modem for DTMF receive usage if(!offsettime) if ((millis() - offsettime) > 5000) restartmodem(); printdebugln("let's prepare modem for SMS usage! Wait 10-11 seconds, please!"); setupmodemforsmsusage(); delay(10000); case 6://let's send one SMS to the destination receipment if(!offsettime) if ((millis() - offsettime) > 5000) restartmodem(); printdebugln("let's send one SMS to the destination receipment!"); delay(100); //if(sendsms(destinationnumber,"147",message)==1) printdebugln("test SMS has been send with succees!"); if(sendsms(destinationnumber,"129",message) == 1) printdebugln("test SMS has been send with succees!"); else printdebugln("sms send FAILURE"); delay(10000); case 7://let's read SMSs from active memmory printdebugln("let's find SMS storage usage!"); delay(100); listsmsstatus(); printdebugln(buffd); delay(5000); case 8://let's read one SMS printdebugln("let's read one SMS!"); delay(100); //start READ SMS SMSindex = 1;//h used as SMS index here we read only first index... h >=1, h<=sms.totsms!!!! sprintf(buffd,"at+cmgr=%i,0\r",smsindex);//format the read command... with SMS status changing(second argument) from REC UNREAD to REC READ -6-

agsmwrite(buffd);//send command to modem recuartdata("ok","error",5);//receive modem's response...in buffd //end read SMS printdebugln("modem response:"); printdebugln(buffd);//let's see what modem say //let's extract the message memset(somebuffer,0x00,sizeof(somebuffer)); pch0 = strstr(buffd,"\"\r\n"); pch1 = strstr(buffd,"\r\nok"); strncpy(somebuffer, pch0+3, pch1-pch0-4); printdebugln("list message:"); printdebugln(somebuffer);//here is the message... //end extract the message delay(15000); default: //restartmodem(); delay(10000); state=0; just flush remaining chars from serial void clearhdserial(){ //..function code here -7-