PIR + LoRa
Dependencies: BLE_API LMiC SX1276Lib mbed nRF51822 nrf51_rtc
Fork of BLE_PhysicalWeb by
debug.cpp
00001 /******************************************************************************* 00002 * Copyright (c) 2014-2015 IBM Corporation. 00003 * All rights reserved. This program and the accompanying materials 00004 * are made available under the terms of the Eclipse Public License v1.0 00005 * which accompanies this distribution, and is available at 00006 * http://www.eclipse.org/legal/epl-v10.html 00007 * 00008 * Contributors: 00009 * IBM Zurich Research Lab - initial API, implementation and documentation 00010 * Semtech Apps Team - Adapted for MBED 00011 *******************************************************************************/ 00012 #include <stdio.h> 00013 #include "mbed.h" 00014 #include "lmic.h" 00015 #include "debug.h" 00016 00017 Serial pc2(USBTX, USBRX); // tx, rx 00018 00019 void debug_init () { 00020 // print banner 00021 debug_str("\r\n============== DEBUG STARTED ==============\r\n"); 00022 } 00023 00024 void debug_led (u1_t val) { 00025 debug_val( "LED = ", val ); 00026 } 00027 00028 void debug_char (u1_t c) { 00029 pc2.printf("%c", c ); 00030 } 00031 00032 void debug_hex (u1_t b) { 00033 pc2.printf("%02X", b ); 00034 } 00035 00036 void debug_buf (const u1_t* buf, u2_t len) { 00037 while( len-- ) { 00038 debug_hex( *buf++ ); 00039 debug_char( ' ' ); 00040 } 00041 debug_char( '\r' ); 00042 debug_char( '\n' ); 00043 } 00044 00045 void debug_uint (u4_t v) { 00046 for( s1_t n = 24; n >= 0; n -= 8 ) { 00047 debug_hex( v >> n ); 00048 } 00049 } 00050 00051 void debug_str (const u1_t* str) { 00052 while( *str ) { 00053 debug_char( *str++ ); 00054 } 00055 } 00056 00057 void debug_val (const u1_t* label, u4_t val) { 00058 debug_str( label ); 00059 debug_uint( val ); 00060 debug_char( '\r' ); 00061 debug_char( '\n' ); 00062 } 00063 00064 void debug_event (int ev) { 00065 static const u1_t* evnames[] = { 00066 [EV_SCAN_TIMEOUT] = "SCAN_TIMEOUT", 00067 [EV_BEACON_FOUND] = "BEACON_FOUND", 00068 [EV_BEACON_MISSED] = "BEACON_MISSED", 00069 [EV_BEACON_TRACKED] = "BEACON_TRACKED", 00070 [EV_JOINING] = "JOINING", 00071 [EV_JOINED] = "JOINED", 00072 [EV_RFU1] = "RFU1", 00073 [EV_JOIN_FAILED] = "JOIN_FAILED", 00074 [EV_REJOIN_FAILED] = "REJOIN_FAILED", 00075 [EV_TXCOMPLETE] = "TXCOMPLETE", 00076 [EV_LOST_TSYNC] = "LOST_TSYNC", 00077 [EV_RESET] = "RESET", 00078 [EV_RXCOMPLETE] = "RXCOMPLETE", 00079 [EV_LINK_DEAD] = "LINK_DEAD", 00080 [EV_LINK_ALIVE] = "LINK_ALIVE", 00081 }; 00082 debug_str(evnames[ev]); 00083 debug_char('\r'); 00084 debug_char('\n'); 00085 }
Generated on Tue Jul 12 2022 12:34:27 by 1.7.2