22 #if !defined(BOARD_ATTINY) 26 #define TRACE_ON_EVENT 27 #if defined(TRACE_ON_EVENT) 33 #define FD_ISSET(fd,set) (((1UL << (fd)) & set) != 0UL) 34 #define FD_SET(fd,set) set = (1UL << (fd)) | set 40 uint8_t* dp = (uint8_t*) dest;
41 const uint8_t* sp = ((uint8_t*) src) + n ;
42 do *dp++ = *--sp;
while (--n);
49 #if defined(TRACE_ON_EVENT) 55 #if defined(TRACE_ON_EVENT) 56 trace <<
PSTR(
"HCI_EVNT_WLAN_UNSOL_KEEPALIVE:");
62 #if defined(TRACE_ON_EVENT) 63 trace <<
PSTR(
"HCI_EVNT_WLAN_UNSOL_CONNECT:");
69 #if defined(TRACE_ON_EVENT) 70 trace <<
PSTR(
"HCI_EVNT_WLAN_UNSOL_DISCONNECT:");
78 if (evnt->
status != 0)
return;
80 #if defined(TRACE_ON_EVENT) 81 trace <<
PSTR(
"HCI_EVNT_WLAN_UNSOL_TCP_CLOSE_WAIT:handle=")
90 if (evnt->
status != 0)
return;
92 #if defined(TRACE_ON_EVENT) 93 trace <<
PSTR(
"HCI_EVNT_DATA_UNSOL_FREE_BUFF:buffers_freed=")
102 if (evnt->
status != 0)
return;
107 #if defined(TRACE_ON_EVENT) 108 trace <<
PSTR(
"HCI_EVNT_WLAN_UNSOL_DHCP:");
113 #if defined(TRACE_ON_EVENT) 121 #if defined(TRACE_ON_EVENT) 129 uint32_t readhndls =
FD_ZERO();
130 uint32_t writehndls =
FD_ZERO();
131 uint32_t errorhndls =
FD_ZERO();
132 FD_SET(m_hndl, readhndls);
133 int res =
m_dev->
select(m_hndl + 1, readhndls, writehndls, errorhndls, 0, 50000);
134 if (res < 0)
return (res);
135 return (
FD_ISSET(m_hndl,readhndls));
150 if (res == 0)
return (0);
250 if (progmem)
return (
ENOSYS);
256 uint8_t dest[4], uint16_t port,
287 if (res < 0)
return (
false);
292 if (res < 0)
return (
false);
296 if (res < 0)
return (
false);
308 if (res < 0)
return (
false);
341 int res =
socket(domain, type, protocol);
342 if (res < 0)
return (
NULL);
346 driver->
m_dev =
this;
380 uint8_t len =
sizeof(cmnd) -
sizeof(cmnd.
data);
385 if (
UNLIKELY(res < 0))
return (res);
392 if (
UNLIKELY(res < 0))
return (res);
433 if (
UNLIKELY(res < 0))
return (res);
441 if (
UNLIKELY(res < 0))
return (res);
449 if (
UNLIKELY(res < 0))
return (res);
454 if (
UNLIKELY(res < 0))
return (res);
460 bool should_use_fast_connect,
461 bool auto_start_use_profiles)
464 cmnd(should_connect_to_open_ap, should_use_fast_connect, auto_start_use_profiles);
466 if (
UNLIKELY(res < 0))
return (res);
474 if (
UNLIKELY(res < 0))
return (res);
483 if (
UNLIKELY(res < 0))
return (res);
487 if (
UNLIKELY(res < 0))
return (res);
496 if (
UNLIKELY(res < 0))
return (res);
504 if (
UNLIKELY(res < 0))
return (res);
513 if (
UNLIKELY(res < 0))
return (res);
518 if (
UNLIKELY(res < 0))
return (res);
527 if (
UNLIKELY(res < 0))
return (res);
531 if (
UNLIKELY(res < 0))
return (res);
535 if (
UNLIKELY(res < 0))
return (res);
536 if ((args.
fileid != fileid)
537 || (args.
length != length)
574 if (
UNLIKELY(res < 0))
return (res);
582 if (
UNLIKELY(res < 0))
return (res);
587 if (
UNLIKELY(res < 0))
return (res);
597 if (
UNLIKELY(res < 0))
return (res);
602 if (
UNLIKELY(res < 0))
return (res);
614 if (
UNLIKELY(res < 0))
return (res);
619 if (
UNLIKELY(res < 0))
return (res);
628 if (
UNLIKELY(res < 0))
return (res);
633 if (
UNLIKELY(res < 0))
return (res);
640 uint32_t &readhndls, uint32_t &writehndls, uint32_t &errorhndls,
641 uint32_t sec, uint32_t us)
645 if (
UNLIKELY(res < 0))
return (res);
650 if (
UNLIKELY(res < 0))
return (res);
662 if (
UNLIKELY(res < 0))
return (res);
667 if (
UNLIKELY(res < 0))
return (res);
680 for (uint8_t retry = 0; retry < 3; retry++) {
685 if (
UNLIKELY(res < 0))
return (res);
690 uint32_t TIMEOUT = 3000;
707 if (
UNLIKELY(res < 0))
return (res);
713 if (
UNLIKELY(res < 0))
return (res);
723 if (
UNLIKELY(res < 0))
return (res);
728 if (
UNLIKELY(res < 0))
return (res);
737 if (
UNLIKELY(res < 0))
return (res);
742 if (
UNLIKELY(res < 0))
return (res);
753 if (
UNLIKELY(res < 0))
return (res);
759 if (
UNLIKELY(res < 0))
return (res);
777 if (
UNLIKELY(res < 0))
return (res);
786 if (
UNLIKELY(res < 0))
return (res);
int wlan_ioctl_set_connection_policy(bool should_connect_to_open_ap, bool should_use_fast_connect, bool auto_start_use_profiles)
static const hci_cmnd_wlan_ioctl_set_scanparam_t DEFAULT_SCANPARAM
static const uint16_t HCI_EVNT_WLAN_IOCTL_SET_CONNECTION_POLICY
static const size_t HCI_CMND_WLAN_CONNECT_KEY_MAX
uint8_t transfer(uint8_t data)
static const uint16_t HCI_EVNT_WLAN_UNSOL_DHCP
static const uint16_t HCI_CMND_ACCEPT
static const uint16_t HCI_EVNT_SOCKET
static const uint8_t HCI_DATA_NVMEM_READ
static const uint16_t HCI_EVNT_ACCEPT
static const uint16_t HCI_CMND_BIND
virtual int write(const void *buf, size_t size)
void addr(uint8_t ip[4], uint8_t subnet[4])
static const uint16_t HCI_CMND_WLAN_CONNECT
static const uint16_t HCI_EVNT_CLOSE_SOCKET
void print(int value, Base base=dec)
int nvmem_read(uint8_t fileid, void *dst, uint32_t src, size_t n)
int service(uint16_t timeout=100)
static const uint16_t HCI_CMND_CLOSE_SOCKET
virtual int datagram(uint8_t addr[4], uint16_t port)
void acquire(Driver *dev)
static const uint16_t HCI_CMND_WLAN_IOCTL_STATUSGET
int await(uint16_t op, void *args=NULL, uint8_t len=0)
struct CC3000::hci_evnt_data_unsol_free_buff_t::@82 flow_control_event
int wlan_ioctl_set_scanparam(const hci_cmnd_wlan_ioctl_set_scanparam_t *param=NULL)
static const uint16_t HCI_EVNT_SELECT
int bind(int hndl, int port)
static const uint32_t HCI_CMND_WLAN_IOCTL_SET_SCANPARAM_MAGIC
int write_data(uint8_t op, const void *args, uint8_t args_len, const void *data, uint16_t data_len)
virtual int is_connected()
static const size_t HCI_CMND_WLAN_CONNECT_SSID_MAX
static const uint16_t HCI_CMND_READ_SP_VERSION
int wlan_ioctl_get_scan_results(hci_evnt_wlan_ioctl_get_scan_results_t &ret)
uint8_t data[HCI_CMND_WLAN_CONNECT_DATA_MAX]
static const uint16_t HCI_CMND_SETSOCKOPT
virtual int send(const void *buf, size_t len, bool progmem)
static const uint16_t HCI_EVNT_WLAN_UNSOL_TCP_CLOSE_WAIT
static const uint16_t HCI_EVNT_WLAN_IOCTL_DEL_PROFILE
static const uint16_t HCI_CMND_WLAN_SET_EVENT_MASK
static const uint16_t HCI_CMND_RECV
static const uint16_t HCI_EVNT_RECV
static void memrevcpy(void *dest, const void *src, size_t n)
static uint32_t since(uint32_t start)
static const uint16_t HCI_EVNT_WLAN_UNSOL_KEEPALIVE
static const uint16_t HCI_CMND_SIMPLE_LINK_START
static const uint16_t HCI_EVNT_NVMEM_READ
int read_data(uint8_t op, void *args, uint8_t args_len, void *data, uint16_t data_len)
static const uint16_t HCI_EVNT_ANY
virtual void on_event(uint16_t event, void *args, size_t len)
void(* delay)(uint32_t ms)
static const uint16_t HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY
int wlan_connect(Security type, str_P ssid, str_P bssid, str_P key)
Socket * socket(Socket::Protocol proto, uint16_t port=0, uint8_t flag=0)
static const uint16_t HCI_CMND_WLAN_IOCTL_SET_SCANPARAM
const class prog_str * str_P
bool begin_P(str_P hostname, uint16_t timeout=5000)
static const uint16_t HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS
static const uint16_t HCI_CMND_NVMEM_READ
int recv(int hndl, void *buf, size_t size)
static const uint16_t HCI_CMND_WLAN_IOCTL_DEL_PROFILE
static const uint16_t HCI_EVNT_BIND
static const uint16_t HCI_EVNT_SIMPLE_LINK_START
static const uint16_t HCI_EVNT_WLAN_UNSOL_CONNECT
static const uint16_t HCI_CMND_CONNECT
#define FD_ISSET(fd, set)
virtual int read(void *buf, size_t size)
static const uint8_t HCI_DATA_SEND
virtual int recv(void *buf, size_t len)
int connect(int hndl, uint8_t ip[4], int port)
int accept(int hndl, uint8_t ip[4], int &port)
int read_sp_version(uint8_t &package_id, uint8_t &package_build_nr)
static const uint16_t HCI_EVNT_WLAN_CONNECT
static const uint16_t HCI_CMND_SOCKET
int simple_link_start(uint8_t src)
IOStream & endl(IOStream &outs)
static const uint16_t HCI_EVNT_LISTEN
HCI Command (SPI_OP_WRITE only).
static const uint8_t HCI_DATA_RECV
virtual int open(Protocol proto, uint16_t port, uint8_t flag)
static const uint16_t HCI_EVNT_WLAN_UNSOL_DISCONNECT
static const uint16_t HCI_EVNT_READ_BUFFER_SIZE
static const uint16_t HCI_EVNT_SEND
static const uint16_t HCI_EVNT_WLAN_IOCTL_STATUSGET
int issue(uint16_t op, const void *args=NULL, uint8_t len=0)
Driver m_socket[SOCKET_MAX]
static const uint16_t HCI_EVNT_WLAN_SET_EVENT_MASK
volatile bool m_available
virtual int connect(uint8_t addr[4], uint16_t port)
static const uint16_t HCI_EVNT_CONNECT
static const uint16_t HCI_CMND_LISTEN
int wlan_ioctl_statusget()
SPI Write(Payload Length,0).
static const uint16_t DEFAULT_TIMEOUT
int wlan_set_event_mask(uint16_t mask)
int send(int hndl, const void *buf, size_t size)
static const uint16_t HCI_EVNT_WLAN_IOCTL_GET_SCAN_RESULTS
const CC3000::hci_cmnd_wlan_ioctl_set_scanparam_t CC3000::DEFAULT_SCANPARAM __PROGMEM
static const uint16_t HCI_EVNT_DATA_UNSOL_FREE_BUFF
int read_buffer_size(uint8_t &count, uint16_t &size)
static const uint16_t HCI_CMND_SELECT
IOStream & hex(IOStream &outs)
int setsockopt(int hndl, int level, int optname, const void *optval, size_t optlen)
int wlan_ioctl_del_profile(uint8_t index)
int select(int hndls, uint32_t &readhnds, uint32_t &writehndls, uint32_t &errorhndls, uint32_t sec=0UL, uint32_t us=0UL)
int issue_P(uint16_t op, const void *args, uint8_t len)
static const uint16_t HCI_CMND_READ_BUFFER_SIZE
static const uint16_t HCI_EVNT_SETSOCKOPT
static const uint16_t HCI_EVNT_READ_SP_VERSION
static const uint16_t HCI_EVNT_WLAN_IOCTL_SET_SCANPARAM
bool socket_state(int hndl, bool state)