Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 9Rmain
  • anon/gpndemo
  • anon/update-sim
  • anon/webflasher
  • audio_input
  • audio_io
  • bl00mbox
  • bl00mbox_old
  • captouch-threshold
  • ch3/bl00mbox_docs
  • ci-1690580595
  • compressor
  • dev_p4
  • dev_p4-iggy
  • dev_p4-iggy-rebased
  • dos
  • dos-main-patch-50543
  • events
  • fm_fix
  • fm_fix2
  • fpletz/flake
  • history-rewrite
  • icon-flower
  • iggy/stemming
  • iggy/stemming_merge
  • json-error
  • main
  • main+schneider
  • media-buf
  • micropython_api
  • moon2_applications
  • moon2_demo_temp
  • moon2_gay_drums
  • passthrough
  • phhw
  • pippin/display-python-errors-on-display
  • pippin/make_empty_drawlists_skip_render_and_blit
  • pippin/media_framework
  • pippin/uhm_flash_access_bust
  • pressable_bugfix
  • q3k/doom-poc
  • rahix/big-flow3r
  • rahix/flow3rseeds
  • raw_captouch_new
  • raw_captouch_old
  • release/1.0.0
  • release/1.1.0
  • release/1.1.1
  • rev4_micropython
  • schneider/application-remove-name
  • schneider/bhi581
  • schneider/factory_test
  • schneider/recovery
  • scope
  • scope_hack
  • sdkconfig-spiram-tinyusb
  • sec/auto-nick
  • sec/blinky
  • simtest
  • slewtest
  • t
  • test
  • test2
  • uctx-wip
  • view-think
  • vm-pending
  • vsync
  • wave
  • wip-docs
  • wip-tinyusb
  • v1.0.0
  • v1.0.0+rc1
  • v1.0.0+rc2
  • v1.0.0+rc3
  • v1.0.0+rc4
  • v1.0.0+rc5
  • v1.0.0+rc6
  • v1.1.0
  • v1.1.0+rc1
  • v1.1.1
  • v1.2.0
  • v1.2.0+rc1
  • v1.3.0
83 results

Target

Select target project
  • flow3r/flow3r-firmware
  • Vespasian/flow3r-firmware
  • alxndr42/flow3r-firmware
  • pl/flow3r-firmware
  • Kari/flow3r-firmware
  • raimue/flow3r-firmware
  • grandchild/flow3r-firmware
  • mu5tach3/flow3r-firmware
  • Nervengift/flow3r-firmware
  • arachnist/flow3r-firmware
  • TheNewCivilian/flow3r-firmware
  • alibi/flow3r-firmware
  • manuel_v/flow3r-firmware
  • xeniter/flow3r-firmware
  • maxbachmann/flow3r-firmware
  • yGifoom/flow3r-firmware
  • istobic/flow3r-firmware
  • EiNSTeiN_/flow3r-firmware
  • gnudalf/flow3r-firmware
  • 999eagle/flow3r-firmware
  • toerb/flow3r-firmware
  • pandark/flow3r-firmware
  • teal/flow3r-firmware
  • x42/flow3r-firmware
  • alufers/flow3r-firmware
  • dos/flow3r-firmware
  • yrlf/flow3r-firmware
  • LuKaRo/flow3r-firmware
  • ThomasElRubio/flow3r-firmware
  • ai/flow3r-firmware
  • T_X/flow3r-firmware
  • highTower/flow3r-firmware
  • beanieboi/flow3r-firmware
  • Woazboat/flow3r-firmware
  • gooniesbro/flow3r-firmware
  • marvino/flow3r-firmware
  • kressnerd/flow3r-firmware
  • quazgar/flow3r-firmware
  • aoid/flow3r-firmware
  • jkj/flow3r-firmware
  • naomi/flow3r-firmware
41 results
Select Git revision
  • 89-apps-should-be-able-to-specify-if-they-want-wifi-to-be-disabled-when-entering-them
  • 9Rmain
  • allow-reloading-sunmenu
  • always-have-a-wifi-instance
  • anon/gpndemo
  • anon/update-sim
  • anon/webflasher
  • app_text_viewer
  • audio_input
  • audio_io
  • blm_dev_chan
  • ch3/bl00mbox_docs
  • ci-1690580595
  • dev_p4
  • dev_p4-iggy
  • dev_p4-iggy-rebased
  • dx/dldldld
  • dx/fb-save-restore
  • dx/hint-hint
  • dx/jacksense-headset-mic-only
  • events
  • fil3s-limit-filesize
  • fil3s-media
  • fpletz/flake
  • gr33nhouse-improvements
  • history-rewrite
  • icon-flower
  • iggy/stemming
  • iggy/stemming_merge
  • led_fix_fix
  • main
  • main+schneider
  • media_has_video_has_audio
  • micropython_api
  • mixer2
  • moon2_demo_temp
  • moon2_migrate_apps
  • more-accurate-battery
  • pippin/ctx_sprite_sheet_support
  • pippin/display-python-errors-on-display
  • pippin/make_empty_drawlists_skip_render_and_blit
  • pippin/more-accurate-battery
  • pippin/tcp_redirect_hack
  • pippin/tune_ctx_config_update_from_upstream
  • pippin/uhm_flash_access_bust
  • pressable_bugfix
  • py_only_update_fps_overlay_when_changing
  • q3k/doom-poc
  • q3k/render-to-texture
  • rahix/flow3rseeds
  • raw_captouch_new
  • raw_captouch_old
  • release/1.0.0
  • release/1.1.0
  • release/1.1.1
  • release/1.2.0
  • release/1.3.0
  • release/1.4.0
  • restore_blit
  • return_of_melodic_demo
  • rev4_micropython
  • schneider/application-remove-name
  • schneider/bhi581
  • schneider/factory_test
  • schneider/recovery
  • scope_hack
  • sdkconfig-spiram-tinyusb
  • sec/auto-nick
  • sec/blinky
  • sector_size_512
  • shoegaze-fps
  • smaller_gradient_lut
  • store_delta_ms_and_ins_as_class_members
  • task_cleanup
  • uctx-wip
  • w1f1-in-sim
  • widgets_draw
  • wifi-json-error-handling
  • wip-docs
  • wip-tinyusb
  • v1.0.0
  • v1.0.0+rc1
  • v1.0.0+rc2
  • v1.0.0+rc3
  • v1.0.0+rc4
  • v1.0.0+rc5
  • v1.0.0+rc6
  • v1.1.0
  • v1.1.0+rc1
  • v1.1.1
  • v1.2.0
  • v1.2.0+rc1
  • v1.3.0
  • v1.4.0
94 results
Show changes
Showing
with 9708 additions and 0 deletions
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "drivers/bus/qspi.h"
#define CS_LOW(self) mp_hal_pin_write(self->cs, 0)
#define CS_HIGH(self) mp_hal_pin_write(self->cs, 1)
#ifdef MICROPY_HW_SOFTQSPI_SCK_LOW
// Use externally provided functions for SCK control and IO reading
#define SCK_LOW(self) MICROPY_HW_SOFTQSPI_SCK_LOW(self)
#define SCK_HIGH(self) MICROPY_HW_SOFTQSPI_SCK_HIGH(self)
#define NIBBLE_READ(self) MICROPY_HW_SOFTQSPI_NIBBLE_READ(self)
#else
// Use generic pin functions for SCK control and IO reading
#define SCK_LOW(self) mp_hal_pin_write(self->clk, 0)
#define SCK_HIGH(self) mp_hal_pin_write(self->clk, 1)
#define NIBBLE_READ(self) ( \
mp_hal_pin_read(self->io0) \
| (mp_hal_pin_read(self->io1) << 1) \
| (mp_hal_pin_read(self->io2) << 2) \
| (mp_hal_pin_read(self->io3) << 3))
#endif
STATIC void nibble_write(mp_soft_qspi_obj_t *self, uint8_t v) {
mp_hal_pin_write(self->io0, v & 1);
mp_hal_pin_write(self->io1, (v >> 1) & 1);
mp_hal_pin_write(self->io2, (v >> 2) & 1);
mp_hal_pin_write(self->io3, (v >> 3) & 1);
}
STATIC int mp_soft_qspi_ioctl(void *self_in, uint32_t cmd) {
mp_soft_qspi_obj_t *self = (mp_soft_qspi_obj_t*)self_in;
switch (cmd) {
case MP_QSPI_IOCTL_INIT:
mp_hal_pin_high(self->cs);
mp_hal_pin_output(self->cs);
// Configure pins
mp_hal_pin_write(self->clk, 0);
mp_hal_pin_output(self->clk);
//mp_hal_pin_write(self->clk, 1);
mp_hal_pin_output(self->io0);
mp_hal_pin_input(self->io1);
mp_hal_pin_write(self->io2, 1);
mp_hal_pin_output(self->io2);
mp_hal_pin_write(self->io3, 1);
mp_hal_pin_output(self->io3);
break;
}
return 0; // success
}
STATIC void mp_soft_qspi_transfer(mp_soft_qspi_obj_t *self, size_t len, const uint8_t *src, uint8_t *dest) {
// Will run as fast as possible, limited only by CPU speed and GPIO time
mp_hal_pin_input(self->io1);
mp_hal_pin_output(self->io0);
if (self->io3) {
mp_hal_pin_write(self->io2, 1);
mp_hal_pin_output(self->io2);
mp_hal_pin_write(self->io3, 1);
mp_hal_pin_output(self->io3);
}
if (src) {
for (size_t i = 0; i < len; ++i) {
uint8_t data_out = src[i];
uint8_t data_in = 0;
for (int j = 0; j < 8; ++j, data_out <<= 1) {
mp_hal_pin_write(self->io0, (data_out >> 7) & 1);
mp_hal_pin_write(self->clk, 1);
data_in = (data_in << 1) | mp_hal_pin_read(self->io1);
mp_hal_pin_write(self->clk, 0);
}
if (dest != NULL) {
dest[i] = data_in;
}
}
} else {
for (size_t i = 0; i < len; ++i) {
uint8_t data_in = 0;
for (int j = 0; j < 8; ++j) {
mp_hal_pin_write(self->clk, 1);
data_in = (data_in << 1) | mp_hal_pin_read(self->io1);
mp_hal_pin_write(self->clk, 0);
}
if (dest != NULL) {
dest[i] = data_in;
}
}
}
}
STATIC void mp_soft_qspi_qread(mp_soft_qspi_obj_t *self, size_t len, uint8_t *buf) {
// Make all IO lines input
mp_hal_pin_input(self->io2);
mp_hal_pin_input(self->io3);
mp_hal_pin_input(self->io0);
mp_hal_pin_input(self->io1);
// Will run as fast as possible, limited only by CPU speed and GPIO time
while (len--) {
SCK_HIGH(self);
uint8_t data_in = NIBBLE_READ(self);
SCK_LOW(self);
SCK_HIGH(self);
*buf++ = (data_in << 4) | NIBBLE_READ(self);
SCK_LOW(self);
}
}
STATIC void mp_soft_qspi_qwrite(mp_soft_qspi_obj_t *self, size_t len, const uint8_t *buf) {
// Make all IO lines output
mp_hal_pin_output(self->io2);
mp_hal_pin_output(self->io3);
mp_hal_pin_output(self->io0);
mp_hal_pin_output(self->io1);
// Will run as fast as possible, limited only by CPU speed and GPIO time
for (size_t i = 0; i < len; ++i) {
nibble_write(self, buf[i] >> 4);
SCK_HIGH(self);
SCK_LOW(self);
nibble_write(self, buf[i]);
SCK_HIGH(self);
SCK_LOW(self);
}
//mp_hal_pin_input(self->io1);
}
STATIC int mp_soft_qspi_write_cmd_data(void *self_in, uint8_t cmd, size_t len, uint32_t data) {
mp_soft_qspi_obj_t *self = (mp_soft_qspi_obj_t*)self_in;
uint32_t cmd_buf = cmd | data << 8;
CS_LOW(self);
mp_soft_qspi_transfer(self, 1 + len, (uint8_t*)&cmd_buf, NULL);
CS_HIGH(self);
return 0;
}
STATIC int mp_soft_qspi_write_cmd_addr_data(void *self_in, uint8_t cmd, uint32_t addr, size_t len, const uint8_t *src) {
mp_soft_qspi_obj_t *self = (mp_soft_qspi_obj_t*)self_in;
uint8_t cmd_buf[5] = {cmd};
uint8_t addr_len = mp_spi_set_addr_buff(&cmd_buf[1], addr);
CS_LOW(self);
mp_soft_qspi_transfer(self, addr_len + 1, cmd_buf, NULL);
mp_soft_qspi_transfer(self, len, src, NULL);
CS_HIGH(self);
return 0;
}
STATIC int mp_soft_qspi_read_cmd(void *self_in, uint8_t cmd, size_t len, uint32_t *dest) {
mp_soft_qspi_obj_t *self = (mp_soft_qspi_obj_t*)self_in;
uint32_t cmd_buf = cmd;
CS_LOW(self);
mp_soft_qspi_transfer(self, 1 + len, (uint8_t*)&cmd_buf, (uint8_t*)&cmd_buf);
CS_HIGH(self);
*dest = cmd_buf >> 8;
return 0;
}
STATIC int mp_soft_qspi_read_cmd_qaddr_qdata(void *self_in, uint8_t cmd, uint32_t addr, size_t len, uint8_t *dest) {
mp_soft_qspi_obj_t *self = (mp_soft_qspi_obj_t*)self_in;
uint8_t cmd_buf[7] = {cmd};
uint8_t addr_len = mp_spi_set_addr_buff(&cmd_buf[1], addr);
CS_LOW(self);
mp_soft_qspi_transfer(self, 1, cmd_buf, NULL);
mp_soft_qspi_qwrite(self, addr_len + 3, &cmd_buf[1]); // 3/4 addr bytes, 1 extra byte (0), 2 dummy bytes (4 dummy cycles)
mp_soft_qspi_qread(self, len, dest);
CS_HIGH(self);
return 0;
}
const mp_qspi_proto_t mp_soft_qspi_proto = {
.ioctl = mp_soft_qspi_ioctl,
.write_cmd_data = mp_soft_qspi_write_cmd_data,
.write_cmd_addr_data = mp_soft_qspi_write_cmd_addr_data,
.read_cmd = mp_soft_qspi_read_cmd,
.read_cmd_qaddr_qdata = mp_soft_qspi_read_cmd_qaddr_qdata,
};
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "drivers/bus/spi.h"
int mp_soft_spi_ioctl(void *self_in, uint32_t cmd) {
mp_soft_spi_obj_t *self = (mp_soft_spi_obj_t*)self_in;
switch (cmd) {
case MP_SPI_IOCTL_INIT:
mp_hal_pin_write(self->sck, self->polarity);
mp_hal_pin_output(self->sck);
mp_hal_pin_output(self->mosi);
mp_hal_pin_input(self->miso);
break;
case MP_SPI_IOCTL_DEINIT:
break;
}
return 0;
}
void mp_soft_spi_transfer(void *self_in, size_t len, const uint8_t *src, uint8_t *dest) {
mp_soft_spi_obj_t *self = (mp_soft_spi_obj_t*)self_in;
uint32_t delay_half = self->delay_half;
// only MSB transfer is implemented
// If a port defines MICROPY_HW_SOFTSPI_MIN_DELAY, and the configured
// delay_half is equal to this value, then the software SPI implementation
// will run as fast as possible, limited only by CPU speed and GPIO time.
#ifdef MICROPY_HW_SOFTSPI_MIN_DELAY
if (delay_half == MICROPY_HW_SOFTSPI_MIN_DELAY) {
for (size_t i = 0; i < len; ++i) {
uint8_t data_out = src[i];
uint8_t data_in = 0;
for (int j = 0; j < 8; ++j, data_out <<= 1) {
mp_hal_pin_write(self->mosi, (data_out >> 7) & 1);
mp_hal_pin_write(self->sck, 1 - self->polarity);
data_in = (data_in << 1) | mp_hal_pin_read(self->miso);
mp_hal_pin_write(self->sck, self->polarity);
}
if (dest != NULL) {
dest[i] = data_in;
}
}
return;
}
#endif
for (size_t i = 0; i < len; ++i) {
uint8_t data_out = src[i];
uint8_t data_in = 0;
for (int j = 0; j < 8; ++j, data_out <<= 1) {
mp_hal_pin_write(self->mosi, (data_out >> 7) & 1);
if (self->phase == 0) {
mp_hal_delay_us_fast(delay_half);
mp_hal_pin_write(self->sck, 1 - self->polarity);
} else {
mp_hal_pin_write(self->sck, 1 - self->polarity);
mp_hal_delay_us_fast(delay_half);
}
data_in = (data_in << 1) | mp_hal_pin_read(self->miso);
if (self->phase == 0) {
mp_hal_delay_us_fast(delay_half);
mp_hal_pin_write(self->sck, self->polarity);
} else {
mp_hal_pin_write(self->sck, self->polarity);
mp_hal_delay_us_fast(delay_half);
}
}
if (dest != NULL) {
dest[i] = data_in;
}
}
}
const mp_spi_proto_t mp_soft_spi_proto = {
.ioctl = mp_soft_spi_ioctl,
.transfer = mp_soft_spi_transfer,
};
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_DRIVERS_BUS_SPI_H
#define MICROPY_INCLUDED_DRIVERS_BUS_SPI_H
#include "py/mphal.h"
enum {
MP_SPI_IOCTL_INIT,
MP_SPI_IOCTL_DEINIT,
};
typedef struct _mp_spi_proto_t {
int (*ioctl)(void *self, uint32_t cmd);
void (*transfer)(void *self, size_t len, const uint8_t *src, uint8_t *dest);
} mp_spi_proto_t;
typedef struct _mp_soft_spi_obj_t {
uint32_t delay_half; // microsecond delay for half SCK period
uint8_t polarity;
uint8_t phase;
mp_hal_pin_obj_t sck;
mp_hal_pin_obj_t mosi;
mp_hal_pin_obj_t miso;
} mp_soft_spi_obj_t;
extern const mp_spi_proto_t mp_soft_spi_proto;
int mp_soft_spi_ioctl(void *self, uint32_t cmd);
void mp_soft_spi_transfer(void *self, size_t len, const uint8_t *src, uint8_t *dest);
#endif // MICROPY_INCLUDED_DRIVERS_BUS_SPI_H
/*
* device.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef __DEVICE_H__
#define __DEVICE_H__
#ifdef __cplusplus
extern "C" {
#endif
/*!
\addtogroup device
@{
*/
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
/* SL internal Error codes */
/* Receive this error in case there are no resources to issue the command
If possible, increase the number of MAX_CUNCURENT_ACTIONS (result in memory increase)
If not, try again later */
#define SL_POOL_IS_EMPTY (-2000)
/* Receive this error in case a given length for RX buffer was too small.
Receive payload was bigger than the given buffer size. Therefore, payload is cut according to receive size
Recommend to increase buffer size */
#define SL_ESMALLBUF (-2001)
/* Receive this error in case zero length is supplied to a "get" API
Recommend to supply length according to requested information (view options defines for help) */
#define SL_EZEROLEN (-2002)
/* User supplied invalid parameter */
#define SL_INVALPARAM (-2003)
/* Failed to open interface */
#define SL_BAD_INTERFACE (-2004)
/* End of SL internal Error codes */
/*****************************************************************************/
/* Errors returned from the general error async event */
/*****************************************************************************/
/* Send types */
typedef enum
{
SL_ERR_SENDER_HEALTH_MON,
SL_ERR_SENDER_CLI_UART,
SL_ERR_SENDER_SUPPLICANT,
SL_ERR_SENDER_NETWORK_STACK,
SL_ERR_SENDER_WLAN_DRV_IF,
SL_ERR_SENDER_WILINK,
SL_ERR_SENDER_INIT_APP,
SL_ERR_SENDER_NETX,
SL_ERR_SENDER_HOST_APD,
SL_ERR_SENDER_MDNS,
SL_ERR_SENDER_HTTP_SERVER,
SL_ERR_SENDER_DHCP_SERVER,
SL_ERR_SENDER_DHCP_CLIENT,
SL_ERR_DISPATCHER,
SL_ERR_NUM_SENDER_LAST=0xFF
}SlErrorSender_e;
/* Error codes */
#define SL_ERROR_STATIC_ADDR_SUBNET_ERROR (-60) /* network stack error*/
#define SL_ERROR_ILLEGAL_CHANNEL (-61) /* supplicant error */
#define SL_ERROR_SUPPLICANT_ERROR (-72) /* init error code */
#define SL_ERROR_HOSTAPD_INIT_FAIL (-73) /* init error code */
#define SL_ERROR_HOSTAPD_INIT_IF_FAIL (-74) /* init error code */
#define SL_ERROR_WLAN_DRV_INIT_FAIL (-75) /* init error code */
#define SL_ERROR_WLAN_DRV_START_FAIL (-76) /* wlan start error */
#define SL_ERROR_FS_FILE_TABLE_LOAD_FAILED (-77) /* init file system failed */
#define SL_ERROR_PREFERRED_NETWORKS_FILE_LOAD_FAILED (-78) /* init file system failed */
#define SL_ERROR_HOSTAPD_BSSID_VALIDATION_ERROR (-79) /* Ap configurations BSSID error */
#define SL_ERROR_HOSTAPD_FAILED_TO_SETUP_INTERFACE (-80) /* Ap configurations interface error */
#define SL_ERROR_MDNS_ENABLE_FAIL (-81) /* mDNS enable failed */
#define SL_ERROR_HTTP_SERVER_ENABLE_FAILED (-82) /* HTTP server enable failed */
#define SL_ERROR_DHCP_SERVER_ENABLE_FAILED (-83) /* DHCP server enable failed */
#define SL_ERROR_PREFERRED_NETWORK_LIST_FULL (-93) /* supplicant error */
#define SL_ERROR_PREFERRED_NETWORKS_FILE_WRITE_FAILED (-94) /* supplicant error */
#define SL_ERROR_DHCP_CLIENT_RENEW_FAILED (-100) /* DHCP client error */
/* WLAN Connection management status */
#define SL_ERROR_CON_MGMT_STATUS_UNSPECIFIED (-102)
#define SL_ERROR_CON_MGMT_STATUS_AUTH_REJECT (-103)
#define SL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT (-104)
#define SL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE (-105)
#define SL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE (-106)
#define SL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE (-107)
#define SL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER (-108)
#define SL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT (-109)
#define SL_ERROR_CON_MGMT_STATUS_SG_RESELECT (-110)
#define SL_ERROR_CON_MGMT_STATUS_ROC_FAILURE (-111)
#define SL_ERROR_CON_MGMT_STATUS_MIC_FAILURE (-112)
/* end of WLAN connection management error statuses */
#define SL_ERROR_WAKELOCK_ERROR_PREFIX (-115) /* Wake lock expired */
#define SL_ERROR_LENGTH_ERROR_PREFIX (-116) /* Uart header length error */
#define SL_ERROR_MDNS_CREATE_FAIL (-121) /* mDNS create failed */
#define SL_ERROR_GENERAL_ERROR (-127)
#define SL_DEVICE_GENERAL_CONFIGURATION (1)
#define SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME (11)
#define SL_DEVICE_GENERAL_VERSION (12)
#define SL_DEVICE_STATUS (2)
/*
Declare the different event group classifications
The SimpleLink device send asynchronous events. Each event has a group
classification according to its nature.
*/
/* SL_EVENT_CLASS_WLAN connection user events */
#define SL_WLAN_CONNECT_EVENT (1)
#define SL_WLAN_DISCONNECT_EVENT (2)
/* WLAN Smart Config user events */
#define SL_WLAN_SMART_CONFIG_COMPLETE_EVENT (3)
#define SL_WLAN_SMART_CONFIG_STOP_EVENT (4)
/* WLAN AP user events */
#define SL_WLAN_STA_CONNECTED_EVENT (5)
#define SL_WLAN_STA_DISCONNECTED_EVENT (6)
/* WLAN P2P user events */
#define SL_WLAN_P2P_DEV_FOUND_EVENT (7)
#define SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT (8)
#define SL_WLAN_CONNECTION_FAILED_EVENT (9)
/* SL_EVENT_CLASS_DEVICE user events */
#define SL_DEVICE_FATAL_ERROR_EVENT (1)
#define SL_DEVICE_ABORT_ERROR_EVENT (2)
/* SL_EVENT_CLASS_BSD user events */
#define SL_SOCKET_TX_FAILED_EVENT (1)
#define SL_SOCKET_ASYNC_EVENT (2)
/* SL_EVENT_CLASS_NETAPP user events */
#define SL_NETAPP_IPV4_IPACQUIRED_EVENT (1)
#define SL_NETAPP_IPV6_IPACQUIRED_EVENT (2)
#define SL_NETAPP_IP_LEASED_EVENT (3)
#define SL_NETAPP_IP_RELEASED_EVENT (4)
/* Server Events */
#define SL_NETAPP_HTTPGETTOKENVALUE_EVENT (1)
#define SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT (2)
/*
Declare the different event group classifications for sl_DevGet
for getting status indications
*/
/* Events list to mask/unmask*/
#define SL_EVENT_CLASS_GLOBAL (0)
#define SL_EVENT_CLASS_DEVICE (1)
#define SL_EVENT_CLASS_WLAN (2)
#define SL_EVENT_CLASS_BSD (3)
#define SL_EVENT_CLASS_NETAPP (4)
#define SL_EVENT_CLASS_NETCFG (5)
#define SL_EVENT_CLASS_FS (6)
/****************** DEVICE CLASS status ****************/
#define EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR (0x00000001L)
#define STATUS_DEVICE_SMART_CONFIG_ACTIVE (0x80000000L)
/****************** WLAN CLASS status ****************/
#define EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE (0x00000001L)
#define EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE (0x00000002L)
#define EVENT_DROPPED_WLAN_STA_CONNECTED (0x00000004L)
#define EVENT_DROPPED_WLAN_STA_DISCONNECTED (0x00000008L)
#define STATUS_WLAN_STA_CONNECTED (0x80000000L)
/****************** NETAPP CLASS status ****************/
#define EVENT_DROPPED_NETAPP_IPACQUIRED (0x00000001L)
#define EVENT_DROPPED_NETAPP_IPACQUIRED_V6 (0x00000002L)
#define EVENT_DROPPED_NETAPP_IP_LEASED (0x00000004L)
#define EVENT_DROPPED_NETAPP_IP_RELEASED (0x00000008L)
/****************** BSD CLASS status ****************/
#define EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE (0x00000001L)
/****************** FS CLASS ****************/
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
#define ROLE_UNKNOWN_ERR (-1)
#ifdef SL_IF_TYPE_UART
typedef struct
{
_u32 BaudRate;
_u8 FlowControlEnable;
_u8 CommPort;
} SlUartIfParams_t;
#endif
typedef struct
{
_u32 ChipId;
_u32 FwVersion[4];
_u8 PhyVersion[4];
}_SlPartialVersion;
typedef struct
{
_SlPartialVersion ChipFwAndPhyVersion;
_u32 NwpVersion[4];
_u16 RomVersion;
_u16 Padding;
}SlVersionFull;
typedef struct
{
_u32 AbortType;
_u32 AbortData;
}sl_DeviceReportAbort;
typedef struct
{
_i8 status;
SlErrorSender_e sender;
}sl_DeviceReport;
typedef union
{
sl_DeviceReport deviceEvent;
sl_DeviceReportAbort deviceReport;
} _SlDeviceEventData_u;
typedef struct
{
_u32 Event;
_SlDeviceEventData_u EventData;
} SlDeviceEvent_t;
typedef struct
{
/* time */
_u32 sl_tm_sec;
_u32 sl_tm_min;
_u32 sl_tm_hour;
/* date */
_u32 sl_tm_day; /* 1-31 */
_u32 sl_tm_mon; /* 1-12 */
_u32 sl_tm_year; /* YYYY 4 digits */
_u32 sl_tm_week_day; /* not required */
_u32 sl_tm_year_day; /* not required */
_u32 reserved[3];
}SlDateTime_t;
/******************************************************************************/
/* Type declarations */
/******************************************************************************/
typedef void (*P_INIT_CALLBACK)(_u32 Status);
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief Start the SimpleLink device
This function initialize the communication interface, set the enable pin
of the device, and call to the init complete callback.
\param[in] pIfHdl Opened Interface Object. In case the interface
must be opened outside the SimpleLink Driver, the
user might give the handler to be used in \n
any access of the communication interface with the
device (UART/SPI). \n
The SimpleLink driver will open an interface port
only if this parameter is null! \n
\param[in] pDevName The name of the device to open. Could be used when
the pIfHdl is null, to transfer information to the
open interface function \n
This pointer could be used to pass additional information to
sl_IfOpen in case it is required (e.g. UART com port name)
\param[in] pInitCallBack Pointer to function that would be called
on completion of the initialization process.\n
If this parameter is NULL the function is
blocked until the device initialization
is completed, otherwise the function returns
immediately.
\return Returns the current active role (STA/AP/P2P) or an error code:
- ROLE_STA, ROLE_AP, ROLE_P2P in case of success,
otherwise in failure one of the following is return:
- ROLE_STA_ERR (Failure to load MAC/PHY in STA role)
- ROLE_AP_ERR (Failure to load MAC/PHY in AP role)
- ROLE_P2P_ERR (Failure to load MAC/PHY in P2P role)
\sa sl_Stop
\note belongs to \ref basic_api
\warning This function must be called before any other SimpleLink API is used, or after sl_Stop is called for reinit the device
\par Example:
\code
An example for open interface without callback routine. The interface name and handler are
handled by the sl_IfOpen routine:
if( sl_Start(NULL, NULL, NULL) < 0 )
{
LOG("Error opening interface to device\n");
}
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_Start)
_i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCallBack);
#endif
/*!
\brief Stop the SimpleLink device
This function clears the enable pin of the device, closes the communication \n
interface and invokes the stop complete callback
\param[in] timeout Stop timeout in msec. Should be used to give the device time to finish \n
any transmission/reception that is not completed when the function was called. \n
Additional options:
- 0 Enter to hibernate immediately \n
- 0xFFFF Host waits for device's response before \n
hibernating, without timeout protection \n
- 0 < Timeout[msec] < 0xFFFF Host waits for device's response before \n
hibernating, with a defined timeout protection \n
This timeout defines the max time to wait. The NWP \n
response can be sent earlier than this timeout.
\return On success, zero is returned. On error, -1 is returned
\sa sl_Start
\note This API will shutdown the device and invoke the "i/f close" function regardless \n
if it was opened implicitly or explicitly. \n
It is up to the platform interface library to properly handle interface close \n
routine \n
belongs to \ref basic_api \n
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Stop)
_i16 sl_Stop(const _u16 timeout);
#endif
/*!
\brief Internal function for setting device configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] DeviceSetId configuration id
\param[in] Option configurations option
\param[in] ConfigLen configurations len
\param[in] pValues configurations values
\sa
\note
\warning
\par Examples:
\code
Setting device time and date example:
SlDateTime_t dateTime= {0};
dateTime.sl_tm_day = (_u32)23; // Day of month (DD format) range 1-31
dateTime.sl_tm_mon = (_u32)6; // Month (MM format) in the range of 1-12
dateTime.sl_tm_year = (_u32)2014; // Year (YYYY format)
dateTime.sl_tm_hour = (_u32)17; // Hours in the range of 0-23
dateTime.sl_tm_min = (_u32)55; // Minutes in the range of 0-59
dateTime.sl_tm_sec = (_u32)22; // Seconds in the range of 0-59
sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,
SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
sizeof(SlDateTime_t),
(_u8 *)(&dateTime));
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_DevSet)
_i32 sl_DevSet(const _u8 DeviceSetId ,const _u8 Option,const _u8 ConfigLen,const _u8 *pValues);
#endif
/*!
\brief Internal function for getting device configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] DeviceGetId configuration id - example SL_DEVICE_STATUS
\param[out] pOption Get configurations option, example for get status options
- SL_EVENT_CLASS_GLOBAL
- SL_EVENT_CLASS_DEVICE
- SL_EVENT_CLASS_WLAN
- SL_EVENT_CLASS_BSD
- SL_EVENT_CLASS_NETAPP
- SL_EVENT_CLASS_NETCFG
- SL_EVENT_CLASS_FS
\param[out] pConfigLen The length of the allocated memory as input, when the
function complete, the value of this parameter would be
the len that actually read from the device.\n
If the device return length that is longer from the input
value, the function will cut the end of the returned structure
and will return SL_ESMALLBUF
\param[out] pValues Get configurations values
\sa
\note
\warning
\par Examples:
\code
Example for getting WLAN class status:
_u32 statusWlan;
_u8 pConfigOpt;
_u8 pConfigLen;
pConfigOpt = SL_EVENT_CLASS_WLAN;
pConfigLen = sizeof(_u32);
sl_DevGet(SL_DEVICE_STATUS,&pConfigOpt,&pConfigLen,(_u8 *)(&statusWlan));
Example for getting version:
SlVersionFull ver;
pConfigLen = sizeof(ver);
pConfigOpt = SL_DEVICE_GENERAL_VERSION;
sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&pConfigOpt,&pConfigLen,(_u8 *)(&ver));
printf("CHIP %d\nMAC 31.%d.%d.%d.%d\nPHY %d.%d.%d.%d\nNWP %d.%d.%d.%d\nROM %d\nHOST %d.%d.%d.%d\n",
ver.ChipFwAndPhyVersion.ChipId,
ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1],
ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3],
ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1],
ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3],
ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3],
ver.RomVersion,
SL_MAJOR_VERSION_NUM,SL_MINOR_VERSION_NUM,SL_VERSION_NUM,SL_SUB_VERSION_NUM);
\endcode
\code
Getting Device time and date example:
SlDateTime_t dateTime = {0};
_i8 configLen = sizeof(SlDateTime_t);
_i8 configOpt = SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME;
sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION,&configOpt, &configLen,(_u8 *)(&dateTime));
printf("Day %d,Mon %d,Year %d,Hour %,Min %d,Sec %d\n",dateTime.sl_tm_day,dateTime.sl_tm_mon,dateTime.sl_tm_year
dateTime.sl_tm_hour,dateTime.sl_tm_min,dateTime.sl_tm_sec);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_DevGet)
_i32 sl_DevGet(const _u8 DeviceGetId,_u8 *pOption,_u8 *pConfigLen, _u8 *pValues);
#endif
/*!
\brief Set asynchronous event mask
Mask asynchronous events from the device. Masked events do not
generate asynchronous messages from the device.
By default - all events are active
\param[in] EventClass The classification groups that the
mask is referred to. Need to be one of
the following:
- SL_EVENT_CLASS_GLOBAL
- SL_EVENT_CLASS_DEVICE
- SL_EVENT_CLASS_WLAN
- SL_EVENT_CLASS_BSD
- SL_EVENT_CLASS_NETAPP
- SL_EVENT_CLASS_NETCFG
- SL_EVENT_CLASS_FS
\param[in] Mask Event Mask bitmap. Valid mask are (per group):
- SL_EVENT_CLASS_WLAN user events
- SL_WLAN_CONNECT_EVENT
- SL_WLAN_DISCONNECT_EVENT
- SL_EVENT_CLASS_DEVICE user events
- SL_DEVICE_FATAL_ERROR_EVENT
- SL_EVENT_CLASS_BSD user events
- SL_SOCKET_TX_FAILED_EVENT
- SL_SOCKET_ASYNC_EVENT
- SL_EVENT_CLASS_NETAPP user events
- SL_NETAPP_IPV4_IPACQUIRED_EVENT
- SL_NETAPP_IPV6_IPACQUIRED_EVENT
\return On success, zero is returned. On error, -1 is returned
\sa sl_EventMaskGet
\note belongs to \ref ext_api
\warning
\par Example:
\code
An example of masking connection/disconnection async events from WLAN class:
sl_EventMaskSet(SL_EVENT_CLASS_WLAN, (SL_WLAN_CONNECT_EVENT | SL_WLAN_DISCONNECT_EVENT) );
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_EventMaskSet)
_i16 sl_EventMaskSet(const _u8 EventClass ,const _u32 Mask);
#endif
/*!
\brief Get current event mask of the device
return the events bit mask from the device. In case that event is
masked, the device is not sending this event.
\param[in] EventClass The classification groups that the
mask is referred to. Need to be one of
the following:
- SL_EVENT_CLASS_GLOBAL
- SL_EVENT_CLASS_DEVICE
- SL_EVENT_CLASS_WLAN
- SL_EVENT_CLASS_BSD
- SL_EVENT_CLASS_NETAPP
- SL_EVENT_CLASS_NETCFG
- SL_EVENT_CLASS_FS
\param[out] pMask Pointer to Mask bitmap where the
value should be stored. Bitmasks are the same as in \ref sl_EventMaskSet
\return On success, zero is returned. On error, -1 is returned
\sa sl_EventMaskSet
\note belongs to \ref ext_api
\warning
\par Example:
\code
An example of getting an event mask for WLAN class
_u32 maskWlan;
sl_StatusGet(SL_EVENT_CLASS_WLAN,&maskWlan);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_EventMaskGet)
_i16 sl_EventMaskGet(const _u8 EventClass,_u32 *pMask);
#endif
/*!
\brief the simple link task entry
\Param
This function must be called from the main loop or from dedicated thread in
the following cases:
- Non-Os Platform - should be called from the mail loop
- Multi Threaded Platform when the user does not implement the external spawn functions -
should be called from dedicated thread allocated to the simplelink driver.
In this mode the function never return.
\return None
\sa sl_Stop
\note belongs to \ref basic_api
\warning This function must be called from a thread that is start running before
any call to other simple link API
*/
#if _SL_INCLUDE_FUNC(sl_Task)
void sl_Task(void);
#endif
/*!
\brief Setting the internal uart mode
\param[in] pUartParams Pointer to the uart configuration parameter set:
baudrate - up to 711 Kbps
flow control - enable/disable
comm port - the comm port number
\return On success zero is returned, otherwise - Failed.
\sa sl_Stop
\note belongs to \ref basic_api
\warning This function must consider the host uart capability
*/
#ifdef SL_IF_TYPE_UART
#if _SL_INCLUDE_FUNC(sl_UartSetMode)
_i16 sl_UartSetMode(const SlUartIfParams_t* pUartParams);
#endif
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __DEVICE_H__ */
/*
* driver.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __DRIVER_INT_H__
#define __DRIVER_INT_H__
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
#ifndef CPU_FREQ_IN_MHZ
#define CPU_FREQ_IN_MHZ (200)
#endif
#define USEC_DELAY (50)
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
typedef struct
{
_SlOpcode_t Opcode;
_SlArgSize_t TxDescLen;
_SlArgSize_t RxDescLen;
}_SlCmdCtrl_t;
typedef struct
{
_u16 TxPayloadLen;
_i16 RxPayloadLen;
_i16 ActualRxPayloadLen;
_u8 *pTxPayload;
_u8 *pRxPayload;
}_SlCmdExt_t;
typedef struct _SlArgsData_t
{
_u8 *pArgs;
_u8 *pData;
} _SlArgsData_t;
typedef struct _SlPoolObj_t
{
_SlSyncObj_t SyncObj;
_u8 *pRespArgs;
_u8 ActionID;
_u8 AdditionalData; /* use for socketID and one bit which indicate supprt IPV6 or not (1=support, 0 otherwise) */
_u8 NextIndex;
} _SlPoolObj_t;
typedef enum
{
SOCKET_0,
SOCKET_1,
SOCKET_2,
SOCKET_3,
SOCKET_4,
SOCKET_5,
SOCKET_6,
SOCKET_7,
MAX_SOCKET_ENUM_IDX,
#ifndef SL_TINY_EXT
ACCEPT_ID = MAX_SOCKET_ENUM_IDX,
CONNECT_ID,
#else
CONNECT_ID = MAX_SOCKET_ENUM_IDX,
#endif
#ifndef SL_TINY_EXT
SELECT_ID,
#endif
GETHOSYBYNAME_ID,
#ifndef SL_TINY_EXT
GETHOSYBYSERVICE_ID,
PING_ID,
#endif
START_STOP_ID,
RECV_ID
}_SlActionID_e;
typedef struct _SlActionLookup_t
{
_u8 ActionID;
_u16 ActionAsyncOpcode;
_SlSpawnEntryFunc_t AsyncEventHandler;
} _SlActionLookup_t;
typedef struct
{
_u8 TxPoolCnt;
_SlLockObj_t TxLockObj;
_SlSyncObj_t TxSyncObj;
}_SlFlowContCB_t;
typedef enum
{
RECV_RESP_CLASS,
CMD_RESP_CLASS,
ASYNC_EVT_CLASS,
DUMMY_MSG_CLASS
}_SlRxMsgClass_e;
typedef struct
{
_u8 *pAsyncBuf; /* place to write pointer to buffer with CmdResp's Header + Arguments */
_u8 ActionIndex;
_SlSpawnEntryFunc_t AsyncEvtHandler; /* place to write pointer to AsyncEvent handler (calc-ed by Opcode) */
_SlRxMsgClass_e RxMsgClass; /* type of Rx message */
} AsyncExt_t;
typedef _u8 _SlSd_t;
typedef struct
{
_SlCmdCtrl_t *pCmdCtrl;
_u8 *pTxRxDescBuff;
_SlCmdExt_t *pCmdExt;
AsyncExt_t AsyncExt;
}_SlFunctionParams_t;
typedef struct
{
_SlFd_t FD;
_SlLockObj_t GlobalLockObj;
_SlCommandHeader_t TempProtocolHeader;
P_INIT_CALLBACK pInitCallback;
_SlPoolObj_t ObjPool[MAX_CONCURRENT_ACTIONS];
_u8 FreePoolIdx;
_u8 PendingPoolIdx;
_u8 ActivePoolIdx;
_u32 ActiveActionsBitmap;
_SlLockObj_t ProtectionLockObj;
_SlSyncObj_t CmdSyncObj;
_u8 IsCmdRespWaited;
_SlFlowContCB_t FlowContCB;
_u8 TxSeqNum;
_u8 RxDoneCnt;
_u8 SocketNonBlocking;
_u8 SocketTXFailure;
/* for stack reduction the parameters are globals */
_SlFunctionParams_t FunctionParams;
_u8 ActionIndex;
}_SlDriverCb_t;
extern _volatile _u8 RxIrqCnt;
extern _SlDriverCb_t* g_pCB;
extern P_SL_DEV_PING_CALLBACK pPingCallBackFunc;
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
extern void _SlDrvDriverCBInit(void);
extern void _SlDrvDriverCBDeinit(void);
extern void _SlDrvRxIrqHandler(void *pValue);
extern _SlReturnVal_t _SlDrvCmdOp(_SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt);
extern _SlReturnVal_t _SlDrvCmdSend(_SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt);
extern _SlReturnVal_t _SlDrvDataReadOp(_SlSd_t Sd, _SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt);
extern _SlReturnVal_t _SlDrvDataWriteOp(_SlSd_t Sd, _SlCmdCtrl_t *pCmdCtrl , void* pTxRxDescBuff , _SlCmdExt_t* pCmdExt);
extern void _sl_HandleAsync_InitComplete(void *pVoidBuf);
extern void _sl_HandleAsync_Connect(void *pVoidBuf);
#ifndef SL_TINY_EXT
extern _i16 _SlDrvBasicCmd(_SlOpcode_t Opcode);
extern void _sl_HandleAsync_Accept(void *pVoidBuf);
extern void _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf);
extern void _sl_HandleAsync_Select(void *pVoidBuf);
#endif
extern void _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf);
extern void _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf);
extern void _sl_HandleAsync_PingResponse(void *pVoidBuf);
extern void _SlDrvNetAppEventHandler(void* pArgs);
extern void _SlDrvDeviceEventHandler(void* pArgs);
extern void _sl_HandleAsync_Stop(void *pVoidBuf);
extern _u8 _SlDrvWaitForPoolObj(_u8 ActionID, _u8 SocketID);
extern void _SlDrvReleasePoolObj(_u8 pObj);
extern _u16 _SlDrvAlignSize(_u16 msgLen);
extern _u8 _SlDrvProtectAsyncRespSetting(_u8 *pAsyncRsp, _u8 ActionID, _u8 SocketID);
extern void _SlDrvSyncObjWaitForever(_SlSyncObj_t *pSyncObj);
extern void _SlDrvSyncObjSignal(_SlSyncObj_t *pSyncObj);
extern void _SlDrvObjLock(_SlLockObj_t *pLockObj, _SlTime_t Timeout);
extern void _SlDrvObjLockWaitForever(_SlLockObj_t *pLockObj);
extern void _SlDrvProtectionObjLockWaitForever();
extern void _SlDrvObjUnLock(_SlLockObj_t *pLockObj);
extern void _SlDrvProtectionObjUnLock();
extern void _SlDrvMemZero(void* Addr, _u16 size);
extern void _SlDrvResetCmdExt(_SlCmdExt_t* pCmdExt);
#define _SL_PROTOCOL_ALIGN_SIZE(msgLen) (((msgLen)+3) & (~3))
#define _SL_IS_PROTOCOL_ALIGNED_SIZE(msgLen) (!((msgLen) & 3))
#define _SL_PROTOCOL_CALC_LEN(pCmdCtrl,pCmdExt) ((pCmdExt) ? \
(_SL_PROTOCOL_ALIGN_SIZE(pCmdCtrl->TxDescLen) + _SL_PROTOCOL_ALIGN_SIZE(pCmdExt->TxPayloadLen)) : \
(_SL_PROTOCOL_ALIGN_SIZE(pCmdCtrl->TxDescLen)))
#endif /* __DRIVER_INT_H__ */
/*
* flowcont.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __FLOWCONT_H__
#define __FLOWCONT_H__
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
#define FLOW_CONT_MIN 1
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
extern void _SlDrvFlowContInit(void);
extern void _SlDrvFlowContDeinit(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __FLOWCONT_H__ */
/*
* fs.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef __FS_H__
#define __FS_H__
#ifdef __cplusplus
extern "C" {
#endif
/*!
\addtogroup FileSystem
@{
*/
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
/* FS error codes */
#define SL_FS_OK (0)
#define SL_FS_ERR_EMPTY_SFLASH (-67)
#define SL_FS_ERR_FILE_IS_NOT_SECURE_AND_SIGN (-66)
#define SL_FS_ERASING_FLASH (-65)
#define SL_FS_FILE_HAS_NOT_BEEN_CLOSE_CORRECTLY (-64)
#define SL_FS_WRONG_SIGNATURE (-63)
#define SL_FS_WRONG_SIGNATURE_OR_CERTIFIC_NAME_LENGTH (-62)
#define SL_FS_NOT_16_ALIGNED (-61)
#define SL_FS_CERT_CHAIN_ERROR (-60)
#define SL_FS_FILE_NAME_EXIST (-59)
#define SL_FS_SECURITY_BUF_ALREADY_ALLOC (-58)
#define SL_FS_SECURE_FILE_MUST_BE_COMMIT (-57)
#define SL_FS_ERR_INCORRECT_OFFSET_ALIGNMENT (-56)
#define SL_FS_ERR_FAILED_READ_NVMEM_HEADER (-55)
#define SL_FS_WRONG_FILE_NAME (-54)
#define SL_FS_FILE_SYSTEM_IS_LOCKED (-53)
#define SL_FS_SECURITY_ALLERT (-52)
#define SL_FS_FILE_UNVALID_FILE_SIZE (-51)
#define SL_FS_ERR_TOKEN_IS_NOT_VALID (-50)
#define SL_FS_NO_DEVICE_IS_LOADED (-49)
#define SL_FS_DATA_ADDRESS_SHOUD_BE_IN_DATA_RAM (-48)
#define SL_FS_DATA_IS_NOT_ALIGNED (-47)
#define SL_FS_ERR_OVERLAP_DETECTION_THRESHHOLD (-46)
#define SL_FS_FILE_HAS_RESERVED_NV_INDEX (-45)
#define SL_FS_ERR_MAX_FS_FILES_IS_LARGER (-44)
#define SL_FS_ERR_MAX_FS_FILES_IS_SMALLER (-43)
#define SL_FS_FILE_MAX_SIZE_EXCEEDED (-42)
#define SL_FS_INVALID_BUFFER_FOR_READ (-41)
#define SL_FS_INVALID_BUFFER_FOR_WRITE (-40)
#define SL_FS_ERR_FILE_IMAGE_IS_CORRUPTED (-39)
#define SL_FS_ERR_SIZE_OF_FILE_EXT_EXCEEDED (-38)
#define SL_FS_WARNING_FILE_NAME_NOT_KEPT (-37)
#define SL_FS_ERR_DEVICE_IS_NOT_FORMATTED (-36)
#define SL_FS_ERR_FAILED_WRITE_NVMEM_HEADER (-35)
#define SL_FS_ERR_NO_AVAILABLE_NV_INDEX (-34)
#define SL_FS_ERR_FAILED_TO_ALLOCATE_MEM (-33)
#define SL_FS_ERR_FAILED_TO_READ_INTEGRITY_HEADER_2 (-32)
#define SL_FS_ERR_FAILED_TO_READ_INTEGRITY_HEADER_1 (-31)
#define SL_FS_ERR_NO_AVAILABLE_BLOCKS (-30)
#define SL_FS_ERR_FILE_MAX_SIZE_BIGGER_THAN_EXISTING_FILE (-29)
#define SL_FS_ERR_FILE_EXISTS_ON_DIFFERENT_DEVICE_ID (-28)
#define SL_FS_ERR_INVALID_ACCESS_TYPE (-27)
#define SL_FS_ERR_FILE_ALREADY_EXISTS (-26)
#define SL_FS_ERR_PROGRAM (-25)
#define SL_FS_ERR_NO_ENTRIES_AVAILABLE (-24)
#define SL_FS_ERR_FILE_ACCESS_IS_DIFFERENT (-23)
#define SL_FS_ERR_BAD_FILE_MODE (-22)
#define SL_FS_ERR_FAILED_READ_NVFILE (-21)
#define SL_FS_ERR_FAILED_INIT_STORAGE (-20)
#define SL_FS_ERR_CONTINUE_WRITE_MUST_BE_MOD_4 (-19)
#define SL_FS_ERR_FAILED_LOAD_FILE (-18)
#define SL_FS_ERR_INVALID_HANDLE (-17)
#define SL_FS_ERR_FAILED_TO_WRITE (-16)
#define SL_FS_ERR_OFFSET_OUT_OF_RANGE (-15)
#define SL_FS_ERR_ALLOC (-14)
#define SL_FS_ERR_READ_DATA_LENGTH (-13)
#define SL_FS_ERR_INVALID_FILE_ID (-12)
#define SL_FS_ERR_FILE_NOT_EXISTS (-11)
#define SL_FS_ERR_EMPTY_ERROR (-10)
#define SL_FS_ERR_INVALID_ARGS (-9)
#define SL_FS_ERR_FAILED_TO_CREATE_FILE (-8)
#define SL_FS_ERR_FS_ALREADY_LOADED (-7)
#define SL_FS_ERR_UNKNOWN (-6)
#define SL_FS_ERR_FAILED_TO_CREATE_LOCK_OBJ (-5)
#define SL_FS_ERR_DEVICE_NOT_LOADED (-4)
#define SL_FS_ERR_INVALID_MAGIC_NUM (-3)
#define SL_FS_ERR_FAILED_TO_READ (-2)
#define SL_FS_ERR_NOT_SUPPORTED (-1)
/* end of error codes */
#define _FS_MODE_ACCESS_RESERVED_OFFSET (24)
#define _FS_MODE_ACCESS_RESERVED_MASK (0xFF)
#define _FS_MODE_ACCESS_FLAGS_OFFSET (16)
#define _FS_MODE_ACCESS_FLAGS_MASK (0xFF)
#define _FS_MODE_ACCESS_OFFSET (12)
#define _FS_MODE_ACCESS_MASK (0xF)
#define _FS_MODE_OPEN_SIZE_GRAN_OFFSET (8)
#define _FS_MODE_OPEN_SIZE_GRAN_MASK (0xF)
#define _FS_MODE_OPEN_SIZE_OFFSET (0)
#define _FS_MODE_OPEN_SIZE_MASK (0xFF)
#define MAX_MODE_SIZE (0xFF)
#define _FS_MODE(Access, SizeGran, Size,Flags) (_u32)(((_u32)((Access) & _FS_MODE_ACCESS_MASK)<<_FS_MODE_ACCESS_OFFSET) | \
((_u32)((SizeGran) & _FS_MODE_OPEN_SIZE_GRAN_MASK)<<_FS_MODE_OPEN_SIZE_GRAN_OFFSET) | \
((_u32)((Size) & _FS_MODE_OPEN_SIZE_MASK)<<_FS_MODE_OPEN_SIZE_OFFSET) | \
((_u32)((Flags) & _FS_MODE_ACCESS_FLAGS_MASK)<<_FS_MODE_ACCESS_FLAGS_OFFSET))
/* sl_FsOpen options */
/* Open for Read */
#define FS_MODE_OPEN_READ _FS_MODE(_FS_MODE_OPEN_READ,0,0,0)
/* Open for Write (in case file exist) */
#define FS_MODE_OPEN_WRITE _FS_MODE(_FS_MODE_OPEN_WRITE,0,0,0)
/* Open for Creating a new file */
#define FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) _sl_GetCreateFsMode(maxSizeInBytes,accessModeFlags)
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
typedef struct
{
_u16 flags;
_u32 FileLen;
_u32 AllocatedLen;
_u32 Token[4];
}SlFsFileInfo_t;
typedef enum
{
_FS_MODE_OPEN_READ = 0,
_FS_MODE_OPEN_WRITE,
_FS_MODE_OPEN_CREATE,
_FS_MODE_OPEN_WRITE_CREATE_IF_NOT_EXIST
}SlFsFileOpenAccessType_e;
typedef enum
{
_FS_FILE_OPEN_FLAG_COMMIT = 0x1, /* MIRROR - for fail safe */
_FS_FILE_OPEN_FLAG_SECURE = 0x2, /* SECURE */
_FS_FILE_OPEN_FLAG_NO_SIGNATURE_TEST = 0x4, /* Relevant to secure file only */
_FS_FILE_OPEN_FLAG_STATIC = 0x8, /* Relevant to secure file only */
_FS_FILE_OPEN_FLAG_VENDOR = 0x10, /* Relevant to secure file only */
_FS_FILE_PUBLIC_WRITE= 0x20, /* Relevant to secure file only, the file can be opened for write without Token */
_FS_FILE_PUBLIC_READ = 0x40 /* Relevant to secure file only, the file can be opened for read without Token */
}SlFileOpenFlags_e;
typedef enum
{
_FS_MODE_SIZE_GRAN_256B = 0, /* MAX_SIZE = 64K */
_FS_MODE_SIZE_GRAN_1KB, /* MAX_SIZE = 256K */
_FS_MODE_SIZE_GRAN_4KB, /* MAX_SZIE = 1M */
_FS_MODE_SIZE_GRAN_16KB, /* MAX_SIZE = 4M */
_FS_MODE_SIZE_GRAN_64KB, /* MAX_SIZE = 16M */
_FS_MAX_MODE_SIZE_GRAN
}_SlFsFileOpenMaxSizeGran_e;
/*****************************************************************************/
/* Internal Function prototypes */
/*****************************************************************************/
_u32 _sl_GetCreateFsMode(_u32 maxSizeInBytes,_u32 accessFlags);
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief open file for read or write from/to storage device
\param[in] pFileName File Name buffer pointer
\param[in] AccessModeAndMaxSize Options: As described below
\param[in] pToken Reserved for future use. Use NULL for this field
\param[out] pFileHandle Pointing on the file and used for read and write commands to the file
AccessModeAndMaxSize possible input \n
FS_MODE_OPEN_READ - Read a file \n
FS_MODE_OPEN_WRITE - Open for write for an existing file \n
FS_MODE_OPEN_CREATE(maxSizeInBytes,accessModeFlags) - Open for creating a new file. Max file size is defined in bytes. \n
For optimal FS size, use max size in 4K-512 bytes steps (e.g. 3584,7680,117760) \n
Several access modes bits can be combined together from SlFileOpenFlags_e enum
\return On success, zero is returned. On error, an error code is returned
\sa sl_FsRead sl_FsWrite sl_FsClose
\note belongs to \ref basic_api
\warning
\par Example:
\code
char* DeviceFileName = "MyFile.txt";
unsigned long MaxSize = 63 * 1024; //62.5K is max file size
long DeviceFileHandle = -1;
long RetVal; //negative retval is an error
unsigned long Offset = 0;
unsigned char InputBuffer[100];
// Create a file and write data. The file in this example is secured, without signature and with a fail safe commit
RetVal = sl_FsOpen((unsigned char *)DeviceFileName,
FS_MODE_OPEN_CREATE(MaxSize , _FS_FILE_OPEN_FLAG_NO_SIGNATURE_TEST | _FS_FILE_OPEN_FLAG_COMMIT ),
NULL, &DeviceFileHandle);
Offset = 0;
//Preferred in secure file that the Offset and the length will be aligned to 16 bytes.
RetVal = sl_FsWrite( DeviceFileHandle, Offset, (unsigned char *)"HelloWorld", strlen("HelloWorld"));
RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
// open the same file for read, using the Token we got from the creation procedure above
RetVal = sl_FsOpen((unsigned char *)DeviceFileName,
FS_MODE_OPEN_READ,
NULL, &DeviceFileHandle);
Offset = 0;
RetVal = sl_FsRead( DeviceFileHandle, Offset, (unsigned char *)InputBuffer, strlen("HelloWorld"));
RetVal = sl_FsClose(DeviceFileHandle, NULL, NULL , 0);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsOpen)
_i32 sl_FsOpen(const _u8 *pFileName,const _u32 AccessModeAndMaxSize,_u32 *pToken,_i32 *pFileHandle);
#endif
/*!
\brief close file in storage device
\param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
\param[in] pCeritificateFileName Reserved for future use. Use NULL.
\param[in] pSignature Reserved for future use. Use NULL.
\param[in] SignatureLen Reserved for future use. Use 0.
\return On success, zero is returned. On error, an error code is returned
\sa sl_FsRead sl_FsWrite sl_FsOpen
\note Call the fs_Close with signature = 'A' signature len = 1 for activating an abort action
\warning
\par Example:
\code
sl_FsClose(FileHandle,0,0,0);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsClose)
_i16 sl_FsClose(const _i32 FileHdl,const _u8* pCeritificateFileName,const _u8* pSignature,const _u32 SignatureLen);
#endif
/*!
\brief Read block of data from a file in storage device
\param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
\param[in] Offset Offset to specific read block
\param[out] pData Pointer for the received data
\param[in] Len Length of the received data
\return On success, returns the number of read bytes. On error, negative number is returned
\sa sl_FsClose sl_FsWrite sl_FsOpen
\note belongs to \ref basic_api
\warning
\par Example:
\code
Status = sl_FsRead(FileHandle, 0, &readBuff[0], readSize);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsRead)
_i32 sl_FsRead(const _i32 FileHdl,_u32 Offset ,_u8* pData,_u32 Len);
#endif
/*!
\brief write block of data to a file in storage device
\param[in] FileHdl Pointer to the file (assigned from sl_FsOpen)
\param[in] Offset Offset to specific block to be written
\param[in] pData Pointer the transmitted data to the storage device
\param[in] Len Length of the transmitted data
\return On success, returns the number of written bytes. On error, an error code is returned
\sa
\note belongs to \ref basic_api
\warning
\par Example:
\code
Status = sl_FsWrite(FileHandle, 0, &buff[0], readSize);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsWrite)
_i32 sl_FsWrite(const _i32 FileHdl,_u32 Offset,_u8* pData,_u32 Len);
#endif
/*!
\brief get info on a file
\param[in] pFileName File name
\param[in] Token Reserved for future use. Use 0
\param[out] pFsFileInfo Returns the File's Information: flags,file size, allocated size and Tokens
\return On success, zero is returned. On error, an error code is returned
\sa sl_FsOpen
\note belongs to \ref basic_api
\warning
\par Example:
\code
Status = sl_FsGetInfo("FileName.html",0,&FsFileInfo);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsGetInfo)
_i16 sl_FsGetInfo(const _u8 *pFileName,const _u32 Token,SlFsFileInfo_t* pFsFileInfo);
#endif
/*!
\brief Delete specific file from a storage or all files from a storage (format)
\param[in] pFileName File Name
\param[in] Token Reserved for future use. Use 0
\return On success, zero is returned. On error, an error code is returned
\sa
\note belongs to \ref basic_api
\warning
\par Example:
\code
Status = sl_FsDel("FileName.html",0);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_FsDel)
_i16 sl_FsDel(const _u8 *pFileName,const _u32 Token);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __FS_H__ */
/*
* netapp.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef __NETAPP_H__
#define __NETAPP_H__
#ifdef __cplusplus
extern "C" {
#endif
/*!
\addtogroup netapp
@{
*/
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
/*ERROR code*/
#define SL_ERROR_NETAPP_RX_BUFFER_LENGTH_ERROR (-230)
/* Http Server interface */
#define MAX_INPUT_STRING (64) /* because of WPA */
#define MAX_AUTH_NAME_LEN (20)
#define MAX_AUTH_PASSWORD_LEN (20)
#define MAX_AUTH_REALM_LEN (20)
#define MAX_DEVICE_URN_LEN (15+1)
#define MAX_DOMAIN_NAME_LEN (24+1)
#define MAX_ACTION_LEN (30)
/* Important: in case the max len is changed, make sure the struct sl_NetAppHttpServerSendToken_t in protocol.h is padded correctly! */
#define MAX_TOKEN_NAME_LEN (20)
#define MAX_TOKEN_VALUE_LEN MAX_INPUT_STRING
#define NETAPP_MAX_SERVICE_TEXT_SIZE (256)
#define NETAPP_MAX_SERVICE_NAME_SIZE (60)
#define NETAPP_MAX_SERVICE_HOST_NAME_SIZE (64)
/* Server Responses */
#define SL_NETAPP_RESPONSE_NONE (0)
#define SL_NETAPP_HTTPSETTOKENVALUE (1)
#define SL_NETAPP_FAMILY_MASK (0x80)
/* mDNS types */
#define SL_NET_APP_MASK_IPP_TYPE_OF_SERVICE (0x00000001)
#define SL_NET_APP_MASK_DEVICE_INFO_TYPE_OF_SERVICE (0x00000002)
#define SL_NET_APP_MASK_HTTP_TYPE_OF_SERVICE (0x00000004)
#define SL_NET_APP_MASK_HTTPS_TYPE_OF_SERVICE (0x00000008)
#define SL_NET_APP_MASK_WORKSATION_TYPE_OF_SERVICE (0x00000010)
#define SL_NET_APP_MASK_GUID_TYPE_OF_SERVICE (0x00000020)
#define SL_NET_APP_MASK_H323_TYPE_OF_SERVICE (0x00000040)
#define SL_NET_APP_MASK_NTP_TYPE_OF_SERVICE (0x00000080)
#define SL_NET_APP_MASK_OBJECITVE_TYPE_OF_SERVICE (0x00000100)
#define SL_NET_APP_MASK_RDP_TYPE_OF_SERVICE (0x00000200)
#define SL_NET_APP_MASK_REMOTE_TYPE_OF_SERVICE (0x00000400)
#define SL_NET_APP_MASK_RTSP_TYPE_OF_SERVICE (0x00000800)
#define SL_NET_APP_MASK_SIP_TYPE_OF_SERVICE (0x00001000)
#define SL_NET_APP_MASK_SMB_TYPE_OF_SERVICE (0x00002000)
#define SL_NET_APP_MASK_SOAP_TYPE_OF_SERVICE (0x00004000)
#define SL_NET_APP_MASK_SSH_TYPE_OF_SERVICE (0x00008000)
#define SL_NET_APP_MASK_TELNET_TYPE_OF_SERVICE (0x00010000)
#define SL_NET_APP_MASK_TFTP_TYPE_OF_SERVICE (0x00020000)
#define SL_NET_APP_MASK_XMPP_CLIENT_TYPE_OF_SERVICE (0x00040000)
#define SL_NET_APP_MASK_RAOP_TYPE_OF_SERVICE (0x00080000)
#define SL_NET_APP_MASK_ALL_TYPE_OF_SERVICE (0xFFFFFFFF)
/********************************************************************************************************/
/* sl_NetAppDnsGetHostByName error codes */
#define SL_NET_APP_DNS_QUERY_NO_RESPONSE (-159) /* DNS query failed, no response */
#define SL_NET_APP_DNS_NO_SERVER (-161) /* No DNS server was specified */
#define SL_NET_APP_DNS_PARAM_ERROR (-162) /* mDNS parameters error */
#define SL_NET_APP_DNS_QUERY_FAILED (-163) /* DNS query failed; no DNS server sent an 'answer' */
#define SL_NET_APP_DNS_INTERNAL_1 (-164)
#define SL_NET_APP_DNS_INTERNAL_2 (-165)
#define SL_NET_APP_DNS_MALFORMED_PACKET (-166) /* Improperly formed or corrupted DNS packet received */
#define SL_NET_APP_DNS_INTERNAL_3 (-167)
#define SL_NET_APP_DNS_INTERNAL_4 (-168)
#define SL_NET_APP_DNS_INTERNAL_5 (-169)
#define SL_NET_APP_DNS_INTERNAL_6 (-170)
#define SL_NET_APP_DNS_INTERNAL_7 (-171)
#define SL_NET_APP_DNS_INTERNAL_8 (-172)
#define SL_NET_APP_DNS_INTERNAL_9 (-173)
#define SL_NET_APP_DNS_MISMATCHED_RESPONSE (-174) /* Server response type does not match the query request*/
#define SL_NET_APP_DNS_INTERNAL_10 (-175)
#define SL_NET_APP_DNS_INTERNAL_11 (-176)
#define SL_NET_APP_DNS_NO_ANSWER (-177) /* No response for one-shot query */
#define SL_NET_APP_DNS_NO_KNOWN_ANSWER (-178) /* No known answer for query */
#define SL_NET_APP_DNS_NAME_MISMATCH (-179) /* Illegal service name according to the RFC */
#define SL_NET_APP_DNS_NOT_STARTED (-180) /* mDNS is not running */
#define SL_NET_APP_DNS_HOST_NAME_ERROR (-181) /* Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763 */
#define SL_NET_APP_DNS_NO_MORE_ENTRIES (-182) /* No more entries be found. */
#define SL_NET_APP_DNS_MAX_SERVICES_ERROR (-200) /* Maximum advertise services are already configured */
#define SL_NET_APP_DNS_IDENTICAL_SERVICES_ERROR (-201) /* Trying to register a service that is already exists */
#define SL_NET_APP_DNS_NOT_EXISTED_SERVICE_ERROR (-203) /* Trying to delete service that does not existed */
#define SL_NET_APP_DNS_ERROR_SERVICE_NAME_ERROR (-204) /* Illegal service name according to the RFC */
#define SL_NET_APP_DNS_RX_PACKET_ALLOCATION_ERROR (-205) /* Retry request */
#define SL_NET_APP_DNS_BUFFER_SIZE_ERROR (-206) /* List size buffer is bigger than internally allowed in the NWP */
#define SL_NET_APP_DNS_NET_APP_SET_ERROR (-207) /* Illegal length of one of the mDNS Set functions */
#define SL_NET_APP_DNS_GET_SERVICE_LIST_FLAG_ERROR (-208)
#define SL_NET_APP_DNS_NO_CONFIGURATION_ERROR (-209)
/* Set Dev name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN) */
#define SL_ERROR_DEVICE_NAME_LEN_ERR (-117)
#define SL_ERROR_DEVICE_NAME_INVALID (-118)
/* Set domain name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME) */
#define SL_ERROR_DOMAIN_NAME_LEN_ERR (-119)
#define SL_ERROR_DOMAIN_NAME_INVALID (-120)
/********************************************************************************************************/
/* NetApp application IDs */
#define SL_NET_APP_HTTP_SERVER_ID (1)
#define SL_NET_APP_DHCP_SERVER_ID (2)
#define SL_NET_APP_MDNS_ID (4)
#define SL_NET_APP_DNS_SERVER_ID (8)
#define SL_NET_APP_DEVICE_CONFIG_ID (16)
/* NetApp application set/get options */
#define NETAPP_SET_DHCP_SRV_BASIC_OPT (0)
/* HTTP server set/get options */
#define NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER (0)
#define NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK (1)
#define NETAPP_SET_GET_HTTP_OPT_AUTH_NAME (2)
#define NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD (3)
#define NETAPP_SET_GET_HTTP_OPT_AUTH_REALM (4)
#define NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS (5)
#define NETAPP_SET_GET_MDNS_CONT_QUERY_OPT (1)
#define NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT (2)
#define NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT (3)
/* DNS server set/get options */
#define NETAPP_SET_GET_DNS_OPT_DOMAIN_NAME (0)
/* Device Config set/get options */
#define NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN (0)
#define NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME (1)
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
typedef struct
{
_u32 PacketsSent;
_u32 PacketsReceived;
_u16 MinRoundTime;
_u16 MaxRoundTime;
_u16 AvgRoundTime;
_u32 TestTime;
}SlPingReport_t;
typedef struct
{
_u32 PingIntervalTime; /* delay between pings, in milliseconds */
_u16 PingSize; /* ping packet size in bytes */
_u16 PingRequestTimeout; /* timeout time for every ping in milliseconds */
_u32 TotalNumberOfAttempts; /* max number of ping requests. 0 - forever */
_u32 Flags; /* flag - 0 report only when finished, 1 - return response for every ping, 2 - stop after 1 successful ping. */
_u32 Ip; /* IPv4 address or IPv6 first 4 bytes */
_u32 Ip1OrPaadding;
_u32 Ip2OrPaadding;
_u32 Ip3OrPaadding;
}SlPingStartCommand_t;
typedef struct _slHttpServerString_t
{
_u8 len;
_u8 *data;
} slHttpServerString_t;
typedef struct _slHttpServerData_t
{
_u8 value_len;
_u8 name_len;
_u8 *token_value;
_u8 *token_name;
} slHttpServerData_t;
typedef struct _slHttpServerPostData_t
{
slHttpServerString_t action;
slHttpServerString_t token_name;
slHttpServerString_t token_value;
}slHttpServerPostData_t;
typedef union
{
slHttpServerString_t httpTokenName; /* SL_NETAPP_HTTPGETTOKENVALUE */
slHttpServerPostData_t httpPostData; /* SL_NETAPP_HTTPPOSTTOKENVALUE */
} SlHttpServerEventData_u;
typedef union
{
slHttpServerString_t token_value;
} SlHttpServerResponsedata_u;
typedef struct
{
_u32 Event;
SlHttpServerEventData_u EventData;
}SlHttpServerEvent_t;
typedef struct
{
_u32 Response;
SlHttpServerResponsedata_u ResponseData;
}SlHttpServerResponse_t;
typedef struct
{
_u32 lease_time;
_u32 ipv4_addr_start;
_u32 ipv4_addr_last;
}SlNetAppDhcpServerBasicOpt_t;
/*mDNS parameters*/
typedef enum
{
SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1,
SL_NET_APP_FULL_SERVICE_IPV4_TYPE,
SL_NET_APP_SHORT_SERVICE_IPV4_TYPE
} SlNetAppGetServiceListType_e;
typedef struct
{
_u32 service_ipv4;
_u16 service_port;
_u16 Reserved;
}SlNetAppGetShortServiceIpv4List_t;
typedef struct
{
_u32 service_ipv4;
_u16 service_port;
_u16 Reserved;
_u8 service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
_u8 service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
}SlNetAppGetFullServiceIpv4List_t;
typedef struct
{
_u32 service_ipv4;
_u16 service_port;
_u16 Reserved;
_u8 service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
_u8 service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
_u8 service_text[NETAPP_MAX_SERVICE_TEXT_SIZE];
}SlNetAppGetFullServiceWithTextIpv4List_t;
typedef struct
{
/*The below parameters are used to configure the advertise times and interval
For example:
If:
Period is set to T
Repetitions are set to P
Telescopic factor is K=2
The transmission shall be:
advertise P times
wait T
advertise P times
wait 4 * T
advertise P time
wait 16 * T ... (till max time reached / configuration changed / query issued)
*/
_u32 t; /* Number of ticks for the initial period. Default is 100 ticks for 1 second. */
_u32 p; /* Number of repetitions. Default value is 1 */
_u32 k; /* Telescopic factor. Default value is 2. */
_u32 RetransInterval;/* Announcing retransmission interval */
_u32 Maxinterval; /* Announcing max period interval */
_u32 max_time; /* Announcing max time */
}SlNetAppServiceAdvertiseTimingParameters_t;
/*****************************************************************************/
/* Types declarations */
/*****************************************************************************/
typedef void (*P_SL_DEV_PING_CALLBACK)(SlPingReport_t*);
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief Starts a network application
Gets and starts network application for the current WLAN mode
\param[in] AppBitMap application bitmap, could be one or combination of the following: \n
- SL_NET_APP_HTTP_SERVER_ID
- SL_NET_APP_DHCP_SERVER_ID
- SL_NET_APP_MDNS_ID
\return On error, negative number is returned
\sa Stop one or more the above started applications using sl_NetAppStop
\note This command activates the application for the current WLAN mode (AP or STA)
\warning
\par Example:
\code
For example: Starting internal HTTP server + DHCP server:
sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID | SL_NET_APP_DHCP_SERVER_ID)
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppStart)
_i16 sl_NetAppStart(const _u32 AppBitMap);
#endif
/*!
\brief Stops a network application
Gets and stops network application for the current WLAN mode
\param[in] AppBitMap application id, could be one of the following: \n
- SL_NET_APP_HTTP_SERVER_ID
- SL_NET_APP_DHCP_SERVER_ID
- SL_NET_APP_MDNS_ID
\return On error, negative number is returned
\sa
\note This command disables the application for the current active WLAN mode (AP or STA)
\warning
\par Example:
\code
For example: Stopping internal HTTP server:
sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppStop)
_i16 sl_NetAppStop(const _u32 AppBitMap);
#endif
/*!
\brief Get host IP by name
Obtain the IP Address of machine on network, by machine name.
\param[in] hostname host name
\param[in] usNameLen name length
\param[out] out_ip_addr This parameter is filled in with
host IP address. In case that host name is not
resolved, out_ip_addr is zero.
\param[in] family protocol family
\return On success, 0 is returned.
On error, negative is returned
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
Possible DNS error codes:
- SL_NET_APP_DNS_QUERY_NO_RESPONSE
- SL_NET_APP_DNS_NO_SERVER
- SL_NET_APP_DNS_QUERY_FAILED
- SL_NET_APP_DNS_MALFORMED_PACKET
- SL_NET_APP_DNS_MISMATCHED_RESPONSE
\sa
\note Only one sl_NetAppDnsGetHostByName can be handled at a time.
Calling this API while the same command is called from another thread, may result
in one of the two scenarios:
1. The command will wait (internal) until the previous command finish, and then be executed.
2. There are not enough resources and POOL_IS_EMPTY error will return.
In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
again later to issue the command.
\warning
In case an IP address in a string format is set as input, without any prefix (e.g. "1.2.3.4") the device will not
try to access the DNS and it will return the input address on the 'out_ip_addr' field
\par Example:
\code
_u32 DestinationIP;
sl_NetAppDnsGetHostByName("www.google.com", strlen("www.google.com"), &DestinationIP,SL_AF_INET);
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(80);
Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);
AddrSize = sizeof(SlSockAddrIn_t);
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
_i16 sl_NetAppDnsGetHostByName(_i8 * hostname,const _u16 usNameLen, _u32* out_ip_addr,const _u8 family );
#endif
/*!
\brief Return service attributes like IP address, port and text according to service name
\par
The user sets a service name Full/Part (see example below), and should get:
- IP of service
- The port of service
- The text of service
Hence it can make a connection to the specific service and use it.
It is similar to get host by name method.
It is done by a single shot query with PTR type on the service name.
The command that is sent is from constant parameters and variables parameters.
\param[in] pService Service name can be full or partial. \n
Example for full service name:
1. PC1._ipp._tcp.local
2. PC2_server._ftp._tcp.local \n
.
Example for partial service name:
1. _ipp._tcp.local
2. _ftp._tcp.local
\param[in] ServiceLen The length of the service name (in_pService).
\param[in] Family IPv4 or IPv6 (SL_AF_INET , SL_AF_INET6).
\param[out] pAddr Contains the IP address of the service.
\param[out] pPort Contains the port of the service.
\param[out] pTextLen Has 2 options. One as Input field and the other one as output:
- Input: \n
Contains the max length of the text that the user wants to get.\n
It means that if the text len of service is bigger that its value than
the text is cut to inout_TextLen value.
- Output: \n
Contain the length of the text that is returned. Can be full text or part of the text (see above).
\param[out] pOut_pText Contains the text of the service full or partial
\return On success, zero is returned
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
In case No service is found error SL_NET_APP_DNS_NO_ANSWER will be returned
\note The returns attributes belongs to the first service found.
There may be other services with the same service name that will response to the query.
The results of these responses are saved in the peer cache of the Device and should be read by another API.
Only one sl_NetAppDnsGetHostByService can be handled at a time.
Calling this API while the same command is called from another thread, may result
in one of the two scenarios:
1. The command will wait (internal) until the previous command finish, and then be executed.
2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
again later to issue the command.
\warning Text length can be 120 bytes only
*/
#if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
_i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all (or only part): name + subtype + service */
const _u8 ServiceLen,
const _u8 Family, /* 4-IPv4 , 16-IPv6 */
_u32 pAddr[],
_u32 *pPort,
_u16 *pTextLen, /* in: max len , out: actual len */
_i8 *pText
);
#endif
/*!
\brief Get service List
Insert into out pBuffer a list of peer's services that are the NWP.
The list is in a form of service struct. The user should chose the type
of the service struct like:
- Full service parameters with text.
- Full service parameters.
- Short service parameters (port and IP only) especially for tiny hosts.
The different types of struct are made to give the
Possibility to save memory in the host
The user also chose how many max services to get and start point index
NWP peer cache.
For example:
1. Get max of 3 full services from index 0.Up to 3 full services
from index 0 are inserted into pBuffer (services that are in indexes 0,1,2).
2. Get max of 4 full services from index 3.Up to 4 full services
from index 3 are inserted into pBuffer (services that are in indexes 3,4,5,6).
3. Get max of 2 int services from index 6.Up to 2 int services
from index 6 are inserted into pBuffer (services that are in indexes 6,7).
See below - command parameters.
\param[in] indexOffset - The start index in the peer cache that from it the first service is returned.
\param[in] MaxServiceCount - The Max services that can be returned if existed or if not exceed the max index
in the peer cache
\param[in] Flags - an ENUM number that means which service struct to use (means which types of service to fill)
- use SlNetAppGetFullServiceWithTextIpv4List_t
- use SlNetAppGetFullServiceIpv4List_t
- use SlNetAppGetShortServiceIpv4List_t
\param[out] Buffer - The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags
input parameter.
\return ServiceFoundCount - The number of the services that were inserted into the buffer. zero means no service is found
negative number means an error
\sa sl_NetAppMDNSRegisterService
\note
\warning
if the out pBuffer size is bigger than an RX packet(1480), than
an error is returned because there
is no place in the RX packet.
The size is a multiply of MaxServiceCount and size of service struct(that is set
according to flag value).
*/
#if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
_i16 sl_NetAppGetServiceList(const _u8 IndexOffest,
const _u8 MaxServiceCount,
const _u8 Flags,
_i8 *pBuffer,
const _u32 RxBufferLength
);
#endif
/*!
\brief Unregister mDNS service
This function deletes the mDNS service from the mDNS package and the database.
The mDNS service that is to be unregistered is a service that the application no longer wishes to provide. \n
The service name should be the full service name according to RFC
of the DNS-SD - meaning the value in name field in the SRV answer.
Examples for service names:
1. PC1._ipp._tcp.local
2. PC2_server._ftp._tcp.local
\param[in] pServiceName Full service name. \n
Example for service name:
1. PC1._ipp._tcp.local
2. PC2_server._ftp._tcp.local
\param[in] ServiceLen The length of the service.
\return On success, zero is returned
\sa sl_NetAppMDNSRegisterService
\note
\warning
The size of the service length should be smaller than 255.
*/
#if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
_i16 sl_NetAppMDNSUnRegisterService(const _i8 *pServiceName,const _u8 ServiceNameLen);
#endif
/*!
\brief Register a new mDNS service
\par
This function registers a new mDNS service to the mDNS package and the DB.
This registered service is a service offered by the application.
The service name should be full service name according to RFC
of the DNS-SD - meaning the value in name field in the SRV answer.
Example for service name:
1. PC1._ipp._tcp.local
2. PC2_server._ftp._tcp.local
If the option is_unique is set, mDNS probes the service name to make sure
it is unique before starting to announce the service on the network.
Instance is the instance portion of the service name.
\param[in] ServiceLen The length of the service.
\param[in] TextLen The length of the service should be smaller than 64.
\param[in] port The port on this target host port.
\param[in] TTL The TTL of the service
\param[in] Options bitwise parameters: \n
- bit 0 - service is unique (means that the service needs to be unique)
- bit 31 - for internal use if the service should be added or deleted (set means ADD).
- bit 1-30 for future.
\param[in] pServiceName The service name.
Example for service name: \n
1. PC1._ipp._tcp.local
2. PC2_server._ftp._tcp.local
\param[in] pText The description of the service.
should be as mentioned in the RFC
(according to type of the service IPP,FTP...)
\return On success, zero is returned
Possible error codes:
- Maximum advertise services are already configured.
Delete another existed service that is registered and then register again the new service
- Trying to register a service that is already exists
- Trying to delete service that does not existed
- Illegal service name according to the RFC
- Retry request
- Illegal length of one of the mDNS Set functions
- mDNS is not operational as the device has no IP.Connect the device to an AP to get an IP address.
- mDNS parameters error
- mDNS internal cache error
- mDNS internal error
- Adding a service is not allowed as it is already exist (duplicate service)
- mDNS is not running
- Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763
- List size buffer is bigger than internally allowed in the NWP (API get service list),
change the APIs parameters to decrease the size of the list
\sa sl_NetAppMDNSUnRegisterService
\warning 1) Temporary - there is an allocation on stack of internal buffer.
Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. \n
It means that the sum of the text length and service name length cannot be bigger than
NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.\n
If it is - An error is returned. \n
2) According to now from certain constraints the variables parameters are set in the
attribute part (contain constant parameters)
*/
#if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
_i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName,
const _u8 ServiceNameLen,
const _i8* pText,
const _u8 TextLen,
const _u16 Port,
const _u32 TTL,
_u32 Options);
#endif
/*!
\brief send ICMP ECHO_REQUEST to network hosts
Ping uses the ICMP protocol's mandatory ECHO_REQUEST
\param[in] pPingParams Pointer to the ping request structure: \n
- if flags parameter is set to 0, ping will report back once all requested pings are done (as defined by TotalNumberOfAttempts). \n
- if flags parameter is set to 1, ping will report back after every ping, for TotalNumberOfAttempts.
- if flags parameter is set to 2, ping will stop after the first successful ping, and report back for the successful ping, as well as any preceding failed ones.
For stopping an ongoing ping activity, set parameters IP address to 0
\param[in] family SL_AF_INET or SL_AF_INET6
\param[out] pReport Ping pReport
\param[out] pCallback Callback function upon completion.
If callback is NULL, the API is blocked until data arrives
\return On success, zero is returned. On error, -1 is returned
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_NetAppPingReport
\note Only one sl_NetAppPingStart can be handled at a time.
Calling this API while the same command is called from another thread, may result
in one of the two scenarios:
1. The command will wait (internal) until the previous command finish, and then be executed.
2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
again later to issue the command.
\warning
\par Example:
\code
An example of sending 20 ping requests and reporting results to a callback routine when
all requests are sent:
// callback routine
void pingRes(SlPingReport_t* pReport)
{
// handle ping results
}
// ping activation
void PingTest()
{
SlPingReport_t report;
SlPingStartCommand_t pingCommand;
pingCommand.Ip = SL_IPV4_VAL(10,1,1,200); // destination IP address is 10.1.1.200
pingCommand.PingSize = 150; // size of ping, in bytes
pingCommand.PingIntervalTime = 100; // delay between pings, in milliseconds
pingCommand.PingRequestTimeout = 1000; // timeout for every ping in milliseconds
pingCommand.TotalNumberOfAttempts = 20; // max number of ping requests. 0 - forever
pingCommand.Flags = 0; // report only when finished
sl_NetAppPingStart( &pingCommand, SL_AF_INET, &report, pingRes ) ;
}
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppPingStart)
_i16 sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams,const _u8 family,SlPingReport_t *pReport,const P_SL_DEV_PING_CALLBACK pPingCallback);
#endif
/*!
\brief Internal function for setting network application configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] AppId Application id, could be one of the following: \n
- SL_NET_APP_HTTP_SERVER_ID
- SL_NET_APP_DHCP_SERVER_ID
- SL_NET_APP_MDNS_ID
- SL_NET_APP_DEVICE_CONFIG_ID
\param[in] SetOptions set option, could be one of the following: \n
- SL_NET_APP_DHCP_SERVER_ID
- NETAPP_SET_DHCP_SRV_BASIC_OPT
- SL_NET_APP_HTTP_SERVER_ID
- NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
- NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
- NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
- NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
- NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
- NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
- SL_NET_APP_MDNS_ID
- NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
- NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
- NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
- SL_NET_APP_DEVICE_CONFIG_ID
- NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
- NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
\param[in] OptionLen option structure length
\param[in] pOptionValues pointer to the option structure
\sa
\note
\warning
\par
\code
Set DHCP Server (AP mode) parameters example:
SlNetAppDhcpServerBasicOpt_t dhcpParams;
_u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
dhcpParams.lease_time = 4096; // lease time (in seconds) of the IP Address
dhcpParams.ipv4_addr_start = SL_IPV4_VAL(192,168,1,10); // first IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1)
dhcpParams.ipv4_addr_last = SL_IPV4_VAL(192,168,1,16); // last IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1)
sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID); // Stop DHCP server before settings
sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, outLen, (_u8* )&dhcpParams); // set parameters
sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID); // Start DHCP server with new settings
\endcode
\code
Set Device URN name example:
Device name, maximum length of 33 characters
Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
In case no device URN name set, the default name is "mysimplelink"
Allowed characters in device name are: 'a - z' , 'A - Z' , '0-9' and '-'
_u8 *my_device = "MY-SIMPLELINK-DEV";
sl_NetAppSet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device), (_u8 *) my_device);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppSet)
_i32 sl_NetAppSet(const _u8 AppId ,const _u8 Option,const _u8 OptionLen,const _u8 *pOptionValue);
#endif
/*!
\brief Internal function for getting network applications configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] AppId Application id, could be one of the following: \n
- SL_NET_APP_HTTP_SERVER_ID
- SL_NET_APP_DHCP_SERVER_ID
- SL_NET_APP_MDNS_ID
- SL_NET_APP_DEVICE_CONFIG_ID
\param[in] SetOptions set option, could be one of the following: \n
- SL_NET_APP_DHCP_SERVER_ID
- NETAPP_SET_DHCP_SRV_BASIC_OPT
- SL_NET_APP_HTTP_SERVER_ID
- NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
- NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
- NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
- NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
- NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
- NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
- SL_NET_APP_MDNS_ID
- NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
- NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
- NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
- SL_NET_APP_DEVICE_CONFIG_ID
- NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
- NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
\param[in] OptionLen The length of the allocated memory as input, when the
function complete, the value of this parameter would be
the len that actually read from the device.
If the device return length that is longer from the input
value, the function will cut the end of the returned structure
and will return ESMALLBUF
\param[out] pValues pointer to the option structure which will be filled with the response from the device
\sa
\note
\warning
\par
\code
Get DHCP Server parameters example:
SlNetAppDhcpServerBasicOpt_t dhcpParams;
_u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
sl_NetAppGet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (_u8* )&dhcpParams);
printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n",
SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2),
SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0),
SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2),
SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0),
dhcpParams.lease_time);
\endcode
\code
Get Device URN name example:
Maximum length of 33 characters of device name.
Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
in case no device URN name set, the default name is "mysimplelink"
_u8 my_device_name[35];
sl_NetAppGet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device_name), (_u8 *)my_device_name);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetAppGet)
_i32 sl_NetAppGet(const _u8 AppId,const _u8 Option,_u8 *pOptionLen, _u8 *pOptionValue);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __NETAPP_H__ */
/*
* netcfg.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef __NETCFG_H__
#define __NETCFG_H__
#ifdef __cplusplus
extern "C" {
#endif
/*!
\addtogroup netcfg
@{
*/
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
#define SL_MAC_ADDR_LEN (6)
#define SL_IPV4_VAL(add_3,add_2,add_1,add_0) ((((_u32)add_3 << 24) & 0xFF000000) | (((_u32)add_2 << 16) & 0xFF0000) | (((_u32)add_1 << 8) & 0xFF00) | ((_u32)add_0 & 0xFF) )
#define SL_IPV4_BYTE(val,index) ( (val >> (index*8)) & 0xFF )
#define IPCONFIG_MODE_DISABLE_IPV4 (0)
#define IPCONFIG_MODE_ENABLE_IPV4 (1)
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
typedef enum
{
SL_MAC_ADDRESS_SET = 1,
SL_MAC_ADDRESS_GET = 2,
SL_IPV4_STA_P2P_CL_GET_INFO = 3,
SL_IPV4_STA_P2P_CL_DHCP_ENABLE = 4,
SL_IPV4_STA_P2P_CL_STATIC_ENABLE = 5,
SL_IPV4_AP_P2P_GO_GET_INFO = 6,
SL_IPV4_AP_P2P_GO_STATIC_ENABLE = 7,
SL_SET_HOST_RX_AGGR = 8,
MAX_SETTINGS = 0xFF
}Sl_NetCfg_e;
typedef struct
{
_u32 ipV4;
_u32 ipV4Mask;
_u32 ipV4Gateway;
_u32 ipV4DnsServer;
}SlNetCfgIpV4Args_t;
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief Internal function for setting network configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] ConfigId configuration id
\param[in] ConfigOpt configurations option
\param[in] ConfigLen configurations len
\param[in] pValues configurations values
\sa
\note
\warning
\par Examples:
\code
SL_MAC_ADDRESS_SET:
Setting MAC address to the Device.
The new MAC address will override the default MAC address and it be saved in the FileSystem.
Requires restarting the device for updating this setting.
_u8 MAC_Address[6];
MAC_Address[0] = 0x8;
MAC_Address[1] = 0x0;
MAC_Address[2] = 0x28;
MAC_Address[3] = 0x22;
MAC_Address[4] = 0x69;
MAC_Address[5] = 0x31;
sl_NetCfgSet(SL_MAC_ADDRESS_SET,1,SL_MAC_ADDR_LEN,(_u8 *)newMacAddress);
sl_Stop(0);
sl_Start(NULL,NULL,NULL);
\endcode
\code
SL_IPV4_STA_P2P_CL_STATIC_ENABLE:
Setting a static IP address to the device working in STA mode or P2P client.
The IP address will be stored in the FileSystem.
In order to disable the static IP and get the address assigned from DHCP one should use SL_STA_P2P_CL_IPV4_DHCP_SET
SlNetCfgIpV4Args_t ipV4;
ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address
ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this STA/P2P
ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address
ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
sl_Stop(0);
sl_Start(NULL,NULL,NULL);
\endcode
\code
SL_IPV4_STA_P2P_CL_DHCP_ENABLE:
Setting IP address by DHCP to FileSystem using WLAN sta mode or P2P client.
This should be done once if using Serial Flash.
This is the system's default mode for acquiring an IP address after WLAN connection.
_u8 val = 1;
sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,1,&val);
sl_Stop(0);
sl_Start(NULL,NULL,NULL);
\endcode
\code
SL_IPV4_AP_P2P_GO_STATIC_ENABLE:
Setting a static IP address to the device working in AP mode or P2P go.
The IP address will be stored in the FileSystem. Requires restart.
SlNetCfgIpV4Args_t ipV4;
ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address
ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this AP/P2P
ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address
ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
sl_Stop(0);
sl_Start(NULL,NULL,NULL);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetCfgSet)
_i32 sl_NetCfgSet(const _u8 ConfigId,const _u8 ConfigOpt,const _u8 ConfigLen,const _u8 *pValues);
#endif
/*!
\brief Internal function for getting network configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] ConfigId configuration id
\param[out] pConfigOpt Get configurations option
\param[out] pConfigLen The length of the allocated memory as input, when the
function complete, the value of this parameter would be
the len that actually read from the device.\n
If the device return length that is longer from the input
value, the function will cut the end of the returned structure
and will return ESMALLBUF
\param[out] pValues - get configurations values
\sa
\note
\warning
\par Examples:
\code
SL_MAC_ADDRESS_GET:
Get the device MAC address.
The returned MAC address is taken from FileSystem first. If the MAC address was not set by SL_MAC_ADDRESS_SET, the default MAC address
is retrieved from HW.
_u8 macAddressVal[SL_MAC_ADDR_LEN];
_u8 macAddressLen = SL_MAC_ADDR_LEN;
sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(_u8 *)macAddressVal);
\endcode
\code
SL_IPV4_STA_P2P_CL_GET_INFO:
Get IP address from WLAN station or P2P client. A DHCP flag is returned to indicate if the IP address is static or from DHCP.
_u8 len = sizeof(SlNetCfgIpV4Args_t);
_u8 dhcpIsOn = 0;
SlNetCfgIpV4Args_t ipV4 = {0};
sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&dhcpIsOn,&len,(_u8 *)&ipV4);
printf("DHCP is %s IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
(dhcpIsOn > 0) ? "ON" : "OFF",
SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0),
SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0),
SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0),
SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0));
\endcode
\code
SL_IPV4_AP_P2P_GO_GET_INFO:
Get static IP address for AP or P2P go.
_u8 len = sizeof(SlNetCfgIpV4Args_t);
_u8 dhcpIsOn = 0; // this flag is meaningless on AP/P2P go.
SlNetCfgIpV4Args_t ipV4 = {0};
sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&dhcpIsOn,&len,(_u8 *)&ipV4);
printf("IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0),
SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0),
SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0),
SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0));
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_NetCfgGet)
_i32 sl_NetCfgGet(const _u8 ConfigId ,_u8 *pConfigOpt, _u8 *pConfigLen, _u8 *pValues);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __NETCFG_H__ */
/*
* nonos.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __NONOS_H__
#define __NONOS_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SL_PLATFORM_MULTI_THREADED
/* This function call the user defined function, if defined, from the sync wait loop */
/* The use case of this function is to allow nonos system to call a user function to put the device into sleep */
/* The wake up should be activated after getting an interrupt from the device to Host */
/* The user function must return without blocking to prevent a delay on the event handling */
/*
#define _SlSyncWaitLoopCallback UserSleepFunction
*/
#define NONOS_WAIT_FOREVER 0xFF
#define NONOS_NO_WAIT 0x00
#define NONOS_RET_OK (0)
#define NONOS_RET_ERR (0xFF)
#define OSI_OK NONOS_RET_OK
#define __NON_OS_SYNC_OBJ_CLEAR_VALUE 0x11
#define __NON_OS_SYNC_OBJ_SIGNAL_VALUE 0x22
#define __NON_OS_LOCK_OBJ_UNLOCK_VALUE 0x33
#define __NON_OS_LOCK_OBJ_LOCK_VALUE 0x44
/*!
\brief type definition for the return values of this adaptation layer
*/
typedef _i8 _SlNonOsRetVal_t;
/*!
\brief type definition for a time value
*/
typedef _u8 _SlNonOsTime_t;
/*!
\brief type definition for a sync object container
Sync object is object used to synchronize between two threads or thread and interrupt handler.
One thread is waiting on the object and the other thread send a signal, which then
release the waiting thread.
The signal must be able to be sent from interrupt context.
This object is generally implemented by binary semaphore or events.
*/
typedef _u8 _SlNonOsSemObj_t;
#define _SlTime_t _SlNonOsTime_t
#define _SlSyncObj_t _SlNonOsSemObj_t
#define _SlLockObj_t _SlNonOsSemObj_t
#define SL_OS_WAIT_FOREVER NONOS_WAIT_FOREVER
#define SL_OS_RET_CODE_OK NONOS_RET_OK
#define SL_OS_NO_WAIT NONOS_NO_WAIT
/*!
\brief This function creates a sync object
The sync object is used for synchronization between different thread or ISR and
a thread.
\param pSyncObj - pointer to the sync object control block
\return upon successful creation the function return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsSyncObjCreate(pSyncObj) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_CLEAR_VALUE)
/*!
\brief This function deletes a sync object
\param pSyncObj - pointer to the sync object control block
\return upon successful deletion the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsSyncObjDelete(pSyncObj) _SlNonOsSemSet(pSyncObj,0)
/*!
\brief This function generates a sync signal for the object.
All suspended threads waiting on this sync object are resumed
\param pSyncObj - pointer to the sync object control block
\return upon successful signaling the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note the function could be called from ISR context
\warning
*/
#define _SlNonOsSyncObjSignal(pSyncObj) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_SIGNAL_VALUE)
/*!
\brief This function waits for a sync signal of the specific sync object
\param pSyncObj - pointer to the sync object control block
\param Timeout - numeric value specifies the maximum number of mSec to
stay suspended while waiting for the sync signal
Currently, the simple link driver uses only two values:
- NONOS_WAIT_FOREVER
- NONOS_NO_WAIT
\return upon successful reception of the signal within the timeout window return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsSyncObjWait(pSyncObj , Timeout) _SlNonOsSemGet(pSyncObj,__NON_OS_SYNC_OBJ_SIGNAL_VALUE,__NON_OS_SYNC_OBJ_CLEAR_VALUE,Timeout)
/*!
\brief This function clears a sync object
\param pSyncObj - pointer to the sync object control block
\return upon successful clearing the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsSyncObjClear(pSyncObj) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_CLEAR_VALUE)
/*!
\brief This function creates a locking object.
The locking object is used for protecting a shared resources between different
threads.
\param pLockObj - pointer to the locking object control block
\return upon successful creation the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsLockObjCreate(pLockObj) _SlNonOsSemSet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE)
/*!
\brief This function deletes a locking object.
\param pLockObj - pointer to the locking object control block
\return upon successful deletion the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsLockObjDelete(pLockObj) _SlNonOsSemSet(pLockObj,0)
/*!
\brief This function locks a locking object.
All other threads that call this function before this thread calls
the _SlNonOsLockObjUnlock would be suspended
\param pLockObj - pointer to the locking object control block
\param Timeout - numeric value specifies the maximum number of mSec to
stay suspended while waiting for the locking object
Currently, the simple link driver uses only two values:
- NONOS_WAIT_FOREVER
- NONOS_NO_WAIT
\return upon successful reception of the locking object the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsLockObjLock(pLockObj , Timeout) _SlNonOsSemGet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE,__NON_OS_LOCK_OBJ_LOCK_VALUE,Timeout)
/*!
\brief This function unlock a locking object.
\param pLockObj - pointer to the locking object control block
\return upon successful unlocking the function should return 0
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
#define _SlNonOsLockObjUnlock(pLockObj) _SlNonOsSemSet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE)
/*!
\brief This function call the pEntry callback from a different context
\param pEntry - pointer to the entry callback function
\param pValue - pointer to any type of memory structure that would be
passed to pEntry callback from the execution thread.
\param flags - execution flags - reserved for future usage
\return upon successful registration of the spawn the function return 0
(the function is not blocked till the end of the execution of the function
and could be returned before the execution is actually completed)
Otherwise, a negative value indicating the error code shall be returned
\note
\warning
*/
_SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags);
/*!
\brief This function must be called from the main loop in non-os paltforms
\param None
\return 0 - No more activities
1 - Activity still in progress
\note
\warning
*/
_SlNonOsRetVal_t _SlNonOsMainLoopTask(void);
extern _SlNonOsRetVal_t _SlNonOsSemGet(_SlNonOsSemObj_t* pSyncObj, _SlNonOsSemObj_t WaitValue, _SlNonOsSemObj_t SetValue, _SlNonOsTime_t Timeout);
extern _SlNonOsRetVal_t _SlNonOsSemSet(_SlNonOsSemObj_t* pSemObj , _SlNonOsSemObj_t Value);
extern _SlNonOsRetVal_t _SlNonOsSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags);
#if (defined(_SlSyncWaitLoopCallback))
extern void _SlSyncWaitLoopCallback(void);
#endif
/*****************************************************************************
Overwrite SimpleLink driver OS adaptation functions
*****************************************************************************/
#undef sl_SyncObjCreate
#define sl_SyncObjCreate(pSyncObj,pName) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_CLEAR_VALUE)
#undef sl_SyncObjDelete
#define sl_SyncObjDelete(pSyncObj) _SlNonOsSemSet(pSyncObj,0)
#undef sl_SyncObjSignal
#define sl_SyncObjSignal(pSyncObj) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_SIGNAL_VALUE)
#undef sl_SyncObjSignalFromIRQ
#define sl_SyncObjSignalFromIRQ(pSyncObj) _SlNonOsSemSet(pSyncObj,__NON_OS_SYNC_OBJ_SIGNAL_VALUE)
#undef sl_SyncObjWait
#define sl_SyncObjWait(pSyncObj,Timeout) _SlNonOsSemGet(pSyncObj,__NON_OS_SYNC_OBJ_SIGNAL_VALUE,__NON_OS_SYNC_OBJ_CLEAR_VALUE,Timeout)
#undef sl_LockObjCreate
#define sl_LockObjCreate(pLockObj,pName) _SlNonOsSemSet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE)
#undef sl_LockObjDelete
#define sl_LockObjDelete(pLockObj) _SlNonOsSemSet(pLockObj,0)
#undef sl_LockObjLock
#define sl_LockObjLock(pLockObj,Timeout) _SlNonOsSemGet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE,__NON_OS_LOCK_OBJ_LOCK_VALUE,Timeout)
#undef sl_LockObjUnlock
#define sl_LockObjUnlock(pLockObj) _SlNonOsSemSet(pLockObj,__NON_OS_LOCK_OBJ_UNLOCK_VALUE)
#undef sl_Spawn
#define sl_Spawn(pEntry,pValue,flags) _SlNonOsSpawn(pEntry,pValue,flags)
#undef _SlTaskEntry
#define _SlTaskEntry _SlNonOsMainLoopTask
#endif /* !SL_PLATFORM_MULTI_THREADED */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/*
* objInclusion.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <simplelink.h>
#ifndef OBJINCLUSION_H_
#define OBJINCLUSION_H_
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
For future use
*******************************************************************************/
#define __inln /* if inline functions requiered: #define __inln inline */
#define SL_DEVICE /* Device silo is currently always mandatory */
/******************************************************************************
Qualifiers for package customizations
*******************************************************************************/
#if defined (SL_DEVICE)
#define __dev 1
#else
#define __dev 0
#endif
#if defined (SL_DEVICE) && defined (SL_INC_EXT_API)
#define __dev__ext 1
#else
#define __dev__ext 0
#endif
#if (!defined (SL_PLATFORM_MULTI_THREADED)) || (!defined (SL_PLATFORM_EXTERNAL_SPAWN))
#define __int__spwn 1
#else
#define __int__spwn 0
#endif
#if defined (SL_INC_NET_APP_PKG)
#define __nap 1
#else
#define __nap 0
#endif
#if defined (SL_INC_NET_APP_PKG) && defined (SL_INC_SOCK_CLIENT_SIDE_API)
#define __nap__clt 1
#else
#define __nap__clt 0
#endif
#if defined (SL_INC_NET_APP_PKG) && defined (SL_INC_EXT_API)
#define __nap__ext 1
#else
#define __nap__ext 0
#endif
#if defined (SL_INC_NET_CFG_PKG)
#define __ncg 1
#else
#define __ncg 0
#endif
#if defined (SL_INC_NET_CFG_PKG) && defined (SL_INC_EXT_API)
#define __ncg__ext 1
#else
#define __ncg__ext 0
#endif
#if defined (SL_INC_NVMEM_PKG)
#define __nvm 1
#else
#define __nvm 0
#endif
#if defined (SL_INC_SOCKET_PKG)
#define __sck 1
#else
#define __sck 0
#endif
#if defined (SL_INC_SOCKET_PKG) && defined (SL_INC_EXT_API)
#define __sck__ext 1
#else
#define __sck__ext 0
#endif
#if defined (SL_INC_SOCKET_PKG) && defined (SL_INC_SOCK_SERVER_SIDE_API)
#define __sck__srv 1
#else
#define __sck__srv 0
#endif
#if defined (SL_INC_SOCKET_PKG) && defined (SL_INC_SOCK_CLIENT_SIDE_API)
#define __sck__clt 1
#else
#define __sck__clt 0
#endif
#if defined (SL_INC_SOCKET_PKG) && defined (SL_INC_SOCK_RECV_API)
#define __sck__rcv 1
#else
#define __sck__rcv 0
#endif
#if defined (SL_INC_SOCKET_PKG) && defined (SL_INC_SOCK_SEND_API)
#define __sck__snd 1
#else
#define __sck__snd 0
#endif
#if defined (SL_INC_WLAN_PKG)
#define __wln 1
#else
#define __wln 0
#endif
#if defined (SL_INC_WLAN_PKG) && defined (SL_INC_EXT_API)
#define __wln__ext 1
#else
#define __wln__ext 0
#endif
/* The return 1 is the function need to be included in the output */
#define _SL_INCLUDE_FUNC(Name) (_SL_INC_##Name)
/* Driver */
#define _SL_INC_sl_NetAppStart __nap__ext
#define _SL_INC_sl_NetAppStop __nap__ext
#define _SL_INC_sl_NetAppDnsGetHostByName __nap__clt
#define _SL_INC_sl_NetAppDnsGetHostByService __nap__ext
#define _SL_INC_sl_NetAppMDNSRegisterService __nap__ext
#define _SL_INC_sl_NetAppMDNSUnRegisterService __nap__ext
#define _SL_INC_sl_NetAppMDNSRegisterUnregisterService __nap__ext
#define _SL_INC_sl_NetAppGetServiceList __nap__ext
#define _SL_INC_sl_DnsGetHostByAddr __nap__ext
#define _SL_INC_sl_NetAppPingStart __nap__ext
#define _SL_INC_sl_NetAppPingReport __nap__ext
#define _SL_INC_sl_NetAppSet __nap__ext
#define _SL_INC_sl_NetAppGet __nap__ext
/* FS */
#define _SL_INC_sl_FsOpen __nvm
#define _SL_INC_sl_FsClose __nvm
#define _SL_INC_sl_FsRead __nvm
#define _SL_INC_sl_FsWrite __nvm
#define _SL_INC_sl_FsGetInfo __nvm
#define _SL_INC_sl_FsDel __nvm
/* netcfg */
#define _SL_INC_sl_MacAdrrSet __ncg
#define _SL_INC_sl_MacAdrrGet __ncg
#define _SL_INC_sl_NetCfgGet __ncg
#define _SL_INC_sl_NetCfgSet __ncg
/* socket */
#define _SL_INC_sl_Socket __sck
#define _SL_INC_sl_Close __sck
#define _SL_INC_sl_Accept __sck__srv
#define _SL_INC_sl_Bind __sck
#define _SL_INC_sl_Listen __sck__srv
#define _SL_INC_sl_Connect __sck__clt
#define _SL_INC_sl_Select __sck
#define _SL_INC_sl_SetSockOpt __sck
#define _SL_INC_sl_GetSockOpt __sck__ext
#define _SL_INC_sl_Recv __sck__rcv
#define _SL_INC_sl_RecvFrom __sck__rcv
#define _SL_INC_sl_Write __sck__snd
#define _SL_INC_sl_Send __sck__snd
#define _SL_INC_sl_SendTo __sck__snd
#define _SL_INC_sl_Htonl __sck
#define _SL_INC_sl_Htons __sck
/* wlan */
#define _SL_INC_sl_WlanConnect __wln__ext
#define _SL_INC_sl_WlanDisconnect __wln__ext
#define _SL_INC_sl_WlanProfileAdd __wln__ext
#define _SL_INC_sl_WlanProfileGet __wln__ext
#define _SL_INC_sl_WlanProfileDel __wln__ext
#define _SL_INC_sl_WlanPolicySet __wln__ext
#define _SL_INC_sl_WlanPolicyGet __wln__ext
#define _SL_INC_sl_WlanGetNetworkList __wln__ext
#define _SL_INC_sl_WlanRxFilterAdd __wln__ext
#define _SL_INC_sl_WlanRxFilterSet __wln__ext
#define _SL_INC_sl_WlanRxFilterGet __wln__ext
#define _SL_INC_sl_SmartConfigStart __wln
#define _SL_INC_sl_SmartConfigOptSet __wln__ext
#define _SL_INC_sl_WlanSmartConfigStart __wln
#define _SL_INC_sl_WlanSmartConfigStop __wln
#define _SL_INC_sl_WlanSetMode __wln
#define _SL_INC_sl_WlanSet __wln
#define _SL_INC_sl_WlanGet __wln
#define _SL_INC_sl_SmartConfigOptSet __wln__ext
#define _SL_INC_sl_SmartConfigOptGet __wln__ext
#define _SL_INC_sl_WlanRxStatStart __wln__ext
#define _SL_INC_sl_WlanRxStatStop __wln__ext
#define _SL_INC_sl_WlanRxStatGet __wln__ext
/* device */
#define _SL_INC_sl_Task __int__spwn
#define _SL_INC_sl_Start __dev
#define _SL_INC_sl_Stop __dev
#define _SL_INC_sl_StatusGet __dev
#ifdef SL_IF_TYPE_UART
#define _SL_INC_sl_UartSetMode __dev__ext
#endif
#define _SL_INC_sl_EventMaskGet __dev__ext
#define _SL_INC_sl_EventMaskSet __dev__ext
#define _SL_INC_sl_DevGet __dev__ext
#define _SL_INC_sl_DevSet __dev__ext
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /*OBJINCLUSION_H_ */
/*
* protocol.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*******************************************************************************\
*
* FILE NAME: protocol.h
*
* DESCRIPTION: Constant and data structure definitions and function
* prototypes for the SL protocol module, which implements
* processing of SimpleLink Commands.
*
* AUTHOR:
*
\*******************************************************************************/
#ifndef _SL_PROTOCOL_TYPES_H_
#define _SL_PROTOCOL_TYPES_H_
/****************************************************************************
**
** User I/F pools definitions
**
****************************************************************************/
/****************************************************************************
**
** Definitions for SimpleLink Commands
**
****************************************************************************/
/* pattern for LE 8/16/32 or BE*/
#define H2N_SYNC_PATTERN {0xBBDDEEFF,0x4321,0x34,0x12}
#define H2N_CNYS_PATTERN {0xBBDDEEFF,0x8765,0x78,0x56}
#define H2N_DUMMY_PATTERN (_u32)0xFFFFFFFF
#define N2H_SYNC_PATTERN (_u32)0xABCDDCBA
#define SYNC_PATTERN_LEN (_u32)sizeof(_u32)
#define UART_SET_MODE_MAGIC_CODE (_u32)0xAA55AA55
#define SPI_16BITS_BUG(pattern) (_u32)((_u32)pattern & (_u32)0xFFFF7FFF)
#define SPI_8BITS_BUG(pattern) (_u32)((_u32)pattern & (_u32)0xFFFFFF7F)
typedef struct
{
_u16 Opcode;
_u16 Len;
}_SlGenericHeader_t;
typedef struct
{
_u32 Long;
_u16 Short;
_u8 Byte1;
_u8 Byte2;
}_SlSyncPattern_t;
typedef _SlGenericHeader_t _SlCommandHeader_t;
typedef struct
{
_SlGenericHeader_t GenHeader;
_u8 TxPoolCnt;
_u8 DevStatus;
_u8 SocketTXFailure;
_u8 SocketNonBlocking;
}_SlResponseHeader_t;
#define _SL_RESP_SPEC_HDR_SIZE (sizeof(_SlResponseHeader_t) - sizeof(_SlGenericHeader_t))
#define _SL_RESP_HDR_SIZE sizeof(_SlResponseHeader_t)
#define _SL_CMD_HDR_SIZE sizeof(_SlCommandHeader_t)
#define _SL_RESP_ARGS_START(_pMsg) (((_SlResponseHeader_t *)(_pMsg)) + 1)
/* Used only in NWP! */
typedef struct
{
_SlCommandHeader_t sl_hdr;
_u8 func_args_start;
} T_SCMD;
#define WLAN_CONN_STATUS_BIT 0x01
#define EVENTS_Q_STATUS_BIT 0x02
#define PENDING_RCV_CMD_BIT 0x04
#define FW_BUSY_PACKETS_BIT 0x08
#define INIT_STA_OK 0x11111111
#define INIT_STA_ERR 0x22222222
#define INIT_AP_OK 0x33333333
#define INIT_AP_ERR 0x44444444
#define INIT_P2P_OK 0x55555555
#define INIT_P2P_ERR 0x66666666
/****************************************************************************
** OPCODES
****************************************************************************/
#define SL_IPV4_IPV6_OFFSET ( 9 )
#define SL_OPCODE_IPV4 ( 0x0 << SL_IPV4_IPV6_OFFSET )
#define SL_OPCODE_IPV6 ( 0x1 << SL_IPV4_IPV6_OFFSET )
#define SL_SYNC_ASYNC_OFFSET ( 10 )
#define SL_OPCODE_SYNC (0x1 << SL_SYNC_ASYNC_OFFSET )
#define SL_OPCODE_SILO_OFFSET ( 11 )
#define SL_OPCODE_SILO_MASK ( 0xF << SL_OPCODE_SILO_OFFSET )
#define SL_OPCODE_SILO_DEVICE ( 0x0 << SL_OPCODE_SILO_OFFSET )
#define SL_OPCODE_SILO_WLAN ( 0x1 << SL_OPCODE_SILO_OFFSET )
#define SL_OPCODE_SILO_SOCKET ( 0x2 << SL_OPCODE_SILO_OFFSET )
#define SL_OPCODE_SILO_NETAPP ( 0x3 << SL_OPCODE_SILO_OFFSET )
#define SL_OPCODE_SILO_NVMEM ( 0x4 << SL_OPCODE_SILO_OFFSET )
#define SL_OPCODE_SILO_NETCFG ( 0x5 << SL_OPCODE_SILO_OFFSET )
#define SL_FAMILY_SHIFT (0x4)
#define SL_FLAGS_MASK (0xF)
#define SL_OPCODE_DEVICE_INITCOMPLETE 0x0008
#define SL_OPCODE_DEVICE_ABORT 0x000C
#define SL_OPCODE_DEVICE_STOP_COMMAND 0x8473
#define SL_OPCODE_DEVICE_STOP_RESPONSE 0x0473
#define SL_OPCODE_DEVICE_STOP_ASYNC_RESPONSE 0x0073
#define SL_OPCODE_DEVICE_DEVICEASYNCDUMMY 0x0063
#define SL_OPCODE_DEVICE_VERSIONREADCOMMAND 0x8470
#define SL_OPCODE_DEVICE_VERSIONREADRESPONSE 0x0470
#define SL_OPCODE_DEVICE_DEVICEASYNCFATALERROR 0x0078
#define SL_OPCODE_WLAN_WLANCONNECTCOMMAND 0x8C80
#define SL_OPCODE_WLAN_WLANCONNECTRESPONSE 0x0C80
#define SL_OPCODE_WLAN_WLANASYNCCONNECTEDRESPONSE 0x0880
#define SL_OPCODE_WLAN_P2P_DEV_FOUND 0x0830
#define SL_OPCODE_WLAN_CONNECTION_FAILED 0x0831
#define SL_OPCODE_WLAN_P2P_NEG_REQ_RECEIVED 0x0832
#define SL_OPCODE_WLAN_WLANDISCONNECTCOMMAND 0x8C81
#define SL_OPCODE_WLAN_WLANDISCONNECTRESPONSE 0x0C81
#define SL_OPCODE_WLAN_WLANASYNCDISCONNECTEDRESPONSE 0x0881
#define SL_OPCODE_WLAN_WLANCONNECTEAPCOMMAND 0x8C82
#define SL_OPCODE_WLAN_WLANCONNECTEAPCRESPONSE 0x0C82
#define SL_OPCODE_WLAN_PROFILEADDCOMMAND 0x8C83
#define SL_OPCODE_WLAN_PROFILEADDRESPONSE 0x0C83
#define SL_OPCODE_WLAN_PROFILEGETCOMMAND 0x8C84
#define SL_OPCODE_WLAN_PROFILEGETRESPONSE 0x0C84
#define SL_OPCODE_WLAN_PROFILEDELCOMMAND 0x8C85
#define SL_OPCODE_WLAN_PROFILEDELRESPONSE 0x0C85
#define SL_OPCODE_WLAN_POLICYSETCOMMAND 0x8C86
#define SL_OPCODE_WLAN_POLICYSETRESPONSE 0x0C86
#define SL_OPCODE_WLAN_POLICYGETCOMMAND 0x8C87
#define SL_OPCODE_WLAN_POLICYGETRESPONSE 0x0C87
#define SL_OPCODE_WLAN_FILTERADD 0x8C88
#define SL_OPCODE_WLAN_FILTERADDRESPONSE 0x0C88
#define SL_OPCODE_WLAN_FILTERGET 0x8C89
#define SL_OPCODE_WLAN_FILTERGETRESPONSE 0x0C89
#define SL_OPCODE_WLAN_FILTERDELETE 0x8C8A
#define SL_OPCODE_WLAN_FILTERDELETERESPOSNE 0x0C8A
#define SL_OPCODE_WLAN_WLANGETSTATUSCOMMAND 0x8C8F
#define SL_OPCODE_WLAN_WLANGETSTATUSRESPONSE 0x0C8F
#define SL_OPCODE_WLAN_STARTTXCONTINUESCOMMAND 0x8CAA
#define SL_OPCODE_WLAN_STARTTXCONTINUESRESPONSE 0x0CAA
#define SL_OPCODE_WLAN_STOPTXCONTINUESCOMMAND 0x8CAB
#define SL_OPCODE_WLAN_STOPTXCONTINUESRESPONSE 0x0CAB
#define SL_OPCODE_WLAN_STARTRXSTATCOMMAND 0x8CAC
#define SL_OPCODE_WLAN_STARTRXSTATRESPONSE 0x0CAC
#define SL_OPCODE_WLAN_STOPRXSTATCOMMAND 0x8CAD
#define SL_OPCODE_WLAN_STOPRXSTATRESPONSE 0x0CAD
#define SL_OPCODE_WLAN_GETRXSTATCOMMAND 0x8CAF
#define SL_OPCODE_WLAN_GETRXSTATRESPONSE 0x0CAF
#define SL_OPCODE_WLAN_POLICYSETCOMMANDNEW 0x8CB0
#define SL_OPCODE_WLAN_POLICYSETRESPONSENEW 0x0CB0
#define SL_OPCODE_WLAN_POLICYGETCOMMANDNEW 0x8CB1
#define SL_OPCODE_WLAN_POLICYGETRESPONSENEW 0x0CB1
#define SL_OPCODE_WLAN_SMART_CONFIG_START_COMMAND 0x8CB2
#define SL_OPCODE_WLAN_SMART_CONFIG_START_RESPONSE 0x0CB2
#define SL_OPCODE_WLAN_SMART_CONFIG_START_ASYNC_RESPONSE 0x08B2
#define SL_OPCODE_WLAN_SMART_CONFIG_STOP_COMMAND 0x8CB3
#define SL_OPCODE_WLAN_SMART_CONFIG_STOP_RESPONSE 0x0CB3
#define SL_OPCODE_WLAN_SMART_CONFIG_STOP_ASYNC_RESPONSE 0x08B3
#define SL_OPCODE_WLAN_SET_MODE 0x8CB4
#define SL_OPCODE_WLAN_SET_MODE_RESPONSE 0x0CB4
#define SL_OPCODE_WLAN_CFG_SET 0x8CB5
#define SL_OPCODE_WLAN_CFG_SET_RESPONSE 0x0CB5
#define SL_OPCODE_WLAN_CFG_GET 0x8CB6
#define SL_OPCODE_WLAN_CFG_GET_RESPONSE 0x0CB6
#define SL_OPCODE_WLAN_STA_CONNECTED 0x082E
#define SL_OPCODE_WLAN_STA_DISCONNECTED 0x082F
#define SL_OPCODE_WLAN_EAP_PROFILEADDCOMMAND 0x8C67
#define SL_OPCODE_WLAN_EAP_PROFILEADDCOMMAND_RESPONSE 0x0C67
#define SL_OPCODE_SOCKET_SOCKET 0x9401
#define SL_OPCODE_SOCKET_SOCKETRESPONSE 0x1401
#define SL_OPCODE_SOCKET_CLOSE 0x9402
#define SL_OPCODE_SOCKET_CLOSERESPONSE 0x1402
#define SL_OPCODE_SOCKET_ACCEPT 0x9403
#define SL_OPCODE_SOCKET_ACCEPTRESPONSE 0x1403
#define SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE 0x1003
#define SL_OPCODE_SOCKET_ACCEPTASYNCRESPONSE_V6 0x1203
#define SL_OPCODE_SOCKET_BIND 0x9404
#define SL_OPCODE_SOCKET_BIND_V6 0x9604
#define SL_OPCODE_SOCKET_BINDRESPONSE 0x1404
#define SL_OPCODE_SOCKET_LISTEN 0x9405
#define SL_OPCODE_SOCKET_LISTENRESPONSE 0x1405
#define SL_OPCODE_SOCKET_CONNECT 0x9406
#define SL_OPCODE_SOCKET_CONNECT_V6 0x9606
#define SL_OPCODE_SOCKET_CONNECTRESPONSE 0x1406
#define SL_OPCODE_SOCKET_CONNECTASYNCRESPONSE 0x1006
#define SL_OPCODE_SOCKET_SELECT 0x9407
#define SL_OPCODE_SOCKET_SELECTRESPONSE 0x1407
#define SL_OPCODE_SOCKET_SELECTASYNCRESPONSE 0x1007
#define SL_OPCODE_SOCKET_SETSOCKOPT 0x9408
#define SL_OPCODE_SOCKET_SETSOCKOPTRESPONSE 0x1408
#define SL_OPCODE_SOCKET_GETSOCKOPT 0x9409
#define SL_OPCODE_SOCKET_GETSOCKOPTRESPONSE 0x1409
#define SL_OPCODE_SOCKET_RECV 0x940A
#define SL_OPCODE_SOCKET_RECVASYNCRESPONSE 0x100A
#define SL_OPCODE_SOCKET_RECVFROM 0x940B
#define SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE 0x100B
#define SL_OPCODE_SOCKET_RECVFROMASYNCRESPONSE_V6 0x120B
#define SL_OPCODE_SOCKET_SEND 0x940C
#define SL_OPCODE_SOCKET_SENDTO 0x940D
#define SL_OPCODE_SOCKET_SENDTO_V6 0x960D
#define SL_OPCODE_SOCKET_TXFAILEDASYNCRESPONSE 0x100E
#define SL_OPCODE_SOCKET_SOCKETASYNCEVENT 0x100F
#define SL_OPCODE_NETAPP_START_COMMAND 0x9C0A
#define SL_OPCODE_NETAPP_START_RESPONSE 0x1C0A
#define SL_OPCODE_NETAPP_NETAPPSTARTRESPONSE 0x1C0A
#define SL_OPCODE_NETAPP_STOP_COMMAND 0x9C61
#define SL_OPCODE_NETAPP_STOP_RESPONSE 0x1C61
#define SL_OPCODE_NETAPP_NETAPPSET 0x9C0B
#define SL_OPCODE_NETAPP_NETAPPSETRESPONSE 0x1C0B
#define SL_OPCODE_NETAPP_NETAPPGET 0x9C27
#define SL_OPCODE_NETAPP_NETAPPGETRESPONSE 0x1C27
#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAME 0x9C20
#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAMERESPONSE 0x1C20
#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE 0x1820
#define SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE_V6 0x1A20
#define SL_OPCODE_NETAPP_NETAPP_MDNS_LOOKUP_SERVICE 0x9C71
#define SL_OPCODE_NETAPP_NETAPP_MDNS_LOOKUP_SERVICE_RESPONSE 0x1C72
#define SL_OPCODE_NETAPP_MDNSREGISTERSERVICE 0x9C34
#define SL_OPCODE_NETAPP_MDNSREGISTERSERVICERESPONSE 0x1C34
#define SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICE 0x9C35
#define SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICERESPONSE 0x1C35
#define SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE 0x1835
#define SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE_V6 0x1A35
#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDR 0x9C26
#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDR_V6 0x9E26
#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDRRESPONSE 0x1C26
#define SL_OPCODE_NETAPP_DNSGETHOSTBYADDRASYNCRESPONSE 0x1826
#define SL_OPCODE_NETAPP_PINGSTART 0x9C21
#define SL_OPCODE_NETAPP_PINGSTART_V6 0x9E21
#define SL_OPCODE_NETAPP_PINGSTARTRESPONSE 0x1C21
#define SL_OPCODE_NETAPP_PINGREPORTREQUEST 0x9C22
#define SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE 0x1822
#define SL_OPCODE_NETAPP_PINGSTOP 0x9C23
#define SL_OPCODE_NETAPP_PINGSTOPRESPONSE 0x1C23
#define SL_OPCODE_NETAPP_ARPFLUSH 0x9C24
#define SL_OPCODE_NETAPP_ARPFLUSHRESPONSE 0x1C24
#define SL_OPCODE_NETAPP_IPACQUIRED 0x1825
#define SL_OPCODE_NETAPP_IPV4_LOST 0x1832
#define SL_OPCODE_NETAPP_DHCP_IPV4_ACQUIRE_TIMEOUT 0x1833
#define SL_OPCODE_NETAPP_IPACQUIRED_V6 0x1A25
#define SL_OPCODE_NETAPP_IPERFSTARTCOMMAND 0x9C28
#define SL_OPCODE_NETAPP_IPERFSTARTRESPONSE 0x1C28
#define SL_OPCODE_NETAPP_IPERFSTOPCOMMAND 0x9C29
#define SL_OPCODE_NETAPP_IPERFSTOPRESPONSE 0x1C29
#define SL_OPCODE_NETAPP_CTESTSTARTCOMMAND 0x9C2A
#define SL_OPCODE_NETAPP_CTESTSTARTRESPONSE 0x1C2A
#define SL_OPCODE_NETAPP_CTESTASYNCRESPONSE 0x182A
#define SL_OPCODE_NETAPP_CTESTSTOPCOMMAND 0x9C2B
#define SL_OPCODE_NETAPP_CTESTSTOPRESPONSE 0x1C2B
#define SL_OPCODE_NETAPP_IP_LEASED 0x182C
#define SL_OPCODE_NETAPP_IP_RELEASED 0x182D
#define SL_OPCODE_NETAPP_HTTPGETTOKENVALUE 0x182E
#define SL_OPCODE_NETAPP_HTTPSENDTOKENVALUE 0x9C2F
#define SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE 0x1830
#define SL_OPCODE_NVMEM_FILEOPEN 0xA43C
#define SL_OPCODE_NVMEM_FILEOPENRESPONSE 0x243C
#define SL_OPCODE_NVMEM_FILECLOSE 0xA43D
#define SL_OPCODE_NVMEM_FILECLOSERESPONSE 0x243D
#define SL_OPCODE_NVMEM_FILEREADCOMMAND 0xA440
#define SL_OPCODE_NVMEM_FILEREADRESPONSE 0x2440
#define SL_OPCODE_NVMEM_FILEWRITECOMMAND 0xA441
#define SL_OPCODE_NVMEM_FILEWRITERESPONSE 0x2441
#define SL_OPCODE_NVMEM_FILEGETINFOCOMMAND 0xA442
#define SL_OPCODE_NVMEM_FILEGETINFORESPONSE 0x2442
#define SL_OPCODE_NVMEM_FILEDELCOMMAND 0xA443
#define SL_OPCODE_NVMEM_FILEDELRESPONSE 0x2443
#define SL_OPCODE_NVMEM_NVMEMFORMATCOMMAND 0xA444
#define SL_OPCODE_NVMEM_NVMEMFORMATRESPONSE 0x2444
#define SL_OPCODE_DEVICE_SETDEBUGLEVELCOMMAND 0x846A
#define SL_OPCODE_DEVICE_SETDEBUGLEVELRESPONSE 0x046A
#define SL_OPCODE_DEVICE_NETCFG_SET_COMMAND 0x8432
#define SL_OPCODE_DEVICE_NETCFG_SET_RESPONSE 0x0432
#define SL_OPCODE_DEVICE_NETCFG_GET_COMMAND 0x8433
#define SL_OPCODE_DEVICE_NETCFG_GET_RESPONSE 0x0433
/* */
#define SL_OPCODE_DEVICE_SETUARTMODECOMMAND 0x846B
#define SL_OPCODE_DEVICE_SETUARTMODERESPONSE 0x046B
#define SL_OPCODE_DEVICE_SSISIZESETCOMMAND 0x846B
#define SL_OPCODE_DEVICE_SSISIZESETRESPONSE 0x046B
/* */
#define SL_OPCODE_DEVICE_EVENTMASKSET 0x8464
#define SL_OPCODE_DEVICE_EVENTMASKSETRESPONSE 0x0464
#define SL_OPCODE_DEVICE_EVENTMASKGET 0x8465
#define SL_OPCODE_DEVICE_EVENTMASKGETRESPONSE 0x0465
#define SL_OPCODE_DEVICE_DEVICEGET 0x8466
#define SL_OPCODE_DEVICE_DEVICEGETRESPONSE 0x0466
#define SL_OPCODE_DEVICE_DEVICESET 0x84B7
#define SL_OPCODE_DEVICE_DEVICESETRESPONSE 0x04B7
#define SL_OPCODE_WLAN_SCANRESULTSGETCOMMAND 0x8C8C
#define SL_OPCODE_WLAN_SCANRESULTSGETRESPONSE 0x0C8C
#define SL_OPCODE_WLAN_SMARTCONFIGOPTSET 0x8C8D
#define SL_OPCODE_WLAN_SMARTCONFIGOPTSETRESPONSE 0x0C8D
#define SL_OPCODE_WLAN_SMARTCONFIGOPTGET 0x8C8E
#define SL_OPCODE_WLAN_SMARTCONFIGOPTGETRESPONSE 0x0C8E
/* Rx Filters opcodes */
#define SL_OPCODE_WLAN_WLANRXFILTERADDCOMMAND 0x8C6C
#define SL_OPCODE_WLAN_WLANRXFILTERADDRESPONSE 0x0C6C
#define SL_OPCODE_WLAN_WLANRXFILTERSETCOMMAND 0x8C6D
#define SL_OPCODE_WLAN_WLANRXFILTERSETRESPONSE 0x0C6D
#define SL_OPCODE_WLAN_WLANRXFILTERGETSTATISTICSINFOCOMMAND 0x8C6E
#define SL_OPCODE_WLAN_WLANRXFILTERGETSTATISTICSINFORESPONSE 0x0C6E
#define SL_OPCODE_WLAN_WLANRXFILTERGETCOMMAND 0x8C6F
#define SL_OPCODE_WLAN_WLANRXFILTERGETRESPONSE 0x0C6F
#define SL_OPCODE_WLAN_WLANRXFILTERGETINFO 0x8C70
#define SL_OPCODE_WLAN_WLANRXFILTERGETINFORESPONSE 0x0C70
/******************************************************************************************/
/* Device structs */
/******************************************************************************************/
typedef _u32 InitStatus_t;
typedef struct
{
_i32 Status;
}InitComplete_t;
typedef struct
{
_i16 status;
_u16 padding;
}_BasicResponse_t;
typedef struct
{
_u16 Timeout;
_u16 padding;
}_DevStopCommand_t;
typedef struct
{
_u32 group;
_u32 mask;
}_DevMaskEventSetCommand_t;
typedef _BasicResponse_t _DevMaskEventSetResponse_t;
typedef struct
{
_u32 group;
}_DevMaskEventGetCommand_t;
typedef struct
{
_u32 group;
_u32 mask;
}_DevMaskEventGetResponse_t;
typedef struct
{
_u32 group;
}_DevStatusGetCommand_t;
typedef struct
{
_u32 group;
_u32 status;
}_DevStatusGetResponse_t;
typedef struct
{
_u32 ChipId;
_u32 FwVersion[4];
_u8 PhyVersion[4];
}_Device_VersionReadResponsePart_t;
typedef struct
{
_Device_VersionReadResponsePart_t part;
_u32 NwpVersion[4];
_u16 RomVersion;
_u16 Padding;
}_Device_VersionReadResponseFull_t;
typedef struct
{
_u32 BaudRate;
_u8 FlowControlEnable;
}_DevUartSetModeCommand_t;
typedef _BasicResponse_t _DevUartSetModeResponse_t;
/******************************************************/
typedef struct
{
_u8 SsiSizeInBytes;
_u8 Padding[3];
}_StellarisSsiSizeSet_t;
/*****************************************************************************************/
/* WLAN structs */
/*****************************************************************************************/
#define MAXIMAL_PASSWORD_LENGTH (64)
typedef struct{
_u8 SecType;
_u8 SsidLen;
_u8 Bssid[6];
_u8 PasswordLen;
}_WlanConnectCommon_t;
#define SSID_STRING(pCmd) (_i8 *)((_WlanConnectCommon_t *)(pCmd) + 1)
#define PASSWORD_STRING(pCmd) (SSID_STRING(pCmd) + ((_WlanConnectCommon_t *)(pCmd))->SsidLen)
typedef struct{
_WlanConnectCommon_t Common;
_u8 UserLen;
_u8 AnonUserLen;
_u8 CertIndex;
_u32 EapBitmask;
}_WlanConnectEapCommand_t;
#define EAP_SSID_STRING(pCmd) (_i8 *)((_WlanConnectEapCommand_t *)(pCmd) + 1)
#define EAP_PASSWORD_STRING(pCmd) (EAP_SSID_STRING(pCmd) + ((_WlanConnectEapCommand_t *)(pCmd))->Common.SsidLen)
#define EAP_USER_STRING(pCmd) (EAP_PASSWORD_STRING(pCmd) + ((_WlanConnectEapCommand_t *)(pCmd))->Common.PasswordLen)
#define EAP_ANON_USER_STRING(pCmd) (EAP_USER_STRING(pCmd) + ((_WlanConnectEapCommand_t *)(pCmd))->UserLen)
typedef struct
{
_u8 PolicyType;
_u8 Padding;
_u8 PolicyOption;
_u8 PolicyOptionLen;
}_WlanPoliciySetGet_t;
typedef struct{
_u32 minDwellTime;
_u32 maxDwellTime;
_u32 numProbeResponse;
_u32 G_Channels_mask;
_i32 rssiThershold;
_i32 snrThershold;
_i32 defaultTXPower;
_u16 intervalList[16];
}_WlanScanParamSetCommand_t;
typedef struct{
_i8 SecType;
_u8 SsidLen;
_u8 Priority;
_u8 Bssid[6];
_u8 PasswordLen;
_u8 WepKeyId;
}_WlanAddGetProfile_t;
typedef struct{
_WlanAddGetProfile_t Common;
_u8 UserLen;
_u8 AnonUserLen;
_u8 CertIndex;
_u16 padding;
_u32 EapBitmask;
}_WlanAddGetEapProfile_t;
#define PROFILE_SSID_STRING(pCmd) ((_i8 *)((_WlanAddGetProfile_t *)(pCmd) + 1))
#define PROFILE_PASSWORD_STRING(pCmd) (PROFILE_SSID_STRING(pCmd) + ((_WlanAddGetProfile_t *)(pCmd))->SsidLen)
#define EAP_PROFILE_SSID_STRING(pCmd) (_i8 *)((_WlanAddGetEapProfile_t *)(pCmd) + 1)
#define EAP_PROFILE_PASSWORD_STRING(pCmd) (EAP_PROFILE_SSID_STRING(pCmd) + ((_WlanAddGetEapProfile_t *)(pCmd))->Common.SsidLen)
#define EAP_PROFILE_USER_STRING(pCmd) (EAP_PROFILE_PASSWORD_STRING(pCmd) + ((_WlanAddGetEapProfile_t *)(pCmd))->Common.PasswordLen)
#define EAP_PROFILE_ANON_USER_STRING(pCmd) (EAP_PROFILE_USER_STRING(pCmd) + ((_WlanAddGetEapProfile_t *)(pCmd))->UserLen)
typedef struct
{
_u8 index;
_u8 padding[3];
}_WlanProfileDelGetCommand_t;
typedef _BasicResponse_t _WlanGetNetworkListResponse_t;
typedef struct
{
_u8 index;
_u8 count;
_i8 padding[2];
}_WlanGetNetworkListCommand_t;
typedef struct
{
_u32 groupIdBitmask;
_u8 cipher;
_u8 publicKeyLen;
_u8 group1KeyLen;
_u8 group2KeyLen;
}_WlanSmartConfigStartCommand_t;
#define SMART_CONFIG_START_PUBLIC_KEY_STRING(pCmd) ((_i8 *)((_WlanSmartConfigStartCommand_t *)(pCmd) + 1))
#define SMART_CONFIG_START_GROUP1_KEY_STRING(pCmd) ((_i8 *) (SMART_CONFIG_START_PUBLIC_KEY_STRING(pCmd) + ((_WlanSmartConfigStartCommand_t *)(pCmd))->publicKeyLen))
#define SMART_CONFIG_START_GROUP2_KEY_STRING(pCmd) ((_i8 *) (SMART_CONFIG_START_GROUP1_KEY_STRING(pCmd) + ((_WlanSmartConfigStartCommand_t *)(pCmd))->group1KeyLen))
typedef struct
{
_u8 mode;
_u8 padding[3];
}_WlanSetMode_t;
typedef struct
{
_u16 Status;
_u16 ConfigId;
_u16 ConfigOpt;
_u16 ConfigLen;
}_WlanCfgSetGet_t;
/* ******************************************************************************/
/* RX filters - Start */
/* ******************************************************************************/
/* -- 80 bytes */
typedef struct _WlanRxFilterAddCommand_t
{
/* -- 1 byte */
SlrxFilterRuleType_t RuleType;
/* -- 1 byte */
SlrxFilterFlags_t FilterFlags;
/* -- 1 byte */
SlrxFilterID_t FilterId;
/* -- 1 byte */
_u8 Padding;
/* -- 56 byte */
SlrxFilterRule_t Rule;
/* -- 12 byte ( 3 padding ) */
SlrxFilterTrigger_t Trigger;
/* -- 8 byte */
SlrxFilterAction_t Action;
}_WlanRxFilterAddCommand_t;
/* -- 4 bytes */
typedef struct l_WlanRxFilterAddCommandReponse_t
{
/* -- 1 byte */
SlrxFilterID_t FilterId;
/* -- 1 Byte */
_u8 Status;
/* -- 2 byte */
_u8 Padding[2];
}_WlanRxFilterAddCommandReponse_t;
/*
* \struct _WlanRxFilterSetCommand_t
*/
typedef struct _WlanRxFilterSetCommand_t
{
_u16 InputBufferLength;
/* 1 byte */
SLrxFilterOperation_t RxFilterOperation;
_u8 Padding[1];
}_WlanRxFilterSetCommand_t;
/**
* \struct _WlanRxFilterSetCommandReponse_t
*/
typedef struct _WlanRxFilterSetCommandReponse_t
{
/* 1 byte */
_u8 Status;
/* 3 bytes */
_u8 Padding[3];
}_WlanRxFilterSetCommandReponse_t;
/**
* \struct _WlanRxFilterGetCommand_t
*/
typedef struct _WlanRxFilterGetCommand_t
{
_u16 OutputBufferLength;
/* 1 byte */
SLrxFilterOperation_t RxFilterOperation;
_u8 Padding[1];
}_WlanRxFilterGetCommand_t;
/**
* \struct _WlanRxFilterGetCommandReponse_t
*/
typedef struct _WlanRxFilterGetCommandReponse_t
{
/* 1 byte */
_u8 Status;
/* 1 bytes */
_u8 Padding;
/* 2 byte */
_u16 OutputBufferLength;
}_WlanRxFilterGetCommandReponse_t;
/* ******************************************************************************/
/* RX filters -- End */
/* ******************************************************************************/
typedef struct
{
_u16 status;
_u8 WlanRole; /* 0 = station, 2 = AP */
_u8 Ipv6Enabled;
_u8 Ipv6DhcpEnabled;
_u32 ipV6Global[4];
_u32 ipV6Local[4];
_u32 ipV6DnsServer[4];
_u8 Ipv6DhcpState;
}_NetappIpV6configRetArgs_t;
typedef struct
{
_u8 ipV4[4];
_u8 ipV4Mask[4];
_u8 ipV4Gateway[4];
_u8 ipV4DnsServer[4];
_u8 ipV4Start[4];
_u8 ipV4End[4];
}_NetCfgIpV4AP_Args_t;
typedef struct
{
_u16 status;
_u8 MacAddr[6];
} _MAC_Address_SetGet_t;
typedef struct
{
_u16 Status;
_u16 ConfigId;
_u16 ConfigOpt;
_u16 ConfigLen;
}_NetCfgSetGet_t;
typedef struct
{
_u16 Status;
_u16 DeviceSetId;
_u16 Option;
_u16 ConfigLen;
}_DeviceSetGet_t;
/******************************************************************************************/
/* Socket structs */
/******************************************************************************************/
typedef struct
{
_u8 Domain;
_u8 Type;
_u8 Protocol;
_u8 Padding;
}_SocketCommand_t;
typedef struct
{
_i16 statusOrLen;
_u8 sd;
_u8 padding;
}_SocketResponse_t;
typedef struct
{
_u8 sd;
_u8 family;
_u8 padding1;
_u8 padding2;
}_AcceptCommand_t;
typedef struct
{
_i16 statusOrLen;
_u8 sd;
_u8 family;
_u16 port;
_u16 paddingOrAddr;
_u32 address;
}_SocketAddrAsyncIPv4Response_t;
typedef struct
{
_i16 statusOrLen;
_u8 sd;
_u8 family;
_u16 port;
_u8 address[6];
}_SocketAddrAsyncIPv6EUI48Response_t;
typedef struct
{
_i16 statusOrLen;
_u8 sd;
_u8 family;
_u16 port;
_u16 paddingOrAddr;
_u32 address[4];
}_SocketAddrAsyncIPv6Response_t;
typedef struct
{
_i16 lenOrPadding;
_u8 sd;
_u8 FamilyAndFlags;
_u16 port;
_u16 paddingOrAddr;
_u32 address;
}_SocketAddrIPv4Command_t;
typedef struct
{
_i16 lenOrPadding;
_u8 sd;
_u8 FamilyAndFlags;
_u16 port;
_u8 address[6];
}_SocketAddrIPv6EUI48Command_t;
typedef struct
{
_i16 lenOrPadding;
_u8 sd;
_u8 FamilyAndFlags;
_u16 port;
_u16 paddingOrAddr;
_u32 address[4];
}_SocketAddrIPv6Command_t;
typedef union {
_SocketAddrIPv4Command_t IpV4;
_SocketAddrIPv6EUI48Command_t IpV6EUI48;
#ifdef SL_SUPPORT_IPV6
_SocketAddrIPv6Command_t IpV6;
#endif
} _SocketAddrCommand_u;
typedef union {
_SocketAddrAsyncIPv4Response_t IpV4;
_SocketAddrAsyncIPv6EUI48Response_t IpV6EUI48;
#ifdef SL_SUPPORT_IPV6
_SocketAddrAsyncIPv6Response_t IpV6;
#endif
} _SocketAddrResponse_u;
typedef struct
{
_u8 sd;
_u8 backlog;
_u8 padding1;
_u8 padding2;
}_ListenCommand_t;
typedef struct
{
_u8 sd;
_u8 padding0;
_u8 padding1;
_u8 padding2;
}_CloseCommand_t;
typedef struct
{
_u8 nfds;
_u8 readFdsCount;
_u8 writeFdsCount;
_u8 padding;
_u16 readFds;
_u16 writeFds;
_u16 tv_usec;
_u16 tv_sec;
}_SelectCommand_t;
typedef struct
{
_u16 status;
_u8 readFdsCount;
_u8 writeFdsCount;
_u16 readFds;
_u16 writeFds;
}_SelectAsyncResponse_t;
typedef struct
{
_u8 sd;
_u8 level;
_u8 optionName;
_u8 optionLen;
}_setSockOptCommand_t;
typedef struct
{
_u8 sd;
_u8 level;
_u8 optionName;
_u8 optionLen;
}_getSockOptCommand_t;
typedef struct
{
_i16 status;
_u8 sd;
_u8 optionLen;
}_getSockOptResponse_t;
typedef struct
{
_u16 StatusOrLen;
_u8 sd;
_u8 FamilyAndFlags;
}_sendRecvCommand_t;
/*****************************************************************************************
* NETAPP structs
******************************************************************************************/
typedef _BasicResponse_t _NetAppStartStopResponse_t;
typedef struct
{
_u32 appId;
}_NetAppStartStopCommand_t;
typedef struct
{
_u16 Status;
_u16 AppId;
_u16 ConfigOpt;
_u16 ConfigLen;
}_NetAppSetGet_t;
typedef struct
{
_u16 port_number;
} _NetAppHttpServerGetSet_port_num_t;
typedef struct
{
_u8 auth_enable;
}_NetAppHttpServerGetSet_auth_enable_t;
typedef struct _sl_NetAppHttpServerGetToken_t
{
_u8 token_name_len;
_u8 padd1;
_u16 padd2;
}sl_NetAppHttpServerGetToken_t;
typedef struct _sl_NetAppHttpServerSendToken_t
{
_u8 token_value_len;
_u8 token_name_len;
_u8 token_name[MAX_TOKEN_NAME_LEN];
_u16 padd;
}sl_NetAppHttpServerSendToken_t;
typedef struct _sl_NetAppHttpServerPostToken_t
{
_u8 post_action_len;
_u8 token_name_len;
_u8 token_value_len;
_u8 padding;
}sl_NetAppHttpServerPostToken_t;
typedef struct
{
_u16 Len;
_u8 family;
_u8 padding;
}_GetHostByNameCommand_t;
typedef struct
{
_u16 status;
_u16 padding;
_u32 ip0;
_u32 ip1;
_u32 ip2;
_u32 ip3;
}_GetHostByNameIPv6AsyncResponse_t;
typedef struct
{
_u16 status;
_u8 padding1;
_u8 padding2;
_u32 ip0;
}_GetHostByNameIPv4AsyncResponse_t;
typedef enum
{
CTST_BSD_UDP_TX,
CTST_BSD_UDP_RX,
CTST_BSD_TCP_TX,
CTST_BSD_TCP_RX,
CTST_BSD_TCP_SERVER_BI_DIR,
CTST_BSD_TCP_CLIENT_BI_DIR,
CTST_BSD_UDP_BI_DIR,
CTST_BSD_RAW_TX,
CTST_BSD_RAW_RX,
CTST_BSD_RAW_BI_DIR,
CTST_BSD_SECURED_TCP_TX,
CTST_BSD_SECURED_TCP_RX,
CTST_BSD_SECURED_TCP_SERVER_BI_DIR,
CTST_BSD_SECURED_TCP_CLIENT_BI_DIR
}CommTest_e;
typedef struct _sl_protocol_CtestStartCommand_t
{
_u32 Test;
_u16 DestPort;
_u16 SrcPort;
_u32 DestAddr[4];
_u32 PayloadSize;
_u32 timeout;
_u32 csEnabled;
_u32 secure;
_u32 rawProtocol;
_u8 reserved1[4];
}_CtestStartCommand_t;
typedef struct
{
_u8 test;
_u8 socket;
_i16 status;
_u32 startTime;
_u32 endTime;
_u16 txKbitsSec;
_u16 rxKbitsSec;
_u32 outOfOrderPackets;
_u32 missedPackets;
_i16 token;
}_CtestAsyncResponse_t;
typedef struct
{
_u32 pingIntervalTime;
_u16 PingSize;
_u16 pingRequestTimeout;
_u32 totalNumberOfAttempts;
_u32 flags;
_u32 ip0;
_u32 ip1OrPaadding;
_u32 ip2OrPaadding;
_u32 ip3OrPaadding;
}_PingStartCommand_t;
typedef struct
{
_u16 status;
_u16 rttMin;
_u16 rttMax;
_u16 rttAvg;
_u32 numSuccsessPings;
_u32 numSendsPings;
_u32 testTime;
}_PingReportResponse_t;
typedef struct
{
_u32 ip;
_u32 gateway;
_u32 dns;
}_IpV4AcquiredAsync_t;
typedef enum
{
ACQUIRED_IPV6_LOCAL = 1,
ACQUIRED_IPV6_GLOBAL
}IpV6AcquiredType_e;
typedef struct
{
_u32 type;
_u32 ip[4];
_u32 gateway[4];
_u32 dns[4];
}_IpV6AcquiredAsync_t;
typedef union
{
_SocketCommand_t EventMask;
_sendRecvCommand_t DeviceInit;
}_device_commands_t;
/*****************************************************************************************
* FS structs
******************************************************************************************/
typedef struct
{
_u32 FileHandle;
_u32 Offset;
_u16 Len;
_u16 Padding;
}_FsReadCommand_t;
typedef struct
{
_u32 Mode;
_u32 Token;
}_FsOpenCommand_t;
typedef struct
{
_u32 FileHandle;
_u32 Token;
}_FsOpenResponse_t;
typedef struct
{
_u32 FileHandle;
_u32 CertificFileNameLength;
_u32 SignatureLen;
}_FsCloseCommand_t;
typedef _BasicResponse_t _FsReadResponse_t;
typedef _BasicResponse_t _FsDeleteResponse_t;
typedef _BasicResponse_t _FsCloseResponse_t;
typedef struct
{
_u16 Status;
_u16 flags;
_u32 FileLen;
_u32 AllocatedLen;
_u32 Token[4];
}_FsGetInfoResponse_t;
typedef struct
{
_u8 DeviceID;
_u8 Padding[3];
}_FsFormatCommand_t;
typedef _BasicResponse_t _FsFormatResponse_t;
typedef struct
{
_u32 Token;
}_FsDeleteCommand_t;
typedef _FsDeleteCommand_t _FsGetInfoCommand_t;
typedef struct
{
_u32 FileHandle;
_u32 Offset;
_u16 Len;
_u16 Padding;
}_FsWriteCommand_t;
typedef _BasicResponse_t _FsWriteResponse_t;
/* TODO: Set MAx Async Payload length depending on flavor (Tiny, Small, etc.) */
#ifdef SL_TINY_EXT
#define SL_ASYNC_MAX_PAYLOAD_LEN 120 /* size must be aligned to 4 */
#else
#define SL_ASYNC_MAX_PAYLOAD_LEN 160 /* size must be aligned to 4 */
#endif
#define SL_ASYNC_MAX_MSG_LEN (_SL_RESP_HDR_SIZE + SL_ASYNC_MAX_PAYLOAD_LEN)
#define RECV_ARGS_SIZE (sizeof(_SocketResponse_t))
#define RECVFROM_IPV4_ARGS_SIZE (sizeof(_SocketAddrAsyncIPv4Response_t))
#define RECVFROM_IPV6_ARGS_SIZE (sizeof(_SocketAddrAsyncIPv6Response_t))
#define SL_IPV4_ADDRESS_SIZE (sizeof(_u32))
#define SL_IPV6_ADDRESS_SIZE (4 * sizeof(_u32))
#endif /* _SL_PROTOCOL_TYPES_H_ */
/*
* simplelink.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*!
\mainpage SimpleLink Driver
\section intro_sec Introduction
The SimpleLink CC31xx/CC2xx family allows to add Wi-Fi and networking capabilities
to low-cost embedded products without having prior Wi-Fi, RF or networking expertise.
The CC31xx/CC32xx is an ideal solution for microcontroller-based sensor and control
applications such as home appliances, home automation and smart metering.
The CC31xx/CC32xx has integrated a comprehensive TCP/IP network stack, Wi-Fi driver and
security supplicant leading to easier portability to microcontrollers, to an
ultra-low memory footprint, all without compromising the capabilities and robustness
of the final application.
\section modules_sec Module Names
To make it simple, TI's SimpleLink CC31xx/CC32xx platform capabilities were divided into modules by topic (Silo).
These capabilities range from basic device management through wireless
network configuration, standard BSD socket and much more.
Listed below are the various modules in the SimpleLink CC31xx/CC32xx driver:
-# \ref device - controls the behaviour of the CC31xx/CC32xx device (start/stop, events masking and obtaining specific device status)
-# \ref wlan - controls the use of the WiFi WLAN module including:
- Connection features, such as: profiles, policies, SmartConfig�
- Advanced WLAN features, such as: scans, rx filters and rx statistics collection
-# \ref socket - controls standard client/server sockets programming options and capabilities
-# \ref netapp - activates networking applications, such as: HTTP Server, DHCP Server, Ping, DNS and mDNS.
-# \ref netcfg - controls the configuration of the device addresses (i.e. IP and MAC addresses)
-# \ref FileSystem - provides file system capabilities to TI's CC31XX that can be used by both the CC31XX device and the user.
\section proting_sec Porting Guide
The porting of the SimpleLink driver to any new platform is based on few simple steps.
This guide takes you through this process step by step. Please follow the instructions
carefully to avoid any problems during this process and to enable efficient and proper
work with the device.
Please notice that all modifications and porting adjustments of the driver should be
made in the user.h header file only.
Keep making any of the changes only in this file will ensure smoothly transaction to
new versions of the driver at the future!
\subsection porting_step1 Step 1 - Create your own user.h file
The first step is to create a user.h file that will include your configurations and
adjustments. You can use the empty template provided as part of this driver or
you can choose to base your file on file from one of the wide range of examples
applications provided by Texas Instruments
\subsection porting_step2 Step 2 - Select the capabilities set required for your application
Texas Instruments made a lot of efforts to build set of predefined capability sets that would
fit most of the target application.
It is recommended to try and choose one of this predefined capabilities set before going to
build your own customized set. If you find compatible set you can skip the rest of this step.
The available sets are:
-# SL_TINY - Compatible to be used on platforms with very limited resources. Provides
the best in class foot print in terms of Code and Data consumption.
-# SL_SMALL - Compatible to most common networking applications. Provide the most
common APIs with decent balance between code size, data size, functionality
and performances
-# SL_FULL - Provide access to all SimpleLink functionalities
\subsection porting_step3 Step 3 - Bind the device enable/disable output line
The enable/disable line (nHib) provide mechanism to enter the device into the least current
consumption mode. This mode could be used when no traffic is required (tx/rx).
when this line is not connected to any IO of the host this define should be left empty.
Not connecting this line results in ability to start the driver only once.
\subsection porting_step4 Step 4 - Writing your interface communication driver
The SimpleLink device support several standard communication protocol among SPI and
UART. Depending on your needs and your hardware design, you should choose the
communication channel type.
The interface for this communication channel should include 4 simple access functions:
-# open
-# close
-# read
-# write
The way this driver would be implemented is directly effecting the efficiency and
the performances of the SimpleLink device on this platform.
If your system has DMA you should consider to use it in order to increase the utilization
of the communication channel
If you have enough memory resources you should consider using a buffer to increase the
efficiency of the write operations.
\subsection porting_step5 Step 5 - Choose your memory management model
The SimpleLink driver support two memory models:
-# Static (default)
-# Dynamic
If you choose to work in dynamic model you will have to provide alloc and free functions
to be used by the Simple Link driver otherwise nothing need to be done.
\subsection porting_step6 Step 6 - OS adaptation
The SimpleLink driver could run on two kind of platforms:
-# Non-Os / Single Threaded (default)
-# Multi-Threaded
If you choose to work in multi-threaded environment under operating system you will have to
provide some basic adaptation routines to allow the driver to protect access to resources
for different threads (locking object) and to allow synchronization between threads (sync objects).
In additional the driver support running without dedicated thread allocated solely to the simple
link driver. If you choose to work in this mode, you should also supply a spawn method that
will enable to run function on a temporary context.
\subsection porting_step7 Step 7 - Set your asynchronous event handlers routines
The SimpleLink device generate asynchronous events in several situations.
These asynchronous events could be masked.
In order to catch these events you have to provide handler routines.
Please notice that if you not provide a handler routine and the event is received,
the driver will drop this event without any indication of this drop.
\subsection porting_step8 Step 8 - Run diagnostic tools to validate the correctness of your porting
The driver is delivered with some porting diagnostic tools to simplify the porting validation process
and to reduce issues latter. It is very important to follow carefully this process.
The diagnostic process include:
-# Validating Interface Communication Driver
-# Validating OS adaptation layer
-# Validating HW integrity
-# Validating basic work with the device
\section sw_license License
*
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __SIMPLELINK_H__
#define __SIMPLELINK_H__
#include "user.h"
#ifdef __cplusplus
extern "C"
{
#endif
/*! \attention Async event activation notes
Function prototypes for event callback handlers
Event handler function names should be defined in the user.h file
e.g.
"#define sl_WlanEvtHdlr SLWlanEventHandler"
Indicates all WLAN events are handled by User func "SLWlanEventHandler"
Important notes:
1. Event handlers cannot activate another SimpleLink API from the event's context
2. Event's data is valid during event's context. Any application data
which is required for the user application should be copied or marked
into user's variables
3. It is not recommended to delay the execution of the event callback handler
*/
/*!
\addtogroup UserEvents
@{
*/
/*****************************************************************************/
/* Macro declarations for Host Driver version */
/*****************************************************************************/
#define SL_DRIVER_VERSION "1.0.0.10"
#define SL_MAJOR_VERSION_NUM 1L
#define SL_MINOR_VERSION_NUM 0L
#define SL_VERSION_NUM 0L
#define SL_SUB_VERSION_NUM 10L
/*****************************************************************************/
/* Macro declarations for predefined configurations */
/*****************************************************************************/
#ifdef SL_TINY
#undef SL_INC_ARG_CHECK
#undef SL_INC_EXT_API
#undef SL_INC_SOCK_SERVER_SIDE_API
#undef SL_INC_WLAN_PKG
#undef SL_INC_NET_CFG_PKG
#undef SL_INC_FS_PKG
#undef SL_INC_SET_UART_MODE
#undef SL_INC_STD_BSD_API_NAMING
#undef SL_INC_SOCK_CLIENT_SIDE_API
#undef SL_INC_NET_APP_PKG
#undef SL_INC_SOCK_RECV_API
#undef SL_INC_SOCK_SEND_API
#undef SL_INC_SOCKET_PKG
#endif
#ifdef SL_SMALL
#undef SL_INC_EXT_API
#undef SL_INC_NET_APP_PKG
#undef SL_INC_NET_CFG_PKG
#undef SL_INC_FS_PKG
#define SL_INC_ARG_CHECK
#define SL_INC_WLAN_PKG
#define SL_INC_SOCKET_PKG
#define SL_INC_SOCK_CLIENT_SIDE_API
#define SL_INC_SOCK_SERVER_SIDE_API
#define SL_INC_SOCK_RECV_API
#define SL_INC_SOCK_SEND_API
#define SL_INC_SET_UART_MODE
#endif
#ifdef SL_FULL
#define SL_INC_EXT_API
#define SL_INC_NET_APP_PKG
#define SL_INC_NET_CFG_PKG
#define SL_INC_FS_PKG
#define SL_INC_ARG_CHECK
#define SL_INC_WLAN_PKG
#define SL_INC_SOCKET_PKG
#define SL_INC_SOCK_CLIENT_SIDE_API
#define SL_INC_SOCK_SERVER_SIDE_API
#define SL_INC_SOCK_RECV_API
#define SL_INC_SOCK_SEND_API
#define SL_INC_SET_UART_MODE
#endif
#define SL_RET_CODE_OK (0)
#define SL_RET_CODE_INVALID_INPUT (-2)
#define SL_RET_CODE_SELF_ERROR (-3)
#define SL_RET_CODE_NWP_IF_ERROR (-4)
#define SL_RET_CODE_MALLOC_ERROR (-5)
#define sl_Memcpy memcpy
#define sl_Memset memset
#define sl_SyncObjClear(pObj) sl_SyncObjWait(pObj,SL_OS_NO_WAIT)
#ifndef SL_TINY_EXT
#define SL_MAX_SOCKETS (8)
#else
#define SL_MAX_SOCKETS (2)
#endif
/*****************************************************************************/
/* Types definitions */
/*****************************************************************************/
typedef void (*_SlSpawnEntryFunc_t)(void* pValue);
#ifndef NULL
#define NULL (0)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#ifndef OK
#define OK (0)
#endif
#ifndef _SL_USER_TYPES
typedef unsigned char _u8;
typedef signed char _i8;
typedef unsigned short _u16;
typedef signed short _i16;
typedef unsigned long _u32;
typedef signed long _i32;
#define _volatile volatile
#define _const const
#endif
typedef _u16 _SlOpcode_t;
typedef _u8 _SlArgSize_t;
typedef _i16 _SlDataSize_t;
typedef _i16 _SlReturnVal_t;
#ifdef __cplusplus
}
#endif /* __cplusplus */
/*
* This event status used to block or continue the event propagation
* through all the registered external libs/user application
*
*/
typedef enum {
EVENT_PROPAGATION_BLOCK = 0,
EVENT_PROPAGATION_CONTINUE
} _SlEventPropogationStatus_e;
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#ifdef SL_PLATFORM_MULTI_THREADED
#include "spawn.h"
#else
#include "nonos.h"
#endif
/*
objInclusion.h and user.h must be included before all api header files
objInclusion.h must be the last arrangement just before including the API header files
since it based on the other configurations to decide which object should be included
*/
#include "objInclusion.h"
#include "trace.h"
#include "fs.h"
#include "socket.h"
#include "netapp.h"
#include "wlan.h"
#include "device.h"
#include "netcfg.h"
#include "wlan_rx_filters.h"
/* The general events dispatcher which is
* initialized to the user handler */
#ifdef sl_GeneralEvtHdlr
#define _SlDrvHandleGeneralEvents sl_GeneralEvtHdlr
#endif
/* The wlan events dispatcher which is
* initialized to the user handler */
#ifdef sl_WlanEvtHdlr
#define _SlDrvHandleWlanEvents sl_WlanEvtHdlr
#endif
/* The NetApp events dispatcher which is
* initialized to the user handler */
#ifdef sl_NetAppEvtHdlr
#define _SlDrvHandleNetAppEvents sl_NetAppEvtHdlr
#endif
/* The http server events dispatcher which is
* initialized to the user handler if exists */
#ifdef sl_HttpServerCallback
#define _SlDrvHandleHttpServerEvents sl_HttpServerCallback
#endif
/* The socket events dispatcher which is
* initialized to the user handler */
#ifdef sl_SockEvtHdlr
#define _SlDrvHandleSockEvents sl_SockEvtHdlr
#endif
#ifndef __CONCAT
#define __CONCAT(x,y) x ## y
#endif
#define __CONCAT2(x,y) __CONCAT(x,y)
/*
* The section below handles the external lib event registration
* according to the desired events it specified in its API header file.
* The external lib should be first installed by the user (see user.h)
*/
#ifdef SL_EXT_LIB_1
/* General Event Registration */
#if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_GENERAL_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl) (SlDeviceEvent_t *);
#define SlExtLib1GeneralEventHandler __CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl)
#undef EXT_LIB_REGISTERED_GENERAL_EVENTS
#define EXT_LIB_REGISTERED_GENERAL_EVENTS
#endif
/* Wlan Event Registration */
#if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_WLAN_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _WlanEventHdl) (SlWlanEvent_t *);
#define SlExtLib1WlanEventHandler __CONCAT2(SL_EXT_LIB_1, _WlanEventHdl)
#undef EXT_LIB_REGISTERED_WLAN_EVENTS
#define EXT_LIB_REGISTERED_WLAN_EVENTS
#endif
/* NetApp Event Registration */
#if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_NETAPP_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl) (SlNetAppEvent_t *);
#define SlExtLib1NetAppEventHandler __CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl)
#undef EXT_LIB_REGISTERED_NETAPP_EVENTS
#define EXT_LIB_REGISTERED_NETAPP_EVENTS
#endif
/* Http Server Event Registration */
#if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_HTTP_SERVER_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
#define SlExtLib1HttpServerEventHandler __CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl)
#undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#endif
/* Socket Event Registration */
#if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_SOCK_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _SockEventHdl) (SlSockEvent_t *);
#define SlExtLib1SockEventHandler __CONCAT2(SL_EXT_LIB_1, _SockEventHdl)
#undef EXT_LIB_REGISTERED_SOCK_EVENTS
#define EXT_LIB_REGISTERED_SOCK_EVENTS
#endif
#endif
#ifdef SL_EXT_LIB_2
/* General Event Registration */
#if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_GENERAL_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl) (SlDeviceEvent_t *);
#define SlExtLib2GeneralEventHandler __CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl)
#undef EXT_LIB_REGISTERED_GENERAL_EVENTS
#define EXT_LIB_REGISTERED_GENERAL_EVENTS
#endif
/* Wlan Event Registration */
#if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_WLAN_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _WlanEventHdl) (SlWlanEvent_t *);
#define SlExtLib2WlanEventHandler __CONCAT2(SL_EXT_LIB_2, _WlanEventHdl)
#undef EXT_LIB_REGISTERED_WLAN_EVENTS
#define EXT_LIB_REGISTERED_WLAN_EVENTS
#endif
/* NetApp Event Registration */
#if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_NETAPP_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl) (SlNetAppEvent_t *);
#define SlExtLib2NetAppEventHandler __CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl)
#undef EXT_LIB_REGISTERED_NETAPP_EVENTS
#define EXT_LIB_REGISTERED_NETAPP_EVENTS
#endif
/* Http Server Event Registration */
#if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_HTTP_SERVER_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
#define SlExtLib2HttpServerEventHandler __CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl)
#undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#endif
/* Socket Event Registration */
#if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_SOCK_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _SockEventHdl) (SlSockEvent_t *);
#define SlExtLib2SockEventHandler __CONCAT2(SL_EXT_LIB_2, _SockEventHdl)
#undef EXT_LIB_REGISTERED_SOCK_EVENTS
#define EXT_LIB_REGISTERED_SOCK_EVENTS
#endif
#endif
#ifdef SL_EXT_LIB_3
/* General Event Registration */
#if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_GENERAL_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl) (SlDeviceEvent_t *);
#define SlExtLib3GeneralEventHandler __CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl)
#undef EXT_LIB_REGISTERED_GENERAL_EVENTS
#define EXT_LIB_REGISTERED_GENERAL_EVENTS
#endif
/* Wlan Event Registration */
#if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_WLAN_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _WlanEventHdl) (SlWlanEvent_t *);
#define SlExtLib3WlanEventHandler __CONCAT2(SL_EXT_LIB_3, _WlanEventHdl)
#undef EXT_LIB_REGISTERED_WLAN_EVENTS
#define EXT_LIB_REGISTERED_WLAN_EVENTS
#endif
/* NetApp Event Registration */
#if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_NETAPP_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl) (SlNetAppEvent_t *);
#define SlExtLib3NetAppEventHandler __CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl)
#undef EXT_LIB_REGISTERED_NETAPP_EVENTS
#define EXT_LIB_REGISTERED_NETAPP_EVENTS
#endif
/* Http Server Event Registration */
#if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_HTTP_SERVER_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
#define SlExtLib3HttpServerEventHandler __CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl)
#undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#endif
/* Socket Event Registration */
#if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_SOCK_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _SockEventHdl) (SlSockEvent_t *);
#define SlExtLib3SockEventHandler __CONCAT2(SL_EXT_LIB_3, _SockEventHdl)
#undef EXT_LIB_REGISTERED_SOCK_EVENTS
#define EXT_LIB_REGISTERED_SOCK_EVENTS
#endif
#endif
#ifdef SL_EXT_LIB_4
/* General Event Registration */
#if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_GENERAL_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl) (SlDeviceEvent_t *);
#define SlExtLib4GeneralEventHandler __CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl)
#undef EXT_LIB_REGISTERED_GENERAL_EVENTS
#define EXT_LIB_REGISTERED_GENERAL_EVENTS
#endif
/* Wlan Event Registration */
#if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_WLAN_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _WlanEventHdl) (SlWlanEvent_t *);
#define SlExtLib4WlanEventHandler __CONCAT2(SL_EXT_LIB_4, _WlanEventHdl)
#undef EXT_LIB_REGISTERED_WLAN_EVENTS
#define EXT_LIB_REGISTERED_WLAN_EVENTS
#endif
/* NetApp Event Registration */
#if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_NETAPP_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl) (SlNetAppEvent_t *);
#define SlExtLib4NetAppEventHandler __CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl)
#undef EXT_LIB_REGISTERED_NETAPP_EVENTS
#define EXT_LIB_REGISTERED_NETAPP_EVENTS
#endif
/* Http Server Event Registration */
#if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_HTTP_SERVER_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
#define SlExtLib4HttpServerEventHandler __CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl)
#undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#endif
/* Socket Event Registration */
#if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_SOCK_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _SockEventHdl) (SlSockEvent_t *);
#define SlExtLib4SockEventHandler __CONCAT2(SL_EXT_LIB_4, _SockEventHdl)
#undef EXT_LIB_REGISTERED_SOCK_EVENTS
#define EXT_LIB_REGISTERED_SOCK_EVENTS
#endif
#endif
#ifdef SL_EXT_LIB_5
/* General Event Registration */
#if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_GENERAL_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl) (SlDeviceEvent_t *);
#define SlExtLib5GeneralEventHandler __CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl)
#undef EXT_LIB_REGISTERED_GENERAL_EVENTS
#define EXT_LIB_REGISTERED_GENERAL_EVENTS
#endif
/* Wlan Event Registration */
#if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_WLAN_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _WlanEventHdl) (SlWlanEvent_t *);
#define SlExtLib5WlanEventHandler __CONCAT2(SL_EXT_LIB_5, _WlanEventHdl)
#undef EXT_LIB_REGISTERED_WLAN_EVENTS
#define EXT_LIB_REGISTERED_WLAN_EVENTS
#endif
/* NetApp Event Registration */
#if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_NETAPP_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl) (SlNetAppEvent_t *);
#define SlExtLib5NetAppEventHandler __CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl)
#undef EXT_LIB_REGISTERED_NETAPP_EVENTS
#define EXT_LIB_REGISTERED_NETAPP_EVENTS
#endif
/* Http Server Event Registration */
#if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_HTTP_SERVER_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
#define SlExtLib5HttpServerEventHandler __CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl)
#undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
#endif
/* Socket Event Registration */
#if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_SOCK_EVENT)
extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _SockEventHdl) (SlSockEvent_t *);
#define SlExtLib5SockEventHandler __CONCAT2(SL_EXT_LIB_5, _SockEventHdl)
#undef EXT_LIB_REGISTERED_SOCK_EVENTS
#define EXT_LIB_REGISTERED_SOCK_EVENTS
#endif
#endif
#if defined(EXT_LIB_REGISTERED_GENERAL_EVENTS)
extern void _SlDrvHandleGeneralEvents(SlDeviceEvent_t *slGeneralEvent);
#endif
#if defined(EXT_LIB_REGISTERED_WLAN_EVENTS)
extern void _SlDrvHandleWlanEvents(SlWlanEvent_t *slWlanEvent);
#endif
#if defined (EXT_LIB_REGISTERED_NETAPP_EVENTS)
extern void _SlDrvHandleNetAppEvents(SlNetAppEvent_t *slNetAppEvent);
#endif
#if defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
extern void _SlDrvHandleHttpServerEvents(SlHttpServerEvent_t *slHttpServerEvent, SlHttpServerResponse_t *slHttpServerResponse);
#endif
#if defined(EXT_LIB_REGISTERED_SOCK_EVENTS)
extern void _SlDrvHandleSockEvents(SlSockEvent_t *slSockEvent);
#endif
typedef void (*_SlSpawnEntryFunc_t)(void* pValue);
/* Async functions description*/
/*!
\brief General async event for inspecting general events
\param[out] pSlDeviceEvent pointer to SlDeviceEvent_t
\par
Parameters: \n
- <b>pSlDeviceEvent->Event = SL_DEVICE_FATAL_ERROR_EVENT </b>
- pSlDeviceEvent->EventData.deviceEvent fields:
- status: An error code indication from the device
- sender: The sender originator which is based on SlErrorSender_e enum
- <b>pSlDeviceEvent->Event = SL_DEVICE_ABORT_ERROR_EVENT </b>
Indicates a severe error occured and the device stopped
- pSlDeviceEvent->EventData.deviceReport fields:
- AbortType: An idication of the event type
- AbortData: Additional info about the data error
\par Example for fatal error:
\code
printf(General Event Handler - ID=%d Sender=%d\n\n",
pSlDeviceEvent->EventData.deviceEvent.status, // status of the general event
pSlDeviceEvent->EventData.deviceEvent.sender); // sender type
\endcode
\par Example for abort request:
\code
printf(Abort type =%d Abort Data=%d\n\n",
pSlDeviceEvent->EventData.deviceReport.AbortType,
pSlDeviceEvent->EventData.deviceReport.AbortData);
\endcode
*/
#if (defined(sl_GeneralEvtHdlr))
extern void sl_GeneralEvtHdlr(SlDeviceEvent_t *pSlDeviceEvent);
#endif
/*!
\brief WLAN Async event handler
\param[out] pSlWlanEvent pointer to SlWlanEvent_t data
\par
Parameters:
- <b>pSlWlanEvent->Event = SL_WLAN_CONNECT_EVENT </b>, STA or P2P client connection indication event
- pSlWlanEvent->EventData.STAandP2PModeWlanConnected main fields:
- ssid_name
- ssid_len
- bssid
- go_peer_device_name
- go_peer_device_name_len
- <b>pSlWlanEvent->Event = SL_WLAN_DISCONNECT_EVENT </b>, STA or P2P client disconnection event
- pSlWlanEvent->EventData.STAandP2PModeDisconnected main fields:
- ssid_name
- ssid_len
- reason_code
- <b>pSlWlanEvent->Event = SL_WLAN_STA_CONNECTED_EVENT </b>, AP/P2P(Go) connected STA/P2P(Client)
- pSlWlanEvent->EventData.APModeStaConnected fields:
- go_peer_device_name
- mac
- go_peer_device_name_len
- wps_dev_password_id
- own_ssid: relevant for event sta-connected only
- own_ssid_len: relevant for event sta-connected only
- <b>pSlWlanEvent->Event = SL_WLAN_STA_DISCONNECTED_EVENT </b>, AP/P2P(Go) disconnected STA/P2P(Client)
- pSlWlanEvent->EventData.APModestaDisconnected fields:
- go_peer_device_name
- mac
- go_peer_device_name_len
- wps_dev_password_id
- own_ssid: relevant for event sta-connected only
- own_ssid_len: relevant for event sta-connected only
- <b>pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_COMPLETE_EVENT </b>
- pSlWlanEvent->EventData.smartConfigStartResponse fields:
- status
- ssid_len
- ssid
- private_token_len
- private_token
- <b>pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_STOP_EVENT </b>
- pSlWlanEvent->EventData.smartConfigStopResponse fields:
- status
- <b>pSlWlanEvent->Event = SL_WLAN_P2P_DEV_FOUND_EVENT </b>
- pSlWlanEvent->EventData.P2PModeDevFound fields:
- go_peer_device_name
- mac
- go_peer_device_name_len
- wps_dev_password_id
- own_ssid: relevant for event sta-connected only
- own_ssid_len: relevant for event sta-connected only
- <b>pSlWlanEvent->Event = SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT </b>
- pSlWlanEvent->EventData.P2PModeNegReqReceived fields
- go_peer_device_name
- mac
- go_peer_device_name_len
- wps_dev_password_id
- own_ssid: relevant for event sta-connected only
- <b>pSlWlanEvent->Event = SL_WLAN_CONNECTION_FAILED_EVENT </b>, P2P only
- pSlWlanEvent->EventData.P2PModewlanConnectionFailure fields:
- status
*/
#if (defined(sl_WlanEvtHdlr))
extern void sl_WlanEvtHdlr(SlWlanEvent_t* pSlWlanEvent);
#endif
/*!
\brief NETAPP Async event handler
\param[out] pSlNetApp pointer to SlNetAppEvent_t data
\par
Parameters:
- <b>pSlNetApp->Event = SL_NETAPP_IPV4_IPACQUIRED_EVENT</b>, IPV4 acquired event
- pSlNetApp->EventData.ipAcquiredV4 fields:
- ip
- gateway
- dns
- <b>pSlNetApp->Event = SL_NETAPP_IP_LEASED_EVENT</b>, AP or P2P go dhcp lease event
- pSlNetApp->EventData.ipLeased fields:
- ip_address
- lease_time
- mac
- <b>pSlNetApp->Event = SL_NETAPP_IP_RELEASED_EVENT</b>, AP or P2P go dhcp ip release event
- pSlNetApp->EventData.ipReleased fields
- ip_address
- mac
- reason
*/
#if (defined(sl_NetAppEvtHdlr))
extern void sl_NetAppEvtHdlr(SlNetAppEvent_t* pSlNetApp);
#endif
/*!
\brief Socket Async event handler
\param[out] pSlSockEvent pointer to SlSockEvent_t data
\par
Parameters:\n
- <b>pSlSockEvent->Event = SL_SOCKET_TX_FAILED_EVENT</b>
- pSlSockEvent->SockTxFailData fields:
- sd
- status
- <b>pSlSockEvent->Event = SL_SOCKET_ASYNC_EVENT</b>
- pSlSockEvent->SockAsyncData fields:
- sd
- type: SSL_ACCEPT or RX_FRAGMENTATION_TOO_BIG or OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED
- val
*/
#if (defined(sl_SockEvtHdlr))
extern void sl_SockEvtHdlr(SlSockEvent_t* pSlSockEvent);
#endif
/*!
\brief HTTP server async event
\param[out] pSlHttpServerEvent pointer to SlHttpServerEvent_t
\param[in] pSlHttpServerResponse pointer to SlHttpServerResponse_t
\par
Parameters: \n
- <b>pSlHttpServerEvent->Event = SL_NETAPP_HTTPGETTOKENVALUE_EVENT</b>
- pSlHttpServerEvent->EventData fields:
- httpTokenName
- data
- len
- pSlHttpServerResponse->ResponseData fields:
- data
- len
- <b>pSlHttpServerEvent->Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT</b>
- pSlHttpServerEvent->EventData.httpPostData fields:
- action
- token_name
- token_value
- pSlHttpServerResponse->ResponseData fields:
- data
- len
*/
#if (defined(sl_HttpServerCallback))
extern void sl_HttpServerCallback(SlHttpServerEvent_t *pSlHttpServerEvent, SlHttpServerResponse_t *pSlHttpServerResponse);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __SIMPLELINK_H__ */
/*
* socket.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef __SL_SOCKET_H__
#define __SL_SOCKET_H__
#ifdef __cplusplus
extern "C" {
#endif
/*!
\addtogroup socket
@{
*/
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
#define SL_FD_SETSIZE SL_MAX_SOCKETS /* Number of sockets to select on - same is max sockets! */
#define BSD_SOCKET_ID_MASK (0x0F) /* Index using the LBS 4 bits for socket id 0-7 */
/* Define some BSD protocol constants. */
#define SL_SOCK_STREAM (1) /* TCP Socket */
#define SL_SOCK_DGRAM (2) /* UDP Socket */
#define SL_SOCK_RAW (3) /* Raw socket */
#define SL_IPPROTO_TCP (6) /* TCP Raw Socket */
#define SL_IPPROTO_UDP (17) /* UDP Raw Socket */
#define SL_IPPROTO_RAW (255) /* Raw Socket */
#define SL_SEC_SOCKET (100) /* Secured Socket Layer (SSL,TLS) */
/* Address families. */
#define SL_AF_INET (2) /* IPv4 socket (UDP, TCP, etc) */
#define SL_AF_INET6 (3) /* IPv6 socket (UDP, TCP, etc) */
#define SL_AF_INET6_EUI_48 (9)
#define SL_AF_RF (6) /* data include RF parameter, All layer by user (Wifi could be disconnected) */
#define SL_AF_PACKET (17)
/* Protocol families, same as address families. */
#define SL_PF_INET AF_INET
#define SL_PF_INET6 AF_INET6
#define SL_INADDR_ANY (0) /* bind any address */
/* error codes */
#define SL_SOC_ERROR (-1) /* Failure. */
#define SL_SOC_OK ( 0) /* Success. */
#define SL_INEXE (-8) /* socket command in execution */
#define SL_EBADF (-9) /* Bad file number */
#define SL_ENSOCK (-10) /* The system limit on the total number of open socket, has been reached */
#define SL_EAGAIN (-11) /* Try again */
#define SL_EWOULDBLOCK SL_EAGAIN
#define SL_ENOMEM (-12) /* Out of memory */
#define SL_EACCES (-13) /* Permission denied */
#define SL_EFAULT (-14) /* Bad address */
#define SL_ECLOSE (-15) /* close socket operation failed to transmit all queued packets */
#define SL_EALREADY_ENABLED (-21) /* Transceiver - Transceiver already ON. there could be only one */
#define SL_EINVAL (-22) /* Invalid argument */
#define SL_EAUTO_CONNECT_OR_CONNECTING (-69) /* Transceiver - During connection, connected or auto mode started */
#define SL_CONNECTION_PENDING (-72) /* Transceiver - Device is connected, disconnect first to open transceiver */
#define SL_EUNSUPPORTED_ROLE (-86) /* Transceiver - Trying to start when WLAN role is AP or P2P GO */
#define SL_EDESTADDRREQ (-89) /* Destination address required */
#define SL_EPROTOTYPE (-91) /* Protocol wrong type for socket */
#define SL_ENOPROTOOPT (-92) /* Protocol not available */
#define SL_EPROTONOSUPPORT (-93) /* Protocol not supported */
#define SL_ESOCKTNOSUPPORT (-94) /* Socket type not supported */
#define SL_EOPNOTSUPP (-95) /* Operation not supported on transport endpoint */
#define SL_EAFNOSUPPORT (-97) /* Address family not supported by protocol */
#define SL_EADDRINUSE (-98) /* Address already in use */
#define SL_EADDRNOTAVAIL (-99) /* Cannot assign requested address */
#define SL_ENETUNREACH (-101) /* Network is unreachable */
#define SL_ENOBUFS (-105) /* No buffer space available */
#define SL_EOBUFF SL_ENOBUFS
#define SL_EISCONN (-106) /* Transport endpoint is already connected */
#define SL_ENOTCONN (-107) /* Transport endpoint is not connected */
#define SL_ETIMEDOUT (-110) /* Connection timed out */
#define SL_ECONNREFUSED (-111) /* Connection refused */
#define SL_EALREADY (-114) /* Non blocking connect in progress, try again */
#define SL_ESEC_RSA_WRONG_TYPE_E (-130) /* RSA wrong block type for RSA function */
#define SL_ESEC_RSA_BUFFER_E (-131) /* RSA buffer error, output too small or */
#define SL_ESEC_BUFFER_E (-132) /* output buffer too small or input too large */
#define SL_ESEC_ALGO_ID_E (-133) /* setting algo id error */
#define SL_ESEC_PUBLIC_KEY_E (-134) /* setting public key error */
#define SL_ESEC_DATE_E (-135) /* setting date validity error */
#define SL_ESEC_SUBJECT_E (-136) /* setting subject name error */
#define SL_ESEC_ISSUER_E (-137) /* setting issuer name error */
#define SL_ESEC_CA_TRUE_E (-138) /* setting CA basic constraint true error */
#define SL_ESEC_EXTENSIONS_E (-139) /* setting extensions error */
#define SL_ESEC_ASN_PARSE_E (-140) /* ASN parsing error, invalid input */
#define SL_ESEC_ASN_VERSION_E (-141) /* ASN version error, invalid number */
#define SL_ESEC_ASN_GETINT_E (-142) /* ASN get big _i16 error, invalid data */
#define SL_ESEC_ASN_RSA_KEY_E (-143) /* ASN key init error, invalid input */
#define SL_ESEC_ASN_OBJECT_ID_E (-144) /* ASN object id error, invalid id */
#define SL_ESEC_ASN_TAG_NULL_E (-145) /* ASN tag error, not null */
#define SL_ESEC_ASN_EXPECT_0_E (-146) /* ASN expect error, not zero */
#define SL_ESEC_ASN_BITSTR_E (-147) /* ASN bit string error, wrong id */
#define SL_ESEC_ASN_UNKNOWN_OID_E (-148) /* ASN oid error, unknown sum id */
#define SL_ESEC_ASN_DATE_SZ_E (-149) /* ASN date error, bad size */
#define SL_ESEC_ASN_BEFORE_DATE_E (-150) /* ASN date error, current date before */
#define SL_ESEC_ASN_AFTER_DATE_E (-151) /* ASN date error, current date after */
#define SL_ESEC_ASN_SIG_OID_E (-152) /* ASN signature error, mismatched oid */
#define SL_ESEC_ASN_TIME_E (-153) /* ASN time error, unknown time type */
#define SL_ESEC_ASN_INPUT_E (-154) /* ASN input error, not enough data */
#define SL_ESEC_ASN_SIG_CONFIRM_E (-155) /* ASN sig error, confirm failure */
#define SL_ESEC_ASN_SIG_HASH_E (-156) /* ASN sig error, unsupported hash type */
#define SL_ESEC_ASN_SIG_KEY_E (-157) /* ASN sig error, unsupported key type */
#define SL_ESEC_ASN_DH_KEY_E (-158) /* ASN key init error, invalid input */
#define SL_ESEC_ASN_NTRU_KEY_E (-159) /* ASN ntru key decode error, invalid input */
#define SL_ESEC_ECC_BAD_ARG_E (-170) /* ECC input argument of wrong type */
#define SL_ESEC_ASN_ECC_KEY_E (-171) /* ASN ECC bad input */
#define SL_ESEC_ECC_CURVE_OID_E (-172) /* Unsupported ECC OID curve type */
#define SL_ESEC_BAD_FUNC_ARG (-173) /* Bad function argument provided */
#define SL_ESEC_NOT_COMPILED_IN (-174) /* Feature not compiled in */
#define SL_ESEC_UNICODE_SIZE_E (-175) /* Unicode password too big */
#define SL_ESEC_NO_PASSWORD (-176) /* no password provided by user */
#define SL_ESEC_ALT_NAME_E (-177) /* alt name size problem, too big */
#define SL_ESEC_AES_GCM_AUTH_E (-180) /* AES-GCM Authentication check failure */
#define SL_ESEC_AES_CCM_AUTH_E (-181) /* AES-CCM Authentication check failure */
#define SL_SOCKET_ERROR_E (-208) /* Error state on socket */
#define SL_ESEC_MEMORY_ERROR (-203) /* out of memory */
#define SL_ESEC_VERIFY_FINISHED_ERROR (-204) /* verify problem on finished */
#define SL_ESEC_VERIFY_MAC_ERROR (-205) /* verify mac problem */
#define SL_ESEC_UNKNOWN_HANDSHAKE_TYPE (-207) /* weird handshake type */
#define SL_ESEC_SOCKET_ERROR_E (-208) /* error state on socket */
#define SL_ESEC_SOCKET_NODATA (-209) /* expected data, not there */
#define SL_ESEC_INCOMPLETE_DATA (-210) /* don't have enough data to complete task */
#define SL_ESEC_UNKNOWN_RECORD_TYPE (-211) /* unknown type in record hdr */
#define SL_ESEC_FATAL_ERROR (-213) /* recvd alert fatal error */
#define SL_ESEC_ENCRYPT_ERROR (-214) /* error during encryption */
#define SL_ESEC_NO_PEER_KEY (-216) /* need peer's key */
#define SL_ESEC_NO_PRIVATE_KEY (-217) /* need the private key */
#define SL_ESEC_RSA_PRIVATE_ERROR (-218) /* error during rsa priv op */
#define SL_ESEC_NO_DH_PARAMS (-219) /* server missing DH params */
#define SL_ESEC_BUILD_MSG_ERROR (-220) /* build message failure */
#define SL_ESEC_BAD_HELLO (-221) /* client hello malformed */
#define SL_ESEC_DOMAIN_NAME_MISMATCH (-222) /* peer subject name mismatch */
#define SL_ESEC_WANT_READ (-223) /* want read, call again */
#define SL_ESEC_NOT_READY_ERROR (-224) /* handshake layer not ready */
#define SL_ESEC_PMS_VERSION_ERROR (-225) /* pre m secret version error */
#define SL_ESEC_VERSION_ERROR (-226) /* record layer version error */
#define SL_ESEC_WANT_WRITE (-227) /* want write, call again */
#define SL_ESEC_BUFFER_ERROR (-228) /* malformed buffer input */
#define SL_ESEC_VERIFY_CERT_ERROR (-229) /* verify cert error */
#define SL_ESEC_VERIFY_SIGN_ERROR (-230) /* verify sign error */
#define SL_ESEC_LENGTH_ERROR (-241) /* record layer length error */
#define SL_ESEC_PEER_KEY_ERROR (-242) /* can't decode peer key */
#define SL_ESEC_ZERO_RETURN (-243) /* peer sent close notify */
#define SL_ESEC_SIDE_ERROR (-244) /* wrong client/server type */
#define SL_ESEC_NO_PEER_CERT (-245) /* peer didn't send key */
#define SL_ESEC_ECC_CURVETYPE_ERROR (-250) /* Bad ECC Curve Type */
#define SL_ESEC_ECC_CURVE_ERROR (-251) /* Bad ECC Curve */
#define SL_ESEC_ECC_PEERKEY_ERROR (-252) /* Bad Peer ECC Key */
#define SL_ESEC_ECC_MAKEKEY_ERROR (-253) /* Bad Make ECC Key */
#define SL_ESEC_ECC_EXPORT_ERROR (-254) /* Bad ECC Export Key */
#define SL_ESEC_ECC_SHARED_ERROR (-255) /* Bad ECC Shared Secret */
#define SL_ESEC_NOT_CA_ERROR (-257) /* Not a CA cert error */
#define SL_ESEC_BAD_PATH_ERROR (-258) /* Bad path for opendir */
#define SL_ESEC_BAD_CERT_MANAGER_ERROR (-259) /* Bad Cert Manager */
#define SL_ESEC_MAX_CHAIN_ERROR (-268) /* max chain depth exceeded */
#define SL_ESEC_SUITES_ERROR (-271) /* suites pointer error */
#define SL_ESEC_SSL_NO_PEM_HEADER (-272) /* no PEM header found */
#define SL_ESEC_OUT_OF_ORDER_E (-273) /* out of order message */
#define SL_ESEC_SANITY_CIPHER_E (-275) /* sanity check on cipher error */
#define SL_ESEC_GEN_COOKIE_E (-277) /* Generate Cookie Error */
#define SL_ESEC_NO_PEER_VERIFY (-278) /* Need peer cert verify Error */
#define SL_ESEC_UNKNOWN_SNI_HOST_NAME_E (-281) /* Unrecognized host name Error */
/* begin negotiation parameter errors */
#define SL_ESEC_UNSUPPORTED_SUITE (-290) /* unsupported cipher suite */
#define SL_ESEC_MATCH_SUITE_ERROR (-291 ) /* can't match cipher suite */
/* ssl tls security start with -300 offset */
#define SL_ESEC_CLOSE_NOTIFY (-300) /* ssl/tls alerts */
#define SL_ESEC_UNEXPECTED_MESSAGE (-310) /* ssl/tls alerts */
#define SL_ESEC_BAD_RECORD_MAC (-320) /* ssl/tls alerts */
#define SL_ESEC_DECRYPTION_FAILED (-321) /* ssl/tls alerts */
#define SL_ESEC_RECORD_OVERFLOW (-322) /* ssl/tls alerts */
#define SL_ESEC_DECOMPRESSION_FAILURE (-330) /* ssl/tls alerts */
#define SL_ESEC_HANDSHAKE_FAILURE (-340) /* ssl/tls alerts */
#define SL_ESEC_NO_CERTIFICATE (-341) /* ssl/tls alerts */
#define SL_ESEC_BAD_CERTIFICATE (-342) /* ssl/tls alerts */
#define SL_ESEC_UNSUPPORTED_CERTIFICATE (-343) /* ssl/tls alerts */
#define SL_ESEC_CERTIFICATE_REVOKED (-344) /* ssl/tls alerts */
#define SL_ESEC_CERTIFICATE_EXPIRED (-345) /* ssl/tls alerts */
#define SL_ESEC_CERTIFICATE_UNKNOWN (-346) /* ssl/tls alerts */
#define SL_ESEC_ILLEGAL_PARAMETER (-347) /* ssl/tls alerts */
#define SL_ESEC_UNKNOWN_CA (-348) /* ssl/tls alerts */
#define SL_ESEC_ACCESS_DENIED (-349) /* ssl/tls alerts */
#define SL_ESEC_DECODE_ERROR (-350) /* ssl/tls alerts */
#define SL_ESEC_DECRYPT_ERROR (-351) /* ssl/tls alerts */
#define SL_ESEC_EXPORT_RESTRICTION (-360) /* ssl/tls alerts */
#define SL_ESEC_PROTOCOL_VERSION (-370) /* ssl/tls alerts */
#define SL_ESEC_INSUFFICIENT_SECURITY (-371) /* ssl/tls alerts */
#define SL_ESEC_INTERNAL_ERROR (-380) /* ssl/tls alerts */
#define SL_ESEC_USER_CANCELLED (-390) /* ssl/tls alerts */
#define SL_ESEC_NO_RENEGOTIATION (-400) /* ssl/tls alerts */
#define SL_ESEC_UNSUPPORTED_EXTENSION (-410) /* ssl/tls alerts */
#define SL_ESEC_CERTIFICATE_UNOBTAINABLE (-411) /* ssl/tls alerts */
#define SL_ESEC_UNRECOGNIZED_NAME (-412) /* ssl/tls alerts */
#define SL_ESEC_BAD_CERTIFICATE_STATUS_RESPONSE (-413) /* ssl/tls alerts */
#define SL_ESEC_BAD_CERTIFICATE_HASH_VALUE (-414) /* ssl/tls alerts */
/* propierty secure */
#define SL_ESECGENERAL (-450) /* error secure level general error */
#define SL_ESECDECRYPT (-451) /* error secure level, decrypt recv packet fail */
#define SL_ESECCLOSED (-452) /* secure layrer is closed by other size , tcp is still connected */
#define SL_ESECSNOVERIFY (-453) /* Connected without server verification */
#define SL_ESECNOCAFILE (-454) /* error secure level CA file not found*/
#define SL_ESECMEMORY (-455) /* error secure level No memory space available */
#define SL_ESECBADCAFILE (-456) /* error secure level bad CA file */
#define SL_ESECBADCERTFILE (-457) /* error secure level bad Certificate file */
#define SL_ESECBADPRIVATEFILE (-458) /* error secure level bad private file */
#define SL_ESECBADDHFILE (-459) /* error secure level bad DH file */
#define SL_ESECT00MANYSSLOPENED (-460) /* MAX SSL Sockets are opened */
#define SL_ESECDATEERROR (-461) /* connected with certificate date verification error */
#define SL_ESECHANDSHAKETIMEDOUT (-462) /* connection timed out due to handshake time */
/* end error codes */
/* Max payload size by protocol */
#define SL_SOCKET_PAYLOAD_TYPE_MASK (0xF0) /*4 bits type, 4 bits sockets id */
#define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4 (0x00) /* 1472 bytes */
#define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4 (0x10) /* 1460 bytes */
#define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV6 (0x20) /* 1452 bytes */
#define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6 (0x30) /* 1440 bytes */
#define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4_SECURE (0x40) /* */
#define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4_SECURE (0x50) /* */
#define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV6_SECURE (0x60) /* */
#define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6_SECURE (0x70) /* */
#define SL_SOCKET_PAYLOAD_TYPE_RAW_TRANCEIVER (0x80) /* 1536 bytes */
#define SL_SOCKET_PAYLOAD_TYPE_RAW_PACKET (0x90) /* 1536 bytes */
#define SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 (0xa0)
#define SL_SOCKET_PAYLOAD_TYPE_RAW_IP6 (SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 )
#define SL_SOL_SOCKET (1) /* Define the socket option category. */
#define SL_IPPROTO_IP (2) /* Define the IP option category. */
#define SL_SOL_PHY_OPT (3) /* Define the PHY option category. */
#define SL_SO_RCVBUF (8) /* Setting TCP receive buffer size */
#define SL_SO_KEEPALIVE (9) /* Connections are kept alive with periodic messages */
#define SL_SO_RCVTIMEO (20) /* Enable receive timeout */
#define SL_SO_NONBLOCKING (24) /* Enable . disable nonblocking mode */
#define SL_SO_SECMETHOD (25) /* security metohd */
#define SL_SO_SECURE_MASK (26) /* security mask */
#define SL_SO_SECURE_FILES (27) /* security files */
#define SL_SO_CHANGE_CHANNEL (28) /* This option is available only when transceiver started */
#define SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME (30) /* This option used to configue secure file */
#define SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME (31) /* This option used to configue secure file */
#define SL_SO_SECURE_FILES_CA_FILE_NAME (32) /* This option used to configue secure file */
#define SL_SO_SECURE_FILES_DH_KEY_FILE_NAME (33) /* This option used to configue secure file */
#define SL_IP_MULTICAST_IF (60) /* Specify outgoing multicast interface */
#define SL_IP_MULTICAST_TTL (61) /* Specify the TTL value to use for outgoing multicast packet. */
#define SL_IP_ADD_MEMBERSHIP (65) /* Join IPv4 multicast membership */
#define SL_IP_DROP_MEMBERSHIP (66) /* Leave IPv4 multicast membership */
#define SL_IP_HDRINCL (67) /* Raw socket IPv4 header included. */
#define SL_IP_RAW_RX_NO_HEADER (68) /* Proprietary socket option that does not includeIPv4/IPv6 header (and extension headers) on received raw sockets*/
#define SL_IP_RAW_IPV6_HDRINCL (69) /* Transmitted buffer over IPv6 socket contains IPv6 header. */
#define SL_SO_PHY_RATE (100) /* WLAN Transmit rate */
#define SL_SO_PHY_TX_POWER (101) /* TX Power level */
#define SL_SO_PHY_NUM_FRAMES_TO_TX (102) /* Number of frames to transmit */
#define SL_SO_PHY_PREAMBLE (103) /* Preamble for transmission */
#define SL_SO_SEC_METHOD_SSLV3 (0) /* security metohd SSL v3*/
#define SL_SO_SEC_METHOD_TLSV1 (1) /* security metohd TLS v1*/
#define SL_SO_SEC_METHOD_TLSV1_1 (2) /* security metohd TLS v1_1*/
#define SL_SO_SEC_METHOD_TLSV1_2 (3) /* security metohd TLS v1_2*/
#define SL_SO_SEC_METHOD_SSLv3_TLSV1_2 (4) /* use highest possible version from SSLv3 - TLS 1.2*/
#define SL_SO_SEC_METHOD_DLSV1 (5) /* security metohd DTL v1 */
#define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA (1 << 0)
#define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_MD5 (1 << 1)
#define SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA (1 << 2)
#define SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_256_CBC_SHA (1 << 3)
#define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (1 << 4)
#define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_RC4_128_SHA (1 << 5)
#define SL_SEC_MASK_TLS_RSA_WITH_AES_128_CBC_SHA256 (1 << 6)
#define SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA256 (1 << 7)
#define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (1 << 8)
#define SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 (1 << 9)
#define SL_SEC_MASK_SECURE_DEFAULT ((SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 << 1) - 1)
#define SL_MSG_DONTWAIT (0x00000008) /* Nonblocking IO */
/* AP DHCP Server - IP Release reason code */
#define SL_IP_LEASE_PEER_RELEASE (0)
#define SL_IP_LEASE_PEER_DECLINE (1)
#define SL_IP_LEASE_EXPIRED (2)
/* possible types when receiving SL_SOCKET_ASYNC_EVENT*/
#define SSL_ACCEPT (1) /* accept failed due to ssl issue ( tcp pass) */
#define RX_FRAGMENTATION_TOO_BIG (2) /* connection less mode, rx packet fragmentation > 16K, packet is being released */
#define OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED (3) /* remote side down from secure to unsecure */
#ifdef SL_INC_STD_BSD_API_NAMING
#define FD_SETSIZE SL_FD_SETSIZE
#define SOCK_STREAM SL_SOCK_STREAM
#define SOCK_DGRAM SL_SOCK_DGRAM
#define SOCK_RAW SL_SOCK_RAW
#define IPPROTO_TCP SL_IPPROTO_TCP
#define IPPROTO_UDP SL_IPPROTO_UDP
#define IPPROTO_RAW SL_IPPROTO_RAW
#define AF_INET SL_AF_INET
#define AF_INET6 SL_AF_INET6
#define AF_INET6_EUI_48 SL_AF_INET6_EUI_48
#define AF_RF SL_AF_RF
#define AF_PACKET SL_AF_PACKET
#define PF_INET SL_PF_INET
#define PF_INET6 SL_PF_INET6
#define INADDR_ANY SL_INADDR_ANY
#define ERROR SL_SOC_ERROR
#define INEXE SL_INEXE
#define EBADF SL_EBADF
#define ENSOCK SL_ENSOCK
#define EAGAIN SL_EAGAIN
#define EWOULDBLOCK SL_EWOULDBLOCK
#define ENOMEM SL_ENOMEM
#define EACCES SL_EACCES
#define EFAULT SL_EFAULT
#define EINVAL SL_EINVAL
#define EDESTADDRREQ SL_EDESTADDRREQ
#define EPROTOTYPE SL_EPROTOTYPE
#define ENOPROTOOPT SL_ENOPROTOOPT
#define EPROTONOSUPPORT SL_EPROTONOSUPPORT
#define ESOCKTNOSUPPORT SL_ESOCKTNOSUPPORT
#define EOPNOTSUPP SL_EOPNOTSUPP
#define EAFNOSUPPORT SL_EAFNOSUPPORT
#define EADDRINUSE SL_EADDRINUSE
#define EADDRNOTAVAIL SL_EADDRNOTAVAIL
#define ENETUNREACH SL_ENETUNREACH
#define ENOBUFS SL_ENOBUFS
#define EOBUFF SL_EOBUFF
#define EISCONN SL_EISCONN
#define ENOTCONN SL_ENOTCONN
#define ETIMEDOUT SL_ETIMEDOUT
#define ECONNREFUSED SL_ECONNREFUSED
#define SOL_SOCKET SL_SOL_SOCKET
#define IPPROTO_IP SL_IPPROTO_IP
#define SO_KEEPALIVE SL_SO_KEEPALIVE
#define SO_RCVTIMEO SL_SO_RCVTIMEO
#define SO_NONBLOCKING SL_SO_NONBLOCKING
#define IP_MULTICAST_IF SL_IP_MULTICAST_IF
#define IP_MULTICAST_TTL SL_IP_MULTICAST_TTL
#define IP_ADD_MEMBERSHIP SL_IP_ADD_MEMBERSHIP
#define IP_DROP_MEMBERSHIP SL_IP_DROP_MEMBERSHIP
#define socklen_t SlSocklen_t
#define timeval SlTimeval_t
#define sockaddr SlSockAddr_t
#define in6_addr SlIn6Addr_t
#define sockaddr_in6 SlSockAddrIn6_t
#define in_addr SlInAddr_t
#define sockaddr_in SlSockAddrIn_t
#define MSG_DONTWAIT SL_MSG_DONTWAIT
#define FD_SET SL_FD_SET
#define FD_CLR SL_FD_CLR
#define FD_ISSET SL_FD_ISSET
#define FD_ZERO SL_FD_ZERO
#define fd_set SlFdSet_t
#define socket sl_Socket
#define close sl_Close
#define accept sl_Accept
#define bind sl_Bind
#define listen sl_Listen
#define connect sl_Connect
#define select sl_Select
#define setsockopt sl_SetSockOpt
#define getsockopt sl_GetSockOpt
#define recv sl_Recv
#define recvfrom sl_RecvFrom
#define write sl_Write
#define send sl_Send
#define sendto sl_SendTo
#define gethostbyname sl_NetAppDnsGetHostByName
#define htonl sl_Htonl
#define ntohl sl_Ntohl
#define htons sl_Htons
#define ntohs sl_Ntohs
#endif
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
/* Internet address */
typedef struct SlInAddr_t
{
#ifndef s_addr
_u32 s_addr; /* Internet address 32 bits */
#else
union S_un {
struct { _u8 s_b1,s_b2,s_b3,s_b4; } S_un_b;
struct { _u8 s_w1,s_w2; } S_un_w;
_u32 S_addr;
} S_un;
#endif
}SlInAddr_t;
/* sockopt */
typedef struct
{
_u32 KeepaliveEnabled; /* 0 = disabled;1 = enabled; default = 1*/
}SlSockKeepalive_t;
typedef struct
{
_u32 ReuseaddrEnabled; /* 0 = disabled; 1 = enabled; default = 1*/
}SlSockReuseaddr_t;
typedef struct
{
_u32 Winsize; /* receive window size for tcp sockets */
}SlSockWinsize_t;
typedef struct
{
_u32 NonblockingEnabled;/* 0 = disabled;1 = enabled;default = 1*/
}SlSockNonblocking_t;
typedef struct
{
_u8 sd;
_u8 type;
_i16 val;
_u8* pExtraInfo;
} SlSocketAsyncEvent_t;
typedef struct
{
_i16 status;
_u8 sd;
_u8 padding;
} SlSockTxFailEventData_t;
typedef union
{
SlSockTxFailEventData_t SockTxFailData;
SlSocketAsyncEvent_t SockAsyncData;
} SlSockEventData_u;
typedef struct
{
_u32 Event;
SlSockEventData_u socketAsyncEvent;
} SlSockEvent_t;
typedef struct
{
_u32 secureMask;
} SlSockSecureMask;
typedef struct
{
_u8 secureMethod;
} SlSockSecureMethod;
typedef enum
{
SL_BSD_SECURED_PRIVATE_KEY_IDX = 0,
SL_BSD_SECURED_CERTIFICATE_IDX,
SL_BSD_SECURED_CA_IDX,
SL_BSD_SECURED_DH_IDX
}slBsd_secureSocketFilesIndex_e;
typedef struct
{
SlInAddr_t imr_multiaddr; /* The IPv4 multicast address to join */
SlInAddr_t imr_interface; /* The interface to use for this group */
} SlSockIpMreq;
/* sockopt */
typedef _u32 SlTime_t;
typedef _u32 SlSuseconds_t;
typedef struct SlTimeval_t
{
SlTime_t tv_sec; /* Seconds */
SlSuseconds_t tv_usec; /* Microseconds */
}SlTimeval_t;
typedef _u16 SlSocklen_t;
/* IpV4 socket address */
typedef struct SlSockAddr_t
{
_u16 sa_family; /* Address family (e.g. , AF_INET) */
_u8 sa_data[14]; /* Protocol- specific address information*/
}SlSockAddr_t;
/* IpV6 or Ipv6 EUI64 */
typedef struct SlIn6Addr_t
{
union
{
_u8 _S6_u8[16];
_u32 _S6_u32[4];
} _S6_un;
}SlIn6Addr_t;
typedef struct SlSockAddrIn6_t
{
_u16 sin6_family; /* AF_INET6 || AF_INET6_EUI_48*/
_u16 sin6_port; /* Transport layer port. */
_u32 sin6_flowinfo; /* IPv6 flow information. */
SlIn6Addr_t sin6_addr; /* IPv6 address. */
_u32 sin6_scope_id; /* set of interfaces for a scope. */
}SlSockAddrIn6_t;
/* Socket address, Internet style. */
typedef struct SlSockAddrIn_t
{
_u16 sin_family; /* Internet Protocol (AF_INET). */
_u16 sin_port; /* Address port (16 bits). */
SlInAddr_t sin_addr; /* Internet address (32 bits). */
_i8 sin_zero[8]; /* Not used. */
}SlSockAddrIn_t;
typedef struct
{
_u32 ip;
_u32 gateway;
_u32 dns;
}SlIpV4AcquiredAsync_t;
typedef struct
{
_u32 type;
_u32 ip[4];
_u32 gateway[4];
_u32 dns[4];
}SlIpV6AcquiredAsync_t;
typedef struct
{
_u32 ip_address;
_u32 lease_time;
_u8 mac[6];
_u16 padding;
}SlIpLeasedAsync_t;
typedef struct
{
_u32 ip_address;
_u8 mac[6];
_u16 reason;
}SlIpReleasedAsync_t;
typedef union
{
SlIpV4AcquiredAsync_t ipAcquiredV4; /*SL_NETAPP_IPV4_IPACQUIRED_EVENT*/
SlIpV6AcquiredAsync_t ipAcquiredV6; /*SL_NETAPP_IPV6_IPACQUIRED_EVENT*/
_u32 sd; /*SL_SOCKET_TX_FAILED_EVENT*/
SlIpLeasedAsync_t ipLeased; /* SL_NETAPP_IP_LEASED_EVENT */
SlIpReleasedAsync_t ipReleased; /* SL_NETAPP_IP_RELEASED_EVENT */
} SlNetAppEventData_u;
typedef struct
{
_u32 Event;
SlNetAppEventData_u EventData;
}SlNetAppEvent_t;
typedef struct sock_secureFiles
{
_u8 secureFiles[4];
}SlSockSecureFiles_t;
typedef struct SlFdSet_t /* The select socket array manager */
{
_u32 fd_array[(SL_FD_SETSIZE + 31)/32]; /* Bit map of SOCKET Descriptors */
} SlFdSet_t;
typedef struct
{
_u8 rate; /* Recevied Rate */
_u8 channel; /* The received channel*/
_i8 rssi; /* The computed RSSI value in db of current frame */
_u8 padding; /* pad to align to 32 bits */
_u32 timestamp; /* Timestamp in microseconds, */
}SlTransceiverRxOverHead_t;
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief create an endpoint for communication
The socket function creates a new socket of a certain socket type, identified
by an integer number, and allocates system resources to it.
This function is called by the application layer to obtain a socket handle.
\param[in] domain specifies the protocol family of the created socket.
For example:
AF_INET for network protocol IPv4
AF_RF for starting transceiver mode. Notes:
- sending and receiving any packet overriding 802.11 header
- for optimized power consumption the socket will be started in TX
only mode until receive command is activated
AF_INET6 for IPv6
\param[in] type specifies the communication semantic, one of:
SOCK_STREAM (reliable stream-oriented service or Stream Sockets)
SOCK_DGRAM (datagram service or Datagram Sockets)
SOCK_RAW (raw protocols atop the network layer)
when used with AF_RF:
SOCK_DGRAM - L2 socket
SOCK_RAW - L1 socket - bypass WLAN CCA (Clear Channel Assessment)
\param[in] protocol specifies a particular transport to be used with
the socket.
The most common are IPPROTO_TCP, IPPROTO_SCTP, IPPROTO_UDP,
IPPROTO_DCCP.
The value 0 may be used to select a default
protocol from the selected domain and type
\return On success, socket handle that is used for consequent socket operations.
A successful return code should be a positive number (int16)
On error, a negative (int16) value will be returned specifying the error code.
SL_EAFNOSUPPORT - illegal domain parameter
SL_EPROTOTYPE - illegal type parameter
SL_EACCES - permission denied
SL_ENSOCK - exceeded maximal number of socket
SL_ENOMEM - memory allocation error
SL_EINVAL - error in socket configuration
SL_EPROTONOSUPPORT - illegal protocol parameter
SL_EOPNOTSUPP - illegal combination of protocol and type parameters
\sa sl_Close
\note belongs to \ref basic_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Socket)
_i16 sl_Socket(_i16 Domain, _i16 Type, _i16 Protocol);
#endif
/*!
\brief gracefully close socket
This function causes the system to release resources allocated to a socket. \n
In case of TCP, the connection is terminated.
\param[in] sd socket handle (received in sl_Socket)
\return On success, zero is returned.
On error, a negative number is returned.
\sa sl_Socket
\note belongs to \ref ext_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Close)
_i16 sl_Close(_i16 sd);
#endif
/*!
\brief Accept a connection on a socket
This function is used with connection-based socket types (SOCK_STREAM).
It extracts the first connection request on the queue of pending
connections, creates a new connected socket, and returns a new file
descriptor referring to that socket.
The newly created socket is not in the listening state. The
original socket sd is unaffected by this call.
The argument sd is a socket that has been created with
sl_Socket(), bound to a local address with sl_Bind(), and is
listening for connections after a sl_Listen(). The argument \b
\e addr is a pointer to a sockaddr structure. This structure
is filled in with the address of the peer socket, as known to
the communications layer. The exact format of the address
returned addr is determined by the socket's address family.
The \b \e addrlen argument is a value-result argument: it
should initially contain the size of the structure pointed to
by addr, on return it will contain the actual length (in
bytes) of the address returned.
\param[in] sd socket descriptor (handle)
\param[out] addr the argument addr is a pointer
to a sockaddr structure. This
structure is filled in with the
address of the peer socket, as
known to the communications
layer. The exact format of the
address returned addr is
determined by the socket's
address\n
sockaddr:\n - code for the
address format. On this version
only AF_INET is supported.\n -
socket address, the length
depends on the code format
\param[out] addrlen the addrlen argument is a value-result
argument: it should initially contain the
size of the structure pointed to by addr
\return On success, a socket handle.
On a non-blocking accept a possible negative value is SL_EAGAIN.
On failure, negative value.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_Socket sl_Bind sl_Listen
\note belongs to \ref server_side
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Accept)
_i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen);
#endif
/*!
\brief assign a name to a socket
This function gives the socket the local address addr.
addr is addrlen bytes long. Traditionally, this is called
When a socket is created with socket, it exists in a name
space (address family) but has no name assigned.
It is necessary to assign a local address before a SOCK_STREAM
socket may receive connections.
\param[in] sd socket descriptor (handle)
\param[in] addr specifies the destination
addrs\n sockaddr:\n - code for
the address format. On this
version only AF_INET is
supported.\n - socket address,
the length depends on the code
format
\param[in] addrlen contains the size of the structure pointed to by addr
\return On success, zero is returned. On error, a negative error code is returned.
\sa sl_Socket sl_Accept sl_Listen
\note belongs to \ref basic_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Bind)
_i16 sl_Bind(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen);
#endif
/*!
\brief listen for connections on a socket
The willingness to accept incoming connections and a queue
limit for incoming connections are specified with listen(),
and then the connections are accepted with accept.
The listen() call applies only to sockets of type SOCK_STREAM
The backlog parameter defines the maximum length the queue of
pending connections may grow to.
\param[in] sd socket descriptor (handle)
\param[in] backlog specifies the listen queue depth.
\return On success, zero is returned. On error, a negative error code is returned.
\sa sl_Socket sl_Accept sl_Bind
\note belongs to \ref server_side
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Listen)
_i16 sl_Listen(_i16 sd, _i16 backlog);
#endif
/*!
\brief Initiate a connection on a socket
Function connects the socket referred to by the socket
descriptor sd, to the address specified by addr. The addrlen
argument specifies the size of addr. The format of the
address in addr is determined by the address space of the
socket. If it is of type SOCK_DGRAM, this call specifies the
peer with which the socket is to be associated; this address
is that to which datagrams are to be sent, and the only
address from which datagrams are to be received. If the
socket is of type SOCK_STREAM, this call attempts to make a
connection to another socket. The other socket is specified
by address, which is an address in the communications space
of the socket.
\param[in] sd socket descriptor (handle)
\param[in] addr specifies the destination addr\n
sockaddr:\n - code for the
address format. On this version
only AF_INET is supported.\n -
socket address, the length
depends on the code format
\param[in] addrlen contains the size of the structure pointed
to by addr
\return On success, a socket handle.
On a non-blocking connect a possible negative value is SL_EALREADY.
On failure, negative value.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_Socket
\note belongs to \ref client_side
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Connect)
_i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen);
#endif
/*!
\brief Monitor socket activity
Select allow a program to monitor multiple file descriptors,
waiting until one or more of the file descriptors become
"ready" for some class of I/O operation
\param[in] nfds the highest-numbered file descriptor in any of the
three sets, plus 1.
\param[out] readsds socket descriptors list for read monitoring and accept monitoring
\param[out] writesds socket descriptors list for connect monitoring only, write monitoring is not supported, non blocking connect is supported
\param[out] exceptsds socket descriptors list for exception monitoring, not supported.
\param[in] timeout is an upper bound on the amount of time elapsed
before select() returns. Null or above 0xffff seconds means
infinity timeout. The minimum timeout is 10 milliseconds,
less than 10 milliseconds will be set automatically to 10 milliseconds.
Max microseconds supported is 0xfffc00.
\return On success, select() returns the number of
file descriptors contained in the three returned
descriptor sets (that is, the total number of bits that
are set in readfds, writefds, exceptfds) which may be
zero if the timeout expires before anything interesting
happens. On error, a negative value is returned.
readsds - return the sockets on which Read request will
return without delay with valid data.
writesds - return the sockets on which Write request
will return without delay.
exceptsds - return the sockets closed recently.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_Socket
\note If the timeout value set to less than 5ms it will automatically set
to 5ms to prevent overload of the system
belongs to \ref basic_api
Only one sl_Select can be handled at a time.
Calling this API while the same command is called from another thread, may result
in one of the two scenarios:
1. The command will wait (internal) until the previous command finish, and then be executed.
2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
again later to issue the command.
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Select)
_i16 sl_Select(_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *exceptsds, struct SlTimeval_t *timeout);
/*!
\brief Select's SlFdSet_t SET function
Sets current socket descriptor on SlFdSet_t container
*/
void SL_FD_SET(_i16 fd, SlFdSet_t *fdset);
/*!
\brief Select's SlFdSet_t CLR function
Clears current socket descriptor on SlFdSet_t container
*/
void SL_FD_CLR(_i16 fd, SlFdSet_t *fdset);
/*!
\brief Select's SlFdSet_t ISSET function
Checks if current socket descriptor is set (TRUE/FALSE)
\return Returns TRUE if set, FALSE if unset
*/
_i16 SL_FD_ISSET(_i16 fd, SlFdSet_t *fdset);
/*!
\brief Select's SlFdSet_t ZERO function
Clears all socket descriptors from SlFdSet_t
*/
void SL_FD_ZERO(SlFdSet_t *fdset);
#endif
/*!
\brief set socket options
This function manipulate the options associated with a socket.
Options may exist at multiple protocol levels; they are always
present at the uppermost socket level.
When manipulating socket options the level at which the option resides
and the name of the option must be specified. To manipulate options at
the socket level, level is specified as SOL_SOCKET. To manipulate
options at any other level the protocol number of the appropriate proto-
col controlling the option is supplied. For example, to indicate that an
option is to be interpreted by the TCP protocol, level should be set to
the protocol number of TCP;
The parameters optval and optlen are used to access optval -
ues for setsockopt(). For getsockopt() they identify a
buffer in which the value for the requested option(s) are to
be returned. For getsockopt(), optlen is a value-result
parameter, initially containing the size of the buffer
pointed to by option_value, and modified on return to
indicate the actual size of the value returned. If no option
value is to be supplied or returned, option_value may be
NULL.
\param[in] sd socket handle
\param[in] level defines the protocol level for this option
- <b>SL_SOL_SOCKET</b> Socket level configurations (L4, transport layer)
- <b>SL_IPPROTO_IP</b> IP level configurations (L3, network layer)
- <b>SL_SOL_PHY_OPT</b> Link level configurations (L2, link layer)
\param[in] optname defines the option name to interrogate
- <b>SL_SOL_SOCKET</b>
- <b>SL_SO_KEEPALIVE</b> \n
Enable/Disable periodic keep alive.
Keeps TCP connections active by enabling the periodic transmission of messages \n
Timeout is 5 minutes.\n
Default: Enabled \n
This options takes SlSockKeepalive_t struct as parameter
- <b>SL_SO_RCVTIMEO</b> \n
Sets the timeout value that specifies the maximum amount of time an input function waits until it completes. \n
Default: No timeout \n
This options takes SlTimeval_t struct as parameter
- <b>SL_SO_RCVBUF</b> \n
Sets tcp max recv window size. \n
This options takes SlSockWinsize_t struct as parameter
- <b>SL_SO_NONBLOCKING</b> \n
Sets socket to non-blocking operation Impacts: connect, accept, send, sendto, recv and recvfrom. \n
Default: Blocking.
This options takes SlSockNonblocking_t struct as parameter
- <b>SL_SO_SECMETHOD</b> \n
Sets method to tcp secured socket (SL_SEC_SOCKET) \n
Default: SL_SO_SEC_METHOD_SSLv3_TLSV1_2 \n
This options takes SlSockSecureMethod struct as parameter
- <b>SL_SO_SEC_MASK</b> \n
Sets specific cipher to tcp secured socket (SL_SEC_SOCKET) \n
Default: "Best" cipher suitable to method \n
This options takes SlSockSecureMask struct as parameter
- <b>SL_SO_SECURE_FILES_CA_FILE_NAME</b> \n
Map secured socket to CA file by name \n
This options takes <b>_u8</b> buffer as parameter
- <b>SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME</b> \n
Map secured socket to private key by name \n
This options takes <b>_u8</b> buffer as parameter
- <b>SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME</b> \n
Map secured socket to certificate file by name \n
This options takes <b>_u8</b> buffer as parameter
- <b>SL_SO_SECURE_FILES_DH_KEY_FILE_NAME</b> \n
Map secured socket to Diffie Hellman file by name \n
This options takes <b>_u8</b> buffer as parameter
- <b>SL_SO_CHANGE_CHANNEL</b> \n
Sets channel in transceiver mode.
This options takes <b>_u32</b> as channel number parameter
- <b>SL_IPPROTO_IP</b>
- <b>SL_IP_MULTICAST_TTL</b> \n
Set the time-to-live value of outgoing multicast packets for this socket. \n
This options takes <b>_u8</b> as parameter
- <b>SL_IP_ADD_MEMBERSHIP</b> \n
UDP socket, Join a multicast group. \n
This options takes SlSockIpMreq struct as parameter
- <b>SL_IP_DROP_MEMBERSHIP</b> \n
UDP socket, Leave a multicast group \n
This options takes SlSockIpMreq struct as parameter
- <b>SL_IP_RAW_RX_NO_HEADER</b> \n
Raw socket remove IP header from received data. \n
Default: data includes ip header \n
This options takes <b>_u32</b> as parameter
- <b>SL_IP_HDRINCL</b> \n
RAW socket only, the IPv4 layer generates an IP header when sending a packet unless \n
the IP_HDRINCL socket option is enabled on the socket. \n
When it is enabled, the packet must contain an IP header. \n
Default: disabled, IPv4 header generated by Network Stack \n
This options takes <b>_u32</b> as parameter
- <b>SL_IP_RAW_IPV6_HDRINCL</b> (inactive) \n
RAW socket only, the IPv6 layer generates an IP header when sending a packet unless \n
the IP_HDRINCL socket option is enabled on the socket. When it is enabled, the packet must contain an IP header \n
Default: disabled, IPv4 header generated by Network Stack \n
This options takes <b>_u32</b> as parameter
- <b>SL_SOL_PHY_OPT</b>
- <b>SL_SO_PHY_RATE</b> \n
RAW socket, set WLAN PHY transmit rate \n
The values are based on RateIndex_e \n
This options takes <b>_u32</b> as parameter
- <b>SL_SO_PHY_TX_POWER</b> \n
RAW socket, set WLAN PHY TX power \n
Valid rage is 1-15 \n
This options takes <b>_u32</b> as parameter
- <b>SL_SO_PHY_NUM_FRAMES_TO_TX</b> \n
RAW socket, set number of frames to transmit in transceiver mode.
Default: 1 packet
This options takes <b>_u32</b> as parameter
- <b>SL_SO_PHY_PREAMBLE</b> \n
RAW socket, set WLAN PHY preamble for Long/Short\n
This options takes <b>_u32</b> as parameter
\param[in] optval specifies a value for the option
\param[in] optlen specifies the length of the
option value
\return On success, zero is returned.
On error, a negative value is returned.
\sa sl_getsockopt
\note belongs to \ref basic_api
\warning
\par Examples:
\par
<b> SL_SO_KEEPALIVE: </b>(disable Keepalive)
\code
SlSockKeepalive_t enableOption;
enableOption.KeepaliveEnabled = 0;
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_KEEPALIVE, (_u8 *)&enableOption,sizeof(enableOption));
\endcode
\par
<b> SL_SO_RCVTIMEO: </b>
\code
struct SlTimeval_t timeVal;
timeVal.tv_sec = 1; // Seconds
timeVal.tv_usec = 0; // Microseconds. 10000 microseconds resolution
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVTIMEO, (_u8 *)&timeVal, sizeof(timeVal)); // Enable receive timeout
\endcode
\par
<b> SL_SO_RCVBUF: </b>
\code
SlSockWinsize_t size;
size.Winsize = 3000; // bytes
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVBUF, (_u8 *)&size, sizeof(size));
\endcode
\par
<b> SL_SO_NONBLOCKING: </b>
\code
SlSockNonblocking_t enableOption;
enableOption.NonblockingEnabled = 1;
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_NONBLOCKING, (_u8 *)&enableOption,sizeof(enableOption)); // Enable/disable nonblocking mode
\endcode
\par
<b> SL_SO_SECMETHOD:</b>
\code
SlSockSecureMethod method;
method.secureMethod = SL_SO_SEC_METHOD_SSLV3; // security method we want to use
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SECMETHOD, (_u8 *)&method, sizeof(method));
\endcode
\par
<b> SL_SO_SECURE_MASK:</b>
\code
SlSockSecureMask cipher;
cipher.secureMask = SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA; // cipher type
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SEC_MASK,(_u8 *)&cipher, sizeof(cipher));
\endcode
\par
<b> SL_SO_SECURE_FILES_CA_FILE_NAME:</b>
\code
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CA_FILE_NAME,"exuifaxCaCert.der",strlen("exuifaxCaCert.der"));
\endcode
\par
<b> SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME:</b>
\code
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME,"myPrivateKey.der",strlen("myPrivateKey.der"));
\endcode
\par
<b> SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME:</b>
\code
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME,"myCertificate.der",strlen("myCertificate.der"));
\endcode
\par
<b> SL_SO_SECURE_FILES_DH_KEY_FILE_NAME:</b>
\code
sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_DH_KEY_FILE_NAME,"myDHinServerMode.der",strlen("myDHinServerMode.der"));
\endcode
\par
<b> SL_IP_MULTICAST_TTL:</b>
\code
_u8 ttl = 20;
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_MULTICAST_TTL, &ttl, sizeof(ttl));
\endcode
\par
<b> SL_IP_ADD_MEMBERSHIP:</b>
\code
SlSockIpMreq mreq;
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
\endcode
\par
<b> SL_IP_DROP_MEMBERSHIP:</b>
\code
SlSockIpMreq mreq;
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
\endcode
\par
<b> SL_SO_CHANGE_CHANNEL:</b>
\code
_u32 newChannel = 6; // range is 1-13
sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_CHANGE_CHANNEL, &newChannel, sizeof(newChannel));
\endcode
\par
<b> SL_IP_RAW_RX_NO_HEADER:</b>
\code
_u32 header = 1; // remove ip header
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_RX_NO_HEADER, &header, sizeof(header));
\endcode
\par
<b> SL_IP_HDRINCL:</b>
\code
_u32 header = 1;
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_HDRINCL, &header, sizeof(header));
\endcode
\par
<b> SL_IP_RAW_IPV6_HDRINCL:</b>
\code
_u32 header = 1;
sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_IPV6_HDRINCL, &header, sizeof(header));
\endcode
\par
<b> SL_SO_PHY_RATE:</b>
\code
_u32 rate = 6; // see wlan.h RateIndex_e for values
sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_RATE, &rate, sizeof(rate));
\endcode
\par
<b> SL_SO_PHY_TX_POWER:</b>
\code
_u32 txpower = 1; // valid range is 1-15
sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_TX_POWER, &txpower, sizeof(txpower));
\endcode
\par
<b> SL_SO_PHY_NUM_FRAMES_TO_TX:</b>
\code
_u32 numframes = 1;
sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_NUM_FRAMES_TO_TX, &numframes, sizeof(numframes));
\endcode
\par
<b> SL_SO_PHY_PREAMBLE:</b>
\code
_u32 preamble = 1;
sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_PREAMBLE, &preamble, sizeof(preamble));
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_SetSockOpt)
_i16 sl_SetSockOpt(_i16 sd, _i16 level, _i16 optname, const void *optval, SlSocklen_t optlen);
#endif
/*!
\brief Get socket options
This function manipulate the options associated with a socket.
Options may exist at multiple protocol levels; they are always
present at the uppermost socket level.
When manipulating socket options the level at which the option resides
and the name of the option must be specified. To manipulate options at
the socket level, level is specified as SOL_SOCKET. To manipulate
options at any other level the protocol number of the appropriate proto-
col controlling the option is supplied. For example, to indicate that an
option is to be interpreted by the TCP protocol, level should be set to
the protocol number of TCP;
The parameters optval and optlen are used to access optval -
ues for setsockopt(). For getsockopt() they identify a
buffer in which the value for the requested option(s) are to
be returned. For getsockopt(), optlen is a value-result
parameter, initially containing the size of the buffer
pointed to by option_value, and modified on return to
indicate the actual size of the value returned. If no option
value is to be supplied or returned, option_value may be
NULL.
\param[in] sd socket handle
\param[in] level defines the protocol level for this option
\param[in] optname defines the option name to interrogate
\param[out] optval specifies a value for the option
\param[out] optlen specifies the length of the
option value
\return On success, zero is returned.
On error, a negative value is returned.
\sa sl_SetSockOpt
\note See sl_SetSockOpt
belongs to \ref ext_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_GetSockOpt)
_i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t *optlen);
#endif
/*!
\brief read data from TCP socket
function receives a message from a connection-mode socket
\param[in] sd socket handle
\param[out] buf Points to the buffer where the
message should be stored.
\param[in] Len Specifies the length in bytes of
the buffer pointed to by the buffer argument.
Range: 1-16000 bytes
\param[in] flags Specifies the type of message
reception. On this version, this parameter is not
supported.
\return return the number of bytes received,
or a negative value if an error occurred.
using a non-blocking recv a possible negative value is SL_EAGAIN.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_RecvFrom
\note belongs to \ref recv_api
\warning
\par Examples:
\code An example of receiving data using TCP socket:
SlSockAddrIn_t Addr;
SlSockAddrIn_t LocalAddr;
_i16 AddrSize = sizeof(SlSockAddrIn_t);
_i16 SockID, newSockID;
_i16 Status;
_i8 Buf[RECV_BUF_LEN];
LocalAddr.sin_family = SL_AF_INET;
LocalAddr.sin_port = sl_Htons(5001);
LocalAddr.sin_addr.s_addr = 0;
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(5001);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
Status = sl_Listen(SockID, 0);
newSockID = sl_Accept(SockID, (SlSockAddr_t*)&Addr, (SlSocklen_t*) &AddrSize);
Status = sl_Recv(newSockID, Buf, 1460, 0);
\endcode
\code Example code for Rx transceiver mode using a raw socket
_i8 buffer[1536];
_i16 sd;
_u16 size;
SlTransceiverRxOverHead_t *transHeader;
sd = sl_Socket(SL_AF_RF,SL_SOCK_RAW,11); // channel 11
while(1)
{
size = sl_Recv(sd,buffer,1536,0);
transHeader = (SlTransceiverRxOverHead_t *)buffer;
printf("RSSI is %d frame type is 0x%x size %d\n",transHeader->rssi,buffer[sizeof(SlTransceiverRxOverHead_t)],size);
}
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_Recv)
_i16 sl_Recv(_i16 sd, void *buf, _i16 Len, _i16 flags);
#endif
/*!
\brief read data from socket
function receives a message from a connection-mode or
connectionless-mode socket
\param[in] sd socket handle
\param[out] buf Points to the buffer where the message should be stored.
\param[in] Len Specifies the length in bytes of the buffer pointed to by the buffer argument.
Range: 1-16000 bytes
\param[in] flags Specifies the type of message
reception. On this version, this parameter is not
supported.
\param[in] from pointer to an address structure
indicating the source
address.\n sockaddr:\n - code
for the address format. On this
version only AF_INET is
supported.\n - socket address,
the length depends on the code
format
\param[in] fromlen source address structure
size. This parameter MUST be set to the size of the structure pointed to by addr.
\return return the number of bytes received,
or a negative value if an error occurred.
using a non-blocking recv a possible negative value is SL_EAGAIN.
SL_RET_CODE_INVALID_INPUT (-2) will be returned if fromlen has incorrect length.
SL_POOL_IS_EMPTY may be return in case there are no resources in the system
In this case try again later or increase MAX_CONCURRENT_ACTIONS
\sa sl_Recv
\note belongs to \ref recv_api
\warning
\par Example:
\code An example of receiving data:
SlSockAddrIn_t Addr;
SlSockAddrIn_t LocalAddr;
_i16 AddrSize = sizeof(SlSockAddrIn_t);
_i16 SockID;
_i16 Status;
_i8 Buf[RECV_BUF_LEN];
LocalAddr.sin_family = SL_AF_INET;
LocalAddr.sin_port = sl_Htons(5001);
LocalAddr.sin_addr.s_addr = 0;
SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
Status = sl_RecvFrom(SockID, Buf, 1472, 0, (SlSockAddr_t *)&Addr, (SlSocklen_t*)&AddrSize);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_RecvFrom)
_i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, SlSocklen_t *fromlen);
#endif
/*!
\brief write data to TCP socket
This function is used to transmit a message to another socket.
Returns immediately after sending data to device.
In case of TCP failure an async event SL_SOCKET_TX_FAILED_EVENT is going to
be received.
In case of a RAW socket (transceiver mode), extra 4 bytes should be reserved at the end of the
frame data buffer for WLAN FCS
\param[in] sd socket handle
\param[in] buf Points to a buffer containing
the message to be sent
\param[in] Len message size in bytes. Range: 1-1460 bytes
\param[in] flags Specifies the type of message
transmission. On this version, this parameter is not
supported for TCP.
For transceiver mode, the SL_RAW_RF_TX_PARAMS macro can be used to determine
transmission parameters (channel,rate,tx_power,preamble)
\return Return the number of bytes transmitted,
or -1 if an error occurred
\sa sl_SendTo
\note belongs to \ref send_api
\warning
\par Example:
\code An example of sending data:
SlSockAddrIn_t Addr;
_i16 AddrSize = sizeof(SlSockAddrIn_t);
_i16 SockID;
_i16 Status;
_i8 Buf[SEND_BUF_LEN];
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(5001);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
Status = sl_Connect(SockID, (SlSockAddr_t *)&Addr, AddrSize);
Status = sl_Send(SockID, Buf, 1460, 0 );
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_Send )
_i16 sl_Send(_i16 sd, const void *buf, _i16 Len, _i16 flags);
#endif
/*!
\brief write data to socket
This function is used to transmit a message to another socket
(connection less socket SOCK_DGRAM, SOCK_RAW).
Returns immediately after sending data to device.
In case of transmission failure an async event SL_SOCKET_TX_FAILED_EVENT is going to
be received.
\param[in] sd socket handle
\param[in] buf Points to a buffer containing
the message to be sent
\param[in] Len message size in bytes. Range: 1-1460 bytes
\param[in] flags Specifies the type of message
transmission. On this version, this parameter is not
supported
\param[in] to pointer to an address structure
indicating the destination
address.\n sockaddr:\n - code
for the address format. On this
version only AF_INET is
supported.\n - socket address,
the length depends on the code
format
\param[in] tolen destination address structure size
\return Return the number of transmitted bytes,
or -1 if an error occurred
\sa sl_Send
\note belongs to \ref send_api
\warning
\par Example:
\code An example of sending data:
SlSockAddrIn_t Addr;
_i16 AddrSize = sizeof(SlSockAddrIn_t);
_i16 SockID;
_i16 Status;
_i8 Buf[SEND_BUF_LEN];
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(5001);
Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
Status = sl_SendTo(SockID, Buf, 1472, 0, (SlSockAddr_t *)&Addr, AddrSize);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_SendTo)
_i16 sl_SendTo(_i16 sd, const void *buf, _i16 Len, _i16 flags, const SlSockAddr_t *to, SlSocklen_t tolen);
#endif
/*!
\brief Reorder the bytes of a 32-bit unsigned value
This function is used to Reorder the bytes of a 32-bit unsigned value from processor order to network order.
\param[in] var variable to reorder
\return Return the reorder variable,
\sa sl_SendTo sl_Bind sl_Connect sl_RecvFrom sl_Accept
\note belongs to \ref send_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Htonl )
_u32 sl_Htonl( _u32 val );
#define sl_Ntohl sl_Htonl /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
#endif
/*!
\brief Reorder the bytes of a 16-bit unsigned value
This function is used to Reorder the bytes of a 16-bit unsigned value from processor order to network order.
\param[in] var variable to reorder
\return Return the reorder variable,
\sa sl_SendTo sl_Bind sl_Connect sl_RecvFrom sl_Accept
\note belongs to \ref send_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_Htons )
_u16 sl_Htons( _u16 val );
#define sl_Ntohs sl_Htons /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __SOCKET_H__ */
/*
* spawn.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __NONOS_H__
#define __NONOS_H__
#ifdef __cplusplus
extern "C" {
#endif
#if (defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN))
extern void _SlInternalSpawnTaskEntry();
extern _i16 _SlInternalSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags);
#undef sl_Spawn
#define sl_Spawn(pEntry,pValue,flags) _SlInternalSpawn(pEntry,pValue,flags)
#undef _SlTaskEntry
#define _SlTaskEntry _SlInternalSpawnTaskEntry
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/*
* trace.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "simplelink.h"
#ifndef __SIMPLELINK_TRACE_H__
#define __SIMPLELINK_TRACE_H__
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
#define SL_SYNC_SCAN_THRESHOLD (( _u32 )2000)
#define _SL_ASSERT(expr) { ASSERT(expr); }
#define _SL_ERROR(expr, error) { if(!(expr)){return (error); } }
#define SL_HANDLING_ASSERT 2
#define SL_HANDLING_ERROR 1
#define SL_HANDLING_NONE 0
#define SL_SELF_COND_HANDLING SL_HANDLING_NONE
#define SL_PROTOCOL_HANDLING SL_HANDLING_NONE
#define SL_DRV_RET_CODE_HANDLING SL_HANDLING_NONE
#define SL_NWP_IF_HANDLING SL_HANDLING_NONE
#define SL_OSI_RET_OK_HANDLING SL_HANDLING_NONE
#define SL_MALLOC_OK_HANDLING SL_HANDLING_NONE
#define SL_USER_ARGS_HANDLING SL_HANDLING_NONE
#if (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ASSERT)
#define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
#elif (SL_DRV_RET_CODE_HANDLING == SL_HANDLING_ERROR)
#define VERIFY_RET_OK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;}
#else
#define VERIFY_RET_OK(Func) (Func);
#endif
#if (SL_PROTOCOL_HANDLING == SL_HANDLING_ASSERT)
#define VERIFY_PROTOCOL(expr) _SL_ASSERT(expr)
#elif (SL_PROTOCOL_HANDLING == SL_HANDLING_ERROR)
#define VERIFY_PROTOCOL(expr) _SL_ERROR(expr, SL_RET_CODE_PROTOCOL_ERROR)
#else
#define VERIFY_PROTOCOL(expr)
#endif
#if (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ASSERT))
#define VERIFY_SOCKET_CB(expr) _SL_ASSERT(expr)
#elif (defined(PROTECT_SOCKET_ASYNC_RESP) && (SL_SELF_COND_HANDLING == SL_HANDLING_ERROR))
#define VERIFY_SOCKET_CB(expr) _SL_ERROR(expr, SL_RET_CODE_SELF_ERROR)
#else
#define VERIFY_SOCKET_CB(expr)
#endif
#if (SL_NWP_IF_HANDLING == SL_HANDLING_ASSERT)
#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (len); RetSize = sl_IfWrite((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
#define NWP_IF_READ_CHECK(fd,pBuff,len) { _i16 RetSize, ExpSize = (len); RetSize = sl_IfRead((fd),(pBuff),ExpSize); _SL_ASSERT(ExpSize == RetSize)}
#elif (SL_NWP_IF_HANDLING == SL_HANDLING_ERROR)
#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfWrite((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
#define NWP_IF_READ_CHECK(fd,pBuff,len) { _SL_ERROR((len == sl_IfRead((fd),(pBuff),(len))), SL_RET_CODE_NWP_IF_ERROR);}
#else
#define NWP_IF_WRITE_CHECK(fd,pBuff,len) { sl_IfWrite((fd),(pBuff),(len));}
#define NWP_IF_READ_CHECK(fd,pBuff,len) { sl_IfRead((fd),(pBuff),(len));}
#endif
#if (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ASSERT)
#define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); _SL_ASSERT((_SlReturnVal_t)SL_OS_RET_CODE_OK == _RetVal)}
#elif (SL_OSI_RET_OK_HANDLING == SL_HANDLING_ERROR)
#define OSI_RET_OK_CHECK(Func) {_SlReturnVal_t _RetVal = (Func); if (SL_OS_RET_CODE_OK != _RetVal) return _RetVal;}
#else
#define OSI_RET_OK_CHECK(Func) (Func);
#endif
#if (SL_MALLOC_OK_HANDLING == SL_HANDLING_ASSERT)
#define MALLOC_OK_CHECK(Ptr) _SL_ASSERT(NULL != Ptr)
#elif (SL_MALLOC_OK_HANDLING == SL_HANDLING_ERROR)
#define MALLOC_OK_CHECK(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_MALLOC_ERROR)
#else
#define MALLOC_OK_CHECK(Ptr)
#endif
#ifdef SL_INC_ARG_CHECK
#if (SL_USER_ARGS_HANDLING == SL_HANDLING_ASSERT)
#define ARG_CHECK_PTR(Ptr) _SL_ASSERT(NULL != Ptr)
#elif (SL_USER_ARGS_HANDLING == SL_HANDLING_ERROR)
#define ARG_CHECK_PTR(Ptr) _SL_ERROR((NULL != Ptr), SL_RET_CODE_INVALID_INPUT)
#else
#define ARG_CHECK_PTR(Ptr)
#endif
#else
#define ARG_CHECK_PTR(Ptr)
#endif
#define SL_TRACE0(level,msg_id,str)
#define SL_TRACE1(level,msg_id,str,p1)
#define SL_TRACE2(level,msg_id,str,p1,p2)
#define SL_TRACE3(level,msg_id,str,p1,p2,p3)
#define SL_TRACE4(level,msg_id,str,p1,p2,p3,p4)
#define SL_ERROR_TRACE(msg_id,str)
#define SL_ERROR_TRACE1(msg_id,str,p1)
#define SL_ERROR_TRACE2(msg_id,str,p1,p2)
#define SL_ERROR_TRACE3(msg_id,str,p1,p2,p3)
#define SL_ERROR_TRACE4(msg_id,str,p1,p2,p3,p4)
#define SL_TRACE_FLUSH()
/* #define SL_DBG_CNT_ENABLE */
#ifdef SL_DBG_CNT_ENABLE
#define _SL_DBG_CNT_INC(Cnt) g_DbgCnt. ## Cnt++
#define _SL_DBG_SYNC_LOG(index,value) {if(index < SL_DBG_SYNC_LOG_SIZE){*(_u32 *)&g_DbgCnt.SyncLog[index] = *(_u32 *)(value);}}
#else
#define _SL_DBG_CNT_INC(Cnt)
#define _SL_DBG_SYNC_LOG(index,value)
#endif
#define SL_DBG_LEVEL_1 1
#define SL_DBG_LEVEL_2 2
#define SL_DBG_LEVEL_3 4
#define SL_DBG_LEVEL_MASK (SL_DBG_LEVEL_2|SL_DBG_LEVEL_3)
#define SL_INCLUDE_DBG_FUNC(Name) ((Name ## _DBG_LEVEL) & SL_DBG_LEVEL_MASK)
#define _SlDrvPrintStat_DBG_LEVEL SL_DBG_LEVEL_3
#define _SlDrvOtherFunc_DBG_LEVEL SL_DBG_LEVEL_1
#ifdef __cplusplus
}
#endif
#endif /*__SIMPLELINK_TRACE_H__*/
/*
* wlan.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef __WLAN_H__
#define __WLAN_H__
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
/*!
\addtogroup wlan
@{
*/
#define SL_BSSID_LENGTH (6)
#define MAXIMAL_SSID_LENGTH (32)
#define NUM_OF_RATE_INDEXES (20)
#define SIZE_OF_RSSI_HISTOGRAM (6)
/* WLAN Disconnect Reason Codes */
#define SL_DISCONNECT_RESERVED_0 (0)
#define SL_DISCONNECT_UNSPECIFIED_REASON (1)
#define SL_PREVIOUS_AUTHENTICATION_NO_LONGER_VALID (2)
#define SL_DEAUTHENTICATED_BECAUSE_SENDING_STATION_IS_LEAVING (3)
#define SL_DISASSOCIATED_DUE_TO_INACTIVITY (4)
#define SL_DISASSOCIATED_BECAUSE_AP_IS_UNABLE_TO_HANDLE_ALL_CURRENTLY_ASSOCIATED_STATIONS (5)
#define SL_CLASS_2_FRAME_RECEIVED_FROM_NONAUTHENTICATED_STATION (6)
#define SL_CLASS_3_FRAME_RECEIVED_FROM_NONASSOCIATED_STATION (7)
#define SL_DISASSOCIATED_BECAUSE_SENDING_STATION_IS_LEAVING_BSS (8)
#define SL_STATION_REQUESTING_ASSOCIATION_IS_NOT_AUTHENTICATED_WITH_RESPONDING_STATION (9)
#define SL_DISASSOCIATED_BECAUSE_THE_INFORMATION_IN_THE_POWER_CAPABILITY_ELEMENT_IS_UNACCEPTABLE (10)
#define SL_DISASSOCIATED_BECAUSE_THE_INFORMATION_IN_THE_SUPPORTED_CHANNELS_ELEMENT_IS_UNACCEPTABLE (11)
#define SL_DISCONNECT_RESERVED_1 (12)
#define SL_INVALID_INFORMATION_ELEMENT (13)
#define SL_MESSAGE_INTEGRITY_CODE_MIC_FAILURE (14)
#define SL_FOUR_WAY_HANDSHAKE_TIMEOUT (15)
#define SL_GROUP_KEY_HANDSHAKE_TIMEOUT (16)
#define SL_RE_ASSOCIATION_REQUEST_PROBE_RESPONSE_BEACON_FRAME (17)
#define SL_INVALID_GROUP_CIPHER (18)
#define SL_INVALID_PAIRWISE_CIPHER (19)
#define SL_INVALID_AKMP (20)
#define SL_UNSUPPORTED_RSN_INFORMATION_ELEMENT_VERSION (21)
#define SL_INVALID_RSN_INFORMATION_ELEMENT_CAPABILITIES (22)
#define SL_IEEE_802_1X_AUTHENTICATION_FAILED (23)
#define SL_CIPHER_SUITE_REJECTED_BECAUSE_OF_THE_SECURITY_POLICY (24)
#define SL_DISCONNECT_RESERVED_2 (25)
#define SL_DISCONNECT_RESERVED_3 (26)
#define SL_DISCONNECT_RESERVED_4 (27)
#define SL_DISCONNECT_RESERVED_5 (28)
#define SL_DISCONNECT_RESERVED_6 (29)
#define SL_DISCONNECT_RESERVED_7 (30)
#define SL_DISCONNECT_RESERVED_8 (31)
#define SL_USER_INITIATED_DISCONNECTION (200)
/* Wlan error codes */
#define SL_ERROR_KEY_ERROR (-3)
#define SL_ERROR_INVALID_ROLE (-71)
#define SL_ERROR_INVALID_SECURITY_TYPE (-84)
#define SL_ERROR_PASSPHRASE_TOO_LONG (-85)
#define SL_ERROR_WPS_NO_PIN_OR_WRONG_PIN_LEN (-87)
#define SL_ERROR_EAP_WRONG_METHOD (-88)
#define SL_ERROR_PASSWORD_ERROR (-89)
#define SL_ERROR_EAP_ANONYMOUS_LEN_ERROR (-90)
#define SL_ERROR_SSID_LEN_ERROR (-91)
#define SL_ERROR_USER_ID_LEN_ERROR (-92)
#define SL_ERROR_ILLEGAL_WEP_KEY_INDEX (-95)
#define SL_ERROR_INVALID_DWELL_TIME_VALUES (-96)
#define SL_ERROR_INVALID_POLICY_TYPE (-97)
#define SL_ERROR_PM_POLICY_INVALID_OPTION (-98)
#define SL_ERROR_PM_POLICY_INVALID_PARAMS (-99)
#define SL_ERROR_WIFI_ALREADY_DISCONNECTED (-129)
#define SL_ERROR_WIFI_NOT_CONNECTED (-59)
#define SL_SEC_TYPE_OPEN (0)
#define SL_SEC_TYPE_WEP (1)
#define SL_SEC_TYPE_WPA (2) /* deprecated */
#define SL_SEC_TYPE_WPA_WPA2 (2)
#define SL_SEC_TYPE_WPS_PBC (3)
#define SL_SEC_TYPE_WPS_PIN (4)
#define SL_SEC_TYPE_WPA_ENT (5)
#define SL_SEC_TYPE_P2P_PBC (6)
#define SL_SEC_TYPE_P2P_PIN_KEYPAD (7)
#define SL_SEC_TYPE_P2P_PIN_DISPLAY (8)
#define SL_SEC_TYPE_P2P_PIN_AUTO (9) /* NOT Supported yet */
#define SL_SCAN_SEC_TYPE_OPEN (0)
#define SL_SCAN_SEC_TYPE_WEP (1)
#define SL_SCAN_SEC_TYPE_WPA (2)
#define SL_SCAN_SEC_TYPE_WPA2 (3)
#define TLS (0x1)
#define MSCHAP (0x0)
#define PSK (0x2)
#define TTLS (0x10)
#define PEAP0 (0x20)
#define PEAP1 (0x40)
#define FAST (0x80)
#define FAST_AUTH_PROVISIONING (0x02)
#define FAST_UNAUTH_PROVISIONING (0x01)
#define FAST_NO_PROVISIONING (0x00)
#define EAPMETHOD_PHASE2_SHIFT (8)
#define EAPMETHOD_PAIRWISE_CIPHER_SHIFT (19)
#define EAPMETHOD_GROUP_CIPHER_SHIFT (27)
#define WPA_CIPHER_CCMP (0x1)
#define WPA_CIPHER_TKIP (0x2)
#define CC31XX_DEFAULT_CIPHER (WPA_CIPHER_CCMP | WPA_CIPHER_TKIP)
#define EAPMETHOD(phase1,phase2,pairwise_cipher,group_cipher) \
((phase1) | \
((phase2) << EAPMETHOD_PHASE2_SHIFT ) |\
((_u32)(pairwise_cipher) << EAPMETHOD_PAIRWISE_CIPHER_SHIFT ) |\
((_u32)(group_cipher) << EAPMETHOD_GROUP_CIPHER_SHIFT ))
/* phase1 phase2 pairwise_cipher group_cipher */
#define SL_ENT_EAP_METHOD_TLS EAPMETHOD(TLS , 0 , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_TTLS_TLS EAPMETHOD(TTLS , TLS , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_TTLS_MSCHAPv2 EAPMETHOD(TTLS , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_TTLS_PSK EAPMETHOD(TTLS , PSK , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_PEAP0_TLS EAPMETHOD(PEAP0 , TLS , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_PEAP0_MSCHAPv2 EAPMETHOD(PEAP0 , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_PEAP0_PSK EAPMETHOD(PEAP0 , PSK , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_PEAP1_TLS EAPMETHOD(PEAP1 , TLS , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_PEAP1_MSCHAPv2 EAPMETHOD(PEAP1 , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_PEAP1_PSK EAPMETHOD(PEAP1 , PSK , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_FAST_AUTH_PROVISIONING EAPMETHOD(FAST , FAST_AUTH_PROVISIONING , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_FAST_UNAUTH_PROVISIONING EAPMETHOD(FAST , FAST_UNAUTH_PROVISIONING , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_ENT_EAP_METHOD_FAST_NO_PROVISIONING EAPMETHOD(FAST , FAST_NO_PROVISIONING , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
#define SL_LONG_PREAMBLE (0)
#define SL_SHORT_PREAMBLE (1)
#define SL_RAW_RF_TX_PARAMS_CHANNEL_SHIFT (0)
#define SL_RAW_RF_TX_PARAMS_RATE_SHIFT (6)
#define SL_RAW_RF_TX_PARAMS_POWER_SHIFT (11)
#define SL_RAW_RF_TX_PARAMS_PREAMBLE_SHIFT (15)
#define SL_RAW_RF_TX_PARAMS(chan,rate,power,preamble) \
((chan << SL_RAW_RF_TX_PARAMS_CHANNEL_SHIFT) | \
(rate << SL_RAW_RF_TX_PARAMS_RATE_SHIFT) | \
(power << SL_RAW_RF_TX_PARAMS_POWER_SHIFT) | \
(preamble << SL_RAW_RF_TX_PARAMS_PREAMBLE_SHIFT))
/* wlan config application IDs */
#define SL_WLAN_CFG_AP_ID (0)
#define SL_WLAN_CFG_GENERAL_PARAM_ID (1)
#define SL_WLAN_CFG_P2P_PARAM_ID (2)
/* wlan AP Config set/get options */
#define WLAN_AP_OPT_SSID (0)
#define WLAN_AP_OPT_CHANNEL (3)
#define WLAN_AP_OPT_HIDDEN_SSID (4)
#define WLAN_AP_OPT_SECURITY_TYPE (6)
#define WLAN_AP_OPT_PASSWORD (7)
#define WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE (9)
#define WLAN_GENERAL_PARAM_OPT_STA_TX_POWER (10)
#define WLAN_GENERAL_PARAM_OPT_AP_TX_POWER (11)
#define WLAN_P2P_OPT_DEV_NAME (12)
#define WLAN_P2P_OPT_DEV_TYPE (13)
#define WLAN_P2P_OPT_CHANNEL_N_REGS (14)
#define WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT (16)
#define WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS (18) /* change the scan channels and RSSI threshold using this configuration option */
/* SmartConfig CIPHER options */
#define SMART_CONFIG_CIPHER_SFLASH (0) /* password is not delivered by the application. The Simple Manager should */
/* check if the keys are stored in the Flash. */
#define SMART_CONFIG_CIPHER_AES (1) /* AES (other types are not supported) */
#define SMART_CONFIG_CIPHER_NONE (0xFF) /* do not check in the flash */
#define SL_POLICY_CONNECTION (0x10)
#define SL_POLICY_SCAN (0x20)
#define SL_POLICY_PM (0x30)
#define SL_POLICY_P2P (0x40)
#define VAL_2_MASK(position,value) ((1 & (value))<<(position))
#define MASK_2_VAL(position,mask) (((1 << position) & (mask)) >> (position))
#define SL_CONNECTION_POLICY(Auto,Fast,Open,anyP2P,autoSmartConfig) (VAL_2_MASK(0,Auto) | VAL_2_MASK(1,Fast) | VAL_2_MASK(2,Open) | VAL_2_MASK(3,anyP2P) | VAL_2_MASK(4,autoSmartConfig))
#define SL_SCAN_POLICY_EN(policy) (MASK_2_VAL(0,policy))
#define SL_SCAN_POLICY(Enable) (VAL_2_MASK(0,Enable))
#define SL_NORMAL_POLICY (0)
#define SL_LOW_LATENCY_POLICY (1)
#define SL_LOW_POWER_POLICY (2)
#define SL_ALWAYS_ON_POLICY (3)
#define SL_LONG_SLEEP_INTERVAL_POLICY (4)
#define SL_P2P_ROLE_NEGOTIATE (3)
#define SL_P2P_ROLE_GROUP_OWNER (15)
#define SL_P2P_ROLE_CLIENT (0)
#define SL_P2P_NEG_INITIATOR_ACTIVE (0)
#define SL_P2P_NEG_INITIATOR_PASSIVE (1)
#define SL_P2P_NEG_INITIATOR_RAND_BACKOFF (2)
#define POLICY_VAL_2_OPTIONS(position,mask,policy) ((mask & policy) << position )
#define SL_P2P_POLICY(p2pNegType,p2pNegInitiator) (POLICY_VAL_2_OPTIONS(0,0xF,(p2pNegType > SL_P2P_ROLE_GROUP_OWNER ? SL_P2P_ROLE_GROUP_OWNER : p2pNegType)) | \
POLICY_VAL_2_OPTIONS(4,0x1,(p2pNegType > SL_P2P_ROLE_GROUP_OWNER ? 1:0)) | \
POLICY_VAL_2_OPTIONS(5,0x3, p2pNegInitiator))
/* Info elements */
#define INFO_ELEMENT_DEFAULT_ID (0) /* 221 will be used */
/* info element size is up to 252 bytes (+ 3 bytes of OUI). */
#define INFO_ELEMENT_MAX_SIZE (252)
/* For AP - the total length of all info elements is 300 bytes (for example - 4 info elements of 75 bytes each) */
#define INFO_ELEMENT_MAX_TOTAL_LENGTH_AP (300)
/* For P2P - the total length of all info elements is 150 bytes (for example - 4 info elements of 40 bytes each) */
#define INFO_ELEMENT_MAX_TOTAL_LENGTH_P2P_GO (160)
#define INFO_ELEMENT_AP_ROLE (0)
#define INFO_ELEMENT_P2P_GO_ROLE (1)
/* we support up to 4 info elements per Role. */
#define MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED (4)
#define INFO_ELEMENT_DEFAULT_OUI_0 (0x08)
#define INFO_ELEMENT_DEFAULT_OUI_1 (0x00)
#define INFO_ELEMENT_DEFAULT_OUI_2 (0x28)
#define INFO_ELEMENT_DEFAULT_OUI (0x000000) /* 08, 00, 28 will be used */
/*****************************************************************************/
/* Structure/Enum declarations */
/*****************************************************************************/
typedef enum
{
RATE_1M = 1,
RATE_2M = 2,
RATE_5_5M = 3,
RATE_11M = 4,
RATE_6M = 6,
RATE_9M = 7,
RATE_12M = 8,
RATE_18M = 9,
RATE_24M = 10,
RATE_36M = 11,
RATE_48M = 12,
RATE_54M = 13,
RATE_MCS_0 = 14,
RATE_MCS_1 = 15,
RATE_MCS_2 = 16,
RATE_MCS_3 = 17,
RATE_MCS_4 = 18,
RATE_MCS_5 = 19,
RATE_MCS_6 = 20,
RATE_MCS_7 = 21,
MAX_NUM_RATES = 0xFF
}SlRateIndex_e;
typedef enum {
DEV_PW_DEFAULT=0,
DEV_PW_PIN_KEYPAD=1,
DEV_PW_PUSH_BUTTON=4,
DEV_PW_PIN_DISPLAY=5
} sl_p2p_dev_password_method;
typedef struct
{
_u32 status;
_u32 ssid_len;
_u8 ssid[32];
_u32 private_token_len;
_u8 private_token[32];
}slSmartConfigStartAsyncResponse_t;
typedef struct
{
_u16 status;
_u16 padding;
}slSmartConfigStopAsyncResponse_t;
typedef struct
{
_u16 status;
_u16 padding;
}slWlanConnFailureAsyncResponse_t;
typedef struct
{
_u8 connection_type;/* 0-STA,3-P2P_CL */
_u8 ssid_len;
_u8 ssid_name[32];
_u8 go_peer_device_name_len;
_u8 go_peer_device_name[32];
_u8 bssid[6];
_u8 reason_code;
_u8 padding[2];
} slWlanConnectAsyncResponse_t;
typedef struct
{
_u8 go_peer_device_name[32];
_u8 mac[6];
_u8 go_peer_device_name_len;
_u8 wps_dev_password_id;
_u8 own_ssid[32];/* relevant for event sta-connected only */
_u8 own_ssid_len;/* relevant for event sta-connected only */
_u8 padding[3];
}slPeerInfoAsyncResponse_t;
typedef union
{
slSmartConfigStartAsyncResponse_t smartConfigStartResponse; /*SL_WLAN_SMART_CONFIG_COMPLETE_EVENT*/
slSmartConfigStopAsyncResponse_t smartConfigStopResponse; /*SL_WLAN_SMART_CONFIG_STOP_EVENT */
slPeerInfoAsyncResponse_t APModeStaConnected; /* SL_WLAN_STA_CONNECTED_EVENT - relevant only in AP mode - holds information regarding a new STA connection */
slPeerInfoAsyncResponse_t APModestaDisconnected; /* SL_WLAN_STA_DISCONNECTED_EVENT - relevant only in AP mode - holds information regarding a STA disconnection */
slWlanConnectAsyncResponse_t STAandP2PModeWlanConnected; /* SL_WLAN_CONNECT_EVENT - relevant only in STA and P2P mode - holds information regarding a new connection */
slWlanConnectAsyncResponse_t STAandP2PModeDisconnected; /* SL_WLAN_DISCONNECT_EVENT - relevant only in STA and P2P mode - holds information regarding a disconnection */
slPeerInfoAsyncResponse_t P2PModeDevFound; /* SL_WLAN_P2P_DEV_FOUND_EVENT - relevant only in P2P mode */
slPeerInfoAsyncResponse_t P2PModeNegReqReceived; /* SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT - relevant only in P2P mode */
slWlanConnFailureAsyncResponse_t P2PModewlanConnectionFailure; /* SL_WLAN_CONNECTION_FAILED_EVENT - relevant only in P2P mode */
} SlWlanEventData_u;
typedef struct
{
_u32 Event;
SlWlanEventData_u EventData;
} SlWlanEvent_t;
typedef struct
{
_u32 ReceivedValidPacketsNumber; /* sum of the packets that been received OK (include filtered) */
_u32 ReceivedFcsErrorPacketsNumber; /* sum of the packets that been dropped due to FCS error */
_u32 ReceivedAddressMismatchPacketsNumber; /* sum of the packets that been received but filtered out by one of the HW filters */
_i16 AvarageDataCtrlRssi; /* average RSSI for all valid data packets received */
_i16 AvarageMgMntRssi; /* average RSSI for all valid management packets received */
_u16 RateHistogram[NUM_OF_RATE_INDEXES]; /* rate histogram for all valid packets received */
_u16 RssiHistogram[SIZE_OF_RSSI_HISTOGRAM]; /* RSSI histogram from -40 until -87 (all below and above\n RSSI will appear in the first and last cells */
_u32 StartTimeStamp; /* the time stamp started collecting the statistics in uSec */
_u32 GetTimeStamp; /* the time stamp called the get statistics command */
}SlGetRxStatResponse_t;
typedef struct
{
_u8 ssid[MAXIMAL_SSID_LENGTH];
_u8 ssid_len;
_u8 sec_type;
_u8 bssid[SL_BSSID_LENGTH];
_i8 rssi;
_i8 reserved[3];
}Sl_WlanNetworkEntry_t;
typedef struct
{
_u8 Type;
_i8* Key;
_u8 KeyLen;
}SlSecParams_t;
typedef struct
{
_i8* User;
_u8 UserLen;
_i8* AnonUser;
_u8 AnonUserLen;
_u8 CertIndex; /* not supported */
_u32 EapMethod;
}SlSecParamsExt_t;
typedef struct
{
_i8 User[32];
_u8 UserLen;
_i8 AnonUser[32];
_u8 AnonUserLen;
_u8 CertIndex; /* not supported */
_u32 EapMethod;
}SlGetSecParamsExt_t;
typedef enum
{
ROLE_STA = 0,
ROLE_AP = 2,
ROLE_P2P = 3,
ROLE_STA_ERR = -1, /* Failure to load MAC/PHY in STA role */
ROLE_AP_ERR = -ROLE_AP, /* Failure to load MAC/PHY in AP role */
ROLE_P2P_ERR = -ROLE_P2P /* Failure to load MAC/PHY in P2P role */
}SlWlanMode_t;
typedef struct
{
_u32 G_Channels_mask;
_i32 rssiThershold;
}slWlanScanParamCommand_t;
typedef struct
{
_u8 id;
_u8 oui[3];
_u16 length;
_u8 data[252];
} sl_protocol_InfoElement_t;
typedef struct
{
_u8 index; /* 0 - MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED */
_u8 role; /* bit0: AP = 0, GO = 1 */
sl_protocol_InfoElement_t ie;
} sl_protocol_WlanSetInfoElement_t;
/*****************************************************************************/
/* Function prototypes */
/*****************************************************************************/
/*!
\brief Connect to wlan network as a station
\param[in] pName up to 32 bytes in case of STA the name is the SSID of the Access Point
\param[in] NameLen name length
\param[in] pMacAddr 6 bytes for MAC address
\param[in] pSecParams Security parameters (use NULL key for SL_SEC_TYPE_OPEN)
Security types options: \n
- SL_SEC_TYPE_OPEN
- SL_SEC_TYPE_WEP
- SL_SEC_TYPE_WPA_WPA2
- SL_SEC_TYPE_WPA_ENT
- SL_SEC_TYPE_WPS_PBC
- SL_SEC_TYPE_WPS_PIN
\param[in] pSecExtParams Enterprise parameters (set NULL in case Enterprise parameters is not in use)
\return On success, zero is returned. On error, negative is returned
In case error number (-71) is returned, it indicates a connection was activated while the device it running in AP role
\sa sl_WlanDisconnect
\note belongs to \ref ext_api
\warning In this version only single enterprise mode could be used
SL_SEC_TYPE_WPA is a deprecated definition, the new definition is SL_SEC_TYPE_WPA_WPA2
*/
#if _SL_INCLUDE_FUNC(sl_WlanConnect)
_i16 sl_WlanConnect(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,const SlSecParams_t* pSecParams ,const SlSecParamsExt_t* pSecExtParams);
#endif
/*!
\brief wlan disconnect
Disconnect connection
\return 0 disconnected done, other already disconnected
\sa sl_WlanConnect
\note belongs to \ref ext_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_WlanDisconnect)
_i16 sl_WlanDisconnect(void);
#endif
/*!
\brief add profile
When auto start is enabled, the device connects to a
station from the profiles table. Up to 7 profiles are
supported. If several profiles configured the device chose
the highest priority profile, within each priority group,
device will chose profile based on security policy, signal
strength, etc parameters.
\param[in] pName up to 32 bytes in case of STA the name is the
SSID of the Access Point
in case of P2P the name is the remote device name
\param[in] NameLen name length
\param[in] pMacAddr 6 bytes for MAC address
\param[in] pSecParams Security parameters - security type
(SL_SEC_TYPE_OPEN,SL_SEC_TYPE_WEP,SL_SEC_TYPE_WPA_WPA2,
SL_SEC_TYPE_P2P_PBC,SL_SEC_TYPE_P2P_PIN_KEYPAD,SL_SEC_TYPE_P2P_PIN_DISPLAY, SL_SEC_TYPE_WPA_ENT), key, and key length
in case of p2p security type pin the key refers to pin code
\param[in] pSecExtParams Enterprise parameters - identity, identity length,
Anonymous, Anonymous length, CertIndex (not supported,
certificates need to be placed in a specific file ID),
EapMethod.Use NULL in case Enterprise parameters is not in use
\param[in] Priority profile priority. Lowest priority: 0
\param[in] Options Not supported
\return On success, profile stored index is returned. On error, negative value is returned
\sa sl_WlanProfileGet , sl_WlanProfileDel
\note belongs to \ref ext_api
\warning Only one Enterprise profile is supported.
Please Note that in case of adding an existing profile (compared by pName,pMACAddr and security type)
the old profile will be deleted and the same index will be returned.
SL_SEC_TYPE_WPA is a deprecated definition, the new definition is SL_SEC_TYPE_WPA_WPA2
*/
#if _SL_INCLUDE_FUNC(sl_WlanProfileAdd)
_i16 sl_WlanProfileAdd(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,const SlSecParams_t* pSecParams ,const SlSecParamsExt_t* pSecExtParams,const _u32 Priority,const _u32 Options);
#endif
/*!
\brief get profile
read profile from the device
\param[in] Index profile stored index, if index does not exists
error is return
\param[out] pName up to 32 bytes, in case of sta mode the name of the Access Point
in case of p2p mode the name of the Remote Device
\param[out] pNameLen name length
\param[out] pMacAddr 6 bytes for MAC address
\param[out] pSecParams security parameters - security type
(SL_SEC_TYPE_OPEN, SL_SEC_TYPE_WEP, SL_SEC_TYPE_WPA_WPA2 or
SL_SEC_TYPE_WPS_PBC, SL_SEC_TYPE_WPS_PIN, SL_SEC_TYPE_WPA_ENT,SL_SEC_TYPE_P2P_PBC,SL_SEC_TYPE_P2P_PIN_KEYPAD or SL_SEC_TYPE_P2P_PIN_DISPLAY), key and key length are not
in case of p2p security type pin the key refers to pin code
return due to security reasons.
\param[out] pSecExtParams enterprise parameters - identity, identity
length, Anonymous, Anonymous length
CertIndex (not supported), EapMethod.
\param[out] Priority profile priority
\return On success, Profile security type is returned (0 or positive number). On error, -1 is
returned
\sa sl_WlanProfileAdd , sl_WlanProfileDel
\note belongs to \ref ext_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_WlanProfileGet)
_i16 sl_WlanProfileGet(const _i16 Index,_i8* pName, _i16 *pNameLen, _u8 *pMacAddr, SlSecParams_t* pSecParams, SlGetSecParamsExt_t* pSecExtParams, _u32 *pPriority);
#endif
/*!
\brief Delete WLAN profile
Delete WLAN profile
\param[in] index number of profile to delete.Possible values are 0 to 6.
Index value 255 will delete all saved profiles
\return On success, zero is returned. On error, -1 is
returned
\sa sl_WlanProfileAdd , sl_WlanProfileGet
\note belongs to \ref ext_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_WlanProfileDel)
_i16 sl_WlanProfileDel(const _i16 Index);
#endif
/*!
\brief Set policy values
\param[in] Type Type of policy to be modified. The Options are:\n
- SL_POLICY_CONNECTION
- SL_POLICY_SCAN
- SL_POLICY_PM
- SL_POLICY_P2P
\param[in] Policy The option value which depends on action type
\param[in] pVal An optional value pointer
\param[in] ValLen An optional value length, in bytes
\return On success, zero is returned. On error, -1 is
returned
\sa sl_WlanPolicyGet
\note belongs to \ref ext_api
\warning
\par
SL_POLICY_CONNECTION type defines three options available to connect the CC31xx device to the AP: \n
- If Auto Connect is set, the CC31xx device tries to automatically reconnect to one of its stored profiles, each time the connection fails or the device is rebooted.\n
To set this option, use: \n
<b> sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL,0) </b>
- If Fast Connect is set, the CC31xx device tries to establish a fast connection to AP. \n
To set this option, use: \n
<b> sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(0,1,0,0,0),NULL,0) </b>
- (relevant for P2P mode only) - If Any P2P is set, CC31xx/CC32xx device tries to automatically connect to the first P2P device available, \n
supporting push button only. To set this option, use: \n
<b> sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(0,0,0,1,0),NULL,0) </b>
- For auto smart config upon restart (any command from Host will end this state) use: \n
<b> sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(0,0,0,0,1),NULL,0) </b> \n
The options above could be combined to a single action, if more than one action is required. \n
\par
SL_POLICY_SCAN defines system scan time interval.Default interval is 10 minutes. \n
After settings scan interval, an immediate scan is activated. The next scan will be based on the interval settings. \n
- For example, setting scan interval to 1 minute interval use: \n
_u32 intervalInSeconds = 60; \n
#define SL_SCAN_ENABLE 1 \n<b>
sl_WlanPolicySet(SL_POLICY_SCAN,SL_SCAN_ENABLE, (_u8 *)&intervalInSeconds,sizeof(intervalInSeconds)); </b>\n
- For example, disable scan: \n
#define SL_SCAN_DISABLE 0 \n<b>
sl_WlanPolicySet(SL_POLICY_SCAN,SL_SCAN_DISABLE,0,0); </b>\n
\par
SL_POLICY_PM defines a power management policy for Station mode only:
- For setting normal power management (default) policy use: <b> sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL,0) </b>
- For setting low latency power management policy use: <b> sl_WlanPolicySet(SL_POLICY_PM , SL_LOW_LATENCY_POLICY, NULL,0) </b>
- For setting low power management policy use: <b> sl_WlanPolicySet(SL_POLICY_PM , SL_LOW_POWER_POLICY, NULL,0) </b>
- For setting always on power management policy use: <b> sl_WlanPolicySet(SL_POLICY_PM , SL_ALWAYS_ON_POLICY, NULL,0) </b>
- For setting Long Sleep Interval policy use: \n
_u16 PolicyBuff[4] = {0,0,800,0}; // PolicyBuff[2] is max sleep time in mSec \n<b>
sl_WlanPolicySet(SL_POLICY_PM , SL_LONG_SLEEP_INTERVAL_POLICY, (_u8*)PolicyBuff,sizeof(PolicyBuff)); </b>\n
SL_POLICY_P2P defines p2p negotiation policy parameters for P2P role:
- To set intent negotiation value, set on of the following:
SL_P2P_ROLE_NEGOTIATE - intent 3
SL_P2P_ROLE_GROUP_OWNER - intent 15
SL_P2P_ROLE_CLIENT - intent 0
- To set negotiation initiator value (initiator policy of first negotiation action frame), set on of the following:
SL_P2P_NEG_INITIATOR_ACTIVE
SL_P2P_NEG_INITIATOR_PASSIVE
SL_P2P_NEG_INITIATOR_RAND_BACKOFF
For example: \n
<b>sl_WlanPolicySet(SL_POLICY_P2P, SL_P2P_POLICY(SL_P2P_ROLE_NEGOTIATE,SL_P2P_NEG_INITIATOR_RAND_BACKOFF),NULL,0) </b>
*/
#if _SL_INCLUDE_FUNC(sl_WlanPolicySet)
_i16 sl_WlanPolicySet(const _u8 Type , const _u8 Policy, _u8 *pVal,const _u8 ValLen);
#endif
/*!
\brief get policy values
\param[in] Type SL_POLICY_CONNECTION, SL_POLICY_SCAN, SL_POLICY_PM,SL_POLICY_P2P \n
\param[in] Policy argument may be set to any value \n
\param[out] The returned values, depends on each policy type, will be stored in the allocated buffer pointed by pVal
with a maximum buffer length set by the calling function and pointed to by argument *pValLen
\return On success, zero is returned. On error, -1 is returned
\sa sl_WlanPolicySet
\note belongs to \ref ext_api
\warning The value pointed by the argument *pValLen should be set to a value different from 0 and
greater than the buffer length returned from the SL device. Otherwise, an error will be returned.
*/
#if _SL_INCLUDE_FUNC(sl_WlanPolicyGet)
_i16 sl_WlanPolicyGet(const _u8 Type , _u8 Policy,_u8 *pVal,_u8 *pValLen);
#endif
/*!
\brief Gets the WLAN scan operation results
Gets scan results , gets entry from scan result table
\param[in] Index - Starting index identifier (range 0-19) for getting scan results
\param[in] Count - How many entries to fetch. Max is (20-"Index").
\param[out] pEntries - pointer to an allocated Sl_WlanNetworkEntry_t.
the number of array items should match "Count"
sec_type: SL_SCAN_SEC_TYPE_OPEN, SL_SCAN_SEC_TYPE_WEP, SL_SCAN_SEC_TYPE_WPA or SL_SCAN_SEC_TYPE_WPA2
\return Number of valid networks list items
\sa
\note belongs to \ref ext_api
\warning This command do not initiate any active scanning action
\par Example:
\code An example of fetching max 10 results:
Sl_WlanNetworkEntry_t netEntries[10];
_i16 resultsCount = sl_WlanGetNetworkList(0,10,&netEntries[0]);
for(i=0; i< resultsCount; i++)
{
printf("%s\n",netEntries[i].ssid);
}
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_WlanGetNetworkList)
_i16 sl_WlanGetNetworkList(const _u8 Index,const _u8 Count, Sl_WlanNetworkEntry_t *pEntries);
#endif
/*!
\brief Start collecting wlan RX statistics, for unlimited time.
\return On success, zero is returned. On error, -1 is returned
\sa sl_WlanRxStatStop sl_WlanRxStatGet
\note belongs to \ref ext_api
\warning
\par Example:
\code Getting wlan RX statistics:
void RxStatCollectTwice()
{
SlGetRxStatResponse_t rxStat;
_i16 rawSocket;
_i8 DataFrame[200];
struct SlTimeval_t timeval;
timeval.tv_sec = 0; // Seconds
timeval.tv_usec = 20000; // Microseconds. 10000 microseconds resolution
sl_WlanRxStatStart(); // set statistics mode
rawSocket = sl_Socket(SL_AF_RF, SL_SOCK_RAW, eChannel);
// set timeout - in case we have no activity for the specified channel
sl_SetSockOpt(rawSocket,SL_SOL_SOCKET,SL_SO_RCVTIMEO, &timeval, sizeof(timeval)); // Enable receive timeout
status = sl_Recv(rawSocket, DataFrame, sizeof(DataFrame), 0);
Sleep(1000); // sleep for 1 sec
sl_WlanRxStatGet(&rxStat,0); // statistics has been cleared upon read
Sleep(1000); // sleep for 1 sec
sl_WlanRxStatGet(&rxStat,0);
}
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_WlanRxStatStart)
_i16 sl_WlanRxStatStart(void);
#endif
/*!
\brief Stop collecting wlan RX statistic, (if previous called sl_WlanRxStatStart)
\return On success, zero is returned. On error, -1 is returned
\sa sl_WlanRxStatStart sl_WlanRxStatGet
\note belongs to \ref ext_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_WlanRxStatStop)
_i16 sl_WlanRxStatStop(void);
#endif
/*!
\brief Get wlan RX statistics. upon calling this command, the statistics counters will be cleared.
\param[in] Flags should be 0 ( not applicable right now, will be added the future )
\param[in] pRxStat a pointer to SlGetRxStatResponse_t filled with Rx statistics results
\return On success, zero is returned. On error, -1 is returned
\sa sl_WlanRxStatStart sl_WlanRxStatStop
\note belongs to \ref ext_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_WlanRxStatGet)
_i16 sl_WlanRxStatGet(SlGetRxStatResponse_t *pRxStat,const _u32 Flags);
#endif
/*!
\brief Stop Smart Config procedure. Once Smart Config will be stopped,
Asynchronous event will be received - SL_OPCODE_WLAN_SMART_CONFIG_STOP_ASYNC_RESPONSE.
\param[in] none
\param[out] none
\return 0 - if Stop Smart Config is about to be executed without errors.
\sa sl_WlanSmartConfigStart
\note belongs to \ref ext_api
\warning
*/
#if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStop)
_i16 sl_WlanSmartConfigStop(void);
#endif
/*!
\brief Start Smart Config procedure
\par
The target of the procedure is to let the \n
device to gain the network parameters: SSID and Password (if network is secured) \n
and to connect to it once located in the network range. \n
An external application should be used on a device connected to any mobile network. \n
The external application will transmit over the air the network parameters in secured manner.\n
The Password may be decrypted using a Key. \n
The decryption method may be decided in the command or embedded in the Flash. \n
The procedure can be activated for 1-3 group ID in the range of BIT_0 - BIT_15 where the default group ID id 0 (BIT_0) \n
Once Smart Config has ended successfully, Asynchronous event will be received - \n
SL_OPCODE_WLAN_SMART_CONFIG_START_ASYNC_RESPONSE. \n
The Event will hold the SSID and an extra field that might have been delivered as well (i.e. - device name)
\param[in] groupIdBitmask - each bit represent a group ID that should be searched.
The Default group ID id BIT_0. 2 more group can be searched
in addition. The range is BIT_0 - BIT_15.
\param[in] chiper - 0: check in flash, 1 - AES, 0xFF - do not check in flash
\param[in] publicKeyLen - public key len (used for the default group ID - BIT_0)
\param[in] group1KeyLen - group ID1 length
\param[in] group2KeyLen - group ID2 length
\param[in] publicKey - public key (used for the default group ID - BIT_0)
\param[in] group1Key - group ID1 key
\param[in] group2Key - group ID2 key
\param[out] none
\return 0 - if Smart Config started successfully.
\sa sl_WlanSmartConfigStop
\note belongs to \ref ext_api
\warning
\par
\code An example of starting smart Config on group ID's 0 + 1 + 2
sl_WlanSmartConfigStart(7, //group ID's (BIT_0 | BIT_1 | BIT_2)
1, //decrypt key by AES method
16, //decryption key length for group ID0
16, //decryption key length for group ID1
16, //decryption key length for group ID2
"Key0Key0Key0Key0", //decryption key for group ID0
"Key1Key1Key1Key1", //decryption key for group ID1
"Key2Key2Key2Key2" //decryption key for group ID2
);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStart)
_i16 sl_WlanSmartConfigStart(const _u32 groupIdBitmask,
const _u8 cipher,
const _u8 publicKeyLen,
const _u8 group1KeyLen,
const _u8 group2KeyLen,
const _u8* publicKey,
const _u8* group1Key,
const _u8* group2Key);
#endif
/*!
\brief Wlan set mode
Setting WLAN mode
\param[in] mode - WLAN mode to start the CC31xx device. Possible options are:
- ROLE_STA - for WLAN station mode
- ROLE_AP - for WLAN AP mode
- ROLE_P2P -for WLAN P2P mode
\return 0 - if mode was set correctly
\sa sl_Start sl_Stop
\note belongs to \ref ext_api
\warning After setting the mode the system must be restarted for activating the new mode
\par Example:
\code
//Switch from any role to STA:
sl_WlanSetMode(ROLE_STA);
sl_Stop(0);
sl_Start(NULL,NULL,NULL);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_WlanSetMode)
_i16 sl_WlanSetMode(const _u8 mode);
#endif
/*!
\brief Internal function for setting WLAN configurations
\return On success, zero is returned. On error one of the following error codes returned:
- CONF_ERROR (-1)
- CONF_NVMEM_ACCESS_FAILED (-2)
- CONF_OLD_FILE_VERSION (-3)
- CONF_ERROR_NO_SUCH_COUNTRY_CODE (-4)
\param[in] ConfigId - configuration id
- <b>SL_WLAN_CFG_AP_ID</b>
- <b>SL_WLAN_CFG_GENERAL_PARAM_ID</b>
- <b>SL_WLAN_CFG_P2P_PARAM_ID</b>
\param[in] ConfigOpt - configurations option
- <b>SL_WLAN_CFG_AP_ID</b>
- <b>WLAN_AP_OPT_SSID</b> \n
Set SSID for AP mode. \n
This options takes <b>_u8</b> buffer as parameter
- <b>WLAN_AP_OPT_CHANNEL</b> \n
Set channel for AP mode. \n
The channel is dependant on the country code which is set. i.e. for "US" the channel should be in the range of [1-11] \n
This option takes <b>_u8</b> as a parameter
- <b>WLAN_AP_OPT_HIDDEN_SSID</b> \n
Set Hidden SSID Mode for AP mode.Hidden options: \n
0: disabled \n
1: Send empty (length=0) SSID in beacon and ignore probe request for broadcast SSID \n
2: Clear SSID (ASCII 0), but keep the original length (this may be required with some \n
clients that do not support empty SSID) and ignore probe requests for broadcast SSID \n
This option takes <b>_u8</b> as a parameter
- <b>WLAN_AP_OPT_SECURITY_TYPE</b> \n
Set Security type for AP mode. Security options are:
- Open security: SL_SEC_TYPE_OPEN
- WEP security: SL_SEC_TYPE_WEP
- WPA security: SL_SEC_TYPE_WPA_WPA2 \n
This option takes <b>_u8</b> pointer as a parameter
- <b>WLAN_AP_OPT_PASSWORD</b> \n
Set Password for for AP mode (for WEP or for WPA): \n
Password - for WPA: 8 - 63 characters \n
for WEP: 5 / 13 characters (ascii) \n
This options takes <b>_u8</b> buffer as parameter
- <b>SL_WLAN_CFG_GENERAL_PARAM_ID</b>
- <b> WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS </b> \n
Set scan parameters.
This option uses slWlanScanParamCommand_t as parameter
- <b>WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE</b> \n
Set Country Code for AP mode \n
This options takes <b>_u8</b> 2 bytes buffer as parameter
- <b>WLAN_GENERAL_PARAM_OPT_STA_TX_POWER</b> \n
Set STA mode Tx power level \n
Number between 0-15, as dB offset from max power (0 will set MAX power) \n
This options takes <b>_u8</b> as parameter
- <b>WLAN_GENERAL_PARAM_OPT_AP_TX_POWER</b>
Set AP mode Tx power level \n
Number between 0-15, as dB offset from max power (0 will set MAX power) \n
This options takes <b>_u8</b> as parameter
- <b>WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT</b>
Set Info Element for AP mode. \n
The Application can set up to MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED info elements per Role (AP / P2P GO). \n
To delete an info element use the relevant index and length = 0. \n
The Application can set up to MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED to the same role. \n
However, for AP - no more than INFO_ELEMENT_MAX_TOTAL_LENGTH_AP bytes can be stored for all info elements. \n
For P2P GO - no more than INFO_ELEMENT_MAX_TOTAL_LENGTH_P2P_GO bytes can be stored for all info elements. \n
This option takes sl_protocol_WlanSetInfoElement_t as parameter
- <b>SL_WLAN_CFG_P2P_PARAM_ID</b>
- <b>WLAN_P2P_OPT_DEV_TYPE</b> \n
Set P2P Device type.Maximum length of 17 characters. Device type is published under P2P I.E, \n
allows to make devices easier to recognize. \n
In case no device type is set, the default type is "1-0050F204-1" \n
This options takes <b>_u8</b> buffer as parameter
- <b>WLAN_P2P_OPT_CHANNEL_N_REGS</b> \n
Set P2P Channels. \n
listen channel (either 1/6/11 for 2.4GHz) \n
listen regulatory class (81 for 2.4GHz) \n
oper channel (either 1/6/11 for 2.4GHz) \n
oper regulatory class (81 for 2.4GHz) \n
listen channel and regulatory class will determine the device listen channel during p2p find listen phase \n
oper channel and regulatory class will determine the operating channel preferred by this device (in case it is group owner this will be the operating channel) \n
channels should be one of the social channels (1/6/11). In case no listen/oper channel selected, a random 1/6/11 will be selected.
This option takes pointer to <b>_u8[4]</b> as parameter
\param[in] ConfigLen - configurations len
\param[in] pValues - configurations values
\sa
\note
\warning
\par Examples:
\par
<b> WLAN_AP_OPT_SSID: </b>
\code
_u8 str[33];
memset(str, 0, 33);
memcpy(str, ssid, len); // ssid string of 32 characters
sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(ssid), str);
\endcode
\par
<b> WLAN_AP_OPT_CHANNEL: </b>
\code
_u8 val = channel;
sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_CHANNEL, 1, (_u8 *)&val);
\endcode
\par
<b> WLAN_AP_OPT_HIDDEN_SSID: </b>
\code
_u8 val = hidden;
sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_HIDDEN_SSID, 1, (_u8 *)&val);
\endcode
\par
<b> WLAN_AP_OPT_SECURITY_TYPE: </b>
\code
_u8 val = SL_SEC_TYPE_WPA_WPA2;
sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (_u8 *)&val);
\endcode
\par
<b> WLAN_AP_OPT_PASSWORD: </b>
\code
_u8 str[65];
_u16 len = strlen(password);
memset(str, 0, 65);
memcpy(str, password, len);
sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, len, (_u8 *)str);
\endcode
\par
<b> WLAN_GENERAL_PARAM_OPT_STA_TX_POWER: </b>
\code
_u8 stapower=(_u8)power;
sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER,1,(_u8 *)&stapower);
\endcode
\par
<b> WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS: </b>
\code
slWlanScanParamCommand_t ScanParamConfig;
ScanParamConfig.G_Channels_mask = 0x01; // bit mask for channels:1 means channel 1 is enabled, 3 means channels 1 + 2 are enabled
ScanParamConfig.rssiThershold = -70; // only for RSSI level which is higher than -70
sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID ,WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS,sizeof(slWlanScanParamCommand_t),(_u8*)&ScanParamConfig);
\endcode
\par
<b> WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE: </b>
\code
_u8* str = (_u8 *) country; // string of 2 characters. i.e. - "US"
sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE, 2, str);
\endcode
\par
<b> WLAN_GENERAL_PARAM_OPT_AP_TX_POWER: </b>
\code
_u8 appower=(_u8)power;
sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_AP_TX_POWER,1,(_u8 *)&appower);
\endcode
\par
<b> WLAN_P2P_OPT_DEV_TYPE: </b>
\code
_u8 str[17];
_u16 len = strlen(device_type);
memset(str, 0, 17);
memcpy(str, device_type, len);
sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_DEV_TYPE, len, str);
\endcode
\par
<b> WLAN_P2P_OPT_CHANNEL_N_REGS: </b>
\code
_u8 str[4];
str[0] = (_u8)11; // listen channel
str[1] = (_u8)81; // listen regulatory class
str[2] = (_u8)6; // oper channel
str[3] = (_u8)81; // oper regulatory class
sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_CHANNEL_N_REGS, 4, str);
\endcode
\par
<b> WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT: </b>
\code
sl_protocol_WlanSetInfoElement_t infoele;
infoele.index = Index; // Index of the info element. range: 0 - MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED
infoele.role = Role; // INFO_ELEMENT_AP_ROLE (0) or INFO_ELEMENT_P2P_GO_ROLE (1)
infoele.ie.id = Id; // Info element ID. if INFO_ELEMENT_DEFAULT_ID (0) is set, ID will be set to 221.
// Organization unique ID. If all 3 bytes are zero - it will be replaced with 08,00,28.
infoele.ie.oui[0] = Oui0; // Organization unique ID first Byte
infoele.ie.oui[1] = Oui1; // Organization unique ID second Byte
infoele.ie.oui[2] = Oui2; // Organization unique ID third Byte
infoele.ie.length = Len; // Length of the info element. must be smaller than 253 bytes
memset(infoele.ie.data, 0, INFO_ELEMENT_MAX_SIZE);
if ( Len <= INFO_ELEMENT_MAX_SIZE )
{
memcpy(infoele.ie.data, IE, Len); // Info element. length of the info element is [0-252]
sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT,sizeof(sl_protocol_WlanSetInfoElement_t),(_u8* ) &infoele);
}
sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT,sizeof(sl_protocol_WlanSetInfoElement_t),(_u8* ) &infoele);
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_WlanSet)
_i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,const _u8 *pValues);
#endif
/*!
\brief Internal function for getting WLAN configurations
\return On success, zero is returned. On error, -1 is
returned
\param[in] ConfigId - configuration id
- <b>SL_WLAN_CFG_AP_ID</b>
- <b>SL_WLAN_CFG_GENERAL_PARAM_ID</b>
- <b>SL_WLAN_CFG_P2P_PARAM_ID</b>
\param[out] pConfigOpt - get configurations option
- <b>SL_WLAN_CFG_AP_ID</b>
- <b>WLAN_AP_OPT_SSID</b> \n
Get SSID for AP mode. \n
Get up to 32 characters of SSID \n
This options takes <b>_u8</b> as parameter
- <b>WLAN_AP_OPT_CHANNEL</b> \n
Get channel for AP mode. \n
This option takes <b>_u8</b> as a parameter
- <b>WLAN_AP_OPT_HIDDEN_SSID</b> \n
Get Hidden SSID Mode for AP mode.Hidden options: \n
0: disabled \n
1: Send empty (length=0) SSID in beacon and ignore probe request for broadcast SSID \n
2: Clear SSID (ASCII 0), but keep the original length (this may be required with some \n
clients that do not support empty SSID) and ignore probe requests for broadcast SSID \n
This option takes <b>_u8</b> as a parameter
- <b>WLAN_AP_OPT_SECURITY_TYPE</b> \n
Get Security type for AP mode. Security options are:
- Open security: SL_SEC_TYPE_OPEN
- WEP security: SL_SEC_TYPE_WEP
- WPA security: SL_SEC_TYPE_WPA_WPA2 \n
This option takes <b>_u8</b> as a parameter
- <b>WLAN_AP_OPT_PASSWORD</b> \n
Get Password for for AP mode (for WEP or for WPA): \n
Returns password - string, fills up to 64 characters. \n
This options takes <b>_u8</b> buffer as parameter
- <b>SL_WLAN_CFG_GENERAL_PARAM_ID</b>
- <b> WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS </b> \n
Get scan parameters.
This option uses slWlanScanParamCommand_t as parameter
- <b>WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE</b> \n
Get Country Code for AP mode \n
This options takes <b>_u8</b> buffer as parameter
- <b>WLAN_GENERAL_PARAM_OPT_STA_TX_POWER</b> \n
Get STA mode Tx power level \n
Number between 0-15, as dB offset from max power (0 indicates MAX power) \n
This options takes <b>_u8</b> as parameter
- <b>WLAN_GENERAL_PARAM_OPT_AP_TX_POWER</b>
Get AP mode Tx power level \n
Number between 0-15, as dB offset from max power (0 indicates MAX power) \n
This options takes <b>_u8</b> as parameter
- <b>SL_WLAN_CFG_P2P_PARAM_ID</b>
- <b>WLAN_P2P_OPT_CHANNEL_N_REGS</b> \n
Get P2P Channels. \n
listen channel (either 1/6/11 for 2.4GHz) \n
listen regulatory class (81 for 2.4GHz) \n
oper channel (either 1/6/11 for 2.4GHz) \n
oper regulatory class (81 for 2.4GHz) \n
listen channel and regulatory class will determine the device listen channel during p2p find listen phase \n
oper channel and regulatory class will determine the operating channel preferred by this device (in case it is group owner this will be the operating channel) \n
channels should be one of the social channels (1/6/11). In case no listen/oper channel selected, a random 1/6/11 will be selected. \n
This option takes pointer to <b>_u8[4]</b> as parameter
\param[out] pConfigLen - The length of the allocated memory as input, when the
function complete, the value of this parameter would be
the len that actually read from the device.
If the device return length that is longer from the input
value, the function will cut the end of the returned structure
and will return SL_ESMALLBUF.
\param[out] pValues - get configurations values
\sa sl_WlanSet
\note
\warning
\par Examples:
\par
<b> WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS: </b>
\code
slWlanScanParamCommand_t ScanParamConfig;
_u16 Option = WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS;
_u16 OptionLen = sizeof(slWlanScanParamCommand_t);
sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID ,&Option,&OptionLen,(_u8 *)&ScanParamConfig);
\endcode
\par
<b> WLAN_GENERAL_PARAM_OPT_AP_TX_POWER: </b>
\code
_i8 TXPower = 0;
_u16 Option = WLAN_GENERAL_PARAM_OPT_AP_TX_POWER;
_u16 OptionLen = sizeof(_i8);
sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID ,&Option,&OptionLen,(_u8 *)&TXPower);
\endcode
\par
<b> WLAN_GENERAL_PARAM_OPT_STA_TX_POWER: </b>
\code
_i8 TXPower = 0;
_u16 Option = WLAN_GENERAL_PARAM_OPT_STA_TX_POWER;
_u16 OptionLen = sizeof(_i8);
sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID ,&Option,&OptionLen,(_u8 *)&TXPower);
\endcode
\par
<b> WLAN_P2P_OPT_DEV_TYPE: </b>
\code
_i8 device_type[18];
_u16 len = 18;
_u16 config_opt = WLAN_P2P_OPT_DEV_TYPE;
sl_WlanGet(SL_WLAN_CFG_P2P_PARAM_ID, &config_opt , &len, (_u8* )device_type);
\endcode
\par
<b> WLAN_AP_OPT_SSID: </b>
\code
_i8 ssid[32];
_u16 len = 32;
_u16 config_opt = WLAN_AP_OPT_SSID;
sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt , &len, (_u8* )ssid);
\endcode
\par
<b> WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE: </b>
\code
_i8 country[3];
_u16 len = 3;
_u16 config_opt = WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE;
sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID, &config_opt, &len, (_u8* )country);
\endcode
\par
<b> WLAN_AP_OPT_CHANNEL: </b>
\code
_i8 channel;
_u16 len = 1;
_u16 config_opt = WLAN_AP_OPT_CHANNEL;
sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8* )&channel);
\endcode
\par
<b> WLAN_AP_OPT_HIDDEN_SSID: </b>
\code
_u8 hidden;
_u16 len = 1;
_u16 config_opt = WLAN_AP_OPT_HIDDEN_SSID;
sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8* )&hidden);
\endcode
\par
<b> WLAN_AP_OPT_SECURITY_TYPE: </b>
\code
_u8 sec_type;
_u16 len = 1;
_u16 config_opt = WLAN_AP_OPT_SECURITY_TYPE;
sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8* )&sec_type);
\endcode
\par
<b> WLAN_AP_OPT_PASSWORD: </b>
\code
_u8 password[64];
_u16 len = 64;
memset(password,0,64);
_u16 config_opt = WLAN_AP_OPT_PASSWORD;
sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8* )password);
\endcode
\par
<b> WLAN_P2P_OPT_CHANNEL_N_REGS: </b>
\code
_u16 listen_channel,listen_reg,oper_channel,oper_reg;
_u16 len = 4;
_u16 config_opt = WLAN_P2P_OPT_CHANNEL_N_REGS;
_u8 channel_n_regs[4];
sl_WlanGet(SL_WLAN_CFG_P2P_PARAM_ID, &config_opt, &len, (_u8* )channel_n_regs);
listen_channel = channel_n_regs[0];
listen_reg = channel_n_regs[1];
oper_channel = channel_n_regs[2];
oper_reg = channel_n_regs[3];
\endcode
*/
#if _SL_INCLUDE_FUNC(sl_WlanGet)
_i16 sl_WlanGet(const _u16 ConfigId, _u16 *pConfigOpt,_u16 *pConfigLen, _u8 *pValues);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __WLAN_H__ */
/*
* wlan_rx_filters.h - CC31xx/CC32xx Host Driver Implementation
*
* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*****************************************************************************/
/* Include files */
/*****************************************************************************/
#include "simplelink.h"
#ifndef RX_FILTERS_PREPROCESSOR_CLI_IF_H_
#define RX_FILTERS_PREPROCESSOR_CLI_IF_H_
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
/* Macro declarations */
/*****************************************************************************/
/*!
* \def SL_RX_FILTER_MAX_FILTERS
* The Max number of filters for 64 filters
*/
#define SL_RX_FILTER_MAX_FILTERS 64
/*!
* \def SL_RX_FILTER_MAX_PRE_PREPARED_FILTERS_SETS
* The Max number of software filters
*/
#define SL_RX_FILTER_MAX_PRE_PREPARED_FILTERS_SETS (32)
/*!
* \def SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
*
*/
#define SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS (2)
/*!
* \def SL_RX_FILTER_NUM_OF_FILTER_PAYLOAD_ARGS
*
*/
#define SL_RX_FILTER_NUM_OF_FILTER_PAYLOAD_ARGS (2)
/*!
* \def SL_RX_FILTER_NUM_OF_FILTER_PAYLOAD_ARGS
*
*/
#define SL_RX_FILTER_NUM_OF_COMBINATION_TYPE_ARGS (2)
/*!
* \def SL_RX_FILTER_LENGTH_OF_REGX_PATTERN_LENGTH
*
*/
#define SL_RX_FILTER_LENGTH_OF_REGX_PATTERN_LENGTH (32)
/* List of possible error numbers */
#define RXFL_OK (0) /* O.K */
#define RXFL_OUTPUT_OR_INPUT_BUFFER_LENGTH_TOO_SMALL (76) /* ! The output buffer length is smaller than required for that operation */
#define RXFL_DEPENDENT_FILTER_SOFTWARE_FILTER_NOT_FIT (75) /* Node filter can't be child of software filter and vice_versa */
#define RXFL_DEPENDENCY_IS_NOT_PERSISTENT (74) /* Dependency filter is not persistent */
#define RXFL_SYSTEM_STATE_NOT_SUPPORTED_FOR_THIS_FILTER (72) /* System state is not supported */
#define RXFL_TRIGGER_USE_REG5_TO_REG8 (71) /* Only counters 5 - 8 are allowed, for Tigger */
#define RXFL_TRIGGER_USE_REG1_TO_REG4 (70) /* Only counters 1 - 4 are allowed, for trigger */
#define RXFL_ACTION_USE_REG5_TO_REG8 (69) /* Only counters 5 - 8 are allowed, for action */
#define RXFL_ACTION_USE_REG1_TO_REG4 (68) /* Only counters 1 - 4 are allowed, for action */
#define RXFL_FIELD_SUPPORT_ONLY_EQUAL_AND_NOTEQUAL (67) /* Rule compare function Id is out of range */
#define RXFL_WRONG_MULTICAST_BROADCAST_ADDRESS (66) /* The address should be of type mutlicast or broadcast */
#define RXFL_THE_FILTER_IS_NOT_OF_HEADER_TYPE (65) /* The filter should be of header type */
#define RXFL_WRONG_COMPARE_FUNC_FOR_BROADCAST_ADDRESS (64) /* The compare funcion is not suitable for broadcast address */
#define RXFL_WRONG_MULTICAST_ADDRESS (63) /* The address should be of muticast type */
#define RXFL_DEPENDENT_FILTER_IS_NOT_PERSISTENT (62) /* The dependency filter is not persistent */
#define RXFL_DEPENDENT_FILTER_IS_NOT_ENABLED (61) /* The dependency filter is not enabled */
#define RXFL_FILTER_HAS_CHILDS (60) /* The filter has childs and can't be removed */
#define RXFL_CHILD_IS_ENABLED (59) /* Can't disable filter while the child is enabled */
#define RXFL_DEPENDENCY_IS_DISABLED (58) /* Can't enable filetr in case its depndency filter is disabled */
#define RXFL_NUMBER_OF_CONNECTION_POINTS_EXCEEDED (52) /* Number of connection points exceeded */
#define RXFL_DEPENDENT_FILTER_DEPENDENCY_ACTION_IS_DROP (51) /* The dependent filter has Drop action, thus the filter can't be created */
#define RXFL_FILTER_DO_NOT_EXISTS (50) /* The filter doesn't exists */
#define RXFL_DEPEDENCY_NOT_ON_THE_SAME_LAYER (49) /* The filter and its dependency must be on the same layer */
#define RXFL_NUMBER_OF_ARGS_EXCEEDED (48) /* Number of arguments excceded */
#define RXFL_ACTION_NO_REG_NUMBER (47) /* Action require counter number */
#define RXFL_DEPENDENT_FILTER_LAYER_DO_NOT_FIT (46) /* the filter and its dependency should be from the same layer */
#define RXFL_DEPENDENT_FILTER_SYSTEM_STATE_DO_NOT_FIT (45) /* The filter and its dependency system state don't fit */
#define RXFL_DEPENDENT_FILTER_DO_NOT_EXIST_2 (44) /* The parent filter don't exist */
#define RXFL_DEPENDENT_FILTER_DO_NOT_EXIST_1 (43) /* The parent filter is null */
#define RXFL_RULE_HEADER_ACTION_TYPE_NOT_SUPPORTED (42) /* The action type is not supported */
#define RXFL_RULE_HEADER_TRIGGER_COMPARE_FUNC_OUT_OF_RANGE (41) /* The Trigger comparision function is out of range */
#define RXFL_RULE_HEADER_TRIGGER_OUT_OF_RANGE (40) /* The Trigger is out of range */
#define RXFL_RULE_HEADER_COMPARE_FUNC_OUT_OF_RANGE (39) /* The rule compare function is out of range */
#define RXFL_FRAME_TYPE_NOT_SUPPORTED (38) /* ASCII frame type string is illegal */
#define RXFL_RULE_FIELD_ID_NOT_SUPPORTED (37) /* Rule field ID is out of range */
#define RXFL_RULE_HEADER_FIELD_ID_ASCII_NOT_SUPPORTED (36) /* This ASCII field ID is not supported */
#define RXFL_RULE_HEADER_NOT_SUPPORTED (35) /* The header rule is not supported on current release */
#define RXFL_RULE_HEADER_OUT_OF_RANGE (34) /* The header rule is out of range */
#define RXFL_RULE_HEADER_COMBINATION_OPERATOR_OUT_OF_RANGE (33) /* Combination function Id is out of ramge */
#define RXFL_RULE_HEADER_FIELD_ID_OUT_OF_RANGE (32) /* rule field Id is out of range */
#define RXFL_UPDATE_NOT_SUPPORTED (31) /* Update not supported */
#define RXFL_NO_FILTERS_ARE_DEFINED (24) /* No filters are defined in the system */
#define RXFL_NUMBER_OF_FILTER_EXCEEDED (23) /* Number of max filters excceded */
/******************************************************************************/
/* Type declarations */
/******************************************************************************/
/*!
* \typedef SlrxFilterID_t
* Unique filter ID which is allocated by the system , negative number means error
*/
typedef _i8 SlrxFilterID_t;
/*!
* \typedef SlrxFilterCompareMask_t
* The mask is used for the rule comparison function
*/
typedef _u8 SlrxFilterCompareMask_t;
/*!
* \typedef SlrxFilterIdMask_t
* Representation of filters Id as a bit field
* The bit field is used to declare which filters are involved
* in operation. Number of filter can be up to 128 filters. i.e. 128 bits are needed.
* On the current release, up to 64 filters can be defined.
*/
typedef _u8 SlrxFilterIdMask_t[128/8];
/*!
* \typedef SlrxFilterPrePreparedFilters_t
* Describes the supported software filter sets,
*/
typedef _u8 SlrxFilterPrePreparedFilters_t;
#define SL_ARP_AUTO_REPLY_PRE_PREPARED_FILTERS (0)
#define SL_MULTICASTSIPV4_DROP_PREPREPARED_FILTERS (1)
#define SL_MULTICASTSIPV6_DROP_PREPREPARED_FILTERS (2)
#define SL_MULTICASTSWIFI_DROP_PREPREPARED_FILTERS (3)
/*!
* \typedef SlrxFilterPrePreparedFiltersMask_t
* Describes the supported software filter sets,
* each bit represents different software filter set
* The filter sets are defined at SlrxFilterPrePreparedFilters_t
*/
typedef _u8 SlrxFilterPrePreparedFiltersMask_t[SL_RX_FILTER_MAX_PRE_PREPARED_FILTERS_SETS/8];
/*! \typedef SlrxFilterRegxPattern_t
* The struct contains the regular expression pattern which is used in case of payload rule.
* Not supported in the current release
*/
typedef struct SlrxFilterRegxPattern_t
{
_u8 x[SL_RX_FILTER_LENGTH_OF_REGX_PATTERN_LENGTH];
}SlrxFilterRegxPattern_t;
/*! \typedef SlrxFilterAsciiArg_t
* The buffer is used to provide container for ASCII argument, which may be used in case of HEADER rule.
* example for ASCII argument can be : IP = 256.0.67.1
*/
typedef _u8 SlrxFilterAsciiArg_t;
/*! \typedef SlrxFilterBinaryArg_t
* The buffer provides container for binary argument, which may be used in case of HEADER rule
*/
typedef _u8 SlrxFilterBinaryArg_t ;
/*! \typedef SlrxFilterActionArg_t
* Provides container for the filter action argument.
* for example: in case action is to send automatic response , the argument is the template to be used for the automatic response.
*
*
*/
typedef _u8 SlrxFilterActionArg_t ;
/*! \typedef SlrxFilterOffset_t
* The offset relative to the packet payload start location.
* Not supported on current release
*/
typedef _u32 SlrxFilterOffset_t;
/*! \typedef SlrxFilterRuleType_t
* Enumerates the different filter types.
* On the current release only HEADER and COMBINATION are supported.
*/
typedef _u8 SlrxFilterRuleType_t;
/* possible values for SlrxFilterRuleType_t */
#define HEADER (0)
#define COMBINATION (1)
#define EXACT_PATTERN (2)
#define LIKELIHOOD_PATTERN (3)
#define ALWAYS_TRUE (4)
#define NUM_OF_FILTER_TYPES (5)
/*! \typedef SlrxFilterFlags_t
* Bit field which sets the behaviour of the RX filter
*
*/
#define RX_FILTER_BINARY (0x1)
#define RX_FILTER_PERSISTENT (0x8)
#define RX_FILTER_ENABLE (0x10)
typedef union SlrxFilterFlags_t
{
/* struct
{ */
/*!
* The filter argument can be set as binary argument or ASCII arguments.
* When the bit is on the argument are binary.
*/
/* _u8 Binary: 1; */
/*!
*
*/
/* _u8 AutoSort : 1; */
/*!
*
*/
/* _u8 AutoFaultDetect : 1; */
/*!
* When the bit is on it means the the node is enabled .
*/
/* _u8 Enabled : 1; */
/* _u8 padding : 3; */
/*
};*/
_u8 IntRepresentation;
}SlrxFilterFlags_t;
/*! \typedef SlrxFilterCompareFunction_t
* Used as comparison function for the header type arguments
*
*/
typedef _u8 SlrxFilterCompareFunction_t;
/* Possible values for SlrxFilterCompareFunction_t */
#define COMPARE_FUNC_IN_BETWEEN (0)
#define COMPARE_FUNC_EQUAL (1)
#define COMPARE_FUNC_NOT_EQUAL_TO (2)
#define COMPARE_FUNC_NOT_IN_BETWEEN (3)
#define COMPARE_FUNC_NUM_OF_FILTER_COMPARE_FUNC (4)
/*! \typedef SlrxFilterCompareFunction_t
* Used as comparison function for the header type arguments
*
*/
typedef _u8 SlrxTriggerCompareFunction_t;
/* Possible values for SlrxTriggerCompareFunction_t */
#define TRIGGER_COMPARE_FUNC_EQUAL (0)
/* arg1 == protocolVal ,not supported in current release */
#define TRIGGER_COMPARE_FUNC_NOT_EQUAL_TO (1)
/* arg1 == protocolVal */
#define TRIGGER_COMPARE_FUNC_SMALLER_THAN (2)
/* arg1 == protocolVal */
#define TRIGGER_COMPARE_FUNC_BIGGER_THAN (3)
/* definition */
#define TRIGGER_COMPARE_FUNC_NUM_OF_FILTER_COMPARE_FUNC (4)
/*! \typedef SlrxFilterHdrField_t
* Provides list of possible header types which may be defined as part of the rule
*
*/
typedef _u8 SlrxFilterHdrField_t;
/* Possible values for SlrxFilterHdrField_t */
#define NULL_FIELD_ID_TYPE (0)
/* 802.11 control\data\management */
#define FRAME_TYPE_FIELD (1)
/* 802.11 beacon\probe\.. */
#define FRAME_SUBTYPE_FIELD (2)
/* 802.11 bssid type */
#define BSSID_FIELD (3)
/* */
#define MAC_SRC_ADDRESS_FIELD (4)
/* */
#define MAC_DST_ADDRESS_FIELD (5)
/* */
#define FRAME_LENGTH_FIELD (6)
/* */
#define PROTOCOL_TYPE_FIELD (7)
/* */
#define IP_VERSION_FIELD (8)
/* TCP / UDP */
#define IP_PROTOCOL_FIELD (9)
/* */
#define IPV4_SRC_ADRRESS_FIELD (10)
/* */
#define IPV4_DST_ADDRESS_FIELD (11)
/* */
#define IPV6_SRC_ADRRESS_FIELD (12)
/* */
#define IPV6_DST_ADDRESS_FIELD (13)
/* */
#define SRC_PORT_FIELD (14)
/* */
#define DST_PORT_FIELD (15)
/* Definition */
#define NUM_OF_FIELD_NAME_FIELD (16)
/*! \union SlrxFilterHeaderArg_t
* The structure holds the header ARGS which are used in case of HDR rule.
*/
/* -- 36 bytes */
typedef union SlrxFilterHeaderArg_t
{
/*----------------------------- Large size ---------------------------------*/
/*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* example : IPV6 16 bytes, 39 characters
* ipv6 Ascii address: 2001:0db8:3c4d:0015:0000:0000:abcd:ef12
*/
SlrxFilterBinaryArg_t RxFilterDB16BytesRuleArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][16 ]; /* Binary Values for comparition */
/*! buffer for ASCII arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* example : IPV6 16 bytes, 39 characters
* ipv6 Ascii address: 2001:0db8:3c4d:0015:0000:0000:abcd:ef12
* Ascii format for ipV6 is not supported
*/
/*----------------------------- Medium size ---------------------------------*/
/*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* MAC address: 6 bytes, 17 chars
*/
SlrxFilterBinaryArg_t RxFilterDB6BytesRuleArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][6]; /* Binary Values for comparition */
/*!
* ! buffer for ASCII arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* IP address: 4 bytes, 15 chars
* 2 bytes are added for padding
*/
SlrxFilterAsciiArg_t RxFilterDB18BytesAsciiRuleArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][18]; /* Ascii Values for comparison */
/*----------------------------- Small size ---------------------------------*/
/*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* IP address: 4 bytes, 15 chars
* Port: 2 bytes, chars: 5 chars
*/
SlrxFilterBinaryArg_t RxFilterDB4BytesRuleArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][4]; /* Binary Values for comparison */
/*! buffer for ASCII arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
* Port: 2 bytes, chars: 5 chars
*/
SlrxFilterAsciiArg_t RxFilterDB5BytesRuleAsciiArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][5]; /* Ascii Values for comparison */
/*----------------------------- 1 byte size ---------------------------------*/
/*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS
*/
SlrxFilterBinaryArg_t RxFilterDB1BytesRuleArgs[SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][1]; /* Binary Values for comparison */
}SlrxFilterHeaderArg_t;
/*! \typedef SlrxFilterRuleHeaderArgsAndMask_t
* Structure which defines the Header Args and mask
*/
/* -- 52 bytes */
typedef struct SlrxFilterRuleHeaderArgsAndMask_t
{
/*! Argument for the comparison function */
/* -- 36 byte */
SlrxFilterHeaderArg_t RuleHeaderArgs;
/*! the mask is used in order to enable partial comparison,
* Use the 0xFFFFFFFF in case you don't want to use mask
*/
/* -- 16 bytes */
SlrxFilterCompareMask_t RuleHeaderArgsMask[16];
}SlrxFilterRuleHeaderArgsAndMask_t;
/*! \typedef SlrxFilterHeaderType_t
* Structure which defines the Header rule
* The header rule defines compare function on the protocol header
* For example destMacAddre is between ( 12:6::78:77, 12:6::78:90 )
*
*/
/* -- 56 byte */
typedef struct SlrxFilterHeaderType_t
{
/*! see :: SlrxFilterRuleHeaderArgsAndMask_t */
/* -- 52 bytes */
SlrxFilterRuleHeaderArgsAndMask_t RuleHeaderArgsAndMask;
/*! Packet HDR field which will be compared to the argument */
/* -- 1 byte */
SlrxFilterHdrField_t RuleHeaderfield;
/* -- 1 byte */
/*! type of the comparison function
* see :: SlrxFilterCompareFunction_t
*/
SlrxFilterCompareFunction_t RuleCompareFunc;
/*! padding */
/* -- 2 bytes */
_u8 RulePadding[2];
}SlrxFilterHeaderType_t;
/*! \typedef SlrxFilterPayloadType_t
* Structure which defines payload rule.
* Not supported on current release.
*/
/* -- 40 byte */
typedef struct SlrxFilterPayloadType_t
{
/*! Not supported on current release */
/* -- 32 byte */
SlrxFilterRegxPattern_t RegxPattern;
/*! Not supported on current release */
/* -- 4 byte */
SlrxFilterOffset_t LowerOffset;
/*! Not supported on current release */
/* -- 4 byte */
SlrxFilterOffset_t UpperOffset;
}SlrxFilterPayloadType_t;
/*! \typedef SlrxFilterCombinationTypeOperator_t
* Enumerate the optional operators for the combination type
* filterID1 is located in the first arg , filterId2 is the second arg,see ::SlrxFilterCombinationType_t.CombinationFilterId
*/
typedef _u8 SlrxFilterCombinationTypeOperator_t;
/* Possible values for SlrxFilterCombinationTypeOperator_t */
/*! !filterID1 */
#define COMBINED_FUNC_NOT (0)
/*! filterID1 && filterID2 */
#define COMBINED_FUNC_AND (1)
/*! filterID1 && filterID2 */
#define COMBINED_FUNC_OR (2)
/*! \typedef SlrxFilterCombinationType_t
* Defines the structure which define the combination type filter
* The combined filter enable to make operation on one or two filter,
* for example !filterId1 or and(filterId2,filterId3).
*
*/
/* -- 4 byte */
typedef struct SlrxFilterCombinationType_t
{
/* ! combination operator */
/* -- 1 byte */
SlrxFilterCombinationTypeOperator_t CombinationTypeOperator;
/* ! filterID, may be one or two depends on the combination operator type */
/* -- 2 byte */
SlrxFilterID_t CombinationFilterId[SL_RX_FILTER_NUM_OF_COMBINATION_TYPE_ARGS];
/* ! Padding */
/* -- 1 byte */
_u8 Padding;
}SlrxFilterCombinationType_t;
/*! \typedef SlrxFilterRule_t
* Rule structure composed of behavioral flags and the filter rule definitions
*
*/
/* -- 56 byte */
typedef union SlrxFilterRule_t
{
/* ! Header type rule , see explanation on the ::SlrxFilterHeaderType_t structure */
/* -- 56 byte */
SlrxFilterHeaderType_t HeaderType;
/* ! Payload rule, not supported in current release */
/* -- 40 byte */
SlrxFilterPayloadType_t PayLoadHeaderType; /* future for exact pattern or like hood pattern */
/* ! Combined type rule , see explanation in ::SlrxFilterCombinationType_t structure */
/* -- 4 byte */
SlrxFilterCombinationType_t CombinationType;
}SlrxFilterRule_t;
/*! \typedef SlrxFilterTriggerRoles_t
* Bit field which represents the roleId possible values
* In the current release only Station/AP roles are supported.
*/
#define RX_FILTER_ROLE_AP (1)
#define RX_FILTER_ROLE_STA (2)
#define RX_FILTER_ROLE_PROMISCUOUS (4)
#define RX_FILTER_ROLE_NULL (0)
typedef union SlrxFilterTriggerRoles_t
{
/* struct */
/* { */
/* _u8 RoleAP :1; */
/* _u8 RoleStation :1; */
/* The filter is activated only in Promiscuous mode */
/* _u8 PromiscuousMode :1; */
/* _u8 RoleReserved :5; */
/* }; */
/* ! Bit fiels of the Filter role */
_u8 IntRepresentation;
}SlrxFilterTriggerRoles_t;
/*! \typedef SlrxFilterTriggerConnectionStates_t
* Bit field representing the possible values of the When section of the rule
*
*/
#define RX_FILTER_CONNECTION_STATE_STA_CONNECTED (1)
#define RX_FILTER_CONNECTION_STATE_STA_NOT_CONNECTED (2)
#define RX_FILTER_CONNECTION_STATE_STA_HAS_IP (4)
#define RX_FILTER_CONNECTION_STATE_STA_HAS_NO_IP (8)
typedef union SlrxFilterTriggerConnectionStates_t
{
/* struct */
/* { */
/* _u8 RoleStationWiFiConnected :1; */
/* _u8 RoleStationWiFiDisconneted:1; */
/* _u8 RoleStationWiFiHasIp:1; */
/* _u8 RoleStationWiFiHasNoIp:1; */
/* _u8 RoleStationWiFiSocketOpened:1; */
/* _u8 RoleStationWiFiSocketclosed:1; */
/* }; */
/* */
/* ! */
_u8 IntRepresentation;
}SlrxFilterTriggerConnectionStates_t;
/*! \typedef SlrxFilterDBTriggerArg_t
* Provides container for entering the filter 'when' argument.
* The current release support 'When rules' which has no arguments.
* For example :
* When connect to specific AP -- the AP bssid is the argument.
*
*/
typedef _u32 SlrxFilterDBTriggerArg_t;
/*! \typedef SlrxFilterCounterId_t
* the counter ID we have 4 counters
*/
typedef _u8 SlrxFilterCounterId_t;
/* Possible values for SlrxFilterCounterId_t */
#define NO_TRIGGER (0)
#define RX_FILTER_COUNTER1 (1)
#define RX_FILTER_COUNTER2 (2)
#define RX_FILTER_COUNTER3 (3)
#define RX_FILTER_COUNTER4 (4)
#define RX_FILTER_COUNTER5 (5)
#define RX_FILTER_COUNTER6 (6)
#define RX_FILTER_COUNTER7 (7)
#define RX_FILTER_COUNTER8 (8)
#define MAX_RX_FILTER_COUNTER (9)
/*! \typedef SlrxFilterActionArgs_t
* Possible value for filter action args
*
*/
typedef _u8 SlrxFilterActionArgs_t;
/* Possible values for SlrxFilterActionArgs_t */
#define ACTION_ARG_REG_1_4 (0)
/* ! Can be use as counter */
#define ACTION_ARG_TEMPLATE (1)
/* ! Can be use as counter */
#define ACTION_ARG_EVENT (2)
/* ! GPIO number */
#define ACTION_ARG_GPIO (4)
/*!
* \def SL_RX_FILTER_NUM_OF_BYTES_FOR_ACTIONS_ARGS
*
*/
#define SL_RX_FILTER_NUM_OF_BYTES_FOR_ACTIONS_ARGS (5)
/*! \typedef SlrxFilterTrigger_t
* The filter trigger, determine when the filter is triggered,
* The filter is triggered in the following condition :\n
* 1. The filter parent is triggered\n
* 2. The requested connection type exists, i.e. wlan_connect\n
* 3. The filter role is the same as the system role\n
*
*/
/* -- 12 byte */
typedef struct SlrxFilterTrigger_t
{
/*! The parent filter ID, this is the way to build filter tree. */
/* NULL value means tree root.
*/
/* -- 1 byte */
SlrxFilterID_t ParentFilterID;
/* ! See ::SlrxFilterCounterId_t explanation */
/* -- 1 byte */
SlrxFilterCounterId_t Trigger;
/* ! See :: SlrxFilterTriggerConnectionStates_t */
/* -- 1 byte */
SlrxFilterTriggerConnectionStates_t TriggerArgConnectionState;
/* ! See ::SlrxFilterTriggerRoles_t */
/* -- 1 byte */
SlrxFilterTriggerRoles_t TriggerArgRoleStatus;
/* ! The Trigger arguments are in the same order as the Trigger bit field order. */
/* -- 4 byte */
SlrxFilterDBTriggerArg_t TriggerArg;
/** The compare function which will be operate for each bit that is turned on in the ::SlrxFilterTrigger_t.Trigger field,
* for example , in case the second bit in the Trigger function is on the second function in the list will be executed.
*
*/
/* -- 1 byte */
SlrxTriggerCompareFunction_t TriggerCompareFunction;
/* ! padding */
/* -- 3 byte */
_u8 Padding[3];
} SlrxFilterTrigger_t;
/*! \typedef SlrxFilterActionType_t
* The actions are executed only if the filter is matched,\n
* In case of false match the packet is transfered to the HOST. \n
* The action is composed of bit field structure,
* up to 2 actions can be defined per filter.
*
*/
#define RX_FILTER_ACTION_NULL (0x0)
#define RX_FILTER_ACTION_DROP (0x1)
#define RX_FILTER_ACTION_GPIO (0x2)
#define RX_FILTER_ACTION_ON_REG_INCREASE (0x4)
#define RX_FILTER_ACTION_ON_REG_DECREASE (0x8)
#define RX_FILTER_ACTION_ON_REG_RESET (0x10)
#define RX_FILTER_ACTION_SEND_TEMPLATE (0x20) /* unsupported */
#define RX_FILTER_ACTION_EVENT_TO_HOST (0x40) /* unsupported */
typedef union SlrxFilterActionType_t
{
/* struct */
/* { */
/* ! No action to execute the packet is dropped,drop is always on leaf. */
/* ! If not dropped ,The packet is passed to the next filter or in case it is the last filter to the host */
/* _u8 ActionDrop : 1; */
/* ! Not Supported in the current release */
/* _u8 ActionGpio : 1; */
/*! action can increase counter registers.
* 1 = Increase
* 2 = decrease
* 3 = reset
*/
/* _u8 ActionOnREGIncrease : 1; */
/* _u8 ActionOnREGDecrease : 1; */
/* _u8 ActionOnREGReset : 1; */
/* ! Not Supported in the current release */
/* _u8 ActionSendTemplate : 1; */
/* ! Not Supported in the current release */
/* _u8 ActionEventToHost: 1; */
/* _u8 padding: 1; */
/* }; */
_u8 IntRepresentation;
}SlrxFilterActionType_t;
/*! \typedef SlrxFilterAction_t
* Several actions can be defined,\n
* The action is executed in case the filter rule is matched.
*/
/* -- 8 byte */
typedef struct SlrxFilterAction_t
{
/* -- 1 byte */
/* ! Determine which actions are supported */
SlrxFilterActionType_t ActionType;
/* ! Buffer for the action arguments */
/**
* <b>location 0</b> - The counter to increase
* In case the action is of type "increase" the arg will contain the counter number,
* The counter number values are as in ::SlrxFilterCounterId_t.\n
* <b>location 1</b> - The template arg.\n
* <b>location 2</b> - The event arg.\n
*
*/
/* -- 5 byte */
SlrxFilterActionArg_t ActionArg[SL_RX_FILTER_NUM_OF_BYTES_FOR_ACTIONS_ARGS];
/* ! Padding */
/* - 2 Bytes */
_u8 Padding[2];
} SlrxFilterAction_t;
/*! \struct _WlanRxFilterOperationCommandBuff_t
* The structure is used for the interface HOST NWP.\n
* The supported operation : \n
* ::ENABLE_DISABLE_RX_FILTER,\n
* ::REMOVE_RX_FILTER,\n
*
*/
/* 20 bytes */
typedef struct _WlanRxFilterOperationCommandBuff_t
{
/* -- 16 bytes */
SlrxFilterIdMask_t FilterIdMask;
/* 4 bytes */
_u8 Padding[4];
}_WlanRxFilterOperationCommandBuff_t;
/* -- 56 bytes */
typedef struct _WlanRxFilterUpdateArgsCommandBuff_t
{
/* -- 1 bytes */
_u8 FilterId;
/* -- 1 bytes */
/* ! the args representation */
_u8 BinaryRepresentation;
/* -- 52 byte */
SlrxFilterRuleHeaderArgsAndMask_t FilterRuleHeaderArgsAndMask;
/* -- 2 bytes */
_u8 Padding[2];
}_WlanRxFilterUpdateArgsCommandBuff_t;
/*! \typedef _WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t
* The structure is used for the interface HOST NWP.\n
*
*/
/* -- 16 bytes */
typedef struct _WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t
{
/* ! the filter set bit map */
/* -- 16 bytes */
SlrxFilterIdMask_t FilterIdMask;
}_WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t;
/*! \struct _WlanRxFilterPrePreparedFiltersCommandBuff_t
* The function enables to perform operations on pre-prepared filters
*
*/
typedef struct _WlanRxFilterPrePreparedFiltersCommandBuff_t
{
/* ! the filter set bit map */
/* -- 4 bytes */
SlrxFilterPrePreparedFiltersMask_t FilterPrePreparedFiltersMask;
}_WlanRxFilterPrePreparedFiltersCommandBuff_t;
/*! \typedef sl_protocol_WlanRxFilterPrePreparedFiltersCommandResponseBuff_t
*
*/
/*-- 4 bytes */
typedef struct _WlanRxFilterPrePreparedFiltersCommandResponseBuff_t
{
/* -- 4 bytes */
/* ! the filter set bit map */
SlrxFilterPrePreparedFiltersMask_t FilterPrePreparedFiltersMask;
}_WlanRxFilterPrePreparedFiltersCommandResponseBuff_t;
typedef _u8 SLrxFilterOperation_t;
#define SL_ENABLE_DISABLE_RX_FILTER (0)
#define SL_REMOVE_RX_FILTER (1)
#define SL_STORE_RX_FILTERS (2)
#define SL_UPDATE_RX_FILTER_ARGS (3)
#define SL_FILTER_RETRIEVE_ENABLE_STATE (4)
#define SL_FILTER_PRE_PREPARED_RETRIEVE_CREATE_REMOVE_STATE (5)
#define SL_FILTER_PRE_PREPARED_SET_CREATE_REMOVE_STATE (6)
/* Bit manipulation for 8 bit */
#define ISBITSET8(x,i) ((x[i>>3] & (0x80>>(i&7)))!=0) /* < Is bit set, 8 bit unsigned numbers = x , location = i */
#define SETBIT8(x,i) x[i>>3]|=(0x80>>(i&7)); /* < Set bit,8 bit unsigned numbers = x , location = i */
#define CLEARBIT8(x,i) x[i>>3]&=(0x80>>(i&7))^0xFF; /* < Clear bit,8 bit unsigned numbers = x , location = i */
/*********************************************************************************************/
/* Function prototypes */
/*********************************************************************************************/
/*!
\addtogroup wlan
@{
*/
/*!
\brief Adds new filter rule to the system
\param[in] RuleType The rule type
\param[in] FilterFlags Flags which set the type of header rule Args and sets the persistent flag
\param[in] pRule Determine the filter rule logic
\param[in] pTrigger Determine when the rule is triggered also sets rule parent.
\param[in] pAction Sets the action to be executed in case the match functions pass
\param[out] pFilterId The filterId which was created
\return On success, zero is returned. Otherwise error code is returned
*/
#if _SL_INCLUDE_FUNC(sl_WlanRxFilterAdd)
SlrxFilterID_t sl_WlanRxFilterAdd( SlrxFilterRuleType_t RuleType,
SlrxFilterFlags_t FilterFlags,
const SlrxFilterRule_t* const Rule,
const SlrxFilterTrigger_t* const Trigger,
const SlrxFilterAction_t* const Action,
SlrxFilterID_t* pFilterId);
#endif
/*!
\brief Sets parameters to Rx filters
\param[in] RxFilterOperation
possible operations :
- SL_ENABLE_DISABLE_RX_FILTER - Enables\disables filter in a filter list
- SL_REMOVE_RX_FILTER - Removes filter from memory ( to remove from flash call SL_STORE_RX_FILTERS after this command)
- SL_STORE_RX_FILTERS - Save the filters for persistent
- SL_UPDATE_RX_FILTER_ARGS - Update the arguments of existing filter
- SL_FILTER_PRE_PREPARED_SET_CREATE_REMOVE_STATE - Change the default creation of the pre-prepared filters
\param[in] pInputBuffer options:
The buffer input is _WlanRxFilterOperationCommandBuff_t:
- SL_ENABLE_DISABLE_RX_FILTER
- SL_REMOVE_RX_FILTER
- SL_STORE_RX_FILTERS
The buffer input is _WlanRxFilterUpdateArgsCommandBuff_t:
- SL_UPDATE_RX_FILTER_ARGS
The buffer input is _WlanRxFilterPrePreparedFiltersCommandBuff_t:
- SL_FILTER_PRE_PREPARED_SET_CREATE_REMOVE_STATE
\param[in] InputbufferLength The length in byte of the input buffer
\return On success, zero is returned. Otherwise error code is returned
*/
#if _SL_INCLUDE_FUNC(sl_WlanRxFilterSet)
_i16 sl_WlanRxFilterSet( const SLrxFilterOperation_t RxFilterOperation,
const _u8* const pInputBuffer,
_u16 InputbufferLength);
#endif
/*!
\brief Gets parameters of Rx filters
\param[in] RxFilterOperation
possible operations :
- SL_FILTER_RETRIEVE_ENABLE_STATE - Retrieves the enable disable status
- SL_FILTER_PRE_PREPARED_RETRIEVE_CREATE_REMOVE_STATE - Retrieves the pre-prepared filters creation status
\param[in] pOutputBuffer
The buffer input is _WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t:
- SL_FILTER_RETRIEVE_ENABLE_STATE
The buffer input is _WlanRxFilterPrePreparedFiltersCommandResponseBuff_t:
- SL_FILTER_PRE_PREPARED_RETRIEVE_CREATE_REMOVE_STATE
\param[in] OutputbufferLength The length in byte of the output buffer
\return On success, zero is returned. Otherwise error code is returned
*/
#if _SL_INCLUDE_FUNC(sl_WlanRxFilterGet)
_i16 sl_WlanRxFilterGet(const SLrxFilterOperation_t RxFilterOperation,
_u8* pOutputBuffer,
_u16 OutputbufferLength);
#endif
/*!
Close the Doxygen group.
@}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* RX_FILTERS_PREPROCESSOR_CLI_IF_H_ */