implementação do sgam_mdw baseado na placa NUCLEO FZ429ZI para ser testada
Dependencies: MPU6050 Grove_temperature
Revision 17:8789ab4067a6, committed 2019-07-20
- Comitter:
- AndersonIctus
- Date:
- Sat Jul 20 14:02:50 2019 -0300
- Parent:
- 16:ec2fa31517eb
- Commit message:
- - Inclusao do GPS FAKE
Changed in this revision
--- a/ControlImpl.cpp Sat Jul 20 11:01:19 2019 -0300 +++ b/ControlImpl.cpp Sat Jul 20 14:02:50 2019 -0300 @@ -4,6 +4,7 @@ #include "ControlImpl.h" #include "Temperature.h" #include "Gyroscope.h" +#include "GPS.h" #include "LoRaWanComm.h" ControlImpl::ControlImpl() { @@ -14,6 +15,7 @@ // Incluindo os Sensores includeSensor( (Sensor<void*>*) new Temperature(A1) ); includeSensor( (Sensor<void*>*) new Gyroscope(i2c) ); + includeSensor( (Sensor<void*>*) new GPS() ); // Incluindo Comunicacoes includeCommunication( (Communication<void*>*)new LoRaWanComm("") );
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sensor/gps/GPS.cpp Sat Jul 20 14:02:50 2019 -0300 @@ -0,0 +1,39 @@ +#include "sgam_mdw.h" +#include "mbed.h" + +#include "GPS.h" +#include <stdlib.h> + +// FAKE DATA !! +static float LATITUDE[] = { -3.729082, -3.729681, -3.737186, -3.749637, -3.744262, -3.727500, -3.734366, -3.716379, -3.708595, -3.716506 }; +static float LONGITUDE[] = { -38.527864, -38.522864, -38.506823, -38.518743, -38.493957, -38.485239, -38.502019, -38.593300, -38.557838, -38.565691 }; +static float METERS[] = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 }; + +GPS::GPS() { + D_LOG("GPS Initialized !!\r\n"); + value = new GPSData(); +} + +GPS::~GPS() { + value->~GPSData(); +} + +int GPS::initialize() { D_LOG("INITIALIZE %s! \r\n", this->getName() ); return 1; } +int GPS::finalize() { D_LOG("FINALIZE %s! \r\n", this->getName() ); return 1; } + +// Pega valorews FAKE para latitude, longitude e metros !! +void GPS::getLocation(GPSData* data) { + int pos = rand() % 10; // pega um valor randomico !! + data->latitude = LATITUDE[pos]; + data->longitude = LONGITUDE[pos]; + data->meters = METERS[pos]; +} + +GPSData* GPS::getValue() { + getLocation(value); + return value; +} + +const char* GPS::getName() { + return "GPS"; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sensor/gps/GPS.h Sat Jul 20 14:02:50 2019 -0300 @@ -0,0 +1,32 @@ +#ifndef SGAM_MDW_SENSOR_GPS_H +#define SGAM_MDW_SENSOR_GPS_H + +#include "sgam_mdw.h" +#include "mbed.h" + +class GPSData { +public: + float longitude; + float latitude; + float meters; + + GPSData(){ } + ~GPSData(){ } +}; + +// FAKE Gps to send fake values ! +class GPS: Sensor<GPSData> { +public: + GPS(); + virtual ~GPS(); + + virtual int initialize(); + virtual int finalize(); + + virtual GPSData* getValue(); + virtual const char* getName(); + +private: + void getLocation(GPSData* data); +}; +#endif
--- a/sgam_mdw_impl.h Sat Jul 20 11:01:19 2019 -0300 +++ b/sgam_mdw_impl.h Sat Jul 20 14:02:50 2019 -0300 @@ -3,7 +3,10 @@ #define SGAM_MDW_IMPL_H #include "ControlImpl.h" + +#include "Temperature.h" #include "Gyroscope.h" +#include "GPS.h" #include "LoRaWanComm.h" #include "LoRaWANInterface.h"