Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
internal/common.h@2:05e20e184e7e, 2014-08-11 (annotated)
- Committer:
- dan_ackme
- Date:
- Mon Aug 11 03:38:27 2014 -0700
- Revision:
- 2:05e20e184e7e
- Parent:
- 1:6ec9998427ad
- Child:
- 3:2dc2592bae5e
fixed more warnings
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan_ackme | 0:ea85c4bb5e1f | 1 | /* |
dan_ackme | 0:ea85c4bb5e1f | 2 | * Copyright 2014, ACKme Networks |
dan_ackme | 0:ea85c4bb5e1f | 3 | * All Rights Reserved. |
dan_ackme | 0:ea85c4bb5e1f | 4 | * |
dan_ackme | 0:ea85c4bb5e1f | 5 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; |
dan_ackme | 0:ea85c4bb5e1f | 6 | * the contents of this file may not be disclosed to third parties, copied |
dan_ackme | 0:ea85c4bb5e1f | 7 | * or duplicated in any form, in whole or in part, without the prior |
dan_ackme | 0:ea85c4bb5e1f | 8 | * written permission of ACKme Networks. |
dan_ackme | 0:ea85c4bb5e1f | 9 | */ |
dan_ackme | 0:ea85c4bb5e1f | 10 | |
dan_ackme | 0:ea85c4bb5e1f | 11 | #pragma once |
dan_ackme | 0:ea85c4bb5e1f | 12 | |
dan_ackme | 0:ea85c4bb5e1f | 13 | |
dan_ackme | 0:ea85c4bb5e1f | 14 | |
dan_ackme | 0:ea85c4bb5e1f | 15 | #include "WiconnectCommands.h" |
dan_ackme | 0:ea85c4bb5e1f | 16 | |
dan_ackme | 0:ea85c4bb5e1f | 17 | /* Note we need the 2 concats below because arguments to ## |
dan_ackme | 0:ea85c4bb5e1f | 18 | * are not expanded, so we need to expand __LINE__ with one indirection |
dan_ackme | 0:ea85c4bb5e1f | 19 | * before doing the actual concatenation. */ |
dan_ackme | 0:ea85c4bb5e1f | 20 | #define ASSERT_CONCAT_(a, b) a##b |
dan_ackme | 0:ea85c4bb5e1f | 21 | #define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b) |
dan_ackme | 0:ea85c4bb5e1f | 22 | #define ct_assert(e) enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) } |
dan_ackme | 0:ea85c4bb5e1f | 23 | |
dan_ackme | 0:ea85c4bb5e1f | 24 | |
dan_ackme | 0:ea85c4bb5e1f | 25 | #ifndef WICONNECT_ASYNC_TIMER_ENABLED |
dan_ackme | 0:ea85c4bb5e1f | 26 | #define CHECK_CALLBACK_AVAILABLE(cb) if(cb.isValid()) return WICONNECT_UNSUPPORTED |
dan_ackme | 0:ea85c4bb5e1f | 27 | #else |
dan_ackme | 0:ea85c4bb5e1f | 28 | #define CHECK_CALLBACK_AVAILABLE(cb) |
dan_ackme | 0:ea85c4bb5e1f | 29 | #endif |
dan_ackme | 0:ea85c4bb5e1f | 30 | |
dan_ackme | 2:05e20e184e7e | 31 | #define UNUSED(expr) do { (void)(expr); } while (0) |
dan_ackme | 2:05e20e184e7e | 32 | |
dan_ackme | 0:ea85c4bb5e1f | 33 | #define CHECK_CLEANUP_COMMAND() \ |
dan_ackme | 0:ea85c4bb5e1f | 34 | if(result != WICONNECT_PROCESSING) \ |
dan_ackme | 0:ea85c4bb5e1f | 35 | { \ |
dan_ackme | 0:ea85c4bb5e1f | 36 | wiconnect->internalProcessingState = 0; \ |
dan_ackme | 0:ea85c4bb5e1f | 37 | wiconnect->currentCommandId = NULL; \ |
dan_ackme | 0:ea85c4bb5e1f | 38 | } |
dan_ackme | 0:ea85c4bb5e1f | 39 | |
dan_ackme | 0:ea85c4bb5e1f | 40 | #define CHECK_OTHER_COMMAND_EXECUTING() \ |
dan_ackme | 0:ea85c4bb5e1f | 41 | { \ |
dan_ackme | 0:ea85c4bb5e1f | 42 | static const volatile uint8_t __funcId = 0; \ |
dan_ackme | 0:ea85c4bb5e1f | 43 | if(wiconnect->currentCommandId == NULL) \ |
dan_ackme | 0:ea85c4bb5e1f | 44 | { \ |
dan_ackme | 0:ea85c4bb5e1f | 45 | wiconnect->currentCommandId = (void*)&__funcId; \ |
dan_ackme | 0:ea85c4bb5e1f | 46 | } \ |
dan_ackme | 0:ea85c4bb5e1f | 47 | else if(wiconnect->currentCommandId != (void*)&__funcId) \ |
dan_ackme | 0:ea85c4bb5e1f | 48 | { \ |
dan_ackme | 0:ea85c4bb5e1f | 49 | return WICONNECT_ANOTHER_CMD_EXECUTING; \ |
dan_ackme | 0:ea85c4bb5e1f | 50 | } \ |
dan_ackme | 0:ea85c4bb5e1f | 51 | } |
dan_ackme | 0:ea85c4bb5e1f | 52 | |
dan_ackme | 0:ea85c4bb5e1f | 53 | |
dan_ackme | 0:ea85c4bb5e1f | 54 | #define WICONNECT_IS_IDLE() (wiconnect->currentCommandId == NULL) |
dan_ackme | 0:ea85c4bb5e1f | 55 | |
dan_ackme | 0:ea85c4bb5e1f | 56 | |
dan_ackme | 0:ea85c4bb5e1f | 57 | |
dan_ackme | 0:ea85c4bb5e1f | 58 | |
dan_ackme | 0:ea85c4bb5e1f | 59 | #ifdef WICONNECT_USE_DEFAULT_STRING_BUFFERS |
dan_ackme | 0:ea85c4bb5e1f | 60 | #define SET_STR_BUFFER(_buffer, size) \ |
dan_ackme | 0:ea85c4bb5e1f | 61 | char *ptr, *buf; \ |
dan_ackme | 0:ea85c4bb5e1f | 62 | static char defaultBuffer[size]; \ |
dan_ackme | 2:05e20e184e7e | 63 | ptr = buf = (_buffer == NULL) ? defaultBuffer : _buffer; \ |
dan_ackme | 2:05e20e184e7e | 64 | UNUSED(buf) |
dan_ackme | 0:ea85c4bb5e1f | 65 | #else |
dan_ackme | 0:ea85c4bb5e1f | 66 | #define SET_STR_BUFFER(_buffer, size) \ |
dan_ackme | 0:ea85c4bb5e1f | 67 | char *ptr, *buf; \ |
dan_ackme | 0:ea85c4bb5e1f | 68 | if(_buffer == NULL) \ |
dan_ackme | 0:ea85c4bb5e1f | 69 | { \ |
dan_ackme | 0:ea85c4bb5e1f | 70 | return "<null>"; \ |
dan_ackme | 0:ea85c4bb5e1f | 71 | } \ |
dan_ackme | 2:05e20e184e7e | 72 | ptr = buf = _buffer; \ |
dan_ackme | 2:05e20e184e7e | 73 | UNUSED(buf) |
dan_ackme | 0:ea85c4bb5e1f | 74 | #endif |