From 90f5e8958e0f49e2c303abfb9d1f557e28caf78c Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 7 Dec 2014 00:06:27 +0100 Subject: o Implementing getting and setting of values. --- fiken_status_panel.ino | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'fiken_status_panel.ino') diff --git a/fiken_status_panel.ino b/fiken_status_panel.ino index 35b3d40..82c4671 100644 --- a/fiken_status_panel.ino +++ b/fiken_status_panel.ino @@ -1,5 +1,4 @@ #include -#include #include #include @@ -48,8 +47,11 @@ void setup() { delay(1000); #endif - Serial.println(F("setup()")); + setup_rf(); +} +void setup_rf() { + Serial.println(F("setup_rf()")); // Point ACI data structures to the the setup data that the nRFgo studio generated for the nRF8001 if (NULL != services_pipe_type_mapping) { aci_state.aci_setup_info.services_pipe_type_mapping = &services_pipe_type_mapping[0]; @@ -93,7 +95,7 @@ static bool setup_required = false; static void aci_loop() { uint8_t pipe_number; - + // We enter the if statement only when there is a ACI event available to be processed if (lib_aci_event_get(&aci_state, &aci_data)) { aci_evt_t * aci_evt; @@ -302,16 +304,19 @@ void loop() { if (!rf_started) { static int count = 0; count++; + /* if(count == 3) { - Serial.println(F("RF did not start, resetting")); - - asm volatile ("jmp 0"); + Serial.println(F("RF did not start, resetting RF")); + // asm volatile ("jmp 0"); + // lib_aci_pin_reset(); + setup_rf(); count = 0; return; } else { Serial.println(F("waiting for RF to start")); } + */ } else if (!setup_required) { value++; @@ -319,7 +324,7 @@ void loop() { Serial.print(F("value=")); Serial.println(value, HEX); - show_pipes(); + // show_pipes(); } } } @@ -334,7 +339,9 @@ void show_pipes() { } } -bool send_ctrl(uint8_t *data, uint8_t len) { +bool send_ctrl(fsp_res *res) { + uint8_t *data = (uint8_t *)res; + uint8_t len = 2 + res->len; bool status = false; Serial.print(F("send_ctrl, len=")); @@ -343,7 +350,7 @@ bool send_ctrl(uint8_t *data, uint8_t len) { Serial.println(aci_state.data_credit_available, DEC); Serial.print(F("available=")); Serial.println(lib_aci_is_pipe_available(&aci_state, PIPE_FIKEN_STATUS_PANEL_GAUGE_CONTROL_TX), DEC); - + if (lib_aci_is_pipe_available(&aci_state, PIPE_FIKEN_STATUS_PANEL_GAUGE_CONTROL_TX) && aci_state.data_credit_available >= 1) { status = lib_aci_send_data(PIPE_FIKEN_STATUS_PANEL_GAUGE_CONTROL_TX, data, len); -- cgit v1.2.3