mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
PreProcessor now replace every single char with a space, without collapsing multiline matches
This commit is contained in:
parent
7902fc2591
commit
d0758af29a
@ -257,9 +257,23 @@ public class PdePreprocessor {
|
|||||||
// pre-processor directive
|
// pre-processor directive
|
||||||
p += "|" + "(^\\s*#.*?$)";
|
p += "|" + "(^\\s*#.*?$)";
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder(in);
|
||||||
Pattern pattern = Pattern.compile(p, Pattern.MULTILINE | Pattern.DOTALL);
|
Pattern pattern = Pattern.compile(p, Pattern.MULTILINE | Pattern.DOTALL);
|
||||||
Matcher matcher = pattern.matcher(in);
|
Matcher matcher = pattern.matcher(sb);
|
||||||
return matcher.replaceAll(" ");
|
while (matcher.find()) {
|
||||||
|
String replacement = composeReplacementString(new StringBuilder(sb.subSequence(matcher.start(), matcher.end())));
|
||||||
|
sb.replace(matcher.start(), matcher.end(), replacement);
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String composeReplacementString(StringBuilder sb) {
|
||||||
|
for (int i = 0; i < sb.length(); i++) {
|
||||||
|
if (sb.charAt(i) != '\n') {
|
||||||
|
sb.setCharAt(i, ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -388,7 +402,10 @@ public class PdePreprocessor {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// continue blanking this area
|
// continue blanking this area
|
||||||
p[index++] = ' ';
|
if (p[index] != '\n') {
|
||||||
|
p[index] = ' ';
|
||||||
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!endOfRainbow) {
|
if (!endOfRainbow) {
|
||||||
|
304
app/test/processing/app/preproc/Baladuino.nocomments.ino
Normal file
304
app/test/processing/app/preproc/Baladuino.nocomments.ino
Normal file
@ -0,0 +1,304 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define ENABLE_TOOLS
|
||||||
|
#define ENABLE_SPP
|
||||||
|
#define ENABLE_PS3
|
||||||
|
#define ENABLE_WII
|
||||||
|
#define ENABLE_XBOX
|
||||||
|
#define ENABLE_ADK
|
||||||
|
|
||||||
|
#include "Balanduino.h"
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <usbhub.h>
|
||||||
|
|
||||||
|
#ifdef ENABLE_ADK
|
||||||
|
#include <adk.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <Kalman.h>
|
||||||
|
|
||||||
|
#ifdef ENABLE_XBOX
|
||||||
|
#include <XBOXRECV.h>
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_SPP
|
||||||
|
#include <SPP.h>
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_PS3
|
||||||
|
#include <PS3BT.h>
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_WII
|
||||||
|
#include <Wii.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Kalman kalman;
|
||||||
|
|
||||||
|
#if defined(ENABLE_SPP) || defined(ENABLE_PS3) || defined(ENABLE_WII) || defined(ENABLE_XBOX) || defined(ENABLE_ADK)
|
||||||
|
#define ENABLE_USB
|
||||||
|
USB Usb;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_ADK
|
||||||
|
|
||||||
|
ADK adk(&Usb, "TKJ Electronics",
|
||||||
|
"Balanduino",
|
||||||
|
"Android App for Balanduino",
|
||||||
|
"0.5.0",
|
||||||
|
"https://play.google.com/store/apps/details?id=com.tkjelectronics.balanduino",
|
||||||
|
"1234");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_XBOX
|
||||||
|
XBOXRECV Xbox(&Usb);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_SPP) || defined(ENABLE_PS3) || defined(ENABLE_WII)
|
||||||
|
USBHub Hub(&Usb);
|
||||||
|
BTD Btd(&Usb);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_SPP
|
||||||
|
SPP SerialBT(&Btd, "Balanduino", "0000");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_PS3
|
||||||
|
PS3BT PS3(&Btd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_WII
|
||||||
|
WII Wii(&Btd);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
|
||||||
|
if (!checkInitializationFlags())
|
||||||
|
readEEPROMValues();
|
||||||
|
|
||||||
|
|
||||||
|
pinMode(leftEncoder1, INPUT);
|
||||||
|
pinMode(leftEncoder2, INPUT);
|
||||||
|
pinMode(rightEncoder1, INPUT);
|
||||||
|
pinMode(rightEncoder2, INPUT);
|
||||||
|
attachInterrupt(0, leftEncoder, CHANGE);
|
||||||
|
attachInterrupt(1, rightEncoder, CHANGE);
|
||||||
|
|
||||||
|
|
||||||
|
pinMode(leftEnable, OUTPUT);
|
||||||
|
pinMode(rightEnable, OUTPUT);
|
||||||
|
digitalWrite(leftEnable, HIGH);
|
||||||
|
digitalWrite(rightEnable, HIGH);
|
||||||
|
|
||||||
|
|
||||||
|
sbi(pwmPortDirection, leftPWM);
|
||||||
|
sbi(leftPortDirection, leftA);
|
||||||
|
sbi(leftPortDirection, leftB);
|
||||||
|
sbi(pwmPortDirection, rightPWM);
|
||||||
|
sbi(rightPortDirection, rightA);
|
||||||
|
sbi(rightPortDirection, rightB);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TCCR1B = _BV(WGM13) | _BV(CS10);
|
||||||
|
ICR1 = PWMVALUE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TCCR1A = _BV(COM1A1) | _BV(COM1B1);
|
||||||
|
setPWM(leftPWM, 0);
|
||||||
|
setPWM(rightPWM, 0);
|
||||||
|
|
||||||
|
|
||||||
|
pinMode(buzzer, OUTPUT);
|
||||||
|
|
||||||
|
#ifdef ENABLE_USB
|
||||||
|
if (Usb.Init() == -1) {
|
||||||
|
Serial.print(F("OSC did not start"));
|
||||||
|
digitalWrite(buzzer, HIGH);
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ENABLE_PS3
|
||||||
|
PS3.attachOnInit(onInit);
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_WII
|
||||||
|
Wii.attachOnInit(onInit);
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_XBOX
|
||||||
|
Xbox.attachOnInit(onInit);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Wire.begin();
|
||||||
|
|
||||||
|
while (i2cRead(0x75, i2cBuffer, 1));
|
||||||
|
if (i2cBuffer[0] != 0x68) {
|
||||||
|
Serial.print(F("Error reading sensor"));
|
||||||
|
digitalWrite(buzzer, HIGH);
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
i2cBuffer[0] = 19;
|
||||||
|
i2cBuffer[1] = 0x00;
|
||||||
|
i2cBuffer[2] = 0x00;
|
||||||
|
i2cBuffer[3] = 0x00;
|
||||||
|
while (i2cWrite(0x19, i2cBuffer, 4, false));
|
||||||
|
while (i2cWrite(0x6B, 0x09, true));
|
||||||
|
|
||||||
|
delay(100);
|
||||||
|
|
||||||
|
|
||||||
|
while (i2cRead(0x3D, i2cBuffer, 4));
|
||||||
|
accY = ((i2cBuffer[0] << 8) | i2cBuffer[1]);
|
||||||
|
accZ = ((i2cBuffer[2] << 8) | i2cBuffer[3]);
|
||||||
|
|
||||||
|
|
||||||
|
accAngle = (atan2((double)accY - cfg.accYzero, (double)accZ - cfg.accZzero) + PI) * RAD_TO_DEG;
|
||||||
|
|
||||||
|
kalman.setAngle(accAngle);
|
||||||
|
pitch = accAngle;
|
||||||
|
gyroAngle = accAngle;
|
||||||
|
|
||||||
|
|
||||||
|
calibrateGyro();
|
||||||
|
|
||||||
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
|
|
||||||
|
|
||||||
|
digitalWrite(buzzer, HIGH);
|
||||||
|
delay(100);
|
||||||
|
digitalWrite(buzzer, LOW);
|
||||||
|
|
||||||
|
|
||||||
|
kalmanTimer = micros();
|
||||||
|
pidTimer = kalmanTimer;
|
||||||
|
encoderTimer = kalmanTimer;
|
||||||
|
imuTimer = millis();
|
||||||
|
reportTimer = imuTimer;
|
||||||
|
ledTimer = imuTimer;
|
||||||
|
blinkTimer = imuTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
#ifdef ENABLE_WII
|
||||||
|
if (Wii.wiimoteConnected)
|
||||||
|
Usb.Task();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
while (i2cRead(0x3D, i2cBuffer, 8));
|
||||||
|
accY = ((i2cBuffer[0] << 8) | i2cBuffer[1]);
|
||||||
|
accZ = ((i2cBuffer[2] << 8) | i2cBuffer[3]);
|
||||||
|
gyroX = ((i2cBuffer[6] << 8) | i2cBuffer[7]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
accAngle = (atan2((double)accY - cfg.accYzero, (double)accZ - cfg.accZzero) + PI) * RAD_TO_DEG;
|
||||||
|
|
||||||
|
uint32_t timer = micros();
|
||||||
|
|
||||||
|
if ((accAngle < 90 && pitch > 270) || (accAngle > 270 && pitch < 90)) {
|
||||||
|
kalman.setAngle(accAngle);
|
||||||
|
pitch = accAngle;
|
||||||
|
gyroAngle = accAngle;
|
||||||
|
} else {
|
||||||
|
gyroRate = ((double)gyroX - gyroXzero) / 131.0;
|
||||||
|
double dt = (double)(timer - kalmanTimer) / 1000000.0;
|
||||||
|
gyroAngle += gyroRate * dt;
|
||||||
|
if (gyroAngle < 0 || gyroAngle > 360)
|
||||||
|
gyroAngle = pitch;
|
||||||
|
pitch = kalman.getAngle(accAngle, gyroRate, dt);
|
||||||
|
}
|
||||||
|
kalmanTimer = timer;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ENABLE_WII
|
||||||
|
if (Wii.wiimoteConnected)
|
||||||
|
Usb.Task();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
timer = micros();
|
||||||
|
|
||||||
|
|
||||||
|
if ((layingDown && (pitch < cfg.targetAngle - 10 || pitch > cfg.targetAngle + 10)) || (!layingDown && (pitch < cfg.targetAngle - 45 || pitch > cfg.targetAngle + 45))) {
|
||||||
|
layingDown = true;
|
||||||
|
stopAndReset();
|
||||||
|
} else {
|
||||||
|
layingDown = false;
|
||||||
|
updatePID(cfg.targetAngle, targetOffset, turningOffset, (double)(timer - pidTimer) / 1000000.0);
|
||||||
|
}
|
||||||
|
pidTimer = timer;
|
||||||
|
|
||||||
|
|
||||||
|
timer = micros();
|
||||||
|
if (timer - encoderTimer >= 100000) {
|
||||||
|
encoderTimer = timer;
|
||||||
|
int32_t wheelPosition = getWheelsPosition();
|
||||||
|
wheelVelocity = wheelPosition - lastWheelPosition;
|
||||||
|
lastWheelPosition = wheelPosition;
|
||||||
|
|
||||||
|
if (abs(wheelVelocity) <= 40 && !stopped) {
|
||||||
|
targetPosition = wheelPosition;
|
||||||
|
stopped = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
batteryCounter++;
|
||||||
|
if (batteryCounter > 10) {
|
||||||
|
batteryCounter = 0;
|
||||||
|
batteryVoltage = (double)analogRead(VBAT) / 63.050847458;
|
||||||
|
if (batteryVoltage < 10.2 && batteryVoltage > 5)
|
||||||
|
digitalWrite(buzzer, HIGH);
|
||||||
|
else
|
||||||
|
digitalWrite(buzzer, LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ENABLE_USB
|
||||||
|
readUsb();
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_TOOLS
|
||||||
|
checkSerialData();
|
||||||
|
#endif
|
||||||
|
#if defined(ENABLE_TOOLS) || defined(ENABLE_SPP)
|
||||||
|
printValues();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_SPP) || defined(ENABLE_PS3) || defined(ENABLE_WII)
|
||||||
|
if (Btd.isReady()) {
|
||||||
|
timer = millis();
|
||||||
|
if ((Btd.watingForConnection && timer - blinkTimer > 1000) || (!Btd.watingForConnection && timer - blinkTimer > 100)) {
|
||||||
|
blinkTimer = timer;
|
||||||
|
ledState = !ledState;
|
||||||
|
digitalWrite(LED_BUILTIN, ledState);
|
||||||
|
}
|
||||||
|
} else if (ledState) {
|
||||||
|
ledState = !ledState;
|
||||||
|
digitalWrite(LED_BUILTIN, ledState);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
@ -18,6 +18,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -34,31 +46,38 @@
|
|||||||
Kalman kalman;
|
Kalman kalman;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
USB Usb;
|
USB Usb;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ADK adk(&Usb, ,
|
|
||||||
,
|
ADK adk(&Usb, ,
|
||||||
,
|
,
|
||||||
,
|
,
|
||||||
,
|
,
|
||||||
);
|
,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
XBOXRECV Xbox(&Usb);
|
XBOXRECV Xbox(&Usb);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
USBHub Hub(&Usb);
|
USBHub Hub(&Usb);
|
||||||
BTD Btd(&Usb);
|
BTD Btd(&Usb);
|
||||||
|
|
||||||
|
|
||||||
SPP SerialBT(&Btd, , );
|
|
||||||
|
SPP SerialBT(&Btd, , );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PS3BT PS3(&Btd);
|
PS3BT PS3(&Btd);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WII Wii(&Btd);
|
WII Wii(&Btd);
|
||||||
|
|
||||||
|
|
||||||
@ -111,8 +130,9 @@ void setup() {
|
|||||||
|
|
||||||
pinMode(buzzer, OUTPUT);
|
pinMode(buzzer, OUTPUT);
|
||||||
|
|
||||||
|
|
||||||
if (Usb.Init() == -1) {
|
if (Usb.Init() == -1) {
|
||||||
Serial.print(F( ));
|
Serial.print(F( ));
|
||||||
digitalWrite(buzzer, HIGH);
|
digitalWrite(buzzer, HIGH);
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
@ -135,7 +155,7 @@ void setup() {
|
|||||||
|
|
||||||
while (i2cRead(0x75, i2cBuffer, 1));
|
while (i2cRead(0x75, i2cBuffer, 1));
|
||||||
if (i2cBuffer[0] != 0x68) {
|
if (i2cBuffer[0] != 0x68) {
|
||||||
Serial.print(F( ));
|
Serial.print(F( ));
|
||||||
digitalWrite(buzzer, HIGH);
|
digitalWrite(buzzer, HIGH);
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
@ -214,6 +234,7 @@ void loop() {
|
|||||||
kalmanTimer = timer;
|
kalmanTimer = timer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (Wii.wiimoteConnected)
|
if (Wii.wiimoteConnected)
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
|
|
||||||
@ -266,6 +287,7 @@ void loop() {
|
|||||||
printValues();
|
printValues();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (Btd.isReady()) {
|
if (Btd.isReady()) {
|
||||||
timer = millis();
|
timer = millis();
|
||||||
if ((Btd.watingForConnection && timer - blinkTimer > 1000) || (!Btd.watingForConnection && timer - blinkTimer > 100)) {
|
if ((Btd.watingForConnection && timer - blinkTimer > 1000) || (!Btd.watingForConnection && timer - blinkTimer > 100)) {
|
||||||
|
@ -0,0 +1,339 @@
|
|||||||
|
#include <SoftwareSerial.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define DS3231_I2C_ADDRESS 104
|
||||||
|
#define DS3231_TIME_CAL_ADDR 0
|
||||||
|
#define DS3231_ALARM1_ADDR 7
|
||||||
|
#define DS3231_ALARM2_ADDR 11
|
||||||
|
#define DS3231_CONTROL_ADDR 14
|
||||||
|
#define DS3231_STATUS_ADDR 15
|
||||||
|
|
||||||
|
#define DS3231_TEMPERATURE_ADDR 17
|
||||||
|
|
||||||
|
|
||||||
|
SoftwareSerial GPRS( 7, 8 );
|
||||||
|
byte buffer[ 64 ];
|
||||||
|
int count = 0, e = 0, count2 = 0, t = 0, q;
|
||||||
|
char temp, lastCaller[13] = "blank";
|
||||||
|
boolean callIncoming = false, done;
|
||||||
|
|
||||||
|
|
||||||
|
byte time[ 7 ];
|
||||||
|
byte time_A1[ 5 ];
|
||||||
|
byte time_A2[ 4 ];
|
||||||
|
byte received[1];
|
||||||
|
float temperature;
|
||||||
|
|
||||||
|
|
||||||
|
char telescopeNames[6][4];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void setPowerStateTo( int newState )
|
||||||
|
{
|
||||||
|
if( newState != 1 && newState != 0 ) {
|
||||||
|
Serial.print( "Error: Invalid powerstate. Current powerstate = " );
|
||||||
|
Serial.print( getPowerState() );
|
||||||
|
Serial.print( "\n" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if( newState == getPowerState() ) {
|
||||||
|
Serial.print( "Powerstate = " );
|
||||||
|
Serial.print( newState );
|
||||||
|
Serial.print( " remains unchanged.\n" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
powerUpOrDown();
|
||||||
|
Serial.print( "Powerstate changed from " );
|
||||||
|
Serial.print( 1 - newState );
|
||||||
|
Serial.print( " to " );
|
||||||
|
Serial.print( newState );
|
||||||
|
Serial.print( "\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delay( 5000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPowerState()
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
if ( digitalRead(18) == 0 && digitalRead(19) == 0 )
|
||||||
|
ret = 1;
|
||||||
|
else
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void powerUpOrDown()
|
||||||
|
{
|
||||||
|
pinMode( 9, OUTPUT );
|
||||||
|
digitalWrite( 9, LOW );
|
||||||
|
delay( 1000 );
|
||||||
|
digitalWrite( 9, HIGH );
|
||||||
|
delay( 2000 );
|
||||||
|
digitalWrite( 9, LOW );
|
||||||
|
delay( 3000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void clearBufferArray()
|
||||||
|
{
|
||||||
|
for( int i = 0; i < count; i++ )
|
||||||
|
buffer[ i ] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void makeMissedCall( char num[] )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char in[ 18 ] = "ATD";
|
||||||
|
for( i = 3; i <= 14; i++ )
|
||||||
|
in[ i ] = num[ i - 3] ;
|
||||||
|
in[ 15 ] = ';';
|
||||||
|
in[ 16 ] = '\r';
|
||||||
|
in[ 17 ] = '\0';
|
||||||
|
GPRS.write( in );
|
||||||
|
delay( 10000 );
|
||||||
|
GPRS.write( "ATH\r\0" );
|
||||||
|
delay( 1000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void sendTextMessage( char number[], char messg[] )
|
||||||
|
{
|
||||||
|
char temp[ 27 ] = "AT + CMGS = \"";
|
||||||
|
for( q = 0; q < 12; q++ )
|
||||||
|
temp[ q + 13 ] = number[ q ];
|
||||||
|
temp[ 25 ] = '\"';
|
||||||
|
temp[ 26 ] = '\0';
|
||||||
|
|
||||||
|
GPRS.println( "AT+CMGF=1\r" );
|
||||||
|
delay( 1000 );
|
||||||
|
GPRS.println( temp );
|
||||||
|
delay( 1000 );
|
||||||
|
GPRS.println( messg );
|
||||||
|
delay( 1000 );
|
||||||
|
GPRS.println( (char) 26 );
|
||||||
|
delay( 1000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void analise(byte incoming[], int length)
|
||||||
|
{
|
||||||
|
e = 0;
|
||||||
|
done = false;
|
||||||
|
while( e < length && !done){
|
||||||
|
temp = char( incoming[e] );
|
||||||
|
switch( temp ){
|
||||||
|
case 'R':
|
||||||
|
{
|
||||||
|
if( length > e + 3 && !callIncoming ) {
|
||||||
|
if(char( incoming[e + 1] ) == 'I'
|
||||||
|
&& char( incoming[e + 2] ) == 'N'
|
||||||
|
&& char( incoming[e + 3] ) == 'G'){
|
||||||
|
GPRS.write("AT+CLCC\r");
|
||||||
|
delay(500);
|
||||||
|
GPRS.write("ATH\r");
|
||||||
|
callIncoming = true;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '+':
|
||||||
|
{
|
||||||
|
if(char( buffer[ e + 1]) == '2' && length > e + 11 && callIncoming){
|
||||||
|
for(t = 0; t < 12; t++)
|
||||||
|
lastCaller[t] = char( buffer[ e + t ]);
|
||||||
|
lastCaller[12] = '\0';
|
||||||
|
callIncoming = false;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
Serial.println(lastCaller);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
e++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
byte decToBcd( byte b )
|
||||||
|
{
|
||||||
|
return ( b / 10 << 4 ) + b % 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean getBit( byte addr, int pos )
|
||||||
|
{
|
||||||
|
byte temp = getByte( addr );
|
||||||
|
return boolean( (temp >> pos) & B00000001 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBit( byte addr, int pos, boolean newBit )
|
||||||
|
{
|
||||||
|
boolean oldBit = getBit( addr, pos );
|
||||||
|
byte temp = received[ 0 ];
|
||||||
|
if ( oldBit != newBit )
|
||||||
|
{
|
||||||
|
if( newBit )
|
||||||
|
temp += (B00000001 << pos);
|
||||||
|
else
|
||||||
|
temp -= (B00000001 << pos);
|
||||||
|
}
|
||||||
|
setByte( addr, temp );
|
||||||
|
}
|
||||||
|
|
||||||
|
byte getByte( byte addr )
|
||||||
|
{
|
||||||
|
byte temp;
|
||||||
|
if( getBytes( addr, 1) )
|
||||||
|
temp = received[ 0 ];
|
||||||
|
else temp = -1;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean getBytes( byte addr, int amount )
|
||||||
|
{
|
||||||
|
boolean wireWorked = false;
|
||||||
|
Wire.beginTransmission( DS3231_I2C_ADDRESS );
|
||||||
|
Wire.write( addr );
|
||||||
|
Wire.endTransmission();
|
||||||
|
Wire.requestFrom( DS3231_I2C_ADDRESS, amount );
|
||||||
|
if( Wire.available() ){
|
||||||
|
received[amount];
|
||||||
|
for( int i = 0; i < amount; i++){
|
||||||
|
received[ i ] = Wire.read();
|
||||||
|
}
|
||||||
|
wireWorked = true;
|
||||||
|
}
|
||||||
|
return wireWorked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setByte( byte addr, byte newByte )
|
||||||
|
{
|
||||||
|
setBytes( addr, &newByte, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBytes( byte addr, byte newBytes[], int amount )
|
||||||
|
{
|
||||||
|
Wire.beginTransmission( DS3231_I2C_ADDRESS );
|
||||||
|
Wire.write( addr );
|
||||||
|
for( int i = 0; i < amount; i++ )
|
||||||
|
Wire.write( newBytes[ i ] );
|
||||||
|
Wire.endTransmission();
|
||||||
|
}
|
||||||
|
|
||||||
|
void getTime()
|
||||||
|
{
|
||||||
|
if( getBytes( DS3231_TIME_CAL_ADDR, 7) )
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 7; i++)
|
||||||
|
time[ i ] = received[ i ];
|
||||||
|
|
||||||
|
time[ 0 ] = ( ( time[ 0 ] & B01110000 ) >> 4 ) * 10 + ( time[ 0 ] & B00001111 );
|
||||||
|
time[ 1 ] = ( ( time[ 1 ] & B01110000 ) >> 4 ) * 10 + ( time[ 1 ] & B00001111 );
|
||||||
|
time[ 2 ] = ( ( time[ 2 ] & B00110000 ) >> 4 ) * 10 + ( time[ 2 ] & B00001111 );
|
||||||
|
time[ 4 ] = ( ( time[ 4 ] & B00110000 ) >> 4 ) * 10 + ( time[ 4 ] & B00001111 );
|
||||||
|
time[ 5 ] = ( ( time[ 5 ] & B00010000 ) >> 4 ) * 10 + ( time[ 5 ] & B00001111 );
|
||||||
|
time[ 6 ] = ( ( time[ 6 ] & B11110000 ) >> 4 ) * 10 + ( time[ 6 ] & B00001111 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTime( byte newTime[ 7 ] )
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 7; i++)
|
||||||
|
newTime[i] = decToBcd(newTime[i]);
|
||||||
|
setBytes( DS3231_TIME_CAL_ADDR, newTime, 7 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void getRTCTemperature()
|
||||||
|
{
|
||||||
|
|
||||||
|
if( getBytes( DS3231_TEMPERATURE_ADDR, 2 ) )
|
||||||
|
{
|
||||||
|
temperature = ( received[ 0 ] & B01111111 );
|
||||||
|
temperature += ( ( received[ 1 ] >> 6 ) * 0.25 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gprsListen()
|
||||||
|
{
|
||||||
|
if( GPRS.available() ) {
|
||||||
|
while( GPRS.available() ) {
|
||||||
|
buffer[ count++ ] = GPRS.read();
|
||||||
|
if ( count == 64 )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Serial.write( buffer, count );
|
||||||
|
analise( buffer, count );
|
||||||
|
clearBufferArray();
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
if (Serial.available())
|
||||||
|
GPRS.write(Serial.read());
|
||||||
|
}
|
||||||
|
|
||||||
|
void printTime()
|
||||||
|
{
|
||||||
|
getTime();
|
||||||
|
Serial.print( int( time[ 3 ] ) );
|
||||||
|
Serial.print( ' ' );
|
||||||
|
Serial.print( int( time[ 2 ] ) );
|
||||||
|
Serial.print( ':' );
|
||||||
|
Serial.print( int( time[ 1 ] ) );
|
||||||
|
Serial.print( ':' );
|
||||||
|
Serial.print( int( time[ 0 ] ) );
|
||||||
|
Serial.print( ' ' );
|
||||||
|
Serial.print( int( time[ 4 ] ) );
|
||||||
|
Serial.print( '/' );
|
||||||
|
Serial.print( int( time[ 5 ] ) );
|
||||||
|
Serial.print( "/20" );
|
||||||
|
Serial.print( int( time[ 6 ] ) );
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
|
||||||
|
GPRS.begin( 9600 );
|
||||||
|
delay(1000);
|
||||||
|
setPowerStateTo(1);
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
|
||||||
|
Wire.begin();
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
Serial.begin(9600);
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
gprsListen();
|
||||||
|
getTime();
|
||||||
|
}
|
||||||
|
|
@ -15,7 +15,7 @@
|
|||||||
SoftwareSerial GPRS( 7, 8 );
|
SoftwareSerial GPRS( 7, 8 );
|
||||||
byte buffer[ 64 ];
|
byte buffer[ 64 ];
|
||||||
int count = 0, e = 0, count2 = 0, t = 0, q;
|
int count = 0, e = 0, count2 = 0, t = 0, q;
|
||||||
char temp, lastCaller[13] = ;
|
char temp, lastCaller[13] = ;
|
||||||
boolean callIncoming = false, done;
|
boolean callIncoming = false, done;
|
||||||
|
|
||||||
|
|
||||||
@ -34,26 +34,28 @@ char telescopeNames[6][4];
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setPowerStateTo( int newState )
|
void setPowerStateTo( int newState )
|
||||||
{
|
{
|
||||||
if( newState != 1 && newState != 0 ) {
|
if( newState != 1 && newState != 0 ) {
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( getPowerState() );
|
Serial.print( getPowerState() );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( newState == getPowerState() ) {
|
if( newState == getPowerState() ) {
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( newState );
|
Serial.print( newState );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
powerUpOrDown();
|
powerUpOrDown();
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( 1 - newState );
|
Serial.print( 1 - newState );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( newState );
|
Serial.print( newState );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay( 5000 );
|
delay( 5000 );
|
||||||
@ -94,27 +96,27 @@ void clearBufferArray()
|
|||||||
void makeMissedCall( char num[] )
|
void makeMissedCall( char num[] )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char in[ 18 ] = ;
|
char in[ 18 ] = ;
|
||||||
for( i = 3; i <= 14; i++ )
|
for( i = 3; i <= 14; i++ )
|
||||||
in[ i ] = num[ i - 3] ;
|
in[ i ] = num[ i - 3] ;
|
||||||
in[ 15 ] = ;
|
in[ 15 ] = ;
|
||||||
in[ 16 ] = '\r';
|
in[ 16 ] = '\r';
|
||||||
in[ 17 ] = '\0';
|
in[ 17 ] = '\0';
|
||||||
GPRS.write( in );
|
GPRS.write( in );
|
||||||
delay( 10000 );
|
delay( 10000 );
|
||||||
GPRS.write( );
|
GPRS.write( );
|
||||||
delay( 1000 );
|
delay( 1000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendTextMessage( char number[], char messg[] )
|
void sendTextMessage( char number[], char messg[] )
|
||||||
{
|
{
|
||||||
char temp[ 27 ] = ;
|
char temp[ 27 ] = ;
|
||||||
for( q = 0; q < 12; q++ )
|
for( q = 0; q < 12; q++ )
|
||||||
temp[ q + 13 ] = number[ q ];
|
temp[ q + 13 ] = number[ q ];
|
||||||
temp[ 25 ] = ;
|
temp[ 25 ] = ;
|
||||||
temp[ 26 ] = '\0';
|
temp[ 26 ] = '\0';
|
||||||
|
|
||||||
GPRS.println( );
|
GPRS.println( );
|
||||||
delay( 1000 );
|
delay( 1000 );
|
||||||
GPRS.println( temp );
|
GPRS.println( temp );
|
||||||
delay( 1000 );
|
delay( 1000 );
|
||||||
@ -131,24 +133,24 @@ void analise(byte incoming[], int length)
|
|||||||
while( e < length && !done){
|
while( e < length && !done){
|
||||||
temp = char( incoming[e] );
|
temp = char( incoming[e] );
|
||||||
switch( temp ){
|
switch( temp ){
|
||||||
case :
|
case :
|
||||||
{
|
{
|
||||||
if( length > e + 3 && !callIncoming ) {
|
if( length > e + 3 && !callIncoming ) {
|
||||||
if(char( incoming[e + 1] ) ==
|
if(char( incoming[e + 1] ) ==
|
||||||
&& char( incoming[e + 2] ) ==
|
&& char( incoming[e + 2] ) ==
|
||||||
&& char( incoming[e + 3] ) == ){
|
&& char( incoming[e + 3] ) == ){
|
||||||
GPRS.write( );
|
GPRS.write( );
|
||||||
delay(500);
|
delay(500);
|
||||||
GPRS.write( );
|
GPRS.write( );
|
||||||
callIncoming = true;
|
callIncoming = true;
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case :
|
case :
|
||||||
{
|
{
|
||||||
if(char( buffer[ e + 1]) == && length > e + 11 && callIncoming){
|
if(char( buffer[ e + 1]) == && length > e + 11 && callIncoming){
|
||||||
for(t = 0; t < 12; t++)
|
for(t = 0; t < 12; t++)
|
||||||
lastCaller[t] = char( buffer[ e + t ]);
|
lastCaller[t] = char( buffer[ e + t ]);
|
||||||
lastCaller[12] = '\0';
|
lastCaller[12] = '\0';
|
||||||
@ -157,7 +159,7 @@ void analise(byte incoming[], int length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case :
|
case :
|
||||||
Serial.println(lastCaller);
|
Serial.println(lastCaller);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -170,6 +172,10 @@ void analise(byte incoming[], int length)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
byte decToBcd( byte b )
|
byte decToBcd( byte b )
|
||||||
{
|
{
|
||||||
return ( b / 10 << 4 ) + b % 10;
|
return ( b / 10 << 4 ) + b % 10;
|
||||||
@ -289,23 +295,25 @@ void printTime()
|
|||||||
{
|
{
|
||||||
getTime();
|
getTime();
|
||||||
Serial.print( int( time[ 3 ] ) );
|
Serial.print( int( time[ 3 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 2 ] ) );
|
Serial.print( int( time[ 2 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 1 ] ) );
|
Serial.print( int( time[ 1 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 0 ] ) );
|
Serial.print( int( time[ 0 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 4 ] ) );
|
Serial.print( int( time[ 4 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 5 ] ) );
|
Serial.print( int( time[ 5 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 6 ] ) );
|
Serial.print( int( time[ 6 ] ) );
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
#include <CapacitiveSensorDue.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CapacitiveSensorDue cs_13_8 = CapacitiveSensorDue(13,8);
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
Serial.begin(9600);
|
||||||
|
}
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
long total1 = cs_13_8.read(30);
|
||||||
|
Serial.println(total1);
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CapacitiveSensorDue cs_13_8 = CapacitiveSensorDue(13,8);
|
CapacitiveSensorDue cs_13_8 = CapacitiveSensorDue(13,8);
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
const char *foo = "\
|
||||||
|
hello \
|
||||||
|
world\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
|||||||
const char *foo = ;
|
const char *foo =
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -10,3 +12,23 @@ void loop()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,12 +14,18 @@ public class PdePreprocessorTest {
|
|||||||
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("RemoteCallLogger_v1e0.ino").getFile()));
|
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("RemoteCallLogger_v1e0.ino").getFile()));
|
||||||
|
|
||||||
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
||||||
String actualOutput = pdePreprocessor.strip(s);
|
String stippedOutput = pdePreprocessor.strip(s);
|
||||||
String expectedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("RemoteCallLogger_v1e0.stripped.ino").getFile()));
|
String expectedStrippedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("RemoteCallLogger_v1e0.stripped.ino").getFile()));
|
||||||
|
|
||||||
assertEquals(expectedOutput, actualOutput);
|
assertEquals(expectedStrippedOutput, stippedOutput);
|
||||||
|
|
||||||
pdePreprocessor.writePrefix(s);
|
pdePreprocessor.writePrefix(s);
|
||||||
|
|
||||||
|
String actualCodeWithoutComments = pdePreprocessor.program;
|
||||||
|
String expectedCodeWithoutComments = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("RemoteCallLogger_v1e0.nocomments.ino").getFile()));
|
||||||
|
|
||||||
|
assertEquals(expectedCodeWithoutComments, actualCodeWithoutComments);
|
||||||
|
|
||||||
assertEquals(2, pdePreprocessor.getExtraImports().size());
|
assertEquals(2, pdePreprocessor.getExtraImports().size());
|
||||||
assertEquals("SoftwareSerial.h", pdePreprocessor.getExtraImports().get(0));
|
assertEquals("SoftwareSerial.h", pdePreprocessor.getExtraImports().get(0));
|
||||||
assertEquals("Wire.h", pdePreprocessor.getExtraImports().get(1));
|
assertEquals("Wire.h", pdePreprocessor.getExtraImports().get(1));
|
||||||
@ -30,12 +36,18 @@ public class PdePreprocessorTest {
|
|||||||
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("IncludeBetweenMultilineComment.ino").getFile()));
|
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("IncludeBetweenMultilineComment.ino").getFile()));
|
||||||
|
|
||||||
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
||||||
String actualOutput = pdePreprocessor.strip(s);
|
String stippedOutput = pdePreprocessor.strip(s);
|
||||||
String expectedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("IncludeBetweenMultilineComment.stripped.ino").getFile()));
|
String expectedStrippedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("IncludeBetweenMultilineComment.stripped.ino").getFile()));
|
||||||
|
|
||||||
assertEquals(expectedOutput, actualOutput);
|
assertEquals(expectedStrippedOutput, stippedOutput);
|
||||||
|
|
||||||
pdePreprocessor.writePrefix(s);
|
pdePreprocessor.writePrefix(s);
|
||||||
|
|
||||||
|
String actualCodeWithoutComments = pdePreprocessor.program;
|
||||||
|
String expectedCodeWithoutComments = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("IncludeBetweenMultilineComment.nocomments.ino").getFile()));
|
||||||
|
|
||||||
|
assertEquals(expectedCodeWithoutComments, actualCodeWithoutComments);
|
||||||
|
|
||||||
assertEquals(1, pdePreprocessor.getExtraImports().size());
|
assertEquals(1, pdePreprocessor.getExtraImports().size());
|
||||||
assertEquals("CapacitiveSensorDue.h", pdePreprocessor.getExtraImports().get(0));
|
assertEquals("CapacitiveSensorDue.h", pdePreprocessor.getExtraImports().get(0));
|
||||||
}
|
}
|
||||||
@ -45,12 +57,18 @@ public class PdePreprocessorTest {
|
|||||||
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("Baladuino.ino").getFile()));
|
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("Baladuino.ino").getFile()));
|
||||||
|
|
||||||
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
||||||
String actualOutput = pdePreprocessor.strip(s);
|
String stippedOutput = pdePreprocessor.strip(s);
|
||||||
String expectedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("Baladuino.stripped.ino").getFile()));
|
String expectedStrippedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("Baladuino.stripped.ino").getFile()));
|
||||||
|
|
||||||
assertEquals(expectedOutput, actualOutput);
|
assertEquals(expectedStrippedOutput, stippedOutput);
|
||||||
|
|
||||||
pdePreprocessor.writePrefix(s);
|
pdePreprocessor.writePrefix(s);
|
||||||
|
|
||||||
|
String actualCodeWithoutComments = pdePreprocessor.program;
|
||||||
|
String expectedCodeWithoutComments = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("Baladuino.nocomments.ino").getFile()));
|
||||||
|
|
||||||
|
assertEquals(expectedCodeWithoutComments, actualCodeWithoutComments);
|
||||||
|
|
||||||
assertEquals(9, pdePreprocessor.getExtraImports().size());
|
assertEquals(9, pdePreprocessor.getExtraImports().size());
|
||||||
assertEquals("Balanduino.h", pdePreprocessor.getExtraImports().get(0));
|
assertEquals("Balanduino.h", pdePreprocessor.getExtraImports().get(0));
|
||||||
assertEquals("Wire.h", pdePreprocessor.getExtraImports().get(1));
|
assertEquals("Wire.h", pdePreprocessor.getExtraImports().get(1));
|
||||||
@ -68,12 +86,18 @@ public class PdePreprocessorTest {
|
|||||||
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("StringWithCcomment.ino").getFile()));
|
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("StringWithCcomment.ino").getFile()));
|
||||||
|
|
||||||
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
||||||
String actualOutput = pdePreprocessor.strip(s);
|
String stippedOutput = pdePreprocessor.strip(s);
|
||||||
String expectedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("StringWithCcomment.stripped.ino").getFile()));
|
String expectedStrippedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("StringWithCcomment.stripped.ino").getFile()));
|
||||||
|
|
||||||
assertEquals(expectedOutput, actualOutput);
|
assertEquals(expectedStrippedOutput, stippedOutput);
|
||||||
|
|
||||||
pdePreprocessor.writePrefix(s);
|
pdePreprocessor.writePrefix(s);
|
||||||
|
|
||||||
|
String actualCodeWithoutComments = pdePreprocessor.program;
|
||||||
|
String expectedCodeWithoutComments = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("StringWithCcomment.nocomments.ino").getFile()));
|
||||||
|
|
||||||
|
assertEquals(expectedCodeWithoutComments, actualCodeWithoutComments);
|
||||||
|
|
||||||
assertEquals(0, pdePreprocessor.getExtraImports().size());
|
assertEquals(0, pdePreprocessor.getExtraImports().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,12 +106,18 @@ public class PdePreprocessorTest {
|
|||||||
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("CharWithEscapedDoubleQuote.ino").getFile()));
|
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("CharWithEscapedDoubleQuote.ino").getFile()));
|
||||||
|
|
||||||
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
||||||
String actualOutput = pdePreprocessor.strip(s);
|
String stippedOutput = pdePreprocessor.strip(s);
|
||||||
String expectedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("CharWithEscapedDoubleQuote.stripped.ino").getFile()));
|
String expectedStrippedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("CharWithEscapedDoubleQuote.stripped.ino").getFile()));
|
||||||
|
|
||||||
assertEquals(expectedOutput, actualOutput);
|
assertEquals(expectedStrippedOutput, stippedOutput);
|
||||||
|
|
||||||
pdePreprocessor.writePrefix(s);
|
pdePreprocessor.writePrefix(s);
|
||||||
|
|
||||||
|
String actualCodeWithoutComments = pdePreprocessor.program;
|
||||||
|
String expectedCodeWithoutComments = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("CharWithEscapedDoubleQuote.nocomments.ino").getFile()));
|
||||||
|
|
||||||
|
assertEquals(expectedCodeWithoutComments, actualCodeWithoutComments);
|
||||||
|
|
||||||
assertEquals(2, pdePreprocessor.getExtraImports().size());
|
assertEquals(2, pdePreprocessor.getExtraImports().size());
|
||||||
assertEquals("SoftwareSerial.h", pdePreprocessor.getExtraImports().get(0));
|
assertEquals("SoftwareSerial.h", pdePreprocessor.getExtraImports().get(0));
|
||||||
assertEquals("Wire.h", pdePreprocessor.getExtraImports().get(1));
|
assertEquals("Wire.h", pdePreprocessor.getExtraImports().get(1));
|
||||||
@ -98,12 +128,18 @@ public class PdePreprocessorTest {
|
|||||||
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("LineContinuations.ino").getFile()));
|
String s = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("LineContinuations.ino").getFile()));
|
||||||
|
|
||||||
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
PdePreprocessor pdePreprocessor = new PdePreprocessor();
|
||||||
String actualOutput = pdePreprocessor.strip(s);
|
String stippedOutput = pdePreprocessor.strip(s);
|
||||||
String expectedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("LineContinuations.stripped.ino").getFile()));
|
String expectedStrippedOutput = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("LineContinuations.stripped.ino").getFile()));
|
||||||
|
|
||||||
assertEquals(expectedOutput, actualOutput);
|
assertEquals(expectedStrippedOutput, stippedOutput);
|
||||||
|
|
||||||
pdePreprocessor.writePrefix(s);
|
pdePreprocessor.writePrefix(s);
|
||||||
|
|
||||||
|
String actualCodeWithoutComments = pdePreprocessor.program;
|
||||||
|
String expectedCodeWithoutComments = FileUtils.readFileToString(new File(PdePreprocessorTest.class.getResource("LineContinuations.nocomments.ino").getFile()));
|
||||||
|
|
||||||
|
assertEquals(expectedCodeWithoutComments, actualCodeWithoutComments);
|
||||||
|
|
||||||
assertEquals(0, pdePreprocessor.getExtraImports().size());
|
assertEquals(0, pdePreprocessor.getExtraImports().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,344 @@
|
|||||||
|
|
||||||
|
#include <SoftwareSerial.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define DS3231_I2C_ADDRESS 104
|
||||||
|
#define DS3231_TIME_CAL_ADDR 0
|
||||||
|
#define DS3231_ALARM1_ADDR 7
|
||||||
|
#define DS3231_ALARM2_ADDR 11
|
||||||
|
#define DS3231_CONTROL_ADDR 14
|
||||||
|
#define DS3231_STATUS_ADDR 15
|
||||||
|
|
||||||
|
#define DS3231_TEMPERATURE_ADDR 17
|
||||||
|
|
||||||
|
|
||||||
|
SoftwareSerial GPRS( 7, 8 );
|
||||||
|
byte buffer[ 64 ];
|
||||||
|
int count = 0, e = 0, count2 = 0, t = 0, q;
|
||||||
|
char temp, lastCaller[13] = "blank";
|
||||||
|
boolean callIncoming = false, done;
|
||||||
|
|
||||||
|
|
||||||
|
byte time[ 7 ];
|
||||||
|
byte time_A1[ 5 ];
|
||||||
|
byte time_A2[ 4 ];
|
||||||
|
byte received[1];
|
||||||
|
float temperature;
|
||||||
|
|
||||||
|
|
||||||
|
char telescopeNames[6][4];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void setPowerStateTo( int newState )
|
||||||
|
{
|
||||||
|
if( newState != 1 && newState != 0 ) {
|
||||||
|
Serial.print( "Error: Invalid powerstate. Current powerstate = " );
|
||||||
|
Serial.print( getPowerState() );
|
||||||
|
Serial.print( "\n" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if( newState == getPowerState() ) {
|
||||||
|
Serial.print( "Powerstate = " );
|
||||||
|
Serial.print( newState );
|
||||||
|
Serial.print( " remains unchanged.\n" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
powerUpOrDown();
|
||||||
|
Serial.print( "Powerstate changed from " );
|
||||||
|
Serial.print( 1 - newState );
|
||||||
|
Serial.print( " to " );
|
||||||
|
Serial.print( newState );
|
||||||
|
Serial.print( "\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delay( 5000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPowerState()
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
if ( digitalRead(18) == 0 && digitalRead(19) == 0 )
|
||||||
|
ret = 1;
|
||||||
|
else
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void powerUpOrDown()
|
||||||
|
{
|
||||||
|
pinMode( 9, OUTPUT );
|
||||||
|
digitalWrite( 9, LOW );
|
||||||
|
delay( 1000 );
|
||||||
|
digitalWrite( 9, HIGH );
|
||||||
|
delay( 2000 );
|
||||||
|
digitalWrite( 9, LOW );
|
||||||
|
delay( 3000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void clearBufferArray()
|
||||||
|
{
|
||||||
|
for( int i = 0; i < count; i++ )
|
||||||
|
buffer[ i ] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void makeMissedCall( char num[] )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char in[ 18 ] = "ATD";
|
||||||
|
for( i = 3; i <= 14; i++ )
|
||||||
|
in[ i ] = num[ i - 3] ;
|
||||||
|
in[ 15 ] = ';';
|
||||||
|
in[ 16 ] = '\r';
|
||||||
|
in[ 17 ] = '\0';
|
||||||
|
GPRS.write( in );
|
||||||
|
delay( 10000 );
|
||||||
|
GPRS.write( "ATH\r\0" );
|
||||||
|
delay( 1000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void sendTextMessage( char number[], char messg[] )
|
||||||
|
{
|
||||||
|
char temp[ 27 ] = "AT + CMGS = \"";
|
||||||
|
for( q = 0; q < 12; q++ )
|
||||||
|
temp[ q + 13 ] = number[ q ];
|
||||||
|
temp[ 25 ] = '\"';
|
||||||
|
temp[ 26 ] = '\0';
|
||||||
|
|
||||||
|
GPRS.println( "AT+CMGF=1\r" );
|
||||||
|
delay( 1000 );
|
||||||
|
GPRS.println( temp );
|
||||||
|
delay( 1000 );
|
||||||
|
GPRS.println( messg );
|
||||||
|
delay( 1000 );
|
||||||
|
GPRS.println( (char) 26 );
|
||||||
|
delay( 1000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void analise(byte incoming[], int length)
|
||||||
|
{
|
||||||
|
e = 0;
|
||||||
|
done = false;
|
||||||
|
while( e < length && !done){
|
||||||
|
temp = char( incoming[e] );
|
||||||
|
switch( temp ){
|
||||||
|
case 'R':
|
||||||
|
{
|
||||||
|
if( length > e + 3 && !callIncoming ) {
|
||||||
|
if(char( incoming[e + 1] ) == 'I'
|
||||||
|
&& char( incoming[e + 2] ) == 'N'
|
||||||
|
&& char( incoming[e + 3] ) == 'G'){
|
||||||
|
GPRS.write("AT+CLCC\r");
|
||||||
|
delay(500);
|
||||||
|
GPRS.write("ATH\r");
|
||||||
|
callIncoming = true;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '+':
|
||||||
|
{
|
||||||
|
if(char( buffer[ e + 1]) == '2' && length > e + 11 && callIncoming){
|
||||||
|
for(t = 0; t < 12; t++)
|
||||||
|
lastCaller[t] = char( buffer[ e + t ]);
|
||||||
|
lastCaller[12] = '\0';
|
||||||
|
callIncoming = false;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
Serial.println(lastCaller);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
e++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
byte decToBcd( byte b )
|
||||||
|
{
|
||||||
|
return ( b / 10 << 4 ) + b % 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean getBit( byte addr, int pos )
|
||||||
|
{
|
||||||
|
byte temp = getByte( addr );
|
||||||
|
return boolean( (temp >> pos) & B00000001 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBit( byte addr, int pos, boolean newBit )
|
||||||
|
{
|
||||||
|
boolean oldBit = getBit( addr, pos );
|
||||||
|
byte temp = received[ 0 ];
|
||||||
|
if ( oldBit != newBit )
|
||||||
|
{
|
||||||
|
if( newBit )
|
||||||
|
temp += (B00000001 << pos);
|
||||||
|
else
|
||||||
|
temp -= (B00000001 << pos);
|
||||||
|
}
|
||||||
|
setByte( addr, temp );
|
||||||
|
}
|
||||||
|
|
||||||
|
byte getByte( byte addr )
|
||||||
|
{
|
||||||
|
byte temp;
|
||||||
|
if( getBytes( addr, 1) )
|
||||||
|
temp = received[ 0 ];
|
||||||
|
else temp = -1;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean getBytes( byte addr, int amount )
|
||||||
|
{
|
||||||
|
boolean wireWorked = false;
|
||||||
|
Wire.beginTransmission( DS3231_I2C_ADDRESS );
|
||||||
|
Wire.write( addr );
|
||||||
|
Wire.endTransmission();
|
||||||
|
Wire.requestFrom( DS3231_I2C_ADDRESS, amount );
|
||||||
|
if( Wire.available() ){
|
||||||
|
received[amount];
|
||||||
|
for( int i = 0; i < amount; i++){
|
||||||
|
received[ i ] = Wire.read();
|
||||||
|
}
|
||||||
|
wireWorked = true;
|
||||||
|
}
|
||||||
|
return wireWorked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setByte( byte addr, byte newByte )
|
||||||
|
{
|
||||||
|
setBytes( addr, &newByte, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBytes( byte addr, byte newBytes[], int amount )
|
||||||
|
{
|
||||||
|
Wire.beginTransmission( DS3231_I2C_ADDRESS );
|
||||||
|
Wire.write( addr );
|
||||||
|
for( int i = 0; i < amount; i++ )
|
||||||
|
Wire.write( newBytes[ i ] );
|
||||||
|
Wire.endTransmission();
|
||||||
|
}
|
||||||
|
|
||||||
|
void getTime()
|
||||||
|
{
|
||||||
|
if( getBytes( DS3231_TIME_CAL_ADDR, 7) )
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 7; i++)
|
||||||
|
time[ i ] = received[ i ];
|
||||||
|
|
||||||
|
time[ 0 ] = ( ( time[ 0 ] & B01110000 ) >> 4 ) * 10 + ( time[ 0 ] & B00001111 );
|
||||||
|
time[ 1 ] = ( ( time[ 1 ] & B01110000 ) >> 4 ) * 10 + ( time[ 1 ] & B00001111 );
|
||||||
|
time[ 2 ] = ( ( time[ 2 ] & B00110000 ) >> 4 ) * 10 + ( time[ 2 ] & B00001111 );
|
||||||
|
time[ 4 ] = ( ( time[ 4 ] & B00110000 ) >> 4 ) * 10 + ( time[ 4 ] & B00001111 );
|
||||||
|
time[ 5 ] = ( ( time[ 5 ] & B00010000 ) >> 4 ) * 10 + ( time[ 5 ] & B00001111 );
|
||||||
|
time[ 6 ] = ( ( time[ 6 ] & B11110000 ) >> 4 ) * 10 + ( time[ 6 ] & B00001111 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTime( byte newTime[ 7 ] )
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 7; i++)
|
||||||
|
newTime[i] = decToBcd(newTime[i]);
|
||||||
|
setBytes( DS3231_TIME_CAL_ADDR, newTime, 7 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void getRTCTemperature()
|
||||||
|
{
|
||||||
|
|
||||||
|
if( getBytes( DS3231_TEMPERATURE_ADDR, 2 ) )
|
||||||
|
{
|
||||||
|
temperature = ( received[ 0 ] & B01111111 );
|
||||||
|
temperature += ( ( received[ 1 ] >> 6 ) * 0.25 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gprsListen()
|
||||||
|
{
|
||||||
|
if( GPRS.available() ) {
|
||||||
|
while( GPRS.available() ) {
|
||||||
|
buffer[ count++ ] = GPRS.read();
|
||||||
|
if ( count == 64 )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Serial.write( buffer, count );
|
||||||
|
analise( buffer, count );
|
||||||
|
clearBufferArray();
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
if (Serial.available())
|
||||||
|
GPRS.write(Serial.read());
|
||||||
|
}
|
||||||
|
|
||||||
|
void printTime()
|
||||||
|
{
|
||||||
|
getTime();
|
||||||
|
Serial.print( int( time[ 3 ] ) );
|
||||||
|
Serial.print( ' ' );
|
||||||
|
Serial.print( int( time[ 2 ] ) );
|
||||||
|
Serial.print( ':' );
|
||||||
|
Serial.print( int( time[ 1 ] ) );
|
||||||
|
Serial.print( ':' );
|
||||||
|
Serial.print( int( time[ 0 ] ) );
|
||||||
|
Serial.print( ' ' );
|
||||||
|
Serial.print( int( time[ 4 ] ) );
|
||||||
|
Serial.print( '/' );
|
||||||
|
Serial.print( int( time[ 5 ] ) );
|
||||||
|
Serial.print( "/20" );
|
||||||
|
Serial.print( int( time[ 6 ] ) );
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
|
||||||
|
GPRS.begin( 9600 );
|
||||||
|
delay(1000);
|
||||||
|
setPowerStateTo(1);
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
|
||||||
|
Wire.begin();
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
Serial.begin(9600);
|
||||||
|
delay(1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
gprsListen();
|
||||||
|
getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -12,10 +12,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SoftwareSerial GPRS( 7, 8 );
|
SoftwareSerial GPRS( 7, 8 );
|
||||||
byte buffer[ 64 ];
|
byte buffer[ 64 ];
|
||||||
int count = 0, e = 0, count2 = 0, t = 0, q;
|
int count = 0, e = 0, count2 = 0, t = 0, q;
|
||||||
char temp, lastCaller[13] = ;
|
char temp, lastCaller[13] = ;
|
||||||
boolean callIncoming = false, done;
|
boolean callIncoming = false, done;
|
||||||
|
|
||||||
|
|
||||||
@ -34,26 +35,28 @@ char telescopeNames[6][4];
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setPowerStateTo( int newState )
|
void setPowerStateTo( int newState )
|
||||||
{
|
{
|
||||||
if( newState != 1 && newState != 0 ) {
|
if( newState != 1 && newState != 0 ) {
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( getPowerState() );
|
Serial.print( getPowerState() );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( newState == getPowerState() ) {
|
if( newState == getPowerState() ) {
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( newState );
|
Serial.print( newState );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
powerUpOrDown();
|
powerUpOrDown();
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( 1 - newState );
|
Serial.print( 1 - newState );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( newState );
|
Serial.print( newState );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay( 5000 );
|
delay( 5000 );
|
||||||
@ -94,27 +97,27 @@ void clearBufferArray()
|
|||||||
void makeMissedCall( char num[] )
|
void makeMissedCall( char num[] )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char in[ 18 ] = ;
|
char in[ 18 ] = ;
|
||||||
for( i = 3; i <= 14; i++ )
|
for( i = 3; i <= 14; i++ )
|
||||||
in[ i ] = num[ i - 3] ;
|
in[ i ] = num[ i - 3] ;
|
||||||
in[ 15 ] = ;
|
in[ 15 ] = ;
|
||||||
in[ 16 ] = '\r';
|
in[ 16 ] = '\r';
|
||||||
in[ 17 ] = '\0';
|
in[ 17 ] = '\0';
|
||||||
GPRS.write( in );
|
GPRS.write( in );
|
||||||
delay( 10000 );
|
delay( 10000 );
|
||||||
GPRS.write( );
|
GPRS.write( );
|
||||||
delay( 1000 );
|
delay( 1000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendTextMessage( char number[], char messg[] )
|
void sendTextMessage( char number[], char messg[] )
|
||||||
{
|
{
|
||||||
char temp[ 27 ] = ;
|
char temp[ 27 ] = ;
|
||||||
for( q = 0; q < 12; q++ )
|
for( q = 0; q < 12; q++ )
|
||||||
temp[ q + 13 ] = number[ q ];
|
temp[ q + 13 ] = number[ q ];
|
||||||
temp[ 25 ] = ;
|
temp[ 25 ] = ;
|
||||||
temp[ 26 ] = '\0';
|
temp[ 26 ] = '\0';
|
||||||
|
|
||||||
GPRS.println( );
|
GPRS.println( );
|
||||||
delay( 1000 );
|
delay( 1000 );
|
||||||
GPRS.println( temp );
|
GPRS.println( temp );
|
||||||
delay( 1000 );
|
delay( 1000 );
|
||||||
@ -131,24 +134,24 @@ void analise(byte incoming[], int length)
|
|||||||
while( e < length && !done){
|
while( e < length && !done){
|
||||||
temp = char( incoming[e] );
|
temp = char( incoming[e] );
|
||||||
switch( temp ){
|
switch( temp ){
|
||||||
case :
|
case :
|
||||||
{
|
{
|
||||||
if( length > e + 3 && !callIncoming ) {
|
if( length > e + 3 && !callIncoming ) {
|
||||||
if(char( incoming[e + 1] ) ==
|
if(char( incoming[e + 1] ) ==
|
||||||
&& char( incoming[e + 2] ) ==
|
&& char( incoming[e + 2] ) ==
|
||||||
&& char( incoming[e + 3] ) == ){
|
&& char( incoming[e + 3] ) == ){
|
||||||
GPRS.write( );
|
GPRS.write( );
|
||||||
delay(500);
|
delay(500);
|
||||||
GPRS.write( );
|
GPRS.write( );
|
||||||
callIncoming = true;
|
callIncoming = true;
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case :
|
case :
|
||||||
{
|
{
|
||||||
if(char( buffer[ e + 1]) == && length > e + 11 && callIncoming){
|
if(char( buffer[ e + 1]) == && length > e + 11 && callIncoming){
|
||||||
for(t = 0; t < 12; t++)
|
for(t = 0; t < 12; t++)
|
||||||
lastCaller[t] = char( buffer[ e + t ]);
|
lastCaller[t] = char( buffer[ e + t ]);
|
||||||
lastCaller[12] = '\0';
|
lastCaller[12] = '\0';
|
||||||
@ -157,7 +160,7 @@ void analise(byte incoming[], int length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case :
|
case :
|
||||||
Serial.println(lastCaller);
|
Serial.println(lastCaller);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -170,6 +173,10 @@ void analise(byte incoming[], int length)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
byte decToBcd( byte b )
|
byte decToBcd( byte b )
|
||||||
{
|
{
|
||||||
return ( b / 10 << 4 ) + b % 10;
|
return ( b / 10 << 4 ) + b % 10;
|
||||||
@ -289,23 +296,25 @@ void printTime()
|
|||||||
{
|
{
|
||||||
getTime();
|
getTime();
|
||||||
Serial.print( int( time[ 3 ] ) );
|
Serial.print( int( time[ 3 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 2 ] ) );
|
Serial.print( int( time[ 2 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 1 ] ) );
|
Serial.print( int( time[ 1 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 0 ] ) );
|
Serial.print( int( time[ 0 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 4 ] ) );
|
Serial.print( int( time[ 4 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 5 ] ) );
|
Serial.print( int( time[ 5 ] ) );
|
||||||
Serial.print( );
|
Serial.print( );
|
||||||
Serial.print( int( time[ 6 ] ) );
|
Serial.print( int( time[ 6 ] ) );
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
void setup() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Serial.println("Accept: */*");
|
||||||
|
Serial.println("Accept: \" */*");
|
||||||
|
Serial.println("Accept: \\"); // */*");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,9 +2,9 @@ void setup() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Serial.println( );
|
Serial.println( );
|
||||||
Serial.println( );
|
Serial.println( );
|
||||||
Serial.println( );
|
Serial.println( );
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user