Example implementation of LoraWan specification based on IBM LoraWan in C (ver. 1.5) for Elmo board. Tested only with OTA activation (requires setting AppEui/ DevKey in main.cpp).

Dependencies:   SX1272lib mbed

Committer:
WGorniak
Date:
Wed Oct 07 12:52:36 2015 +0000
Revision:
3:f6bb52cb8d60
Parent:
0:bb3b0e756578
switched from mbed-src to mbed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WGorniak 0:bb3b0e756578 1 /*******************************************************************************
WGorniak 0:bb3b0e756578 2 * Copyright (c) 2014-2015 IBM Corporation.
WGorniak 0:bb3b0e756578 3 * All rights reserved. This program and the accompanying materials
WGorniak 0:bb3b0e756578 4 * are made available under the terms of the Eclipse Public License v1.0
WGorniak 0:bb3b0e756578 5 * which accompanies this distribution, and is available at
WGorniak 0:bb3b0e756578 6 * http://www.eclipse.org/legal/epl-v10.html
WGorniak 0:bb3b0e756578 7 *
WGorniak 0:bb3b0e756578 8 * Contributors:
WGorniak 0:bb3b0e756578 9 * IBM Zurich Research Lab - initial API, implementation and documentation
WGorniak 0:bb3b0e756578 10 * Semtech Apps Team - Adapted for MBED
WGorniak 0:bb3b0e756578 11 *******************************************************************************/
WGorniak 0:bb3b0e756578 12 #include <stdio.h>
WGorniak 0:bb3b0e756578 13 #include "lmic.h"
WGorniak 0:bb3b0e756578 14 #include "debug.h"
WGorniak 0:bb3b0e756578 15
WGorniak 0:bb3b0e756578 16 void debug_init () {
WGorniak 0:bb3b0e756578 17 // print banner
WGorniak 0:bb3b0e756578 18 debug_str((const unsigned char*)"\r\n============== DEBUG STARTED ==============\r\n");
WGorniak 0:bb3b0e756578 19 }
WGorniak 0:bb3b0e756578 20
WGorniak 0:bb3b0e756578 21 void debug_led (u1_t val) {
WGorniak 0:bb3b0e756578 22 debug_val( (const unsigned char*)"LED = ", val );
WGorniak 0:bb3b0e756578 23 }
WGorniak 0:bb3b0e756578 24
WGorniak 0:bb3b0e756578 25 void debug_char (u1_t c) {
WGorniak 0:bb3b0e756578 26 fprintf(stderr, "%c", c );
WGorniak 0:bb3b0e756578 27 }
WGorniak 0:bb3b0e756578 28
WGorniak 0:bb3b0e756578 29 void debug_hex (u1_t b) {
WGorniak 0:bb3b0e756578 30 fprintf(stderr, "%02X", b );
WGorniak 0:bb3b0e756578 31 }
WGorniak 0:bb3b0e756578 32
WGorniak 0:bb3b0e756578 33 void debug_buf (const u1_t* buf, u2_t len) {
WGorniak 0:bb3b0e756578 34 while( len-- ) {
WGorniak 0:bb3b0e756578 35 debug_hex( *buf++ );
WGorniak 0:bb3b0e756578 36 debug_char( ' ' );
WGorniak 0:bb3b0e756578 37 }
WGorniak 0:bb3b0e756578 38 debug_char( '\r' );
WGorniak 0:bb3b0e756578 39 debug_char( '\n' );
WGorniak 0:bb3b0e756578 40 }
WGorniak 0:bb3b0e756578 41
WGorniak 0:bb3b0e756578 42 void debug_uint (u4_t v) {
WGorniak 0:bb3b0e756578 43 for( s1_t n = 24; n >= 0; n -= 8 ) {
WGorniak 0:bb3b0e756578 44 debug_hex( v >> n );
WGorniak 0:bb3b0e756578 45 }
WGorniak 0:bb3b0e756578 46 }
WGorniak 0:bb3b0e756578 47
WGorniak 0:bb3b0e756578 48 void debug_str (const u1_t* str) {
WGorniak 0:bb3b0e756578 49 while( *str ) {
WGorniak 0:bb3b0e756578 50 debug_char( *str++ );
WGorniak 0:bb3b0e756578 51 }
WGorniak 0:bb3b0e756578 52 }
WGorniak 0:bb3b0e756578 53
WGorniak 0:bb3b0e756578 54 void debug_val (const u1_t* label, u4_t val) {
WGorniak 0:bb3b0e756578 55 debug_str( label );
WGorniak 0:bb3b0e756578 56 debug_uint( val );
WGorniak 0:bb3b0e756578 57 debug_char( '\r' );
WGorniak 0:bb3b0e756578 58 debug_char( '\n' );
WGorniak 0:bb3b0e756578 59 }
WGorniak 0:bb3b0e756578 60
WGorniak 0:bb3b0e756578 61 void debug_event (int ev) {
WGorniak 0:bb3b0e756578 62 static const char* evnames[] = {
WGorniak 0:bb3b0e756578 63 [0] = NULL,
WGorniak 0:bb3b0e756578 64 [EV_SCAN_TIMEOUT] = "SCAN_TIMEOUT",
WGorniak 0:bb3b0e756578 65 [EV_BEACON_FOUND] = "BEACON_FOUND",
WGorniak 0:bb3b0e756578 66 [EV_BEACON_MISSED] = "BEACON_MISSED",
WGorniak 0:bb3b0e756578 67 [EV_BEACON_TRACKED] = "BEACON_TRACKED",
WGorniak 0:bb3b0e756578 68 [EV_JOINING] = "JOINING",
WGorniak 0:bb3b0e756578 69 [EV_JOINED] = "JOINED",
WGorniak 0:bb3b0e756578 70 [EV_RFU1] = "RFU1",
WGorniak 0:bb3b0e756578 71 [EV_JOIN_FAILED] = "JOIN_FAILED",
WGorniak 0:bb3b0e756578 72 [EV_REJOIN_FAILED] = "REJOIN_FAILED",
WGorniak 0:bb3b0e756578 73 [EV_TXCOMPLETE] = "TXCOMPLETE",
WGorniak 0:bb3b0e756578 74 [EV_LOST_TSYNC] = "LOST_TSYNC",
WGorniak 0:bb3b0e756578 75 [EV_RESET] = "RESET",
WGorniak 0:bb3b0e756578 76 [EV_RXCOMPLETE] = "RXCOMPLETE",
WGorniak 0:bb3b0e756578 77 [EV_LINK_DEAD] = "LINK_DEAD",
WGorniak 0:bb3b0e756578 78 [EV_LINK_ALIVE] = "LINK_ALIVE",
WGorniak 0:bb3b0e756578 79 };
WGorniak 0:bb3b0e756578 80 debug_str((const unsigned char*)evnames[ev]);
WGorniak 0:bb3b0e756578 81 debug_char('\r');
WGorniak 0:bb3b0e756578 82 debug_char('\n');
WGorniak 0:bb3b0e756578 83 }