Ethernet shild + sim900 module не работает цикл
- Войдите на сайт для отправки комментариев
Пт, 23/05/2014 - 01:28
Всем привет. Столкнулся с непонятной проблеммой: при использовании следующего кода:
#include <SPI.h>
#include <Ethernet.h>
#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"
//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;
#define SEND_LED 9
#define GET_SMS_LED 8
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
String sms_text;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//IPAddress ip(191,11,1,1);
//char server[] = "112.travel";
IPAddress server(194,187,48,247);
int send_sms_status = 2;
EthernetClient client;
void setup() {
Serial.begin(9600);
pinMode(SEND_LED, OUTPUT);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
delay(1000);
Serial.print("My IP address: ");
for (byte thisByte = 0; thisByte < 4; thisByte++) {
Serial.print(Ethernet.localIP()[thisByte], DEC);
Serial.print(".");
}
Serial.println();
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(2400)){
Serial.println("\nstatus=READY");
started=true;
}
else Serial.println("\nstatus=IDLE");
if(started){
//Enable this two lines if you want to send an SMS.
//if (sms.SendSMS("3471234567", "Arduino SMS"))
//Serial.println("\nSMS sent OK");
}
// pinMode(SEND_LED, OUTPUT);
// pinMode(GET_SMS_LED, OUTPUT);
//IPAddress ip(Ethernet.localIP());
/*
Serial.println("sdsd");
Serial.println(str_replace("sms text is!!!"));
Serial.println("sdsd1");
*/
// connectToServer(str_replace("sms text is!!!"), "+380501234567");
};
boolean StartGetResult = false;
boolean start_send_serv = false;
String server_result, ServRes;
long PrevMillForSend = 0;
void loop () {
//func_send_server (str_replace("sms text is!!!"), "+380501234567");
if(started){
//Read if there are messages on SIM card and print them.
if(gsm.readSMS(smsbuffer, 160, n, 20))
{
Serial.println(n);
Serial.println(smsbuffer);
}
delay(1000);
}
}
в порт ничего не выводится. Стоит же только упрать из цикла проверку входящих смс:
#include <SPI.h>
#include <Ethernet.h>
#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"
//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;
#define SEND_LED 9
#define GET_SMS_LED 8
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
String sms_text;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//IPAddress ip(191,11,1,1);
//char server[] = "112.travel";
IPAddress server(194,187,48,247);
int send_sms_status = 2;
EthernetClient client;
void setup() {
Serial.begin(9600);
pinMode(SEND_LED, OUTPUT);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
delay(1000);
Serial.print("My IP address: ");
for (byte thisByte = 0; thisByte < 4; thisByte++) {
Serial.print(Ethernet.localIP()[thisByte], DEC);
Serial.print(".");
}
Serial.println();
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(2400)){
Serial.println("\nstatus=READY");
started=true;
}
else Serial.println("\nstatus=IDLE");
if(started){
//Enable this two lines if you want to send an SMS.
//if (sms.SendSMS("3471234567", "Arduino SMS"))
//Serial.println("\nSMS sent OK");
}
// pinMode(SEND_LED, OUTPUT);
// pinMode(GET_SMS_LED, OUTPUT);
//IPAddress ip(Ethernet.localIP());
/*
Serial.println("sdsd");
Serial.println(str_replace("sms text is!!!"));
Serial.println("sdsd1");
*/
// connectToServer(str_replace("sms text is!!!"), "+380501234567");
};
boolean StartGetResult = false;
boolean start_send_serv = false;
String server_result, ServRes;
long PrevMillForSend = 0;
void loop () {
//func_send_server (str_replace("sms text is!!!"), "+380501234567");
if(started){
//Read if there are messages on SIM card and print them.
/*if(gsm.readSMS(smsbuffer, 160, n, 20))
{
Serial.println(n);
Serial.println(smsbuffer);
}*/
delay(1000);
}
}
как все начинает работать нормально. Статус GMS=READY и нормально выводит мой IP. Может кто подскажет в чем може быть проблема? Буду весьма признателен за помощь!