ACKme
/
wiconnect-test-console
Test serial console demonstrating various API functions of WiConnect library.
util/log/log.cpp@22:26420b641605, 2014-10-23 (annotated)
- Committer:
- dan_ackme
- Date:
- Thu Oct 23 15:17:15 2014 -0700
- Revision:
- 22:26420b641605
- Parent:
- 12:3dd3a1be40c1
Join command fixes and added 'update' command
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan_ackme | 12:3dd3a1be40c1 | 1 | /** |
dan_ackme | 12:3dd3a1be40c1 | 2 | * ACKme WiConnect Host Library is licensed under the BSD licence: |
dan_ackme | 12:3dd3a1be40c1 | 3 | * |
dan_ackme | 12:3dd3a1be40c1 | 4 | * Copyright (c)2014 ACKme Networks. |
dan_ackme | 12:3dd3a1be40c1 | 5 | * All rights reserved. |
dan_ackme | 12:3dd3a1be40c1 | 6 | * |
dan_ackme | 12:3dd3a1be40c1 | 7 | * Redistribution and use in source and binary forms, with or without modification, |
dan_ackme | 12:3dd3a1be40c1 | 8 | * are permitted provided that the following conditions are met: |
dan_ackme | 12:3dd3a1be40c1 | 9 | * |
dan_ackme | 12:3dd3a1be40c1 | 10 | * 1. Redistributions of source code must retain the above copyright notice, |
dan_ackme | 12:3dd3a1be40c1 | 11 | * this list of conditions and the following disclaimer. |
dan_ackme | 12:3dd3a1be40c1 | 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
dan_ackme | 12:3dd3a1be40c1 | 13 | * this list of conditions and the following disclaimer in the documentation |
dan_ackme | 12:3dd3a1be40c1 | 14 | * and/or other materials provided with the distribution. |
dan_ackme | 12:3dd3a1be40c1 | 15 | * 3. The name of the author may not be used to endorse or promote products |
dan_ackme | 12:3dd3a1be40c1 | 16 | * derived from this software without specific prior written permission. |
dan_ackme | 12:3dd3a1be40c1 | 17 | * |
dan_ackme | 12:3dd3a1be40c1 | 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED |
dan_ackme | 12:3dd3a1be40c1 | 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
dan_ackme | 12:3dd3a1be40c1 | 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
dan_ackme | 12:3dd3a1be40c1 | 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
dan_ackme | 12:3dd3a1be40c1 | 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
dan_ackme | 12:3dd3a1be40c1 | 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
dan_ackme | 12:3dd3a1be40c1 | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
dan_ackme | 12:3dd3a1be40c1 | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
dan_ackme | 12:3dd3a1be40c1 | 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
dan_ackme | 12:3dd3a1be40c1 | 27 | * OF SUCH DAMAGE. |
dan_ackme | 0:836c9a6383e0 | 28 | */ |
dan_ackme | 0:836c9a6383e0 | 29 | #include <stdio.h> |
dan_ackme | 0:836c9a6383e0 | 30 | #include <stdarg.h> |
dan_ackme | 0:836c9a6383e0 | 31 | |
dan_ackme | 0:836c9a6383e0 | 32 | |
dan_ackme | 0:836c9a6383e0 | 33 | #include "Wiconnect.h" |
dan_ackme | 0:836c9a6383e0 | 34 | #include "log.h" |
dan_ackme | 0:836c9a6383e0 | 35 | #include "util/CommandProcessor/CommandProcessor.h" |
dan_ackme | 0:836c9a6383e0 | 36 | |
dan_ackme | 0:836c9a6383e0 | 37 | |
dan_ackme | 0:836c9a6383e0 | 38 | extern ConsoleSerial consoleSerial; |
dan_ackme | 0:836c9a6383e0 | 39 | |
dan_ackme | 0:836c9a6383e0 | 40 | |
dan_ackme | 0:836c9a6383e0 | 41 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 42 | void logDebug(const char *msg, ...) |
dan_ackme | 0:836c9a6383e0 | 43 | { |
dan_ackme | 0:836c9a6383e0 | 44 | va_list args; |
dan_ackme | 0:836c9a6383e0 | 45 | |
dan_ackme | 0:836c9a6383e0 | 46 | consoleSerial.write("[DEBUG] "); |
dan_ackme | 0:836c9a6383e0 | 47 | va_start(args, msg); |
dan_ackme | 0:836c9a6383e0 | 48 | consoleSerial.vprintf(msg, args); |
dan_ackme | 0:836c9a6383e0 | 49 | va_end(args); |
dan_ackme | 0:836c9a6383e0 | 50 | } |
dan_ackme | 0:836c9a6383e0 | 51 | |
dan_ackme | 0:836c9a6383e0 | 52 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 53 | void logInfo(const char *msg, ...) |
dan_ackme | 0:836c9a6383e0 | 54 | { |
dan_ackme | 0:836c9a6383e0 | 55 | va_list args; |
dan_ackme | 0:836c9a6383e0 | 56 | consoleSerial.write("[INFO] "); |
dan_ackme | 0:836c9a6383e0 | 57 | va_start(args, msg); |
dan_ackme | 0:836c9a6383e0 | 58 | consoleSerial.vprintf(msg, args); |
dan_ackme | 0:836c9a6383e0 | 59 | va_end(args); |
dan_ackme | 0:836c9a6383e0 | 60 | } |
dan_ackme | 0:836c9a6383e0 | 61 | |
dan_ackme | 0:836c9a6383e0 | 62 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 63 | void logWrite(const void *data, int size) |
dan_ackme | 0:836c9a6383e0 | 64 | { |
dan_ackme | 0:836c9a6383e0 | 65 | consoleSerial.write(data, size); |
dan_ackme | 0:836c9a6383e0 | 66 | } |
dan_ackme | 0:836c9a6383e0 | 67 | |
dan_ackme | 0:836c9a6383e0 | 68 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 69 | void logInfoWriteStr(const char *msg, const char *s) |
dan_ackme | 0:836c9a6383e0 | 70 | { |
dan_ackme | 0:836c9a6383e0 | 71 | consoleSerial.printf("[INFO] %s", msg); |
dan_ackme | 0:836c9a6383e0 | 72 | consoleSerial.write(s); |
dan_ackme | 0:836c9a6383e0 | 73 | consoleSerial.write("\r\n"); |
dan_ackme | 0:836c9a6383e0 | 74 | } |
dan_ackme | 0:836c9a6383e0 | 75 | |
dan_ackme | 0:836c9a6383e0 | 76 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 77 | void logError(const char *msg, ...) |
dan_ackme | 0:836c9a6383e0 | 78 | { |
dan_ackme | 0:836c9a6383e0 | 79 | va_list args; |
dan_ackme | 0:836c9a6383e0 | 80 | consoleSerial.write("[ERROR] "); |
dan_ackme | 0:836c9a6383e0 | 81 | va_start(args, msg); |
dan_ackme | 0:836c9a6383e0 | 82 | consoleSerial.vprintf(msg, args); |
dan_ackme | 0:836c9a6383e0 | 83 | va_end(args); |
dan_ackme | 0:836c9a6383e0 | 84 | } |
dan_ackme | 0:836c9a6383e0 | 85 | |
dan_ackme | 0:836c9a6383e0 | 86 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 87 | void logWiconnectError(WiconnectResult result, const char *msg, ...) |
dan_ackme | 0:836c9a6383e0 | 88 | { |
dan_ackme | 22:26420b641605 | 89 | va_list args; |
dan_ackme | 22:26420b641605 | 90 | |
dan_ackme | 22:26420b641605 | 91 | consoleSerial.printf("[ERROR] (%d) %s. ", result, Wiconnect::getWiconnectResultStr(result)); |
dan_ackme | 22:26420b641605 | 92 | va_start(args, msg); |
dan_ackme | 22:26420b641605 | 93 | consoleSerial.vprintf(msg, args); |
dan_ackme | 22:26420b641605 | 94 | va_end(args); |
dan_ackme | 22:26420b641605 | 95 | consoleSerial.write("\r\n"); |
dan_ackme | 0:836c9a6383e0 | 96 | } |
dan_ackme | 0:836c9a6383e0 | 97 |