void nRF8001MeteoStation::onACIEvent(aci_evt_t* p_event) { switch(p_event->evt_opcode) { // if an ACI_EVT_DATA_ACK occurs, it searches the pipe, which has return a ACK case ACI_EVT_DATA_ACK: if (p_event->params.data_ack.pipe_number == PIPE_METEO_STATION_TEMPERATURE_MEASUREMENT_TX_ACK) { // sets to False; a new sending could take place in case of a new temperature (!= m_last_temp) m_ack_temperature_measure_pending = false; TraceInfo(F("ACK for temperature measurement received\n")); } else if (p_event->params.data_ack.pipe_number == PIPE_METEO_STATION_HUMIDITY_MEASUREMENT_TX_ACK) { m_ack_humidity_measure_pending = false; TraceInfo(F("ACK for humidity measurement received\n")); } /*else if (p_event->params.data_ack.pipe_number == PIPE_METEO_STATION_PRESSURE_MEASUREMENT_TX_ACK) { m_ack_pressure_measure_pending = false; TraceInfo(F("ACK for pressure measurement received\n")); }*/ notif.notify(YELLOW, 1, false); break; // if a paired device is disconnected, it sets the stored values to the biggest FLOAT value // and the ACKs to false. It avoids problems if the device want to connect again case ACI_EVT_DISCONNECTED: m_last_temp = FLT_MAX; m_last_hum = FLT_MAX; //m_last_pres = INT_MAX; m_ack_temperature_measure_pending = false; m_ack_humidity_measure_pending = false; //m_ack_pressure_measure_pending = false; break; // if a device asks for a connection case ACI_EVT_CONNECTED: notif.notify(WHITE, 1, false); break; // if the paired device sends data, it retrieves the data into the min or the max temperature (thermostat) case ACI_EVT_DATA_RECEIVED: if (p_event->params.data_received.rx_data.pipe_number == PIPE_METEO_STATION_THERMOSTAT_TEMPERATUR_RX) { for(uint8_t i = 0; i < p_event->len - 2; i++) { m_uart_buffer[i] = convert_hex_to_uint(p_event->params.data_received.rx_data.aci_data[i]); } if (m_thermo_temp == THERMO_TEMP_MIN) { m_thermo_temp_min = m_uart_buffer[0] * 10 + m_uart_buffer[1]; TraceInfoFormat(F("Thermostat min temperature set to : %u\n"), m_thermo_temp_min); } else if (m_thermo_temp == THERMO_TEMP_MAX) { m_thermo_temp_max = m_uart_buffer[0] * 10 + m_uart_buffer[1]; TraceInfoFormat(F("Thermostat max temperature set to : %u\n"), m_thermo_temp_max); } } notif.notify(WHITE, 1, false); break; } }
void Heater::SetMinTemperature(float p_temperature) { m_min_temperature = p_temperature; UpdateState(); TraceInfoFormat(F("Sets minimal temperature to : %u\n"), (uint16_t)m_min_temperature); //Serial.print("Sets minimal temperature to : "); //Serial.println(m_min_temperature); }
void Heater::SetCurrentTemperature(float p_temperature) { m_current_temperature = p_temperature; UpdateState(); //Serial.print("Current temperature : "); //Serial.println(m_current_temperature); TraceInfoFormat(F("Current temperature : %u\n"), (uint16_t)m_current_temperature); }
bool Moisture::isDry(void) { uint16_t moistureValue = analogRead(m_sensor_pin); TraceInfoFormat(F("Moisture level : %u [0 - 1023]\n"), moistureValue); if (moistureValue > MOISTURE_DRY_LEVEL) { return true; } return false; }