Espotel / Mbed 2 deprecated LoRaWAN_Serial_port_driven_and_configurable_ELMO_based_on_TxRx_Template

Dependencies:   SX1272lib-PABOOST-HW-Modification mbed

Fork of LoRaWAN_ELMO_TxRx_Template by Espotel

Committer:
KosTee
Date:
Fri Oct 07 11:40:18 2016 +0000
Revision:
7:3d16d6fe3b12
Parent:
6:71b489e70063
Child:
9:c7c39e01bda1
My initial commit of Serial Port driven Elmo.; -small configuration can be done through serial port; -data can be delivered through serial port; -RFO to PABOOST transmit route modification on HW

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mleksio 1:2be292bd43f9 1 /*
Pasi 5:be347c6040c1 2
Pasi 5:be347c6040c1 3 _______ ______ ______ _______ _______ _______ _
Pasi 5:be347c6040c1 4 (_______)/ _____|_____ (_______|_______|_______|_)
Pasi 5:be347c6040c1 5 _____ ( (____ _____) ) _ _ _____ _
Pasi 5:be347c6040c1 6 | ___) \____ \| ____/ | | | | | | ___) | |
Pasi 5:be347c6040c1 7 | |_____ _____) ) | | |___| | | | | |_____| |_____
Pasi 5:be347c6040c1 8 |_______|______/|_| \_____/ |_| |_______)_______)
Pasi 5:be347c6040c1 9
Pasi 5:be347c6040c1 10 (C)2016 Espotel Oy/Etteplan Oyj
Pasi 5:be347c6040c1 11 Description: Main code for LORA radio code template
mleksio 0:c58229885f95 12 License: Revised BSD License, see LICENSE.TXT file include in the project
Pasi 5:be347c6040c1 13 Maintainer: Pasi Pulkkinen
Pasi 5:be347c6040c1 14 Version 1.0
mleksio 0:c58229885f95 15 */
mleksio 0:c58229885f95 16
Pasi 5:be347c6040c1 17 #include "mbed.h"
Pasi 5:be347c6040c1 18 #include "RadioHandler.h"
KosTee 7:3d16d6fe3b12 19 #include "Comissioning.h"
KosTee 7:3d16d6fe3b12 20
mleksio 0:c58229885f95 21
Pasi 5:be347c6040c1 22 // --- Important notes! ---
Pasi 5:be347c6040c1 23 // USE_BAND_868 has been defined in LoRaMac-board.h
Pasi 5:be347c6040c1 24 // OVER_THE_AIR_ACTIVATION at Comissioning.h is enabled
Pasi 5:be347c6040c1 25 // LORAWAN_PUBLIC_NETWORK at Comissioning.h is true
Pasi 5:be347c6040c1 26 // LORAWAN_DEVICE_EUI at Comissioning.h should be unique for each board
Pasi 5:be347c6040c1 27 // LORAWAN_APPLICATION_EUI at Comissioning.h should be unique for each conduit. Copy this to conduit network ID EUI
Pasi 5:be347c6040c1 28 // LORAWAN_APPLICATION_KEY at Comissioning.h ensures secure end to end communication. Copy this to conduit network key
Pasi 5:be347c6040c1 29 // dConduitBugs at LoRaMac.cpp patches a bug in Multitech Conduit Firmware 1.1.2 2016-01-13T09:59:04
mleksio 0:c58229885f95 30
mleksio 1:2be292bd43f9 31 DigitalOut Led1(LED1);
Pasi 5:be347c6040c1 32 static bool ButtonPressed = false;
mleksio 0:c58229885f95 33
KosTee 7:3d16d6fe3b12 34 //ELMO Pushbutton interrupt
Pasi 5:be347c6040c1 35 void ButtonHandler( void )
mleksio 0:c58229885f95 36 {
Pasi 5:be347c6040c1 37 ButtonPressed = true;
mleksio 0:c58229885f95 38 }
mleksio 0:c58229885f95 39
KosTee 7:3d16d6fe3b12 40 //Main application entry point.
mleksio 0:c58229885f95 41 int main( void )
mleksio 0:c58229885f95 42 {
Pasi 5:be347c6040c1 43 char XmitBuffer[100]; // Max 16 bytes in LoRa packet!
KosTee 7:3d16d6fe3b12 44 char data[100];
KosTee 7:3d16d6fe3b12 45 uint16_t index = 0;
Pasi 5:be347c6040c1 46 InterruptIn pushButton(USER_BUTTON);
Pasi 5:be347c6040c1 47 Serial debugPort(SERIAL_TX, SERIAL_RX);
Pasi 5:be347c6040c1 48 debugPort.baud(9600);
Pasi 6:71b489e70063 49 debugPort.printf("\r\n\r\nELMO Debug Screen\r\n");
Pasi 5:be347c6040c1 50 pushButton.rise(&ButtonHandler);
Pasi 5:be347c6040c1 51 pushButton.enable_irq();
Pasi 5:be347c6040c1 52 RadioInit();
mleksio 0:c58229885f95 53
mleksio 0:c58229885f95 54 while( 1 )
mleksio 0:c58229885f95 55 {
KosTee 7:3d16d6fe3b12 56 // Show some debug stuff in case Elmo button is pressed. Request packet transmission
KosTee 7:3d16d6fe3b12 57 if (debugPort.readable()) {
KosTee 7:3d16d6fe3b12 58 data[index]=debugPort.getc();
KosTee 7:3d16d6fe3b12 59
KosTee 7:3d16d6fe3b12 60 if (data[index]=='\n'){
KosTee 7:3d16d6fe3b12 61 debugPort.printf("Your input was: %s\r\n", data);
KosTee 7:3d16d6fe3b12 62 sprintf(XmitBuffer, "%s\r\n", data);
KosTee 7:3d16d6fe3b12 63 Led1 = !Led1;
KosTee 7:3d16d6fe3b12 64 RequestPacketTx(XmitBuffer, false);
KosTee 7:3d16d6fe3b12 65 memset(data,' ', sizeof(data));
KosTee 7:3d16d6fe3b12 66 index=0;
KosTee 7:3d16d6fe3b12 67 }
KosTee 7:3d16d6fe3b12 68 index++;
KosTee 7:3d16d6fe3b12 69 if (index>100) {
KosTee 7:3d16d6fe3b12 70 index=0;
KosTee 7:3d16d6fe3b12 71 }
KosTee 7:3d16d6fe3b12 72 }
KosTee 7:3d16d6fe3b12 73
KosTee 7:3d16d6fe3b12 74
KosTee 7:3d16d6fe3b12 75
KosTee 7:3d16d6fe3b12 76
KosTee 7:3d16d6fe3b12 77
KosTee 7:3d16d6fe3b12 78
Pasi 5:be347c6040c1 79 if (ButtonPressed)
KosTee 7:3d16d6fe3b12 80 {
Pasi 5:be347c6040c1 81 debugPort.printf("\r\nButton was pressed\r\n");
KosTee 7:3d16d6fe3b12 82 RadioSetup();
KosTee 7:3d16d6fe3b12 83 debugPort.printf("JOB DONE\r\n");
Pasi 5:be347c6040c1 84 Led1 = !Led1;
KosTee 7:3d16d6fe3b12 85 //State/Status resets for next time
Pasi 5:be347c6040c1 86 ButtonPressed = false;
Pasi 5:be347c6040c1 87 }
KosTee 7:3d16d6fe3b12 88
Pasi 5:be347c6040c1 89 RadioHandler();
mleksio 0:c58229885f95 90 }
mleksio 1:2be292bd43f9 91 }