static void gpioHandler(uint8_t id);
static void tickHandler(void);
-static bool connected = false;
static int32_t cold = 0;
static int32_t hot = 0;
+static bool connected = false;
+static bool updatable = false;
void main() {
Hal_init();
switch (id) {
case 0:
- Pulsecounter_accept(true);
- Hal_greenLedOn();
- Hal_redLedOn();
- Hal_delay(10);
- Hal_greenLedOff();
- Hal_redLedOff();
+ /* Pulsecounter_accept(true); */
+ updatable = true;
+ if (connected) {
+ Pulsecounter_coldTick_indicate();
+ Pulsecounter_hotTick_indicate();
+ }
+ Hal_greenLedOn();
+ Hal_redLedOn();
+ Hal_delay(10);
+ Hal_greenLedOff();
+ Hal_redLedOff();
Hal_tickStart(15000, tickHandler);
break;
case 1:
Hal_delay(50);
Hal_greenLedOff();
}
- Pulsecounter_accept(false);
+ updatable = false;
+ /* Pulsecounter_accept(false); */
}
/* -------- SCHEMA CALLBACKS -------- */
void Pulsecounter_disconnectHandler(void) {
connected = false;
+ updatable = false;
Hal_greenLedOn();
Hal_delay(100);
Hal_greenLedOff();
Hal_redLedOn();
Hal_delay(100);
Hal_redLedOff();
- Hal_tickStart(15000, tickHandler);
+ /* Hal_tickStart(15000, tickHandler); */
Hal_disconnected();
}
}
void Pulsecounter_coldSet_store(Pulsecounter_coldSet_t* const input) {
- cold = *input;
+ if (updatable)
+ cold = *input;
}
void Pulsecounter_hotSet_store(Pulsecounter_hotSet_t* const input) {
- hot = *input;
+ if (updatable)
+ hot = *input;
}