Projeto teste do Programa de integracao com biblioteca SGAM_MDW !! Aqui visa um usuario que usa o projeto implementado para a placa NUCLEO F429ZI
Dependencies: sgam_mdw sgam_mdw_NUCLEOF429ZI_impl Cayenne-LPP
main.cpp@14:8ec6bdff6f67, 2019-06-26 (annotated)
- Committer:
- AndersonIctus
- Date:
- Wed Jun 26 23:47:35 2019 -0300
- Revision:
- 14:8ec6bdff6f67
- Parent:
- 12:2109a8bc8848
- Child:
- 16:2b3715dd0f13
- Exemplo de comunicacao e json de configuracao
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AndersonIctus | 12:2109a8bc8848 | 1 | // #define DEBUG_SGAM |
AndersonIctus | 0:5d86284beacd | 2 | |
AndersonIctus | 12:2109a8bc8848 | 3 | #include "mbed.h" |
AndersonIctus | 7:cabeef41022a | 4 | #include "sgam_mdw.h" |
AndersonIctus | 10:cb7a807b5225 | 5 | |
AndersonIctus | 7:cabeef41022a | 6 | #include "ControlImpl.h" |
AndersonIctus | 7:cabeef41022a | 7 | #include "Gyroscope.h" |
AndersonIctus | 14:8ec6bdff6f67 | 8 | #include "LoRAWanComm.h" |
AndersonIctus | 7:cabeef41022a | 9 | |
AndersonIctus | 7:cabeef41022a | 10 | ControlImpl ctrl; |
AndersonIctus | 7:cabeef41022a | 11 | |
AndersonIctus | 12:2109a8bc8848 | 12 | #define D_LOG(args...) printf(args) |
AndersonIctus | 12:2109a8bc8848 | 13 | |
AndersonIctus | 14:8ec6bdff6f67 | 14 | // LORA WAN CONFIGS |
AndersonIctus | 14:8ec6bdff6f67 | 15 | #define TX_INTERVAL 10000 |
AndersonIctus | 14:8ec6bdff6f67 | 16 | #define MBED_CONF_LORA_APP_PORT 15 //15 |
AndersonIctus | 14:8ec6bdff6f67 | 17 | |
AndersonIctus | 14:8ec6bdff6f67 | 18 | static uint8_t LORAWAN_DEV_EUI[] = { 0x00, 0x1C, 0x73, 0x4A, 0x55, 0x89, 0xAE, 0xC6 }; |
AndersonIctus | 14:8ec6bdff6f67 | 19 | static uint8_t LORAWAN_APP_EUI[] = { 0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x01, 0xD0, 0x2F }; |
AndersonIctus | 14:8ec6bdff6f67 | 20 | static uint8_t LORAWAN_APP_KEY[] = { 0x75, 0xC6, 0xF2, 0xFB, 0xEE, 0xA9, 0x82, 0x6C, 0xA0, 0xBD, 0xB9, 0x0F, 0xC9, 0xEC, 0xF7, 0x10 }; |
AndersonIctus | 14:8ec6bdff6f67 | 21 | |
AndersonIctus | 14:8ec6bdff6f67 | 22 | static uint32_t DEVADDR_1 = 0x2601177B; |
AndersonIctus | 14:8ec6bdff6f67 | 23 | static uint8_t NWKSKEY_1[] = { 0x2A, 0xE9, 0x3F, 0x5E, 0x4C, 0x25, 0xDC, 0x34, 0x16, 0x82, 0x1B, 0xD1, 0x1A, 0x7F, 0xD0, 0xF6 }; |
AndersonIctus | 14:8ec6bdff6f67 | 24 | static uint8_t APPSKEY_1[] = { 0x78, 0x59, 0x61, 0xBB, 0x6B, 0xB7, 0xDE, 0x57, 0x80, 0x74, 0xAF, 0xED, 0x10, 0xD7, 0x47, 0x18 }; |
AndersonIctus | 14:8ec6bdff6f67 | 25 | |
AndersonIctus | 0:5d86284beacd | 26 | int main() { |
AndersonIctus | 12:2109a8bc8848 | 27 | D_LOG("=============== INICIO ===============\r\n"); |
AndersonIctus | 7:cabeef41022a | 28 | |
AndersonIctus | 7:cabeef41022a | 29 | Control* control = ctrl.getControler(); |
AndersonIctus | 12:2109a8bc8848 | 30 | control->initialize(); |
AndersonIctus | 7:cabeef41022a | 31 | |
AndersonIctus | 14:8ec6bdff6f67 | 32 | Communication<LoraData>* comm = (Communication<LoraData>*)control->getCommunication("LoRAWAN"); |
AndersonIctus | 14:8ec6bdff6f67 | 33 | |
AndersonIctus | 14:8ec6bdff6f67 | 34 | // 1 - configura os callbacks do loran WAN e inicializa !! |
AndersonIctus | 14:8ec6bdff6f67 | 35 | LoraData* data = new LoraData(); |
AndersonIctus | 14:8ec6bdff6f67 | 36 | comm->initialize(data); |
AndersonIctus | 10:cb7a807b5225 | 37 | |
AndersonIctus | 14:8ec6bdff6f67 | 38 | |
AndersonIctus | 14:8ec6bdff6f67 | 39 | // 2 - Tentar conectar !! |
AndersonIctus | 14:8ec6bdff6f67 | 40 | if(comm->connect() != TRUE) { |
AndersonIctus | 14:8ec6bdff6f67 | 41 | D_LOG("Não pode connectar ao lora wan !"); |
AndersonIctus | 14:8ec6bdff6f67 | 42 | return -1; |
AndersonIctus | 14:8ec6bdff6f67 | 43 | } |
AndersonIctus | 7:cabeef41022a | 44 | |
AndersonIctus | 14:8ec6bdff6f67 | 45 | |
AndersonIctus | 14:8ec6bdff6f67 | 46 | |
AndersonIctus | 14:8ec6bdff6f67 | 47 | // int count = 0; |
AndersonIctus | 7:cabeef41022a | 48 | |
AndersonIctus | 14:8ec6bdff6f67 | 49 | // Sensor<float>* temp = (Sensor<float>*) control->getSensor("Temperature"); |
AndersonIctus | 14:8ec6bdff6f67 | 50 | // // Sensor<GyroscopeData>* gyro = (Sensor<GyroscopeData>*) control->getSensor("Gyroscope"); |
AndersonIctus | 14:8ec6bdff6f67 | 51 | |
AndersonIctus | 14:8ec6bdff6f67 | 52 | // while( count++ < 10) { |
AndersonIctus | 14:8ec6bdff6f67 | 53 | // float* f = temp->getValue(); |
AndersonIctus | 14:8ec6bdff6f67 | 54 | // D_LOG("Temperatura => %f \r\n", *f); |
AndersonIctus | 14:8ec6bdff6f67 | 55 | |
AndersonIctus | 14:8ec6bdff6f67 | 56 | // wait(1.5); |
AndersonIctus | 14:8ec6bdff6f67 | 57 | // } |
AndersonIctus | 7:cabeef41022a | 58 | |
AndersonIctus | 10:cb7a807b5225 | 59 | control->finalize(); |
AndersonIctus | 12:2109a8bc8848 | 60 | D_LOG("=============== FINAL ===============\r\n"); |
AndersonIctus | 7:cabeef41022a | 61 | return 1; |
AndersonIctus | 0:5d86284beacd | 62 | } |