Hi, I'm building a little gizmo that logs phone calls, and can send its data to you via SMS. As I'm quite new here, I've encountered quite a few obstacles, but I'm now finally in the last stages of development.
The following problem, I think, is pretty isolated, so I'll put the appropriate code in this message, but I will also attach the whole thing, just in case. Please note: I'm still developing, so it's not that neat yet:
The problem:
I declared these global variables as follows
#include <SoftwareSerial.h> // required to send and receive AT commands from the GPRS Shield
#include <Wire.h> // required for I2C communication with the RTC
#define TELESCOPE_NUMS 0
#define ADMIN_NUMS 1
// pin numbers for RTC
#define DS3231_I2C_ADDRESS 104 // 0x68 // Address for RTC
#define DS3231_TIME_CAL_ADDR 0 // 0x00
#define DS3231_ALARM1_ADDR 7 // 0x07
#define DS3231_ALARM2_ADDR 11 // 0x0B
#define DS3231_CONTROL_ADDR 14 // 0x0E
#define DS3231_STATUS_ADDR 15 // 0x0F
//#define DS3231_AGING_OFFSET_ADDR 16 // 0x10
#define DS3231_TEMPERATURE_ADDR 17 // 0x11
// Declarations for GPRS shield
byte buffer[ 64 ]; // Buffer is used to transfer data from the GPRS line to the serial line
int count = 0, smsMemIndex;
char temp, lastCaller[13] = "blank", lastSmsSender[13] = "blank", smsBody[ 160 ];
boolean callIncoming = false, done = true, smsIncoming = false, smsBodyIncoming = false, airtimeBalanceIncoming = false, firstAirtimeCheck = false;
// Declarations for RTC
byte time[ 7 ]; // second, minute, hour, dow, day, month, year
byte time_A1[ 5 ]; // second_A1, minute_A1, hour_A1, day_A1, DY/DT
byte time_A2[ 4 ]; // minute_A2, hour_A2, day_A2, DY/DT
byte received[1]; // used to catch bytes sent from the clock
float temperature; // clock temperature is updated every 64 s
// Declarations for RemoteCallLogger
int phoneBookSize = 6;
char phoneBook[ 2 ][ 6 ][ 13 ] = {
{
"+27xxxxxxx3",
"+27xxxxxxx0",
"+27xxxxxxx9", // telescope numbers
"+27xxxxxxx4",
"+27xxxxxxx6",
"+27xxxxxxx2" }
,
{
"+27xxxxxxx4",
"+27xxxxxxx4",
"+2xxxxxxxxx5", // admin numbers
"eeeeeeeeeeee",
"eeeeeeeeeeee",
"eeeeeeeeeeee" }
};
char callerNames[ 2 ][ 6 ][ 6 ] = {
{
"TB1",
"TB2",
"TB3", // telescope names
"TB4",
"TB5",
"TB6" }
,
{
"Coert",
"Ma",
"Pa",
"leeg", // admin names
"leeg",
"leeg" }
};
char smsCommands[ 3 ][ 10 ] = {
"REPORT\0", "RESET\0", "DIAL\0" }; // sms command strings
double airtimeBalance = 0.00;
double smsTariff = 0.00; // amount of airtime available, and cost per sms
int noOfCommands = 3, lastCommandIndex = -1;
int callsToday[ 6 ] = { // increments with every missed call from a telescope, resets every 24 hours
0, 0, 0, 0, 0, 0};
int daysDown[ 6 ] = { // increments for each consecutive day there were no wissed call from a telescope, resets when a missed call is made
0, 0, 0, 0, 0, 0};
int callsThisMonth[ 6 ] = { // increments with every missed call from a telescope, resets manually via sms
0, 0, 0, 0, 0, 0 };
int lastMatchIdentifier = 0; // indicates whether the last missed call came from admin or a telescope
int lastMatchIndices[ 2 ] = { // indicates which one of each of the two phonebooks' numbers called last
-1, -1 };
SoftwareSerial GPRS( 7, 8 ); // A softwareSerial line is defined for the GPRS Shield
And this is my setup()
void setup()
{
Serial.begin(9600);
delay(1000);
// GPRS Shield startup code
GPRS.begin( 9600 );
delay(1000);
setPowerStateTo(1);
delay(1000);
// RTC Startup code
Wire.begin();
delay(1000);
for(int i = 0; i < 6; i++)
Serial.println(callsToday[ i ]);
}
And my output:
4865
0
0
0
0
0
Question: I clearly initialized the array callsToday with all 0 values, so why is callsToday[0] = 4865?
And how can I fix it?
There isn't even a function I made that could have screwed with anything!
RemoteCallLoggerV1e0safe.ino (29.6 KB)