Commit de43bc43 authored by Patrick's avatar Patrick

EOD: sendReadings won't match casting

parent cfade43a
......@@ -27,6 +27,9 @@
#define REPORTING_PERIOD 1000UL*60UL // one minute
#define RECORDING_PERIOD 1000UL*10UL // 10 seconds
#define SIG_FIG 3 // how many significant figures should we print for float readings?
#define SHORT_BUFF 20 // choose the json progmem output buffer length
typedef struct {
char type[30]; // reading:type
char unit[5]; // reading:unit
......@@ -63,6 +66,8 @@ private:
// character string of set precision from float/double input
char* ftoa(char *a, double f, int precision);
int8_t buildAMON(PGM_P param, PGM_P quali, PGM_P dtype, PGM_P units, PGM_P perid, t_measurement* the_measurements, uint8_t read_head, uint8_t read_tail);
public:
//teal_mallet_gsm(Client& aClient);
void begin(char* server, char* deviceId, char* entityId = DEFAULT_ENTITY_ID, int port = 80);
......@@ -76,7 +81,8 @@ public:
uint8_t endConnection(); // close that connection
// send the hash and size headers, followed by a single reading
// returns the http status code
int16_t sendOneReading(uint16_t _y, uint8_t _m, uint8_t _d, uint8_t _hh, uint8_t _mm, uint8_t _ss, double _float_reading, t_SensorType _sensor_type, bool send_to_serial = true);
//int16_t sendOneReading(uint16_t _y, uint8_t _m, uint8_t _d, uint8_t _hh, uint8_t _mm, uint8_t _ss, double _float_reading, t_SensorType _sensor_type, bool send_to_serial = true);
int16_t sendReadings(PGM_P param, PGM_P quali, PGM_P dtype, PGM_P units, PGM_P perid, t_measurement* the_measurements, uint8_t read_head, uint8_t read_tail);
};
#endif
// set > 0 to get debug serial output
#define DEBUG_MODE 1
#include <red_peg.h>
red_peg RP;
#include <teal_mallet_gsm.h>
teal_mallet_gsm TM;
// set > 0 to get debug serial output
#define DEBUG_MODE 1
// store each char array for datastream info as progmem strings
const char temp_param[] PROGMEM = "Temperature";
const char temp_quali[] PROGMEM = "1 min";
......@@ -20,6 +20,8 @@ PGM_P const dtype[] PROGMEM = {temp_dtype};
PGM_P const units[] PROGMEM = {temp_units};
PGM_P const perid[] PROGMEM = {temp_perid};
//PGM_P const all_readings PROGMEM = {param, quali, dtype, units, perid};
// operating states
enum state_machine_e {
SLEEP_IDLE,
......@@ -43,7 +45,7 @@ uint8_t readings_tail = 0;
// sends happen after a fixed number of ordinals
t_SensorData last_sending_time;
// how many readings should be collected for sending (<NUM_MMNT)
#define NUM_TO_SEND 2
#define NUM_TO_SEND 5
#if NUM_TO_SEND >= NUM_MMNT
#error "Can't hold all the readings, reduce NUM_TO_SEND below NUM_MMNT"
......@@ -188,9 +190,31 @@ void send_reading() {
Serial.print(F("sending "));
Serial.print((readings_head - readings_tail) % NUM_MMNT);
Serial.println(F(" readings"));
//RP.print_data(send_time);
delay(100);
#endif
#if DEBUG_MODE > 0
Serial.println(F("connecting GPRS..."));
#endif
TM.connectGPRS();
#if DEBUG_MODE > 0
Serial.println(F("startConnection..."));
#endif
TM.startConnection();
#if DEBUG_MODE > 0
Serial.println(F("sendReadings..."));
#endif
TM.sendReadings(param, quali, dtype, units, perid, measurements, readings_head, readings_tail);
#if DEBUG_MODE > 0
Serial.println(F("endConnection..."));
#endif
TM.endConnection();
#if DEBUG_MODE > 0
Serial.println(F("disconnectGPRS..."));
#endif
TM.disconnectGPRS();
#if DEBUG_MODE > 0
Serial.println(F("GPRS powered down."));
#endif
// reset the buffer length
readings_tail = readings_head;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment