From afd694f05178c22b4f71f65143c4647ce912d980 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 26 Jul 2015 18:06:29 +0200 Subject: o Much improved Debug class. - Inlining all definitions to make everything shorter and easier to read. - More const so even more can be inlined. o Adding some support for ATTiny85, still more work to be done. o Removing two unused battery characteristics. o Dynamically adding battery and temperature characteristics if their pipes are defined. --- trygvisio_soil_moisture.ino | 49 +++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) (limited to 'trygvisio_soil_moisture.ino') diff --git a/trygvisio_soil_moisture.ino b/trygvisio_soil_moisture.ino index c09f091..8ecc907 100644 --- a/trygvisio_soil_moisture.ino +++ b/trygvisio_soil_moisture.ino @@ -1,8 +1,12 @@ // See config.h on how to configure the sketch #include "config-check.h" +#ifdef USE_LOW_POWER_MODE #include +#endif +#ifdef PERSISTENT_CONFIGURATION_SUPPORT #include +#endif #include #include #include @@ -12,6 +16,14 @@ #include "app.h" #include "Debug.h" +#ifdef PIPE_SOIL_MOISTURE_INTERMEDIATE_TEMPERATURE_SET +#define USE_TEMPERATURE +#endif + +#ifdef PIPE_BATTERY_BATTERY_LEVEL_SET +#define USE_BATTERY +#endif + static void setup_rf(); static void show_pipes(); @@ -57,7 +69,7 @@ void setup() { CLKPR = 0; #endif - debug.begin((unsigned int)115200); + debug.begin(115200); #if WAIT_FOR_SERIAL_BEFORE_STARING // Wait until the serial port is available (useful only for the Leonardo) @@ -188,8 +200,9 @@ static void aci_loop() { // (uint8_t *)&(aci_evt->params.cmd_rsp.params.get_device_version), // sizeof(aci_evt_cmd_rsp_params_get_device_version_t)); } +#ifdef USE_TEMPERATURE if (aci_evt->params.cmd_rsp.cmd_opcode == ACI_CMD_GET_TEMPERATURE) { - debug.print("aci_evt->params.cmd_rsp.params.get_temperature="); + debug.print(F("aci_evt->params.cmd_rsp.params.get_temperature=")); debug.print(aci_evt->params.cmd_rsp.params.get_temperature.temperature_value, DEC); debug.println(); @@ -225,6 +238,7 @@ static void aci_loop() { (uint8_t *) &temperature_measurement, sizeof(temperature_measurement)); } +#endif // USE_TEMPERATURE break; case ACI_EVT_CONNECTED: @@ -238,8 +252,9 @@ static void aci_loop() { // This will trigger a ACI_CMD_GET_DEVICE_VERSION. lib_aci_device_version(); +#ifdef USE_TEMPERATURE lib_aci_get_temperature(); - +#endif sm_on_connect(); break; @@ -420,31 +435,8 @@ static void show_pipes() { debug.println(x, DEC); } } -/* - boolean tx_moisture(sm_res *res) { - static const uint8_t pipe = PIPE_SOIL_MOISTURE_SOIL_MOISTURE_LEVEL_TX; - uint8_t *data = (uint8_t *)res; - uint8_t len = 2 + res->len; - boolean status = false; - - boolean available = lib_aci_is_pipe_available(&aci_state, pipe); - - debug.print(F("tx_soil_moisture, len=")); - debug.println(len, DEC); - debug.print(F("aci_state.data_credit_available=")); - debug.println(aci_state.data_credit_available, DEC); - debug.print(F("available=")); - debug.println(available, DEC); - - if (available && aci_state.data_credit_available > 0) { - status = lib_aci_send_data(pipe, data, len); - if (status) { - aci_state.data_credit_available--; - } - } - return status; - } - */ + +#ifdef USE_BATTERY void notify_battery_level(uint8_t value) { static const uint8_t pipe = PIPE_BATTERY_BATTERY_LEVEL_SET; @@ -455,6 +447,7 @@ void notify_battery_level(uint8_t value) { lib_aci_send_data(pipe, &value, 1); } +#endif // USE_BATTERY void notify_soil_moisture(const struct sm_res &res, uint8_t body_len) { -- cgit v1.2.3