@ KDEV 2007 Some Rights Reserved
How to use CDC-ACM modems for GPRS connections or to send SMS

If you are looking this article probably you'll find interesting the:
 SMS / MMS FOXBOX THE HARDWARE GATEWAY FOR MESSAGING MANAGEMENT


foXServe fully supports cdc-acm USB modem devices as  TELIT MG10, and  Falcom SAMBA 75
This feature was included from release 1.3.4.


                               
The support is built-in in foXServe.

Plug the modem into USB port, type "tail -f /var/log/messages", a output as what is shown below should appear in your messages. This means that the device is connected and available on interface /dev/ttyACM0


Jan  1 00:08:55 axis kernel: crisv10_irq dbg: ctr_status_irq, controller status: host_mode started 
Jan  1 00:08:55 axis kernel: crisv10_irq dbg: ctr_status_irq, controller status: host_mode started running 
Jan  1 00:08:55 axis kernel: usb 1-1: new full speed USB device using hc-crisv10 and address 3
Jan  1 00:08:55 axis kernel: cdc_acm 1-1:1.0: ttyACM0: USB ACM device

Now you can use use ppp connection available on this tutorial to perform GPRS internet connections.

Below there is an example on how to send a SMS using telit MG10 trough AT Commands. The code is usefull to send AT commands to every kind of modem device. Source is available here for download.

/*
 * Kanta SMS
 * Author: Davide Cantaluppi 
 */
#include 
#include 
#include 
#include 
#include 
#include 

#define TX_BUF		400
#define RX_BUF	 	 50
#define TEXT_BUF	370
#define PHONE_BUF	 20

#define K_DEV		"/dev/ttyACM0"
//#define K_DEV		"/dev/null"
// Global variable
int smsdev;

int main(int argc, char *argv[])
{
 int ret;
 int sms_ptr = 0;
 unsigned char tx_String[TX_BUF];
 unsigned char rx_String[RX_BUF];
 unsigned char text_string[TEXT_BUF];
 unsigned char phone_num_string[PHONE_BUF];
 unsigned char sms_num[20];
 char *nptr;
 char az[1];

 smsdev = open(K_DEV, O_RDWR|O_NONBLOCK);
 if(smsdev == -1)
		{
		 perror(K_DEV);
		 exit(errno);
		}

 fprintf(stdout, "smsdev Opened successfully!\n");
 // Need Ioctl ?
 // ioctl(smsdev, ISR_HW_TYPE, &hw);

 ret = lseek(smsdev, 0, SEEK_SET);

 if(argc != 3)	{
		 close(smsdev);
		 fprintf(stdout, "too few argument to main!\n");
		 return -1;
		}

// fprintf(stdout, "argc: %d\n",argc);
// fprintf(stdout, "argv1: %s\n",argv[1]);
// fprintf(stdout, "argv2: %s\n",argv[2]);

 // ********** Inizio sequenza invio comandi AT
 strcpy(tx_String, "at+cpms=\"MT\"\r\n");
 write(smsdev, tx_String, strlen(tx_String));
 fprintf(stdout, "sended: %s\n",tx_String);
 read(smsdev, &rx_String[0], 50);
 fprintf(stdout, "received: %s\n",rx_String);

 strcpy(tx_String, "at+cscs=\"ASCII\"\r\n");
 write(smsdev, tx_String, strlen(tx_String));
 fprintf(stdout, "sended: %s\n",tx_String);
 read(smsdev, &rx_String[0], 50);
 fprintf(stdout, "received: %s\n",rx_String);

 strcpy(tx_String, "at+cmgw=\"");
 strcat(tx_String, argv[1]);
 strcat(tx_String, "\"\r\n");
 write(smsdev, tx_String, strlen(tx_String));
 fprintf(stdout, "sended: %s\n",tx_String);
 sleep(1);
// read(smsdev, &rx_String[0], 50);
 fprintf(stdout, "wait for prompt-received: %s\n",rx_String);

 strcpy(tx_String, argv[2]);
 strcat(tx_String, "\r\n");
 //sleep(10);
 write(smsdev, tx_String, strlen(tx_String));
 fprintf(stdout, "sended: %s\n",tx_String);
 sleep(1);
// read(smsdev, &rx_String[0], 50);

// strcpy(tx_String, "");
// strcpy(tx_String, "^Z");
// strcpy(tx_String, "\26");
// az[0] = 0x1A;
 strcpy(tx_String, "\x1A");
 write(smsdev, tx_String, strlen(tx_String));
 fprintf(stdout, "sended: %s\n",tx_String);
 sleep(1);
 read(smsdev, &rx_String[0], 50);
// ONLY FOR RECEIVE TEST
// strcpy(rx_String, "+CMGW: 6969\r\nOK\r\n");

 fprintf(stdout, "received: %s\n",rx_String);

 //parsing x ottenere sms_ptr
 nptr = strchr(rx_String, ':');
 if(nptr != NULL)
	{
	// fprintf(stdout, "strchr: %s\n",nptr);
	 strncpy(sms_num, nptr+1, 5);
	// fprintf(stdout, "sms num=%s=\n",sms_num);
	 sms_ptr = atoi(sms_num);
	}
 else	 fprintf(stdout, "parsing error on +CMGW:xxx!\n");

 sprintf(tx_String, "at+cmss=%d\r\n",sms_ptr);
 write(smsdev, tx_String, strlen(tx_String));
 fprintf(stdout, "sended: %s\n",tx_String);
 read(smsdev, &rx_String[0], 50);
 fprintf(stdout, "received: %s\n",rx_String);
 sleep (10);
 sprintf(tx_String, "at+cmgd=%d\r\n",sms_ptr);
 write(smsdev, tx_String, strlen(tx_String));
 fprintf(stdout, "sended: %s\n",tx_String);
 read(smsdev, &rx_String[0], 50);
 fprintf(stdout, "received: %s\n",rx_String);

 // ********** Fine sequenza invio comandi AT

 close(smsdev);
 fprintf(stdout, "smsdev Closed successfully!\n");
 return 0;
}



You can compile this example on-line with the WebCompiler


Remember that foXServe support also USB to serial adapters with PL2303 so you can use also USB modems with this built interface converter as falcom samba 55 the difference is the device that will be /dev/ttyUSB0.







SMS MMS FoxBox the appliance based on foxserve for messaging management








foXServe is Developed by KDEV a Davide Cantaluppi company and running on ACME SYSTEMS srl Hardware.

foXServe update
Name:
Email:



@ KDEV 2007 Some Rights Reserved
foXServe firmware is free
foXServe firmware
Download it now!


LICENSES

Apache/1.3.37 Server

Copyright 2007 Kdev of Davide Cantaluppi Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

PHP 5.0.5
"This product includes PHP software, freely available from <http://www.php.net/software/>"

MOD_DAV
This product includes software developed by Greg Stein <gstein@lyra.org> for use in the mod_dav module for Apache (http://www.webdav.org/mod_dav/).