Gestion du Traffic Adaptatif- Code du mbed coordinateur
Dependencies: XBeeLib mbed mbed-rtos EthernetInterface
Diff: main.cpp
- Revision:
- 21:5adfcfd83e95
- Parent:
- 20:2a94c9200119
- Child:
- 22:c3b22291cb9d
--- a/main.cpp Sun Nov 11 21:56:42 2018 +0000 +++ b/main.cpp Sun Nov 18 16:40:36 2018 +0000 @@ -1,17 +1,8 @@ -/** - * Copyright (c) 2015 Digi International Inc., - * All rights not expressly granted are reserved. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 - * ======================================================================= - */ +//SQLUT #include "mbed.h" #include "XBeeLib.h" +#include "rtos.h" #if defined(ENABLE_LOGGING) #include "DigiLoggerMbedSerial.h" using namespace DigiLog; @@ -35,6 +26,14 @@ //vert DigitalOut feux_gauche_vert(p16); +//Nombre de voitures au feu +int nombreDeVoiture = 0; +DigitalIn boutonPlus(p24); +DigitalIn boutonMoins(p23); +Thread t_nbVoiture; + +Thread t_receive; + //liste des message a envoyer rouge et vert seulement pour le coordinateur ////////////////////////// ///// @@ -68,8 +67,19 @@ log_serial->printf("\r\n"); } +void nbVoiture() { + while(1) { + if(boutonPlus){ + nombreDeVoiture++; + } + if(boutonMoins && nombreDeVoiture>0){ + nombreDeVoiture--; + } + printf("Nombre de voitures : %d \r\n", nombreDeVoiture); + } +} -static void send_explicit_data_to_remote_node(XBeeZB& xbee, const RemoteXBeeZB& RemoteDevice,int message){ +/*static void send_explicit_data_to_remote_node(XBeeZB& xbee, const RemoteXBeeZB& RemoteDevice,int message){ //const uint8_t data_len = strlen(data); const uint8_t dstEP = 0xE8; @@ -103,7 +113,7 @@ } -} +}*/ int main() @@ -134,8 +144,10 @@ log_serial->printf("."); } log_serial->printf("OK\r\n"); - - int i =0; + + t_nbVoiture.start(nbVoiture); + t_receive.start(receive_cb); + const RemoteXBeeZB remoteDevice = RemoteXBeeZB(REMOTE_NODE_ADDR64); while (true) {