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

Committer:
dan_ackme
Date:
Sat Aug 23 05:39:17 2014 -0700
Revision:
17:7268f365676b
Parent:
16:7f1d6d359787
Fixes and documentation updates

Who changed what in which revision?

UserRevisionLine numberNew 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 17:7268f365676b 34 #include "mbed.h"
dan_ackme 17:7268f365676b 35
dan_ackme 17:7268f365676b 36
dan_ackme 17:7268f365676b 37
dan_ackme 0:ea85c4bb5e1f 38
dan_ackme 0:ea85c4bb5e1f 39 namespace wiconnect
dan_ackme 0:ea85c4bb5e1f 40 {
dan_ackme 0:ea85c4bb5e1f 41
dan_ackme 11:ea484e1b7fc4 42 /**
dan_ackme 11:ea484e1b7fc4 43 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 44 * @brief When defined enables asynchronous command processing
dan_ackme 11:ea484e1b7fc4 45 */
dan_ackme 0:ea85c4bb5e1f 46 #define WICONNECT_ASYNC_TIMER_ENABLED
dan_ackme 11:ea484e1b7fc4 47 /**
dan_ackme 11:ea484e1b7fc4 48 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 49 * @brief When defined enables user supplied dynamic memory allocation
dan_ackme 11:ea484e1b7fc4 50 */
dan_ackme 0:ea85c4bb5e1f 51 #define WICONNECT_ENABLE_MALLOC
dan_ackme 11:ea484e1b7fc4 52 /**
dan_ackme 11:ea484e1b7fc4 53 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 54 * @brief When defined enables Host<->Wiconnect Module serial RX buffering
dan_ackme 11:ea484e1b7fc4 55 */
dan_ackme 0:ea85c4bb5e1f 56 #define WICONNECT_SERIAL_RX_BUFFER
dan_ackme 11:ea484e1b7fc4 57 /**
dan_ackme 11:ea484e1b7fc4 58 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 59 * @brief When defined enables certain conversion API functions to use a default buffer to store string
dan_ackme 11:ea484e1b7fc4 60 */
dan_ackme 0:ea85c4bb5e1f 61 #define WICONNECT_USE_DEFAULT_STRING_BUFFERS
dan_ackme 0:ea85c4bb5e1f 62
dan_ackme 11:ea484e1b7fc4 63 /**
dan_ackme 11:ea484e1b7fc4 64 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 65 * @brief When WICONNECT_ENABLE_MALLOC defined, this is the default malloc function
dan_ackme 11:ea484e1b7fc4 66 */
dan_ackme 0:ea85c4bb5e1f 67 #define WICONNECT_DEFAULT_MALLOC malloc
dan_ackme 11:ea484e1b7fc4 68 /**
dan_ackme 11:ea484e1b7fc4 69 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 70 * @brief When WICONNECT_ENABLE_MALLOC defined, this is the default free function
dan_ackme 11:ea484e1b7fc4 71 */
dan_ackme 0:ea85c4bb5e1f 72 #define WICONNECT_DEFAULT_FREE free
dan_ackme 0:ea85c4bb5e1f 73
dan_ackme 11:ea484e1b7fc4 74 /**
dan_ackme 11:ea484e1b7fc4 75 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 76 * @brief The default Host<->Wiconnect Module serial BAUD rate
dan_ackme 11:ea484e1b7fc4 77 */
dan_ackme 0:ea85c4bb5e1f 78 #define WICONNECT_DEFAULT_BAUD 115200
dan_ackme 11:ea484e1b7fc4 79 /**
dan_ackme 11:ea484e1b7fc4 80 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 81 * @brief The default command timeout (i.e max command executing time)
dan_ackme 11:ea484e1b7fc4 82 */
dan_ackme 0:ea85c4bb5e1f 83 #define WICONNECT_DEFAULT_TIMEOUT 3000 // ms
dan_ackme 11:ea484e1b7fc4 84 /**
dan_ackme 11:ea484e1b7fc4 85 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 86 * @brief When WICONNECT_ASYNC_TIMER_ENABLED, this specifies the max number of asynchronous commands that may be queued
dan_ackme 11:ea484e1b7fc4 87 */
dan_ackme 0:ea85c4bb5e1f 88 #define WICONNECT_MAX_QUEUED_COMMANDS 8
dan_ackme 11:ea484e1b7fc4 89 /**
dan_ackme 11:ea484e1b7fc4 90 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 91 * @brief When WICONNECT_ASYNC_TIMER_ENABLED, this specifies the period in milliseconds commands should be processed
dan_ackme 11:ea484e1b7fc4 92 */
dan_ackme 0:ea85c4bb5e1f 93 #define WICONNECT_DEFAULT_COMMAND_PROCESSING_PERIOD 50 // ms
dan_ackme 0:ea85c4bb5e1f 94
dan_ackme 11:ea484e1b7fc4 95 /**
dan_ackme 11:ea484e1b7fc4 96 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 97 * @brief The default blocking mode of the Library.
dan_ackme 11:ea484e1b7fc4 98 */
dan_ackme 11:ea484e1b7fc4 99 #define WICONNECT_DEFAULT_NONBLOCKING false
dan_ackme 0:ea85c4bb5e1f 100
dan_ackme 11:ea484e1b7fc4 101
dan_ackme 11:ea484e1b7fc4 102
dan_ackme 11:ea484e1b7fc4 103 // ----------------------------------------------------------------------------
dan_ackme 0:ea85c4bb5e1f 104
dan_ackme 0:ea85c4bb5e1f 105 #define WICONNECT_GPIO_BASE_CLASS : DigitalOut
dan_ackme 0:ea85c4bb5e1f 106 #define WICONNECT_SERIAL_BASE_CLASS : RawSerial
dan_ackme 0:ea85c4bb5e1f 107 #define WICONNECT_PERIODIC_TIMER_BASE_CLASS : Ticker
dan_ackme 0:ea85c4bb5e1f 108 #define WICONNECT_EXTERNAL_INTERRUPT_GPIO_BASE_CLASS : InterruptIn
dan_ackme 0:ea85c4bb5e1f 109
dan_ackme 11:ea484e1b7fc4 110 #define WICONNECT_MAX_PIN_IRQ_HANDLERS 3
dan_ackme 0:ea85c4bb5e1f 111
dan_ackme 0:ea85c4bb5e1f 112
dan_ackme 11:ea484e1b7fc4 113 /**
dan_ackme 11:ea484e1b7fc4 114 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 115 * @brief Default value for a pin, Not connected
dan_ackme 11:ea484e1b7fc4 116 */
dan_ackme 0:ea85c4bb5e1f 117 #define PIN_NC NC
dan_ackme 0:ea85c4bb5e1f 118
dan_ackme 11:ea484e1b7fc4 119 /**
dan_ackme 13:2b51f5267c92 120 * @ingroup api_core_types
dan_ackme 11:ea484e1b7fc4 121 * @brief Pin name on HOST
dan_ackme 11:ea484e1b7fc4 122 */
dan_ackme 0:ea85c4bb5e1f 123 typedef PinName Pin;
dan_ackme 0:ea85c4bb5e1f 124
dan_ackme 11:ea484e1b7fc4 125 /**
dan_ackme 13:2b51f5267c92 126 * @ingroup api_core_types
dan_ackme 11:ea484e1b7fc4 127 * @brief Host<->Wiconnect Module serial configuration
dan_ackme 11:ea484e1b7fc4 128 */
dan_ackme 13:2b51f5267c92 129 class SerialConfig
dan_ackme 0:ea85c4bb5e1f 130 {
dan_ackme 13:2b51f5267c92 131 public:
dan_ackme 0:ea85c4bb5e1f 132 Pin rx;
dan_ackme 0:ea85c4bb5e1f 133 Pin tx;
dan_ackme 0:ea85c4bb5e1f 134 Pin cts;
dan_ackme 0:ea85c4bb5e1f 135 Pin rts;
dan_ackme 0:ea85c4bb5e1f 136 int baud;
dan_ackme 0:ea85c4bb5e1f 137 void *serialRxBuffer;
dan_ackme 0:ea85c4bb5e1f 138 int serialRxBufferSize;
dan_ackme 0:ea85c4bb5e1f 139
dan_ackme 13:2b51f5267c92 140 SerialConfig(Pin rx, Pin tx, Pin cts, Pin rts, int baud, int serialRxBufferSize, void *serialRxBuffer = NULL)
dan_ackme 0:ea85c4bb5e1f 141 {
dan_ackme 0:ea85c4bb5e1f 142 this->rx =rx;
dan_ackme 0:ea85c4bb5e1f 143 this->tx =tx;
dan_ackme 0:ea85c4bb5e1f 144 this->cts =cts;
dan_ackme 0:ea85c4bb5e1f 145 this->rts =rts;
dan_ackme 0:ea85c4bb5e1f 146 this->baud = baud;
dan_ackme 0:ea85c4bb5e1f 147 this->serialRxBuffer =serialRxBuffer;
dan_ackme 0:ea85c4bb5e1f 148 this->serialRxBufferSize =serialRxBufferSize;
dan_ackme 0:ea85c4bb5e1f 149 }
dan_ackme 0:ea85c4bb5e1f 150
dan_ackme 13:2b51f5267c92 151 SerialConfig(Pin rx, Pin tx, int serialRxBufferSize, void *serialRxBuffer = NULL)
dan_ackme 13:2b51f5267c92 152 {
dan_ackme 13:2b51f5267c92 153 this->rx =rx;
dan_ackme 13:2b51f5267c92 154 this->tx =tx;
dan_ackme 13:2b51f5267c92 155 this->cts = PIN_NC;
dan_ackme 13:2b51f5267c92 156 this->rts = PIN_NC;
dan_ackme 13:2b51f5267c92 157 this->baud = WICONNECT_DEFAULT_BAUD;
dan_ackme 13:2b51f5267c92 158 this->serialRxBuffer =serialRxBuffer;
dan_ackme 13:2b51f5267c92 159 this->serialRxBufferSize =serialRxBufferSize;
dan_ackme 13:2b51f5267c92 160 }
dan_ackme 13:2b51f5267c92 161
dan_ackme 13:2b51f5267c92 162 SerialConfig(Pin rx, Pin tx)
dan_ackme 0:ea85c4bb5e1f 163 {
dan_ackme 0:ea85c4bb5e1f 164 this->rx =rx;
dan_ackme 0:ea85c4bb5e1f 165 this->tx =tx;
dan_ackme 0:ea85c4bb5e1f 166 this->cts =PIN_NC;
dan_ackme 0:ea85c4bb5e1f 167 this->rts =PIN_NC;
dan_ackme 13:2b51f5267c92 168 this->baud = WICONNECT_DEFAULT_BAUD;
dan_ackme 0:ea85c4bb5e1f 169 this->serialRxBuffer =NULL;
dan_ackme 0:ea85c4bb5e1f 170 this->serialRxBufferSize =0;
dan_ackme 0:ea85c4bb5e1f 171 }
dan_ackme 0:ea85c4bb5e1f 172
dan_ackme 13:2b51f5267c92 173 };
dan_ackme 0:ea85c4bb5e1f 174
dan_ackme 0:ea85c4bb5e1f 175
dan_ackme 11:ea484e1b7fc4 176 /**
dan_ackme 11:ea484e1b7fc4 177 * @ingroup api_core_macro
dan_ackme 11:ea484e1b7fc4 178 * @brief Function to stop processor for specified number of milliseconds
dan_ackme 11:ea484e1b7fc4 179 */
dan_ackme 0:ea85c4bb5e1f 180 #define delayMs(ms) wait_ms(ms)
dan_ackme 0:ea85c4bb5e1f 181
dan_ackme 0:ea85c4bb5e1f 182
dan_ackme 0:ea85c4bb5e1f 183
dan_ackme 0:ea85c4bb5e1f 184
dan_ackme 0:ea85c4bb5e1f 185 }