From 80646adbb985215b34aac9b73402752a29cd2ef8 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 18 Jan 2015 23:10:07 +0100 Subject: o Making the device blink when connected. --- trygvisio_soil_moisture.ino | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'trygvisio_soil_moisture.ino') diff --git a/trygvisio_soil_moisture.ino b/trygvisio_soil_moisture.ino index f908e4a..a8a7d1f 100644 --- a/trygvisio_soil_moisture.ino +++ b/trygvisio_soil_moisture.ino @@ -97,7 +97,7 @@ static void setup_rf() { // The second parameter is for turning debug printing on for the ACI Commands and Events so they be printed on the Serial lib_aci_init(&aci_state, false); Serial.println(F("lib_aci_init done")); - + sm_setup(); } @@ -184,7 +184,7 @@ static void aci_loop() { // Get the device version of the nRF8001 and store it in the Hardware Revision String. // This will trigger a ACI_CMD_GET_DEVICE_VERSION. lib_aci_device_version(); - + sm_on_connect(); break; @@ -202,6 +202,8 @@ static void aci_loop() { lib_aci_connect(180/* in seconds */, 0x0100 /* advertising interval 100ms*/); Serial.println(F("Advertising started")); + + sm_on_disconnect(); break; case ACI_EVT_DATA_RECEIVED: @@ -209,7 +211,7 @@ static void aci_loop() { Serial.print(F("ACI_EVT_DATA_RECEIVED: pipe_number=")); Serial.println(pipe_number, DEC); - + if (pipe_number == pipe_rx) { on_soil_moisture_ctrl(aci_evt->params.data_received.rx_data.aci_data, aci_evt->len); } @@ -312,11 +314,10 @@ void loop() { count++; if (!reset_attempted) { - if (count == 3) { reset_attempted = true; Serial.println(F("RF did not start, resetting RF")); - + // asm volatile ("jmp 0"); // lib_aci_pin_reset(); setup_rf(); @@ -375,7 +376,7 @@ void notify_battery_level(uint8_t value) { Serial.print(F("notify_battery_level, value=")); Serial.println(value, DEC); - + value = value % 101; lib_aci_send_data(pipe, &value, 1); -- cgit v1.2.3