summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFlorent Duchon2013-02-14 21:46:02 +0100
committerFlorent Duchon2013-03-24 15:51:18 +0100
commitecd22668d1be07a205fb82e580a08cc3ccc908df (patch)
treec58022f34a2a5cb3dd3fa22143f840a884a40a3a
parentc0abbe9cb71ff0aacc19a86b41662beddfb594c7 (diff)
digital/beacon: rework of main & debug_avr to use common functions
-rw-r--r--digital/beacon/src/debug_avr.c8
-rw-r--r--digital/beacon/src/main_avr.c65
2 files changed, 35 insertions, 38 deletions
diff --git a/digital/beacon/src/debug_avr.c b/digital/beacon/src/debug_avr.c
index 0acb5098..919eb778 100644
--- a/digital/beacon/src/debug_avr.c
+++ b/digital/beacon/src/debug_avr.c
@@ -32,10 +32,10 @@
#include "servo.h"
#include "codewheel.h"
#include "laser.h"
-#include "network.h"
+#include "network_specific.h"
#include "motor.h"
-#include "misc.h"
#include "position.h"
+#include "reset.h"
HAL_UsartDescriptor_t appUsartDescriptor; // USART descriptor (required by stack)
static HAL_AppTimer_t debugTimer; // TIMER descripor used by the DEBUG task
@@ -172,9 +172,7 @@ void debug_task(void)
{
uprintf("------------------------- debug TASK -------------------------\r\n");
uprintf("## Network\r\n");
- uprintf("Status : 0x%x - ",network_get_status());
- uprintf("LQI = %d - ",network_get_lqi());
- uprintf("RSSI = %d - \r\n",network_get_rssi());
+ uprintf("Status : 0x%x - ",network_get_state());
#ifdef TYPE_COOR
uprintf("X = %d --- ",position_get_coord(OPPONENT_1,X));
uprintf("Y = %d --- ",position_get_coord(OPPONENT_1,Y));
diff --git a/digital/beacon/src/main_avr.c b/digital/beacon/src/main_avr.c
index 5a069fc3..3d05b8bb 100644
--- a/digital/beacon/src/main_avr.c
+++ b/digital/beacon/src/main_avr.c
@@ -38,18 +38,11 @@
#include "led.h"
#include "twi.h"
-// Application related parameters
-AppState_t appState = APP_INITIAL_STATE; // application state
-
-#ifdef TYPE_COOR
- DeviceType_t deviceType = DEVICE_TYPE_COORDINATOR;
-#else
- DeviceType_t deviceType = DEVICE_TYPE_END_DEVICE;
-#endif
+static uint8_t uid;
void APL_TaskHandler(void)
{
- switch (appState)
+ switch (network_get_state())
{
case APP_INITIAL_STATE:
@@ -59,40 +52,46 @@ void APL_TaskHandler(void)
/* Init Serial Interface for debug */
initSerialInterface();
- switch(deviceType)
+ uid = get_uid();
+
+ /* Init network */
+ network_init(uid);
+
+ if(get_device_type(uid) == DEVICE_TYPE_COORDINATOR)
+ {
+ position_init_struct();
+ twi_init_specific();
+ trust_decrease_task();
+ start_codewheel_timer_task();
+// debug_start_stop_task();
+ }
+ else
{
- case DEVICE_TYPE_COORDINATOR:
- position_init_struct();
- twi_init_specific();
- trust_decrease_task();
- start_codewheel_timer_task();
- network_init();
-// debug_start_stop_task();
- uprintf("coord initialisation OK !%d\n\r",(int)0);
- break;
- case DEVICE_TYPE_END_DEVICE:
- servo_init();
- codewheel_init();
- laser_init();
- network_init();
-// motor_init();
- uprintf("LOL_%d initialisation OK !\n\r",CS_NWK_ADDR);
-// calibration_start_task();
- motor_stop();
- break;
- default:
- break;
+ servo_init();
+ codewheel_init();
+ laser_init();
+// motor_init();
+// calibration_start_task();
+ motor_stop();
}
- appState = APP_NETWORK_JOIN_REQUEST;
+ network_set_state(APP_NETWORK_JOIN_REQUEST);
break;
case APP_NETWORK_JOIN_REQUEST:
+
+ /* Activate the network status led blink */
+ led_start_blink();
+
+ /* St art network */
network_start();
- appState = APP_NETWORK_JOINING_STATE;
+
+ network_set_state(APP_NETWORK_JOINING_STATE);
+
case APP_NETWORK_JOINING_STATE:
break;
case APP_NETWORK_LEAVING_STATE:
break;
case APP_NETWORK_JOINED_STATE:
+ led_stop_blink();
break;
default:
break;