@@ -34,97 +34,99 @@
#include <avr/pgmspace.h>
#include "serial.h"
#include "serparser.h"
#include "slavesensors.h"
#include "sensordata.h"
#include "led.h"
#include "looptime.h"
#include "logger.h"
// !!! Remember to update the ENUM in slavesensors.h when changing things here
// Label lookup table
// Make sure there are never more labels than there are MAX_NUM_SENSORS!
const char label_0[] PROGMEM = "BoardTemp";
const char label_1[] PROGMEM = "Heater";
const char label_2[] PROGMEM = "VBatt";
const char label_3[] PROGMEM = "AirTemp";
const char label_4[] PROGMEM = "Light";
const char label_5[] PROGMEM = "Humidity";
const char label_6[] PROGMEM = "Pressure";
const char label_7[] PROGMEM = "Altitude";
const char label_8[] PROGMEM = "Radiation";
const char *const labelLookup[] PROGMEM =
{
label_0,
label_1,
label_2,
label_3,
label_4,
label_5,
label_6,
label_7,
label_8
};
char labelBuffer[15]; // Size to length of label
char* slavesensors_getLabel(uint8_t sensorID)
if(sensorID < 9)
strncpy_P(labelBuffer,(char*)pgm_read_word(&(labelLookup[sensorID])),15);
return labelBuffer;
}
else
return NULL;
// Print out the sensor ID if there is no label in the lookup table
snprintf(labelBuffer, 15,"%u",sensorID);
uint8_t currentSlave = 0;
uint8_t currentSlaveSensor = 0;
bool requesting = false;
//#define DEBUG_NETWORKSCAN
//#define DEBUG_GETSLAVEDATA
char* bufPtr = 0x00;
static char slaveAddressLow[MAX_NUM_SLAVES][9];
static char slaveAddressHigh[MAX_NUM_SLAVES][9];
static char slaveNames[MAX_NUM_SLAVES][15];
static char loggerAddressLow[9];
static char loggerAddressHigh[9];
uint8_t nodeCount = 0;
bool dataReady = false;
void slavesensors_setup()
loggerAddressLow[0] = 0x00;
loggerAddressHigh[0] = 0x00;
char* slavesensors_slavename(uint8_t id)
return slaveNames[id];
void slavesensors_network_scan()
serial0_ioff();
int atOK;
#ifdef DEBUG_OUTPUT
serial0_sendString("Beginning network scan...\r\n\r\n");
#endif
_delay_ms(500); // xbee warmup
_delay_ms(200); // xbee warmup
wdt_reset();
Status change: