Version FC

Dependencies:   DmTftLibrary eeprom SX1280Lib filesystem mbed

Fork of MSNV2-Terminal_V1-5 by Francis CHATAIN

Committer:
patrick_duc
Date:
Thu Oct 04 07:00:43 2018 +0000
Revision:
33:6ae45cba7958
Parent:
20:b0281e8a375a
Child:
38:9b43b2415093
Child:
41:5a436163dddf
Modifications faites de concert avec Hoel lors de son passage ? Toulouse

Who changed what in which revision?

UserRevisionLine numberNew contents of line
patrick_duc 20:b0281e8a375a 1 /*
patrick_duc 20:b0281e8a375a 2 * MISNet
patrick_duc 20:b0281e8a375a 3 *
patrick_duc 20:b0281e8a375a 4 * DataBase: Contient les données du terminal
patrick_duc 20:b0281e8a375a 5 *
patrick_duc 20:b0281e8a375a 6 * Created on: August 17, 2018 Author: Francis CHATAIN
patrick_duc 20:b0281e8a375a 7 *
patrick_duc 20:b0281e8a375a 8 */
patrick_duc 20:b0281e8a375a 9
patrick_duc 20:b0281e8a375a 10 #ifndef __DATABASE_HPP__
patrick_duc 20:b0281e8a375a 11 #define __DATABASE_HPP__
patrick_duc 20:b0281e8a375a 12
patrick_duc 20:b0281e8a375a 13 #include "Context.h"
patrick_duc 20:b0281e8a375a 14
patrick_duc 20:b0281e8a375a 15 #ifndef TEST_ENVIRONMENT
patrick_duc 20:b0281e8a375a 16 #include "mbed.h"
patrick_duc 20:b0281e8a375a 17 #include "sx1280-hal.h"
patrick_duc 20:b0281e8a375a 18 #include <string>
patrick_duc 20:b0281e8a375a 19 #include <list>
patrick_duc 20:b0281e8a375a 20 #endif
patrick_duc 20:b0281e8a375a 21
patrick_duc 20:b0281e8a375a 22 #include "main.h"
patrick_duc 20:b0281e8a375a 23 #include "Service.hpp"
patrick_duc 20:b0281e8a375a 24 #include "Component.hpp"
patrick_duc 20:b0281e8a375a 25 #include "CandidateComponent.hpp"
patrick_duc 20:b0281e8a375a 26 #include "Payload.hpp"
patrick_duc 20:b0281e8a375a 27
patrick_duc 20:b0281e8a375a 28
patrick_duc 20:b0281e8a375a 29 // ======================================= Define
patrick_duc 20:b0281e8a375a 30
patrick_duc 20:b0281e8a375a 31 #define MODE_STO 0x0000 // P2P Smart Tool
patrick_duc 20:b0281e8a375a 32 #define MODE_GEN 0x4000 // P2P Generic
patrick_duc 20:b0281e8a375a 33 #define MODE_IOT 0x8000 // STAR IoT mode
patrick_duc 20:b0281e8a375a 34 #define MODE_BCA 0xC000 // STAR Broacast mode
patrick_duc 20:b0281e8a375a 35
patrick_duc 20:b0281e8a375a 36
patrick_duc 20:b0281e8a375a 37 namespace misnet {
patrick_duc 20:b0281e8a375a 38 class DataBase;
patrick_duc 20:b0281e8a375a 39 }
patrick_duc 20:b0281e8a375a 40
patrick_duc 20:b0281e8a375a 41 // ======================================= Class content
patrick_duc 20:b0281e8a375a 42 class misnet::DataBase
patrick_duc 20:b0281e8a375a 43 {
patrick_duc 33:6ae45cba7958 44 enum TERMINAL_TYPE {
patrick_duc 33:6ae45cba7958 45 SMART_TOOL = 0, // Smart Tool
patrick_duc 33:6ae45cba7958 46 GENERIC = 1, // Generic tool
patrick_duc 33:6ae45cba7958 47 NORMAL_IOT = 2, // Normal IOT (the terminal is attached to a gateway)
patrick_duc 33:6ae45cba7958 48 BROADCAST_IOT = 3 // Broadcast IOT (the terminal is not attached to a gateway)
patrick_duc 33:6ae45cba7958 49 };
patrick_duc 20:b0281e8a375a 50
patrick_duc 20:b0281e8a375a 51 public:
patrick_duc 20:b0281e8a375a 52 DataBase ();
patrick_duc 20:b0281e8a375a 53 ~DataBase ();
patrick_duc 20:b0281e8a375a 54
patrick_duc 20:b0281e8a375a 55 void init () ;
patrick_duc 20:b0281e8a375a 56
patrick_duc 33:6ae45cba7958 57 TERMINAL_TYPE getTerminalType() {
patrick_duc 33:6ae45cba7958 58 return this->_terminal_type;
patrick_duc 33:6ae45cba7958 59 }
patrick_duc 33:6ae45cba7958 60
patrick_duc 20:b0281e8a375a 61 short getNbService (Service::DEVICE_TYPE cdt); // return the number of declared channels for the payload
patrick_duc 20:b0281e8a375a 62 Service::DEVICE_TYPE getServiceType (short NumService) ; // Get Service type
patrick_duc 20:b0281e8a375a 63
patrick_duc 20:b0281e8a375a 64
patrick_duc 20:b0281e8a375a 65 void SetSensorState (short channel_rank, Service::STATE sensorState) ; // Set Sensor State (Disable/Enable)
patrick_duc 20:b0281e8a375a 66 Service::STATE GetSensorState (short channel_rank) ; // Get Sensor State (Disable/Enable) know if the device shall requested
patrick_duc 20:b0281e8a375a 67
patrick_duc 20:b0281e8a375a 68 void SetSensorValue (uint8_t value) ; // Set Sensor Value + compute value before storage
patrick_duc 20:b0281e8a375a 69 uint8_t GetSensorMessage (short channel_rank) ; // Get Sensor Message (False si no change no threahold, response formated)
patrick_duc 20:b0281e8a375a 70
patrick_duc 20:b0281e8a375a 71
patrick_duc 20:b0281e8a375a 72 short getNbActuator () ;
patrick_duc 20:b0281e8a375a 73 void SetActuatorState () ;
patrick_duc 20:b0281e8a375a 74 Service::STATE GetActuatorState (short actuator_rank) ;
patrick_duc 20:b0281e8a375a 75
patrick_duc 20:b0281e8a375a 76
patrick_duc 20:b0281e8a375a 77 // =============================================================== Radio Parameter (getter/setter)
patrick_duc 20:b0281e8a375a 78
patrick_duc 20:b0281e8a375a 79
patrick_duc 20:b0281e8a375a 80 #ifndef TEST_ENVIRONMENT
patrick_duc 20:b0281e8a375a 81 void getRadioParameter ( uint32_t &rfFrequency,
patrick_duc 20:b0281e8a375a 82 RadioLoRaBandwidths_t &loraBw,
patrick_duc 20:b0281e8a375a 83 RadioLoRaSpreadingFactors_t &loraSf ,
patrick_duc 20:b0281e8a375a 84 int8_t &txOutputPower,
patrick_duc 20:b0281e8a375a 85 uint8_t &bufferSizeMax,
patrick_duc 20:b0281e8a375a 86 int16_t &terminal_heartbeat_period,
patrick_duc 20:b0281e8a375a 87 int16_t &payload_heartbeat_period);
patrick_duc 20:b0281e8a375a 88
patrick_duc 20:b0281e8a375a 89 void setRadioParameter ( uint32_t rfFrequency,
patrick_duc 20:b0281e8a375a 90 RadioLoRaBandwidths_t loraBw,
patrick_duc 20:b0281e8a375a 91 RadioLoRaSpreadingFactors_t loraSf ,
patrick_duc 20:b0281e8a375a 92 int8_t txOutputPower,
patrick_duc 20:b0281e8a375a 93 uint8_t ufferSizeMax,
patrick_duc 20:b0281e8a375a 94 int16_t terminal_heartbeat_period,
patrick_duc 20:b0281e8a375a 95 int16_t payload_heartbeat_period);
patrick_duc 20:b0281e8a375a 96 #endif
patrick_duc 20:b0281e8a375a 97
patrick_duc 20:b0281e8a375a 98 void setPayload(Payload* payload) {
patrick_duc 20:b0281e8a375a 99 this->_payload = payload;
patrick_duc 20:b0281e8a375a 100 }
patrick_duc 20:b0281e8a375a 101
patrick_duc 20:b0281e8a375a 102 Payload* getPayload() {
patrick_duc 20:b0281e8a375a 103 return this->_payload;
patrick_duc 20:b0281e8a375a 104 }
patrick_duc 20:b0281e8a375a 105
patrick_duc 20:b0281e8a375a 106 std::list<CandidateComponent*> * getCandidateSensorsList();
patrick_duc 20:b0281e8a375a 107
patrick_duc 20:b0281e8a375a 108
patrick_duc 20:b0281e8a375a 109 // Private variables /methods
patrick_duc 20:b0281e8a375a 110 private:
patrick_duc 20:b0281e8a375a 111 #ifndef TEST_ENVIRONMENT
patrick_duc 20:b0281e8a375a 112 uint32_t _rf_frequency ; // HzNominal frequency
patrick_duc 20:b0281e8a375a 113 RadioLoRaBandwidths_t _lora_bw ; /* 200; 400; 800; 1600 */
patrick_duc 20:b0281e8a375a 114 RadioLoRaSpreadingFactors_t _lora_sf ; /* SF5; SF6=; SF7; SF8 ; SF9; SF10; SF11 ; SF12 */
patrick_duc 20:b0281e8a375a 115 int8_t _tx_output_power ; /* Output power in dBm [-18..+13] dBm */
patrick_duc 20:b0281e8a375a 116 uint8_t _buffer_size_max ; /* Payload size max */
patrick_duc 20:b0281e8a375a 117 #endif
patrick_duc 20:b0281e8a375a 118 uint16_t _terminal_heartbeat_period; // Terminal heartbeat period
patrick_duc 20:b0281e8a375a 119 uint16_t _payload_heartbeat_period; // Sensors' scan period
patrick_duc 20:b0281e8a375a 120 misnet::Payload* _payload ; // Payload definition
patrick_duc 20:b0281e8a375a 121
patrick_duc 20:b0281e8a375a 122
patrick_duc 20:b0281e8a375a 123 // Protected variable /method
patrick_duc 20:b0281e8a375a 124 protected:
patrick_duc 20:b0281e8a375a 125
patrick_duc 20:b0281e8a375a 126 } ;
patrick_duc 20:b0281e8a375a 127
patrick_duc 20:b0281e8a375a 128 #endif // __DATABASE_HPP__