21 #ifndef COSA_CC3000_HH 22 #define COSA_CC3000_HH 26 #if !defined(BOARD_ATTINY) 74 virtual int write(
const void* buf,
size_t size)
76 return (
write(buf, size,
false));
86 virtual int write_P(
const void* buf,
size_t size)
88 return (
write(buf, size,
true));
101 virtual int read(
void* buf,
size_t size);
150 virtual int connect(uint8_t
addr[4], uint16_t port);
160 virtual int connect(
const char* hostname, uint16_t port);
186 virtual int datagram(uint8_t addr[4], uint16_t port);
198 virtual int recv(
void* buf,
size_t len);
212 virtual int recv(
void* buf,
size_t len, uint8_t
src[4], uint16_t& port);
225 virtual int write(
const void* buf,
size_t size,
bool progmem);
238 virtual int send(
const void* buf,
size_t len,
bool progmem);
253 virtual int send(
const void* buf,
size_t len,
254 uint8_t dest[4], uint16_t port,
316 int service(uint16_t timeout = 100);
329 void addr(uint8_t ip[4], uint8_t subnet[4])
377 virtual void on_event(uint16_t event,
void* args,
size_t len);
417 uint32_t channel_scan_timeout[16];
456 bool should_use_fast_connect,
457 bool auto_start_use_profiles);
468 uint8_t wlan_security:2;
469 uint8_t ssid_name_length:6;
525 int nvmem_read(uint8_t fileid,
void* dst, uint32_t
src,
size_t n);
563 int socket(
int domain,
int type,
int protocol);
584 int setsockopt(
int hndl,
int level,
int optname,
const void* optval,
size_t optlen);
608 uint32_t &readhnds, uint32_t &writehndls, uint32_t &errorhndls,
609 uint32_t sec = 0UL, uint32_t us = 0UL);
619 int recv(
int hndl,
void* buf,
size_t size);
629 int send(
int hndl,
const void* buf,
size_t size);
656 int accept(
int hndl, uint8_t ip[4],
int &
port);
716 return (hndl >= 0 && hndl < SOCKET_MAX);
728 return (
bit_get(m_active_set, hndl) != 0);
769 wlan_security_type = type;
770 ssid_length_plus = ssid_length + 16;
774 memset(this->bssid, 0,
sizeof(bssid));
776 memcpy_P(this->bssid, bssid,
sizeof(bssid));
777 memcpy_P(data, ssid, ssid_length);
778 memcpy_P(data + ssid_length, key, key_length);
804 uint32_t should_use_fast_connect,
805 uint32_t auto_start_use_profiles)
807 this->should_connect_to_open_ap = should_connect_to_open_ap;
808 this->should_use_fast_connect = should_use_fast_connect;
809 this->auto_start_use_profiles = auto_start_use_profiles;
838 this->scan_timeout = scan_timeout;
872 this->fileid = fileid;
873 this->length = length;
874 this->offset = offset;
897 protocol_family = domain;
899 protocol_type = protocol;
921 this->port =
swap(port);
922 memset(ip, 0,
sizeof(ip));
983 uint8_t destination_ip[4];
990 destination_port =
swap(port);
991 memcpy(destination_ip, ip,
sizeof(destination_ip));
1014 uint32_t writehndls,
1015 uint32_t errorhndls,
1020 for (uint8_t i = 0; i <
membersof(magic); i++)
1021 magic[i] = HCI_CMND_SELECT_MAGIC;
1022 flags = (sec == 0) && (us == 0);
1023 read_set = readhndls;
1024 write_set = writehndls;
1025 error_set = errorhndls;
1047 const void* optval,
size_t optlen)
1049 this->handle = hndl;
1050 this->level = level;
1051 this->optname = optname;
1053 this->optlen = optlen;
1054 memcpy(this->optval, optval, optlen);
1139 tcp_data_length = size;
1157 uint32_t reserved[2];
1172 uint32_t reserved[3];
1457 } flow_control_event;
static const uint16_t HCI_EVNT_NETAPP_PING_REPORT
int wlan_ioctl_set_connection_policy(bool should_connect_to_open_ap, bool should_use_fast_connect, bool auto_start_use_profiles)
static const uint16_t HCI_EVNT_WLAN_DISCONNECT
static const hci_cmnd_wlan_ioctl_set_scanparam_t DEFAULT_SCANPARAM
static const uint16_t HCI_EVNT_WLAN_IOCTL_SET_CONNECTION_POLICY
hci_cmnd_setsockopt_t(int hndl, int level, int optname, const void *optval, size_t optlen)
static const size_t HCI_CMND_WLAN_CONNECT_KEY_MAX
static const uint16_t HCI_CMND_RECVFROM
uint32_t default_tx_power
static const uint16_t HCI_EVNT_WLAN_UNSOL_DHCP
static const uint16_t HCI_CMND_ACCEPT
static const uint16_t HCI_EVNT_SOCKET
hci_cmnd_recv_t(int hndl, size_t size)
hci_cmnd_wlan_set_event_mask_t(uint16_t mask=0)
static const size_t HCI_CMND_WLAN_CONNECT_DATA_MAX
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
static const size_t HCI_CMND_WLAN_CONNECT_BSSID_MAX
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_EVNT_NETAPP_PING_STOP
static const uint16_t HCI_CMND_CLOSE_SOCKET
virtual int datagram(uint8_t addr[4], uint16_t port)
virtual int write(const void *buf, size_t size)
virtual int read(void *buf, size_t size)
hci_cmnd_bind_t(int hndl, int port)
static const uint16_t HCI_CMND_WLAN_IOCTL_STATUSGET
uint32_t wlan_security_type
static const uint16_t HCI_EVNT_DATA_SENDTO
uint32_t num_of_probe_requests
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 uint16_t HCI_CMND_NETAPP_PING_STOP
static const uint32_t HCI_CMND_WLAN_IOCTL_SET_SCANPARAM_MAGIC
static const uint16_t HCI_CMND_NETAPP_GETIPCONFIG
virtual int is_connected()
static const size_t HCI_CMND_WLAN_CONNECT_SSID_MAX
uint32_t echo_replies_recieved
static const uint16_t HCI_CMND_READ_SP_VERSION
int wlan_ioctl_get_scan_results(hci_evnt_wlan_ioctl_get_scan_results_t &ret)
static const uint16_t HCI_CMND_WLAN_IOCTL_SMART_CONFIG_STOP
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
virtual int write_P(const void *buf, size_t size)
static const uint16_t HCI_CMND_WLAN_SET_EVENT_MASK
static const uint16_t HCI_EVNT_WLAN_IOCTL_ADD_PROFILE
static const uint16_t HCI_CMND_NETAPP_ARP_FLUSH
static const uint32_t HCI_CMND_SELECT_MAGIC
hci_cmnd_wlan_ioctl_set_connection_policy_t(uint32_t should_connect_to_open_ap, uint32_t should_use_fast_connect, uint32_t auto_start_use_profiles)
static const uint16_t HCI_CMND_RECV
uint32_t echo_requests_sent
static const uint16_t HCI_CMND_GETHOSTBYNAME
uint32_t ssid_length_plus
static const uint16_t HCI_EVNT_RECV
static const uint16_t HCI_EVNT_WLAN_IOCTL_SMART_CONFIG_SET_PREFIX
static const uint16_t HCI_CMND_WLAN_IOCTL_SMART_CONFIG_SET_PREFIX
static const uint16_t HCI_EVNT_WLAN_UNSOL_KEEPALIVE
UnsolicitedEvent(CC3000 *dev)
static const uint16_t HCI_CMND_SIMPLE_LINK_START
hci_cmnd_select_t(uint32_t hndls, uint32_t readhndls, uint32_t writehndls, uint32_t errorhndls, uint32_t sec, uint32_t us)
static const uint16_t HCI_CMND_WLAN_IOCTL_SMART_CONFIG_START
static const uint16_t HCI_EVNT_NVMEM_READ
static const uint16_t HCI_EVNT_ANY
static const uint32_t HCI_CMND_LISTEN_QUEUE_MAX
static const uint16_t HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY
uint16_t destination_port
uint32_t should_use_fast_connect
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
UnsolicitedEvent m_evnt_handler
static const uint16_t HCI_CMND_WLAN_DISCONNECT
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_CREATE_ENTRY
static const uint16_t HCI_CMND_NVMEM_READ
static const uint32_t HCI_CMND_SETSOCKOPT_MAGIC
static const uint16_t HCI_CMND_WLAN_IOCTL_DEL_PROFILE
static const uint16_t HCI_CMND_WLAN_IOCTL_ADD_PROFILE
static const uint16_t HCI_EVNT_BIND
static const uint16_t HCI_EVNT_SIMPLE_LINK_START
void dns_addr(uint8_t ip[4])
uint32_t auto_start_use_profiles
hci_cmnd_nvmem_read_t(uint8_t fileid, uint32_t offset, size_t length)
static const uint16_t HCI_EVNT_WLAN_UNSOL_CONNECT
static const uint16_t HCI_CMND_NETAPP_PING_SEND
static const uint16_t HCI_CMND_CONNECT
static const uint16_t HCI_EVNT_WLAN_UNSOL_SMART_CONFIG_DONE
virtual int read(void *buf, size_t size)
static const uint8_t HCI_DATA_SEND
virtual int recv(void *buf, size_t len)
void src(INET::addr_t &addr) const
static const uint8_t HCI_DATA_NVMEM_WRITE
int read_sp_version(uint8_t &package_id, uint8_t &package_build_nr)
static const uint16_t HCI_EVNT_WLAN_UNSOL_PING_REPORT
static const uint16_t HCI_EVNT_WLAN_CONNECT
static const uint16_t HCI_CMND_SOCKET
int simple_link_start(uint8_t src)
static const uint16_t HCI_EVNT_NETAPP_PING_SEND
#define bit_write(c, p, b)
static const int SOCKET_MAX
void event_handler(Event::Handler *handler)
hci_cmnd_wlan_ioctl_del_profile_t(uint8_t index)
static const uint16_t HCI_EVNT_LISTEN
static const uint8_t HCI_DATA_RECV
hci_cmnd_accept_t(int hndl)
virtual int open(Protocol proto, uint16_t port, uint8_t flag)
static const uint32_t HCI_CMND_WLAN_CONNECT_MAGIC
static const uint16_t HCI_EVNT_WLAN_UNSOL_DISCONNECT
static const uint16_t HCI_EVNT_READ_BUFFER_SIZE
uint32_t should_connect_to_open_ap
hci_cmnd_connect_t(int hndl, uint8_t ip[4], int port)
static const uint16_t HCI_EVNT_SEND
static const uint32_t HCI_DATA_SEND_MAGIC
static const uint16_t HCI_EVNT_WLAN_IOCTL_STATUSGET
Driver m_socket[SOCKET_MAX]
static const uint16_t HCI_EVNT_WLAN_SET_EVENT_MASK
static const uint16_t HCI_EVNT_PATCHES_REQ
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()
hci_cmnd_wlan_ioctl_get_scan_results_t(uint32_t scan_timeout=0UL)
static const uint16_t HCI_CMND_NETAPP_PING_REPORT
static const uint16_t HCI_CMND_GETHOSTBYNAME_MAGIC
static const uint16_t DEFAULT_TIMEOUT
static const uint16_t HCI_EVNT_NETAPP_GETIPCONFIG
int wlan_set_event_mask(uint16_t mask)
static const uint16_t HCI_EVNT_WLAN_IOCTL_GET_SCAN_RESULTS
static const uint16_t HCI_EVNT_DATA_UNSOL_FREE_BUFF
hci_cmnd_close_socket_t(int hndl)
int read_buffer_size(uint8_t &count, uint16_t &size)
hci_cmnd_listen_t(int hndl)
static const uint16_t HCI_CMND_SELECT
hci_data_send_t(int hndl, size_t size)
int setsockopt(int hndl, int level, int optname, const void *optval, size_t optlen)
static const uint16_t HCI_CMND_GETSOCKOPT
CC3000(Board::DigitalPin cs, Board::ExternalInterruptPin irq, Board::DigitalPin vbat, SPI::Clock rate=SPI::DEFAULT_CLOCK)
void mac_addr(uint8_t mac[6])
int wlan_ioctl_del_profile(uint8_t index)
hci_cmnd_wlan_connect_t(uint8_t type, str_P ssid, str_P bssid, str_P key)
int select(int hndls, uint32_t &readhnds, uint32_t &writehndls, uint32_t &errorhndls, uint32_t sec=0UL, uint32_t us=0UL)
static const uint8_t HCI_DATA_SENDTO
static const uint16_t HCI_CMND_NETAPP_SET_DEBUG_LEVEL
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
hci_cmnd_socket_t(int domain, int type, int protocol)
static const uint16_t HOSTNAME_MAX
static const uint16_t HCI_EVNT_WLAN_IOCTL_SET_SCANPARAM
bool socket_state(int hndl, bool state)