Version FC
Dependencies: DmTftLibrary eeprom SX1280Lib filesystem mbed
Fork of MSNV2-Terminal_V1-5 by
ExtMemory.cpp
- Committer:
- patrick_duc
- Date:
- 2018-09-02
- Revision:
- 20:b0281e8a375a
- Parent:
- 19:4b147d8f9164
- Child:
- 21:8524d815c587
File content as of revision 20:b0281e8a375a:
/* * MISNet * * ExtMemory: Accès EEPROM * * Created on: August 17, 2018 Author: Francis CHATAIN * */ // ===================================== Includes #include "ExtMemory.hpp" #include "Service.hpp" #include "Component.hpp" #include "Payload.hpp" using namespace misnet; // ===================================== Methods of class void ExtMemory::read (DataBase* dataBase) { // read eeprom and initialize database //(Example) DEBUG( "*** EXTMEM Reading external memory ***\n"); #ifndef TEST_ENVIRONMENT dataBase->setRadioParameter ( (uint32_t)2400000000UL, LORA_BW_0400, LORA_SF7, (int8_t)-18, (uint8_t)100, (uint16_t)2000, (uint16_t)2000) ; #endif /* ****************************************************************************** In this example, the terminal holds 3 components : * the first is a BME280 component, containing 3 sensors : * a presence sensor (IPSO code = 102) * a temperature sensor (IPSO code = 103) * a humidity sensor (IPSO code = 104) * the second is a LSM303A component, containing 2 sensors : * an accelerometer sensor (IPSO code = 113) * a barometer sensor (IPSO code = 115) * the third one is a DS18B20 containing an actuator (audio, IPCO code = 139). The terminal is of type IOT_PAYLOAD_3 (why not ?). ****************************************************************************** */ /* ************************************************************************************** Pour Hoel et Francis, de la part de Patrick : je me doute bien que les composants BME280, LSM303A et DS18B20 ne contiennent pas les devices décrits ici, c'est juste un exemple ;-) ************************************************************************************** */ Service::ACCESS_PIN access_pins[6] = { 1, 2, 3, 4, 5, 6 }; // Construction du premier service du premier composant // ---------------------------------------------------- Service* service1 = new Service(Service::SENSOR, 102, Service::ENABLED, Service::UART_, Service::IRQ_, Service::BY_VALUE, access_pins, 300, Service::MESSAGE, Service::IO, "Premier service du composant BME280 sur cette payload"); // Construction du deuxieme service du premier composant // ----------------------------------------------------- Service* service2 = new Service(Service::SENSOR, 103, Service::ENABLED, Service::UART_, Service::IRQ_, Service::BY_VALUE, access_pins, 120, Service::MESSAGE, Service::IO, "Deuxieme service du composant BME280 sur cette payload"); // Construction du troisieme service du premier composant // ------------------------------------------------------ Service* service3 = new Service(Service::SENSOR, 104, Service::DISABLED, Service::UART_, Service::IRQ_, Service::BY_VALUE, access_pins, 30, Service::MESSAGE, Service::IO, "Troisieme service du composant BME280 sur cette payload"); // Construction du premier composant // --------------------------------- std::vector<Service*> services = std::vector<Service*>(); services.push_back(service1); services.push_back(service2); services.push_back(service3); Component* component1 = new Component(Component::BME280, services); // Construction du premier service du deuxieme composant // ----------------------------------------------------- Service* service4 = new Service(Service::SENSOR, 113, Service::ENABLED, Service::UART_, Service::IRQ_, Service::BY_VALUE, access_pins, 60, Service::MESSAGE, Service::IO, "Premier service du composant LSM303A sur cette payload"); // Construction du deuxieme service du deuxieme composant // ------------------------------------------------------ Service* service5 = new Service(Service::SENSOR, 115, Service::DISABLED, Service::UART_, Service::IRQ_, Service::BY_VALUE, access_pins, 80, Service::MESSAGE, Service::IO, "Deuxieme service du composant LSM303A sur cette payload"); // Construction du deuxieme composant // ---------------------------------- services.clear(); services.push_back(service4); services.push_back(service5); Component* component2 = new Component(Component::LSM303A, services); // Construction du premier service du troisieme composant // ------------------------------------------------------ Service* service6 = new Service(Service::ACTUATOR, 139, Service::ENABLED, Service::UART_, Service::IRQ_, Service::BY_VALUE, access_pins, 50, Service::MESSAGE, Service::IO, "Premier service du composant DS18B20 sur cette payload"); // Construction du troisieme composant // ----------------------------------- services.clear(); services.push_back(service6); Component* component3 = new Component(Component::DS18B20, services); // Construction de la payload // -------------------------- std::vector<Component*> components = std::vector<Component*>(); components.push_back(component1); components.push_back(component2); components.push_back(component3); Payload * payload = new Payload(Payload::IOT_PAYLOAD_3, components, 10000); /* Payload sampling information, based on this example --------------------------------------------------- - Payload base period is 10000, which means 176 microseconds * 10000, i.e. 1.76 seconds - Service 1 : subsample rate is 300, so the service sampling period is 528 seconds - Service 2 : subsample rate is 120, so the service sampling period is 211.2 seconds - Service 3 : subsample rate is 30, so the service sampling period is 52.8 seconds - Service 4 : subsample rate is 60, so the service sampling period is 105.6 seconds - Service 5 : subsample rate is 80, so the service sampling period is 140.8 seconds - Service 6 : subsample rate is 50, so the service sampling period is 35.2 seconds - GCD (Greatest Common Divisor) of its services is 10, so the payload will be awaken every 17.6 seconds. */ // Enregistrement de la payload dans la database // --------------------------------------------- dataBase->setPayload(payload); }