Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /* 00002 00003 _______ ______ ______ _______ _______ _______ _ 00004 (_______)/ _____|_____ (_______|_______|_______|_) 00005 _____ ( (____ _____) ) _ _ _____ _ 00006 | ___) \____ \| ____/ | | | | | | ___) | | 00007 | |_____ _____) ) | | |___| | | | | |_____| |_____ 00008 |_______|______/|_| \_____/ |_| |_______)_______) 00009 00010 (C)2016 Espotel Oy/Etteplan Oyj 00011 Description: Main code for LORA radio code template 00012 License: Revised BSD License, see LICENSE.TXT file include in the project 00013 Maintainer: Pasi Pulkkinen 00014 Version 1.0 00015 */ 00016 00017 #include "mbed.h" 00018 #include "RadioHandler.h" 00019 00020 // --- Important notes! --- 00021 // USE_BAND_868 has been defined in LoRaMac-board.h 00022 // OVER_THE_AIR_ACTIVATION at Comissioning.h is enabled 00023 // LORAWAN_PUBLIC_NETWORK at Comissioning.h is true 00024 // LORAWAN_DEVICE_EUI at Comissioning.h should be unique for each board 00025 // LORAWAN_APPLICATION_EUI at Comissioning.h should be unique for each conduit. Copy this to conduit network ID EUI 00026 // LORAWAN_APPLICATION_KEY at Comissioning.h ensures secure end to end communication. Copy this to conduit network key 00027 // dConduitBugs at LoRaMac.cpp patches a bug in Multitech Conduit Firmware 1.1.2 2016-01-13T09:59:04 00028 00029 DigitalOut Led1(LED1); 00030 00031 /* 00032 * True if ELMO button was pressed 00033 */ 00034 static bool ButtonPressed = false; 00035 00036 /* 00037 ELMO Pushbutton interrupt 00038 */ 00039 void ButtonHandler( void ) 00040 { 00041 ButtonPressed = true; 00042 } 00043 00044 /** 00045 * Main application entry point. 00046 */ 00047 int main( void ) 00048 { 00049 char XmitBuffer[100]; // Max 16 bytes in LoRa packet! 00050 uint16_t PacketCount = 0; 00051 InterruptIn pushButton(USER_BUTTON); 00052 Serial debugPort(SERIAL_TX, SERIAL_RX); 00053 00054 debugPort.baud(9600); 00055 00056 debugPort.printf("\r\n\r\nELMO Debug Screen\r\n"); 00057 00058 pushButton.rise(&ButtonHandler); 00059 pushButton.enable_irq(); 00060 00061 RadioInit(); 00062 00063 while( 1 ) 00064 { 00065 // Show some debug stuff in case Elmo button is pressed. Request packet transmission 00066 if (ButtonPressed) 00067 { 00068 debugPort.printf("\r\nButton was pressed\r\n"); 00069 Led1 = !Led1; 00070 sprintf(XmitBuffer, "Elmo calling %d", PacketCount); 00071 RequestPacketTx(XmitBuffer, true); // true = enable periodic transmissions. False = send just one packet 00072 if(PacketCount < 99) 00073 { 00074 PacketCount++; 00075 } 00076 else 00077 { 00078 // Start from 1 when 99 is reached 00079 PacketCount = 1; 00080 } 00081 ButtonPressed = false; 00082 } 00083 00084 RadioHandler(); 00085 } 00086 }
Generated on Tue Jul 12 2022 15:51:16 by
1.7.2