Nrithya Theetharappan / easy-connect-httpmodified

Dependencies:   WNC14A2AInterface-httpmodified

Fork of easy-connect by Jim Flynn

Committer:
JMF
Date:
Wed Apr 19 01:13:10 2017 +0000
Revision:
0:2563b0415d1f
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JMF 0:2563b0415d1f 1 /*
JMF 0:2563b0415d1f 2 * Copyright (c) 2005, Swedish Institute of Computer Science.
JMF 0:2563b0415d1f 3 * All rights reserved.
JMF 0:2563b0415d1f 4 *
JMF 0:2563b0415d1f 5 * Redistribution and use in source and binary forms, with or without
JMF 0:2563b0415d1f 6 * modification, are permitted provided that the following conditions
JMF 0:2563b0415d1f 7 * are met:
JMF 0:2563b0415d1f 8 * 1. Redistributions of source code must retain the above copyright
JMF 0:2563b0415d1f 9 * notice, this list of conditions and the following disclaimer.
JMF 0:2563b0415d1f 10 * 2. Redistributions in binary form must reproduce the above copyright
JMF 0:2563b0415d1f 11 * notice, this list of conditions and the following disclaimer in the
JMF 0:2563b0415d1f 12 * documentation and/or other materials provided with the distribution.
JMF 0:2563b0415d1f 13 * 3. Neither the name of the Institute nor the names of its contributors
JMF 0:2563b0415d1f 14 * may be used to endorse or promote products derived from this software
JMF 0:2563b0415d1f 15 * without specific prior written permission.
JMF 0:2563b0415d1f 16 *
JMF 0:2563b0415d1f 17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
JMF 0:2563b0415d1f 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
JMF 0:2563b0415d1f 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
JMF 0:2563b0415d1f 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
JMF 0:2563b0415d1f 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
JMF 0:2563b0415d1f 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
JMF 0:2563b0415d1f 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
JMF 0:2563b0415d1f 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
JMF 0:2563b0415d1f 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
JMF 0:2563b0415d1f 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
JMF 0:2563b0415d1f 27 * SUCH DAMAGE.
JMF 0:2563b0415d1f 28 *
JMF 0:2563b0415d1f 29 * This file is part of the Contiki operating system.
JMF 0:2563b0415d1f 30 *
JMF 0:2563b0415d1f 31 */
JMF 0:2563b0415d1f 32
JMF 0:2563b0415d1f 33 /**
JMF 0:2563b0415d1f 34 * \file
JMF 0:2563b0415d1f 35 * Header file for the radio API
JMF 0:2563b0415d1f 36 * \author
JMF 0:2563b0415d1f 37 * Adam Dunkels <adam@sics.se>
JMF 0:2563b0415d1f 38 * Joakim Eriksson <joakime@sics.se>
JMF 0:2563b0415d1f 39 * Niclas Finne <nfi@sics.se>
JMF 0:2563b0415d1f 40 * Nicolas Tsiftes <nvt@sics.se>
JMF 0:2563b0415d1f 41 */
JMF 0:2563b0415d1f 42
JMF 0:2563b0415d1f 43 /**
JMF 0:2563b0415d1f 44 * \addtogroup dev
JMF 0:2563b0415d1f 45 * @{
JMF 0:2563b0415d1f 46 */
JMF 0:2563b0415d1f 47
JMF 0:2563b0415d1f 48 /**
JMF 0:2563b0415d1f 49 * \defgroup radio Radio API
JMF 0:2563b0415d1f 50 *
JMF 0:2563b0415d1f 51 * The radio API module defines a set of functions that a radio device
JMF 0:2563b0415d1f 52 * driver must implement.
JMF 0:2563b0415d1f 53 *
JMF 0:2563b0415d1f 54 * @{
JMF 0:2563b0415d1f 55 */
JMF 0:2563b0415d1f 56
JMF 0:2563b0415d1f 57 #ifndef RADIO_H_
JMF 0:2563b0415d1f 58 #define RADIO_H_
JMF 0:2563b0415d1f 59
JMF 0:2563b0415d1f 60 #include <stddef.h>
JMF 0:2563b0415d1f 61
JMF 0:2563b0415d1f 62 /**
JMF 0:2563b0415d1f 63 * Each radio has a set of parameters that designate the current
JMF 0:2563b0415d1f 64 * configuration and state of the radio. Parameters can either have
JMF 0:2563b0415d1f 65 * values of type radio_value_t, or, when this type is insufficient, a
JMF 0:2563b0415d1f 66 * generic object that is specified by a memory pointer and the size
JMF 0:2563b0415d1f 67 * of the object.
JMF 0:2563b0415d1f 68 *
JMF 0:2563b0415d1f 69 * The radio_value_t type is set to an integer type that can hold most
JMF 0:2563b0415d1f 70 * values used to configure the radio, and is therefore the most
JMF 0:2563b0415d1f 71 * common type used for a parameter. Certain parameters require
JMF 0:2563b0415d1f 72 * objects of a considerably larger size than radio_value_t, however,
JMF 0:2563b0415d1f 73 * and in these cases the documentation below for the parameter will
JMF 0:2563b0415d1f 74 * indicate this.
JMF 0:2563b0415d1f 75 *
JMF 0:2563b0415d1f 76 * All radio parameters that can vary during runtime are prefixed by
JMF 0:2563b0415d1f 77 * "RADIO_PARAM", whereas those "parameters" that are guaranteed to
JMF 0:2563b0415d1f 78 * remain immutable are prefixed by "RADIO_CONST". Each mutable
JMF 0:2563b0415d1f 79 * parameter has a set of valid parameter values. When attempting to
JMF 0:2563b0415d1f 80 * set a parameter to an invalid value, the radio will return
JMF 0:2563b0415d1f 81 * RADIO_RESULT_INVALID_VALUE.
JMF 0:2563b0415d1f 82 *
JMF 0:2563b0415d1f 83 * Some radios support only a subset of the defined radio parameters.
JMF 0:2563b0415d1f 84 * When trying to set or get such an unsupported parameter, the radio
JMF 0:2563b0415d1f 85 * will return RADIO_RESULT_NOT_SUPPORTED.
JMF 0:2563b0415d1f 86 */
JMF 0:2563b0415d1f 87
JMF 0:2563b0415d1f 88 typedef int radio_value_t;
JMF 0:2563b0415d1f 89 typedef unsigned radio_param_t;
JMF 0:2563b0415d1f 90
JMF 0:2563b0415d1f 91 enum {
JMF 0:2563b0415d1f 92
JMF 0:2563b0415d1f 93 /* Radio power mode determines if the radio is on
JMF 0:2563b0415d1f 94 (RADIO_POWER_MODE_ON) or off (RADIO_POWER_MODE_OFF). */
JMF 0:2563b0415d1f 95 RADIO_PARAM_POWER_MODE,
JMF 0:2563b0415d1f 96
JMF 0:2563b0415d1f 97 /*
JMF 0:2563b0415d1f 98 * Channel used for radio communication. The channel depends on the
JMF 0:2563b0415d1f 99 * communication standard used by the radio. The values can range
JMF 0:2563b0415d1f 100 * from RADIO_CONST_CHANNEL_MIN to RADIO_CONST_CHANNEL_MAX.
JMF 0:2563b0415d1f 101 */
JMF 0:2563b0415d1f 102 RADIO_PARAM_CHANNEL,
JMF 0:2563b0415d1f 103
JMF 0:2563b0415d1f 104 /* Personal area network identifier, which is used by the address filter. */
JMF 0:2563b0415d1f 105 RADIO_PARAM_PAN_ID,
JMF 0:2563b0415d1f 106
JMF 0:2563b0415d1f 107 /* Short address (16 bits) for the radio, which is used by the address
JMF 0:2563b0415d1f 108 filter. */
JMF 0:2563b0415d1f 109 RADIO_PARAM_16BIT_ADDR,
JMF 0:2563b0415d1f 110
JMF 0:2563b0415d1f 111 /*
JMF 0:2563b0415d1f 112 * Radio receiver mode determines if the radio has address filter
JMF 0:2563b0415d1f 113 * (RADIO_RX_MODE_ADDRESS_FILTER) and auto-ACK (RADIO_RX_MODE_AUTOACK)
JMF 0:2563b0415d1f 114 * enabled. This parameter is set as a bit mask.
JMF 0:2563b0415d1f 115 */
JMF 0:2563b0415d1f 116 RADIO_PARAM_RX_MODE,
JMF 0:2563b0415d1f 117
JMF 0:2563b0415d1f 118 /*
JMF 0:2563b0415d1f 119 * Radio transmission mode determines if the radio has send on CCA
JMF 0:2563b0415d1f 120 * (RADIO_TX_MODE_SEND_ON_CCA) enabled or not. This parameter is set
JMF 0:2563b0415d1f 121 * as a bit mask.
JMF 0:2563b0415d1f 122 */
JMF 0:2563b0415d1f 123 RADIO_PARAM_TX_MODE,
JMF 0:2563b0415d1f 124
JMF 0:2563b0415d1f 125 /*
JMF 0:2563b0415d1f 126 * Transmission power in dBm. The values can range from
JMF 0:2563b0415d1f 127 * RADIO_CONST_TXPOWER_MIN to RADIO_CONST_TXPOWER_MAX.
JMF 0:2563b0415d1f 128 *
JMF 0:2563b0415d1f 129 * Some radios restrict the available values to a subset of this
JMF 0:2563b0415d1f 130 * range. If an unavailable TXPOWER value is requested to be set,
JMF 0:2563b0415d1f 131 * the radio may select another TXPOWER close to the requested
JMF 0:2563b0415d1f 132 * one. When getting the value of this parameter, the actual value
JMF 0:2563b0415d1f 133 * used by the radio will be returned.
JMF 0:2563b0415d1f 134 */
JMF 0:2563b0415d1f 135 RADIO_PARAM_TXPOWER,
JMF 0:2563b0415d1f 136
JMF 0:2563b0415d1f 137 /*
JMF 0:2563b0415d1f 138 * Clear channel assessment threshold in dBm. This threshold
JMF 0:2563b0415d1f 139 * determines the minimum RSSI level at which the radio will assume
JMF 0:2563b0415d1f 140 * that there is a packet in the air.
JMF 0:2563b0415d1f 141 *
JMF 0:2563b0415d1f 142 * The CCA threshold must be set to a level above the noise floor of
JMF 0:2563b0415d1f 143 * the deployment. Otherwise mechanisms such as send-on-CCA and
JMF 0:2563b0415d1f 144 * low-power-listening duty cycling protocols may not work
JMF 0:2563b0415d1f 145 * correctly. Hence, the default value of the system may not be
JMF 0:2563b0415d1f 146 * optimal for any given deployment.
JMF 0:2563b0415d1f 147 */
JMF 0:2563b0415d1f 148 RADIO_PARAM_CCA_THRESHOLD,
JMF 0:2563b0415d1f 149
JMF 0:2563b0415d1f 150 /* Received signal strength indicator in dBm. */
JMF 0:2563b0415d1f 151 RADIO_PARAM_RSSI,
JMF 0:2563b0415d1f 152
JMF 0:2563b0415d1f 153 /*
JMF 0:2563b0415d1f 154 * Long (64 bits) address for the radio, which is used by the address filter.
JMF 0:2563b0415d1f 155 * The address is specified in network byte order.
JMF 0:2563b0415d1f 156 *
JMF 0:2563b0415d1f 157 * Because this parameter value is larger than what fits in radio_value_t,
JMF 0:2563b0415d1f 158 * it needs to be used with radio.get_object()/set_object().
JMF 0:2563b0415d1f 159 */
JMF 0:2563b0415d1f 160 RADIO_PARAM_64BIT_ADDR,
JMF 0:2563b0415d1f 161
JMF 0:2563b0415d1f 162 /* Constants (read only) */
JMF 0:2563b0415d1f 163
JMF 0:2563b0415d1f 164 /* The lowest radio channel. */
JMF 0:2563b0415d1f 165 RADIO_CONST_CHANNEL_MIN,
JMF 0:2563b0415d1f 166 /* The highest radio channel. */
JMF 0:2563b0415d1f 167 RADIO_CONST_CHANNEL_MAX,
JMF 0:2563b0415d1f 168
JMF 0:2563b0415d1f 169 /* The minimum transmission power in dBm. */
JMF 0:2563b0415d1f 170 RADIO_CONST_TXPOWER_MIN,
JMF 0:2563b0415d1f 171 /* The maximum transmission power in dBm. */
JMF 0:2563b0415d1f 172 RADIO_CONST_TXPOWER_MAX
JMF 0:2563b0415d1f 173 };
JMF 0:2563b0415d1f 174
JMF 0:2563b0415d1f 175 /* Radio power modes */
JMF 0:2563b0415d1f 176 enum {
JMF 0:2563b0415d1f 177 RADIO_POWER_MODE_OFF,
JMF 0:2563b0415d1f 178 RADIO_POWER_MODE_ON
JMF 0:2563b0415d1f 179 };
JMF 0:2563b0415d1f 180
JMF 0:2563b0415d1f 181 /**
JMF 0:2563b0415d1f 182 * The radio reception mode controls address filtering and automatic
JMF 0:2563b0415d1f 183 * transmission of acknowledgements in the radio (if such operations
JMF 0:2563b0415d1f 184 * are supported by the radio). A single parameter is used to allow
JMF 0:2563b0415d1f 185 * setting these features simultaneously as an atomic operation.
JMF 0:2563b0415d1f 186 *
JMF 0:2563b0415d1f 187 * To enable both address filter and transmissions of automatic
JMF 0:2563b0415d1f 188 * acknowledgments:
JMF 0:2563b0415d1f 189 *
JMF 0:2563b0415d1f 190 * NETSTACK_RADIO.set_value(RADIO_PARAM_RX_MODE,
JMF 0:2563b0415d1f 191 * RADIO_RX_MODE_ADDRESS_FILTER | RADIO_RX_MODE_AUTOACK);
JMF 0:2563b0415d1f 192 */
JMF 0:2563b0415d1f 193 #define RADIO_RX_MODE_ADDRESS_FILTER (1 << 0)
JMF 0:2563b0415d1f 194 #define RADIO_RX_MODE_AUTOACK (1 << 1)
JMF 0:2563b0415d1f 195
JMF 0:2563b0415d1f 196 /**
JMF 0:2563b0415d1f 197 * The radio transmission mode controls whether transmissions should
JMF 0:2563b0415d1f 198 * be done using clear channel assessment (if supported by the
JMF 0:2563b0415d1f 199 * radio). If send-on-CCA is enabled, the radio's send function will
JMF 0:2563b0415d1f 200 * wait for a radio-specific time window for the channel to become
JMF 0:2563b0415d1f 201 * clear. If this does not happen, the send function will return
JMF 0:2563b0415d1f 202 * RADIO_TX_COLLISION.
JMF 0:2563b0415d1f 203 */
JMF 0:2563b0415d1f 204 #define RADIO_TX_MODE_SEND_ON_CCA (1 << 0)
JMF 0:2563b0415d1f 205
JMF 0:2563b0415d1f 206 /* Radio return values when setting or getting radio parameters. */
JMF 0:2563b0415d1f 207 typedef enum {
JMF 0:2563b0415d1f 208 RADIO_RESULT_OK,
JMF 0:2563b0415d1f 209 RADIO_RESULT_NOT_SUPPORTED,
JMF 0:2563b0415d1f 210 RADIO_RESULT_INVALID_VALUE,
JMF 0:2563b0415d1f 211 RADIO_RESULT_ERROR
JMF 0:2563b0415d1f 212 } radio_result_t;
JMF 0:2563b0415d1f 213
JMF 0:2563b0415d1f 214 /* Radio return values for transmissions. */
JMF 0:2563b0415d1f 215 enum {
JMF 0:2563b0415d1f 216 RADIO_TX_OK,
JMF 0:2563b0415d1f 217 RADIO_TX_ERR,
JMF 0:2563b0415d1f 218 RADIO_TX_COLLISION,
JMF 0:2563b0415d1f 219 RADIO_TX_NOACK,
JMF 0:2563b0415d1f 220 };
JMF 0:2563b0415d1f 221
JMF 0:2563b0415d1f 222 /**
JMF 0:2563b0415d1f 223 * The structure of a device driver for a radio in Contiki.
JMF 0:2563b0415d1f 224 */
JMF 0:2563b0415d1f 225 struct radio_driver {
JMF 0:2563b0415d1f 226
JMF 0:2563b0415d1f 227 int (* init)(void);
JMF 0:2563b0415d1f 228
JMF 0:2563b0415d1f 229 /** Prepare the radio with a packet to be sent. */
JMF 0:2563b0415d1f 230 int (* prepare)(const void *payload, unsigned short payload_len);
JMF 0:2563b0415d1f 231
JMF 0:2563b0415d1f 232 /** Send the packet that has previously been prepared. */
JMF 0:2563b0415d1f 233 int (* transmit)(unsigned short transmit_len);
JMF 0:2563b0415d1f 234
JMF 0:2563b0415d1f 235 /** Prepare & transmit a packet. */
JMF 0:2563b0415d1f 236 int (* send)(const void *payload, unsigned short payload_len);
JMF 0:2563b0415d1f 237
JMF 0:2563b0415d1f 238 /** Read a received packet into a buffer. */
JMF 0:2563b0415d1f 239 int (* read)(void *buf, unsigned short buf_len);
JMF 0:2563b0415d1f 240
JMF 0:2563b0415d1f 241 /** Perform a Clear-Channel Assessment (CCA) to find out if there is
JMF 0:2563b0415d1f 242 a packet in the air or not. */
JMF 0:2563b0415d1f 243 int (* channel_clear)(void);
JMF 0:2563b0415d1f 244
JMF 0:2563b0415d1f 245 /** Check if the radio driver is currently receiving a packet */
JMF 0:2563b0415d1f 246 int (* receiving_packet)(void);
JMF 0:2563b0415d1f 247
JMF 0:2563b0415d1f 248 /** Check if the radio driver has just received a packet */
JMF 0:2563b0415d1f 249 int (* pending_packet)(void);
JMF 0:2563b0415d1f 250
JMF 0:2563b0415d1f 251 /** Turn the radio on. */
JMF 0:2563b0415d1f 252 int (* on)(void);
JMF 0:2563b0415d1f 253
JMF 0:2563b0415d1f 254 /** Turn the radio off. */
JMF 0:2563b0415d1f 255 int (* off)(void);
JMF 0:2563b0415d1f 256
JMF 0:2563b0415d1f 257 /** Get a radio parameter value. */
JMF 0:2563b0415d1f 258 radio_result_t (* get_value)(radio_param_t param, radio_value_t *value);
JMF 0:2563b0415d1f 259
JMF 0:2563b0415d1f 260 /** Set a radio parameter value. */
JMF 0:2563b0415d1f 261 radio_result_t (* set_value)(radio_param_t param, radio_value_t value);
JMF 0:2563b0415d1f 262
JMF 0:2563b0415d1f 263 /**
JMF 0:2563b0415d1f 264 * Get a radio parameter object. The argument 'dest' must point to a
JMF 0:2563b0415d1f 265 * memory area of at least 'size' bytes, and this memory area will
JMF 0:2563b0415d1f 266 * contain the parameter object if the function succeeds.
JMF 0:2563b0415d1f 267 */
JMF 0:2563b0415d1f 268 radio_result_t (* get_object)(radio_param_t param, void *dest, size_t size);
JMF 0:2563b0415d1f 269
JMF 0:2563b0415d1f 270 /**
JMF 0:2563b0415d1f 271 * Set a radio parameter object. The memory area referred to by the
JMF 0:2563b0415d1f 272 * argument 'src' will not be accessed after the function returns.
JMF 0:2563b0415d1f 273 */
JMF 0:2563b0415d1f 274 radio_result_t (* set_object)(radio_param_t param, const void *src,
JMF 0:2563b0415d1f 275 size_t size);
JMF 0:2563b0415d1f 276
JMF 0:2563b0415d1f 277 };
JMF 0:2563b0415d1f 278
JMF 0:2563b0415d1f 279 #endif /* RADIO_H_ */
JMF 0:2563b0415d1f 280
JMF 0:2563b0415d1f 281 /** @} */
JMF 0:2563b0415d1f 282 /** @} */