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
sdk/mbed/sdk.h@16:7f1d6d359787, 2014-08-13 (annotated)
- Committer:
- dan_ackme
- Date:
- Wed Aug 13 04:41:04 2014 -0700
- Revision:
- 16:7f1d6d359787
- Parent:
- 13:2b51f5267c92
- Child:
- 17:7268f365676b
updated documentation and copyright
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan_ackme | 16:7f1d6d359787 | 1 | /** |
dan_ackme | 16:7f1d6d359787 | 2 | * ACKme WiConnect Host Library is licensed under the BSD licence: |
dan_ackme | 16:7f1d6d359787 | 3 | * |
dan_ackme | 16:7f1d6d359787 | 4 | * Copyright (c)2014 ACKme Networks. |
dan_ackme | 16:7f1d6d359787 | 5 | * All rights reserved. |
dan_ackme | 16:7f1d6d359787 | 6 | * |
dan_ackme | 16:7f1d6d359787 | 7 | * Redistribution and use in source and binary forms, with or without modification, |
dan_ackme | 16:7f1d6d359787 | 8 | * are permitted provided that the following conditions are met: |
dan_ackme | 16:7f1d6d359787 | 9 | * |
dan_ackme | 16:7f1d6d359787 | 10 | * 1. Redistributions of source code must retain the above copyright notice, |
dan_ackme | 16:7f1d6d359787 | 11 | * this list of conditions and the following disclaimer. |
dan_ackme | 16:7f1d6d359787 | 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
dan_ackme | 16:7f1d6d359787 | 13 | * this list of conditions and the following disclaimer in the documentation |
dan_ackme | 16:7f1d6d359787 | 14 | * and/or other materials provided with the distribution. |
dan_ackme | 16:7f1d6d359787 | 15 | * 3. The name of the author may not be used to endorse or promote products |
dan_ackme | 16:7f1d6d359787 | 16 | * derived from this software without specific prior written permission. |
dan_ackme | 16:7f1d6d359787 | 17 | * |
dan_ackme | 16:7f1d6d359787 | 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS AND ANY EXPRESS OR IMPLIED |
dan_ackme | 16:7f1d6d359787 | 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
dan_ackme | 16:7f1d6d359787 | 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
dan_ackme | 16:7f1d6d359787 | 21 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
dan_ackme | 16:7f1d6d359787 | 22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
dan_ackme | 16:7f1d6d359787 | 23 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
dan_ackme | 16:7f1d6d359787 | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
dan_ackme | 16:7f1d6d359787 | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
dan_ackme | 16:7f1d6d359787 | 26 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
dan_ackme | 16:7f1d6d359787 | 27 | * OF SUCH DAMAGE. |
dan_ackme | 0:ea85c4bb5e1f | 28 | */ |
dan_ackme | 0:ea85c4bb5e1f | 29 | #pragma once |
dan_ackme | 0:ea85c4bb5e1f | 30 | |
dan_ackme | 0:ea85c4bb5e1f | 31 | |
dan_ackme | 0:ea85c4bb5e1f | 32 | #define MBED_SDK |
dan_ackme | 0:ea85c4bb5e1f | 33 | |
dan_ackme | 0:ea85c4bb5e1f | 34 | #include "mbed.h" |
dan_ackme | 0:ea85c4bb5e1f | 35 | |
dan_ackme | 0:ea85c4bb5e1f | 36 | namespace wiconnect |
dan_ackme | 0:ea85c4bb5e1f | 37 | { |
dan_ackme | 0:ea85c4bb5e1f | 38 | |
dan_ackme | 11:ea484e1b7fc4 | 39 | /** |
dan_ackme | 11:ea484e1b7fc4 | 40 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 41 | * @brief When defined enables asynchronous command processing |
dan_ackme | 11:ea484e1b7fc4 | 42 | */ |
dan_ackme | 0:ea85c4bb5e1f | 43 | #define WICONNECT_ASYNC_TIMER_ENABLED |
dan_ackme | 11:ea484e1b7fc4 | 44 | /** |
dan_ackme | 11:ea484e1b7fc4 | 45 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 46 | * @brief When defined enables user supplied dynamic memory allocation |
dan_ackme | 11:ea484e1b7fc4 | 47 | */ |
dan_ackme | 0:ea85c4bb5e1f | 48 | #define WICONNECT_ENABLE_MALLOC |
dan_ackme | 11:ea484e1b7fc4 | 49 | /** |
dan_ackme | 11:ea484e1b7fc4 | 50 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 51 | * @brief When defined enables Host<->Wiconnect Module serial RX buffering |
dan_ackme | 11:ea484e1b7fc4 | 52 | */ |
dan_ackme | 0:ea85c4bb5e1f | 53 | #define WICONNECT_SERIAL_RX_BUFFER |
dan_ackme | 11:ea484e1b7fc4 | 54 | /** |
dan_ackme | 11:ea484e1b7fc4 | 55 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 56 | * @brief When defined enables certain conversion API functions to use a default buffer to store string |
dan_ackme | 11:ea484e1b7fc4 | 57 | */ |
dan_ackme | 0:ea85c4bb5e1f | 58 | #define WICONNECT_USE_DEFAULT_STRING_BUFFERS |
dan_ackme | 0:ea85c4bb5e1f | 59 | |
dan_ackme | 11:ea484e1b7fc4 | 60 | /** |
dan_ackme | 11:ea484e1b7fc4 | 61 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 62 | * @brief When WICONNECT_ENABLE_MALLOC defined, this is the default malloc function |
dan_ackme | 11:ea484e1b7fc4 | 63 | */ |
dan_ackme | 0:ea85c4bb5e1f | 64 | #define WICONNECT_DEFAULT_MALLOC malloc |
dan_ackme | 11:ea484e1b7fc4 | 65 | /** |
dan_ackme | 11:ea484e1b7fc4 | 66 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 67 | * @brief When WICONNECT_ENABLE_MALLOC defined, this is the default free function |
dan_ackme | 11:ea484e1b7fc4 | 68 | */ |
dan_ackme | 0:ea85c4bb5e1f | 69 | #define WICONNECT_DEFAULT_FREE free |
dan_ackme | 0:ea85c4bb5e1f | 70 | |
dan_ackme | 11:ea484e1b7fc4 | 71 | /** |
dan_ackme | 11:ea484e1b7fc4 | 72 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 73 | * @brief The default Host<->Wiconnect Module serial BAUD rate |
dan_ackme | 11:ea484e1b7fc4 | 74 | */ |
dan_ackme | 0:ea85c4bb5e1f | 75 | #define WICONNECT_DEFAULT_BAUD 115200 |
dan_ackme | 11:ea484e1b7fc4 | 76 | /** |
dan_ackme | 11:ea484e1b7fc4 | 77 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 78 | * @brief The default command timeout (i.e max command executing time) |
dan_ackme | 11:ea484e1b7fc4 | 79 | */ |
dan_ackme | 0:ea85c4bb5e1f | 80 | #define WICONNECT_DEFAULT_TIMEOUT 3000 // ms |
dan_ackme | 11:ea484e1b7fc4 | 81 | /** |
dan_ackme | 11:ea484e1b7fc4 | 82 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 83 | * @brief When WICONNECT_ASYNC_TIMER_ENABLED, this specifies the max number of asynchronous commands that may be queued |
dan_ackme | 11:ea484e1b7fc4 | 84 | */ |
dan_ackme | 0:ea85c4bb5e1f | 85 | #define WICONNECT_MAX_QUEUED_COMMANDS 8 |
dan_ackme | 11:ea484e1b7fc4 | 86 | /** |
dan_ackme | 11:ea484e1b7fc4 | 87 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 88 | * @brief When WICONNECT_ASYNC_TIMER_ENABLED, this specifies the period in milliseconds commands should be processed |
dan_ackme | 11:ea484e1b7fc4 | 89 | */ |
dan_ackme | 0:ea85c4bb5e1f | 90 | #define WICONNECT_DEFAULT_COMMAND_PROCESSING_PERIOD 50 // ms |
dan_ackme | 0:ea85c4bb5e1f | 91 | |
dan_ackme | 11:ea484e1b7fc4 | 92 | /** |
dan_ackme | 11:ea484e1b7fc4 | 93 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 94 | * @brief The default blocking mode of the Library. |
dan_ackme | 11:ea484e1b7fc4 | 95 | */ |
dan_ackme | 11:ea484e1b7fc4 | 96 | #define WICONNECT_DEFAULT_NONBLOCKING false |
dan_ackme | 0:ea85c4bb5e1f | 97 | |
dan_ackme | 11:ea484e1b7fc4 | 98 | |
dan_ackme | 11:ea484e1b7fc4 | 99 | |
dan_ackme | 11:ea484e1b7fc4 | 100 | // ---------------------------------------------------------------------------- |
dan_ackme | 0:ea85c4bb5e1f | 101 | |
dan_ackme | 0:ea85c4bb5e1f | 102 | #define WICONNECT_GPIO_BASE_CLASS : DigitalOut |
dan_ackme | 0:ea85c4bb5e1f | 103 | #define WICONNECT_SERIAL_BASE_CLASS : RawSerial |
dan_ackme | 0:ea85c4bb5e1f | 104 | #define WICONNECT_PERIODIC_TIMER_BASE_CLASS : Ticker |
dan_ackme | 0:ea85c4bb5e1f | 105 | #define WICONNECT_EXTERNAL_INTERRUPT_GPIO_BASE_CLASS : InterruptIn |
dan_ackme | 0:ea85c4bb5e1f | 106 | |
dan_ackme | 11:ea484e1b7fc4 | 107 | #define WICONNECT_MAX_PIN_IRQ_HANDLERS 3 |
dan_ackme | 0:ea85c4bb5e1f | 108 | |
dan_ackme | 0:ea85c4bb5e1f | 109 | |
dan_ackme | 11:ea484e1b7fc4 | 110 | /** |
dan_ackme | 11:ea484e1b7fc4 | 111 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 112 | * @brief Default value for a pin, Not connected |
dan_ackme | 11:ea484e1b7fc4 | 113 | */ |
dan_ackme | 0:ea85c4bb5e1f | 114 | #define PIN_NC NC |
dan_ackme | 0:ea85c4bb5e1f | 115 | |
dan_ackme | 11:ea484e1b7fc4 | 116 | /** |
dan_ackme | 13:2b51f5267c92 | 117 | * @ingroup api_core_types |
dan_ackme | 11:ea484e1b7fc4 | 118 | * @brief Pin name on HOST |
dan_ackme | 11:ea484e1b7fc4 | 119 | */ |
dan_ackme | 0:ea85c4bb5e1f | 120 | typedef PinName Pin; |
dan_ackme | 0:ea85c4bb5e1f | 121 | |
dan_ackme | 11:ea484e1b7fc4 | 122 | /** |
dan_ackme | 13:2b51f5267c92 | 123 | * @ingroup api_core_types |
dan_ackme | 11:ea484e1b7fc4 | 124 | * @brief Host<->Wiconnect Module serial configuration |
dan_ackme | 11:ea484e1b7fc4 | 125 | */ |
dan_ackme | 13:2b51f5267c92 | 126 | class SerialConfig |
dan_ackme | 0:ea85c4bb5e1f | 127 | { |
dan_ackme | 13:2b51f5267c92 | 128 | public: |
dan_ackme | 0:ea85c4bb5e1f | 129 | Pin rx; |
dan_ackme | 0:ea85c4bb5e1f | 130 | Pin tx; |
dan_ackme | 0:ea85c4bb5e1f | 131 | Pin cts; |
dan_ackme | 0:ea85c4bb5e1f | 132 | Pin rts; |
dan_ackme | 0:ea85c4bb5e1f | 133 | int baud; |
dan_ackme | 0:ea85c4bb5e1f | 134 | void *serialRxBuffer; |
dan_ackme | 0:ea85c4bb5e1f | 135 | int serialRxBufferSize; |
dan_ackme | 0:ea85c4bb5e1f | 136 | |
dan_ackme | 13:2b51f5267c92 | 137 | SerialConfig(Pin rx, Pin tx, Pin cts, Pin rts, int baud, int serialRxBufferSize, void *serialRxBuffer = NULL) |
dan_ackme | 0:ea85c4bb5e1f | 138 | { |
dan_ackme | 0:ea85c4bb5e1f | 139 | this->rx =rx; |
dan_ackme | 0:ea85c4bb5e1f | 140 | this->tx =tx; |
dan_ackme | 0:ea85c4bb5e1f | 141 | this->cts =cts; |
dan_ackme | 0:ea85c4bb5e1f | 142 | this->rts =rts; |
dan_ackme | 0:ea85c4bb5e1f | 143 | this->baud = baud; |
dan_ackme | 0:ea85c4bb5e1f | 144 | this->serialRxBuffer =serialRxBuffer; |
dan_ackme | 0:ea85c4bb5e1f | 145 | this->serialRxBufferSize =serialRxBufferSize; |
dan_ackme | 0:ea85c4bb5e1f | 146 | } |
dan_ackme | 0:ea85c4bb5e1f | 147 | |
dan_ackme | 13:2b51f5267c92 | 148 | SerialConfig(Pin rx, Pin tx, int serialRxBufferSize, void *serialRxBuffer = NULL) |
dan_ackme | 13:2b51f5267c92 | 149 | { |
dan_ackme | 13:2b51f5267c92 | 150 | this->rx =rx; |
dan_ackme | 13:2b51f5267c92 | 151 | this->tx =tx; |
dan_ackme | 13:2b51f5267c92 | 152 | this->cts = PIN_NC; |
dan_ackme | 13:2b51f5267c92 | 153 | this->rts = PIN_NC; |
dan_ackme | 13:2b51f5267c92 | 154 | this->baud = WICONNECT_DEFAULT_BAUD; |
dan_ackme | 13:2b51f5267c92 | 155 | this->serialRxBuffer =serialRxBuffer; |
dan_ackme | 13:2b51f5267c92 | 156 | this->serialRxBufferSize =serialRxBufferSize; |
dan_ackme | 13:2b51f5267c92 | 157 | } |
dan_ackme | 13:2b51f5267c92 | 158 | |
dan_ackme | 13:2b51f5267c92 | 159 | SerialConfig(Pin rx, Pin tx) |
dan_ackme | 0:ea85c4bb5e1f | 160 | { |
dan_ackme | 0:ea85c4bb5e1f | 161 | this->rx =rx; |
dan_ackme | 0:ea85c4bb5e1f | 162 | this->tx =tx; |
dan_ackme | 0:ea85c4bb5e1f | 163 | this->cts =PIN_NC; |
dan_ackme | 0:ea85c4bb5e1f | 164 | this->rts =PIN_NC; |
dan_ackme | 13:2b51f5267c92 | 165 | this->baud = WICONNECT_DEFAULT_BAUD; |
dan_ackme | 0:ea85c4bb5e1f | 166 | this->serialRxBuffer =NULL; |
dan_ackme | 0:ea85c4bb5e1f | 167 | this->serialRxBufferSize =0; |
dan_ackme | 0:ea85c4bb5e1f | 168 | } |
dan_ackme | 0:ea85c4bb5e1f | 169 | |
dan_ackme | 13:2b51f5267c92 | 170 | }; |
dan_ackme | 0:ea85c4bb5e1f | 171 | |
dan_ackme | 0:ea85c4bb5e1f | 172 | |
dan_ackme | 11:ea484e1b7fc4 | 173 | /** |
dan_ackme | 11:ea484e1b7fc4 | 174 | * @ingroup api_core_macro |
dan_ackme | 11:ea484e1b7fc4 | 175 | * @brief Function to stop processor for specified number of milliseconds |
dan_ackme | 11:ea484e1b7fc4 | 176 | */ |
dan_ackme | 0:ea85c4bb5e1f | 177 | #define delayMs(ms) wait_ms(ms) |
dan_ackme | 0:ea85c4bb5e1f | 178 | |
dan_ackme | 0:ea85c4bb5e1f | 179 | |
dan_ackme | 0:ea85c4bb5e1f | 180 | |
dan_ackme | 0:ea85c4bb5e1f | 181 | |
dan_ackme | 0:ea85c4bb5e1f | 182 | } |