COSA
An Object-Oriented Platform for Arduino Programming
CC3000.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_CC3000_HH
22 #define COSA_CC3000_HH
23 
24 #include "Cosa/Types.h"
25 
26 #if !defined(BOARD_ATTINY)
27 #include "HCI.hh"
28 #include "Cosa/Socket.hh"
29 
38 class CC3000 : public HCI {
39 public:
44  class Driver : public Socket {
45  friend class CC3000;
46  public:
48  Driver() : Socket() {}
49 
55  virtual int available();
56 
62  virtual int room();
63 
66 
74  virtual int write(const void* buf, size_t size)
75  {
76  return (write(buf, size, false));
77  }
78 
86  virtual int write_P(const void* buf, size_t size)
87  {
88  return (write(buf, size, true));
89  }
90 
93 
101  virtual int read(void* buf, size_t size);
102 
108  virtual int flush();
109 
118  virtual int open(Protocol proto, uint16_t port, uint8_t flag);
119 
125  virtual int close();
126 
132  virtual int listen();
133 
141  virtual int accept();
142 
150  virtual int connect(uint8_t addr[4], uint16_t port);
151 
160  virtual int connect(const char* hostname, uint16_t port);
161 
169  virtual int is_connected();
170 
176  virtual int disconnect();
177 
186  virtual int datagram(uint8_t addr[4], uint16_t port);
187 
198  virtual int recv(void* buf, size_t len);
199 
212  virtual int recv(void* buf, size_t len, uint8_t src[4], uint16_t& port);
213 
214  protected:
225  virtual int write(const void* buf, size_t size, bool progmem);
226 
238  virtual int send(const void* buf, size_t len, bool progmem);
239 
253  virtual int send(const void* buf, size_t len,
254  uint8_t dest[4], uint16_t port,
255  bool progmem);
256 
259 
261  uint8_t m_hndl;
262 
264  uint8_t m_ip[4];
265 
267  int m_port;
268  };
269 
270 public:
281  Board::DigitalPin vbat,
283  HCI(cs, irq, rate),
284  m_vbat(vbat, 0),
285  m_evnt_handler(this),
286  m_active_set(0)
287  {
289  }
290 
299  bool begin_P(str_P hostname, uint16_t timeout = 5000);
300 
309  Socket* socket(Socket::Protocol proto, uint16_t port = 0, uint8_t flag = 0);
310 
316  int service(uint16_t timeout = 100);
317 
322  bool end();
323 
329  void addr(uint8_t ip[4], uint8_t subnet[4])
330  {
331  memcpy(ip, m_ip, sizeof(m_ip));
332  memcpy(subnet, m_subnet, sizeof(m_subnet));
333  }
334 
339  void mac_addr(uint8_t mac[6])
340  {
341  memcpy(mac, m_mac, sizeof(m_mac));
342  }
343 
349  void dns_addr(uint8_t ip[4])
350  {
351  memcpy(ip, m_dns, sizeof(m_dns));
352  }
353 
354 public:
359  public:
365  HCI::Event::Handler(),
366  m_dev(dev)
367  {}
368 
369  /*
370  * @override{HCI::Event::Handler}
371  * Handle unsolicited events; buffer free cound, socket close
372  * wait, keepalive, etc.
373  * @param[in] event operation code.
374  * @param[in] args pointer to argument block.
375  * @param[in] len number of bytes in argument block.
376  */
377  virtual void on_event(uint16_t event, void* args, size_t len);
378 
379  protected:
381  };
382 
386  enum Security {
391  };
392 
402  int wlan_connect(Security type, str_P ssid, str_P bssid, str_P key);
403 
408  uint32_t magic;
409  uint32_t intervall;
410  uint32_t min_dwell_time;
411  uint32_t max_dwell_time;
413  uint32_t channel_mask;
414  int32_t rssi_threshold;
415  uint32_t snr_threshold;
417  uint32_t channel_scan_timeout[16];
418  };
419 
423  static const uint32_t HCI_CMND_WLAN_IOCTL_SET_SCANPARAM_MAGIC = 0x00000024L;
424 
429 
437 
438  enum {
443  };
444 
449  int wlan_ioctl_statusget();
450 
455  int wlan_ioctl_set_connection_policy(bool should_connect_to_open_ap,
456  bool should_use_fast_connect,
457  bool auto_start_use_profiles);
458 
463  int8_t status;
464  uint32_t network_id;
465  uint32_t scan_status;
466  uint8_t valid:1;
467  uint8_t rssi:7;
468  uint8_t wlan_security:2;
469  uint8_t ssid_name_length:6;
470  uint16_t entry_time;
471  uint8_t ssid[32];
472  uint8_t bssid[6];
473  uint8_t reserved[2];
474  };
475 
484 
489  int wlan_ioctl_del_profile(uint8_t index);
490 
495  int wlan_set_event_mask(uint16_t mask);
496 
497  enum {
515  };
516 
525  int nvmem_read(uint8_t fileid, void* dst, uint32_t src, size_t n);
526 
534  int simple_link_start(uint8_t src);
535 
543  int read_buffer_size(uint8_t &count, uint16_t &size);
544 
553  int read_sp_version(uint8_t &package_id, uint8_t &package_build_nr);
554 
563  int socket(int domain, int type, int protocol);
564 
565  enum {
566  SOL_SOCKET = 0xffff
567  };
568  enum {
572  };
573 
584  int setsockopt(int hndl, int level, int optname, const void* optval, size_t optlen);
585 
594  int connect(int hndl, uint8_t ip[4], int port);
595 
607  int select(int hndls,
608  uint32_t &readhnds, uint32_t &writehndls, uint32_t &errorhndls,
609  uint32_t sec = 0UL, uint32_t us = 0UL);
610 
619  int recv(int hndl, void* buf, size_t size);
620 
629  int send(int hndl, const void* buf, size_t size);
630 
638  int bind(int hndl, int port);
639 
646  int listen(int hndl);
647 
656  int accept(int hndl, uint8_t ip[4], int &port);
657 
663  int close(int hndl);
664 
665 protected:
668 
671 
673  uint8_t m_mac[6];
674 
676  uint8_t m_ip[4];
677 
679  uint8_t m_subnet[4];
680 
682  uint8_t m_gateway[4];
683 
685  uint8_t m_dns[4];
686 
688  static const uint16_t DEFAULT_TIMEOUT = 300;
689 
691  uint16_t BUFFER_MAX;
692 
694  uint8_t BUFFER_COUNT;
695 
697  uint8_t m_buffer_avail;
698 
700  static const int SOCKET_MAX = 8;
701 
704 
706  uint16_t m_active_set;
707 
714  bool is_socket(int hndl)
715  {
716  return (hndl >= 0 && hndl < SOCKET_MAX);
717  }
718 
725  bool is_active(int hndl)
726  {
727  if (!is_socket(hndl)) return (false);
728  return (bit_get(m_active_set, hndl) != 0);
729  }
730 
739  bool socket_state(int hndl, bool state)
740  {
741  if (!is_socket(hndl)) return (false);
742  bit_write(state, m_active_set, hndl);
743  return (true);
744  }
745 
750  static const uint16_t HCI_CMND_WLAN_CONNECT = 0x0001;
751  static const uint32_t HCI_CMND_WLAN_CONNECT_MAGIC = 0x0000001cL;
752  static const size_t HCI_CMND_WLAN_CONNECT_BSSID_MAX = 6;
753  static const size_t HCI_CMND_WLAN_CONNECT_SSID_MAX = 32;
754  static const size_t HCI_CMND_WLAN_CONNECT_KEY_MAX = 32;
755  static const size_t HCI_CMND_WLAN_CONNECT_DATA_MAX = 64;
757  uint32_t magic;
758  uint32_t ssid_length;
761  uint32_t key_length;
762  uint16_t reserved;
765  hci_cmnd_wlan_connect_t(uint8_t type, str_P ssid, str_P bssid, str_P key)
766  {
768  ssid_length = strlen_P(ssid);
769  wlan_security_type = type;
770  ssid_length_plus = ssid_length + 16;
771  key_length = strlen_P(key);
772  reserved = 0;
773  if (bssid == NULL)
774  memset(this->bssid, 0, sizeof(bssid));
775  else
776  memcpy_P(this->bssid, bssid, sizeof(bssid));
777  memcpy_P(data, ssid, ssid_length);
778  memcpy_P(data + ssid_length, key, key_length);
779  }
780  };
781 
786  static const uint16_t HCI_CMND_WLAN_DISCONNECT = 0x0002;
787 
792  static const uint16_t HCI_CMND_WLAN_IOCTL_SET_SCANPARAM = 0x0003;
793 
798  static const uint16_t HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY = 0x0004;
803  hci_cmnd_wlan_ioctl_set_connection_policy_t(uint32_t should_connect_to_open_ap,
804  uint32_t should_use_fast_connect,
805  uint32_t auto_start_use_profiles)
806  {
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;
810  }
811  };
812 
813  // Fix: Not yet implemented.
814  static const uint16_t HCI_CMND_WLAN_IOCTL_ADD_PROFILE = 0x0005;
815 
820  static const uint16_t HCI_CMND_WLAN_IOCTL_DEL_PROFILE = 0x0006;
822  uint32_t index;
824  {
825  this->index = index;
826  }
827  };
828 
833  static const uint16_t HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS = 0x0007;
835  uint32_t scan_timeout;
836  hci_cmnd_wlan_ioctl_get_scan_results_t(uint32_t scan_timeout = 0UL)
837  {
838  this->scan_timeout = scan_timeout;
839  }
840  };
841 
846  static const uint16_t HCI_CMND_WLAN_SET_EVENT_MASK = 0x0008;
848  uint32_t mask;
850  {
851  this->mask = mask;
852  }
853  };
854 
855  // Fix: Not yet implemented.
856  static const uint16_t HCI_CMND_WLAN_IOCTL_STATUSGET = 0x0009;
857  static const uint16_t HCI_CMND_WLAN_IOCTL_SMART_CONFIG_START = 0x000A;
858  static const uint16_t HCI_CMND_WLAN_IOCTL_SMART_CONFIG_STOP = 0x000B;
859  static const uint16_t HCI_CMND_WLAN_IOCTL_SMART_CONFIG_SET_PREFIX = 0x000C;
860 
865  static const uint16_t HCI_CMND_NVMEM_READ = 0x0201;
867  uint32_t fileid;
868  uint32_t length;
869  uint32_t offset;
870  hci_cmnd_nvmem_read_t(uint8_t fileid, uint32_t offset, size_t length)
871  {
872  this->fileid = fileid;
873  this->length = length;
874  this->offset = offset;
875  }
876  };
877 
878  static const uint16_t HCI_CMND_NVMEM_CREATE_ENTRY = 0x0203;
879 
884  static const uint16_t HCI_CMND_READ_SP_VERSION = 0x0207;
885 
890  static const uint16_t HCI_CMND_SOCKET = 0x1001;
892  uint32_t protocol_family;
893  uint32_t socket_type;
894  uint32_t protocol_type;
895  hci_cmnd_socket_t(int domain, int type, int protocol)
896  {
897  protocol_family = domain;
898  socket_type = type;
899  protocol_type = protocol;
900  }
901  };
902 
907  static const uint16_t HCI_CMND_BIND = 0x1002;
909  uint32_t handle;
910  uint32_t reserved;
911  uint32_t length;
912  uint16_t protocol_family;
913  uint16_t port;
914  uint8_t ip[4];
915  hci_cmnd_bind_t(int hndl, int port)
916  {
917  handle = hndl;
918  reserved = 8;
919  length = 8;
920  protocol_family = AF_INET;
921  this->port = swap(port);
922  memset(ip, 0, sizeof(ip));
923  }
924  };
925 
930  static const uint16_t HCI_CMND_RECV = 0x1004;
932  uint32_t handle;
933  uint32_t count;
934  uint32_t flags;
935  hci_cmnd_recv_t(int hndl, size_t size)
936  {
937  handle = hndl;
938  count = size;
939  flags = 0;
940  }
941  };
942 
947  static const uint16_t HCI_CMND_ACCEPT = 0x1005;
949  uint32_t handle;
951  {
952  handle = hndl;
953  }
954  };
955 
960  static const uint16_t HCI_CMND_LISTEN = 0x1006;
961  static const uint32_t HCI_CMND_LISTEN_QUEUE_MAX = 4;
963  uint32_t handle;
964  uint32_t queue_depth;
966  {
967  handle = hndl;
968  queue_depth = 0UL;
969  }
970  };
971 
976  static const uint16_t HCI_CMND_CONNECT = 0x1007;
978  uint32_t handle;
979  uint32_t reserved;
980  uint32_t length;
981  uint16_t protocol_family;
983  uint8_t destination_ip[4];
984  hci_cmnd_connect_t(int hndl, uint8_t ip[4], int port)
985  {
986  handle = hndl;
987  reserved = 8;
988  length = 8;
989  protocol_family = AF_INET;
990  destination_port = swap(port);
991  memcpy(destination_ip, ip, sizeof(destination_ip));
992  }
993  };
994 
999  static const uint16_t HCI_CMND_SELECT = 0x1008;
1000  static const uint32_t HCI_CMND_SELECT_MAGIC = 0x00000014;
1002  uint32_t handle_max;
1003  uint32_t magic[4];
1004  uint32_t flags;
1005  uint32_t read_set;
1006  uint32_t write_set;
1007  uint32_t error_set;
1008  struct {
1009  uint32_t sec;
1010  uint32_t us;
1011  } timeout;
1012  hci_cmnd_select_t(uint32_t hndls,
1013  uint32_t readhndls,
1014  uint32_t writehndls,
1015  uint32_t errorhndls,
1016  uint32_t sec,
1017  uint32_t us)
1018  {
1019  handle_max = hndls;
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;
1026  timeout.sec = sec;
1027  timeout.us = us;
1028  }
1029  };
1030 
1034  static const uint16_t HCI_CMND_SETSOCKOPT = 0x1009;
1035  static const uint32_t HCI_CMND_SETSOCKOPT_MAGIC = 0x8;
1036  enum {
1038  };
1040  uint32_t handle;
1041  uint32_t level;
1042  uint32_t optname;
1043  uint32_t magic;
1044  uint32_t optlen;
1045  uint8_t optval[OPTVAL_MAX];
1046  hci_cmnd_setsockopt_t(int hndl, int level, int optname,
1047  const void* optval, size_t optlen)
1048  {
1049  this->handle = hndl;
1050  this->level = level;
1051  this->optname = optname;
1052  this->magic = HCI_CMND_SETSOCKOPT_MAGIC;
1053  this->optlen = optlen;
1054  memcpy(this->optval, optval, optlen);
1055  }
1056  };
1057 
1061  static const uint16_t HCI_CMND_GETSOCKOPT = 0x100A;
1063  uint32_t handle;
1064  uint32_t level;
1065  uint32_t optname;
1066  };
1067 
1072  static const uint16_t HCI_CMND_CLOSE_SOCKET = 0x100B;
1074  uint32_t handle;
1076  {
1077  handle = hndl;
1078  }
1079  };
1080 
1084  static const uint16_t HCI_CMND_RECVFROM = 0x100D;
1085  struct hci_cmnd_recvfrom_t { // 12
1086  uint32_t handle;
1087  };
1088 
1092  static const uint16_t HCI_CMND_GETHOSTBYNAME = 0x100D;
1093  static const uint16_t HCI_CMND_GETHOSTBYNAME_MAGIC = 8;
1094  static const uint16_t HOSTNAME_MAX = 32;
1096  uint32_t magic;
1097  uint32_t len;
1098  char hostname[HOSTNAME_MAX];
1099  };
1100 
1101  // Fix: Not yet implemented
1102  static const uint16_t HCI_CMND_NETAPP_PING_SEND = 0x2002;
1103  static const uint16_t HCI_CMND_NETAPP_PING_REPORT = 0x2003;
1104  static const uint16_t HCI_CMND_NETAPP_PING_STOP = 0x2004;
1105  static const uint16_t HCI_CMND_NETAPP_GETIPCONFIG = 0x2005;
1106  static const uint16_t HCI_CMND_NETAPP_ARP_FLUSH = 0x2006;
1107  static const uint16_t HCI_CMND_NETAPP_SET_DEBUG_LEVEL = 0x2008;
1108 
1113  static const uint16_t HCI_CMND_SIMPLE_LINK_START = 0x4000;
1115  uint8_t src;
1116  };
1117 
1122  static const uint16_t HCI_CMND_READ_BUFFER_SIZE = 0x400B;
1123 
1128  static const uint8_t HCI_DATA_SEND = 0x81;
1129  static const uint32_t HCI_DATA_SEND_MAGIC = 0x0000000C;
1131  uint32_t handle;
1132  uint32_t magic;
1134  uint32_t flags;
1135  hci_data_send_t(int hndl, size_t size)
1136  {
1137  handle = hndl;
1138  magic = HCI_DATA_SEND_MAGIC;
1139  tcp_data_length = size;
1140  flags = 0;
1141  }
1142  };
1143 
1144  // Fix: Not yet implemented.
1145  static const uint8_t HCI_DATA_SENDTO = 0x83;
1146 
1151  static const uint8_t HCI_DATA_RECV = 0x85;
1153  uint32_t handle;
1154  uint32_t magic;
1156  uint32_t flags;
1157  uint32_t reserved[2];
1158  };
1159 
1160  // Fix: Not yet implemented.
1161  static const uint8_t HCI_DATA_NVMEM_WRITE = 0x90;
1162 
1167  static const uint8_t HCI_DATA_NVMEM_READ = 0x91;
1169  uint32_t fileid;
1170  uint32_t length;
1171  uint32_t offset;
1172  uint32_t reserved[3];
1173  };
1174 
1176  static const uint16_t HCI_EVNT_ANY = 0x0000;
1177 
1182  static const uint16_t HCI_EVNT_WLAN_CONNECT = 0x0001;
1184  int8_t status;
1185  int32_t result;
1186  };
1187 
1192  static const uint16_t HCI_EVNT_WLAN_DISCONNECT = 0x0002;
1194  int8_t status;
1195  uint32_t result;
1196  };
1197 
1202  static const uint16_t HCI_EVNT_WLAN_IOCTL_SET_SCANPARAM = 0x0003;
1204  int8_t status;
1205  int32_t result;
1206  };
1207 
1212  static const uint16_t HCI_EVNT_WLAN_IOCTL_SET_CONNECTION_POLICY = 0x0004;
1214  int8_t status;
1215  int32_t result;
1216  };
1217 
1218  // Fix: Not yet implemented.
1219  static const uint16_t HCI_EVNT_WLAN_IOCTL_ADD_PROFILE = 0x0005;
1220 
1225  static const uint16_t HCI_EVNT_WLAN_IOCTL_DEL_PROFILE = 0x0006;
1227  int8_t status;
1228  int32_t result;
1229  };
1230 
1235  static const uint16_t HCI_EVNT_WLAN_IOCTL_GET_SCAN_RESULTS = 0x0007;
1236 
1241  static const uint16_t HCI_EVNT_WLAN_SET_EVENT_MASK = 0x0008;
1243  int8_t status;
1244  int32_t result;
1245  };
1246 
1251  static const uint16_t HCI_EVNT_WLAN_IOCTL_STATUSGET = 0x0009;
1253  int8_t status;
1254  uint32_t wlan_status;
1255  };
1256 
1257  // Fix: Not yet implemented.
1258  static const uint16_t HCI_EVNT_WLAN_IOCTL_SMART_CONFIG_SET_PREFIX = 0x000C;
1259 
1264  static const uint16_t HCI_EVNT_NVMEM_READ = 0x0201;
1266  int8_t status;
1267  };
1268 
1273  static const uint16_t HCI_EVNT_READ_SP_VERSION = 0x0207;
1275  int8_t status;
1276  uint16_t dummy;
1277  uint8_t package_id;
1279  };
1280 
1281  static const uint16_t HCI_EVNT_PATCHES_REQ = 0x1000;
1282 
1287  static const uint16_t HCI_EVNT_SOCKET = 0x1001;
1289  int8_t status;
1290  int32_t handle;
1291  };
1292 
1297  static const uint16_t HCI_EVNT_BIND = 0x1002;
1299  int8_t status;
1300  int32_t result;
1301  };
1302 
1307  static const uint16_t HCI_EVNT_SEND = 0x1003;
1309  int8_t status;
1310  int32_t handle;
1311  int32_t result;
1312  };
1313 
1318  static const uint16_t HCI_EVNT_RECV = 0x1004;
1320  int8_t status;
1321  int32_t handle;
1322  int32_t count;
1323  int32_t result;
1324  };
1325 
1330  static const uint16_t HCI_EVNT_ACCEPT = 0x1005;
1332  int8_t status;
1333  int32_t result;
1334  int32_t handle;
1336  uint16_t port;
1337  uint8_t ip[4];
1338  };
1339 
1344  static const uint16_t HCI_EVNT_LISTEN = 0x1006;
1346  int8_t status;
1347  int32_t result;
1348  };
1349 
1354  static const uint16_t HCI_EVNT_CONNECT = 0x1007;
1356  int8_t status;
1357  int32_t result;
1358  };
1359 
1364  static const uint16_t HCI_EVNT_SELECT = 0x1008;
1366  int8_t status;
1367  int32_t result;
1368  uint32_t read_set;
1369  uint32_t write_set;
1370  uint32_t error_set;
1371  };
1372 
1376  static const uint16_t HCI_EVNT_SETSOCKOPT = 0x1009;
1378  int8_t status;
1379  int32_t result;
1380  };
1381 
1386  static const uint16_t HCI_EVNT_CLOSE_SOCKET = 0x100B;
1388  int8_t status;
1389  int32_t result;
1390  };
1391 
1396  static const uint16_t HCI_EVNT_DATA_SENDTO = 0x100F;
1398  int8_t status;
1399  int32_t handle;
1400  int32_t result;
1401  };
1402 
1407  static const uint16_t HCI_EVNT_NETAPP_PING_SEND = 0x2002;
1409  int8_t status;
1410  };
1411 
1416  static const uint16_t HCI_EVNT_NETAPP_PING_REPORT = 0x2003;
1418  int8_t status;
1419  };
1420 
1425  static const uint16_t HCI_EVNT_NETAPP_PING_STOP = 0x2004;
1427  int8_t status;
1428  };
1429 
1434  static const uint16_t HCI_EVNT_NETAPP_GETIPCONFIG = 0x2005;
1436  int8_t status;
1437  uint8_t ip[4];
1438  uint8_t subnet[4];
1439  uint8_t gateway[4];
1440  uint8_t dhcp[4];
1441  uint8_t dns[4];
1442  uint8_t mac[6];
1443  uint8_t ssid[32];
1444  };
1445 
1450  static const uint16_t HCI_EVNT_DATA_UNSOL_FREE_BUFF = 0x4100;
1452  int8_t status;
1453  uint16_t count;
1454  struct {
1455  uint16_t magic;
1456  uint16_t buffers_freed;
1457  } flow_control_event;
1458  };
1459 
1464  static const uint16_t HCI_EVNT_WLAN_UNSOL_CONNECT = 0x8001;
1466  int8_t status;
1467  };
1468 
1473  static const uint16_t HCI_EVNT_WLAN_UNSOL_DISCONNECT = 0x8002;
1475  int8_t status;
1476  };
1477 
1482  static const uint16_t HCI_EVNT_WLAN_UNSOL_DHCP = 0x8010;
1484  int8_t status;
1485  uint8_t ip[4];
1486  uint8_t subnet[4];
1487  uint8_t gateway[4];
1488  uint8_t dhcp[4];
1489  uint8_t dns[4];
1490  };
1491 
1496  static const uint16_t HCI_EVNT_WLAN_UNSOL_PING_REPORT = 0x8040;
1498  int8_t status;
1501  uint32_t max_rtt;
1502  uint32_t min_rtt;
1503  uint32_t avg_rtt;
1504  };
1505 
1510  static const uint16_t HCI_EVNT_WLAN_UNSOL_SMART_CONFIG_DONE = 0x8080;
1512  int8_t status;
1513  };
1514 
1519  static const uint16_t HCI_EVNT_WLAN_UNSOL_KEEPALIVE = 0x8200;
1521  int8_t status;
1522  };
1523 
1528  static const uint16_t HCI_EVNT_WLAN_UNSOL_TCP_CLOSE_WAIT = 0x8800;
1530  int8_t status;
1531  uint32_t handle;
1532  };
1533 
1538  static const uint16_t HCI_EVNT_SIMPLE_LINK_START = 0x4000;
1540  int8_t status;
1541  };
1542 
1547  static const uint16_t HCI_EVNT_READ_BUFFER_SIZE = 0x400B;
1549  int8_t status;
1550  uint8_t count;
1551  uint16_t bytes;
1552  };
1553 };
1554 
1555 #endif
1556 #endif
static const uint16_t HCI_EVNT_NETAPP_PING_REPORT
Definition: CC3000.hh:1416
#define bit_get(p, b)
Definition: Bits.h:34
Definition: Socket.hh:31
int wlan_ioctl_set_connection_policy(bool should_connect_to_open_ap, bool should_use_fast_connect, bool auto_start_use_profiles)
Definition: CC3000.cpp:459
static const uint16_t HCI_EVNT_WLAN_DISCONNECT
Definition: CC3000.hh:1192
static const hci_cmnd_wlan_ioctl_set_scanparam_t DEFAULT_SCANPARAM
Definition: CC3000.hh:428
static const uint16_t HCI_EVNT_WLAN_IOCTL_SET_CONNECTION_POLICY
Definition: CC3000.hh:1212
hci_cmnd_setsockopt_t(int hndl, int level, int optname, const void *optval, size_t optlen)
Definition: CC3000.hh:1046
static const size_t HCI_CMND_WLAN_CONNECT_KEY_MAX
Definition: CC3000.hh:754
static const uint16_t HCI_CMND_RECVFROM
Definition: CC3000.hh:1084
virtual int room()
Definition: CC3000.cpp:139
static const uint16_t HCI_EVNT_WLAN_UNSOL_DHCP
Definition: CC3000.hh:1482
static const uint16_t HCI_CMND_ACCEPT
Definition: CC3000.hh:947
Clock
Definition: SPI.hh:60
static const uint16_t HCI_EVNT_SOCKET
Definition: CC3000.hh:1287
hci_cmnd_recv_t(int hndl, size_t size)
Definition: CC3000.hh:935
hci_cmnd_wlan_set_event_mask_t(uint16_t mask=0)
Definition: CC3000.hh:849
static const size_t HCI_CMND_WLAN_CONNECT_DATA_MAX
Definition: CC3000.hh:755
static const uint8_t HCI_DATA_NVMEM_READ
Definition: CC3000.hh:1167
static const uint16_t HCI_EVNT_ACCEPT
Definition: CC3000.hh:1330
static const uint16_t HCI_CMND_BIND
Definition: CC3000.hh:907
virtual int write(const void *buf, size_t size)
Definition: CC3000.hh:74
Security
Definition: CC3000.hh:386
void addr(uint8_t ip[4], uint8_t subnet[4])
Definition: CC3000.hh:329
static const uint16_t HCI_CMND_WLAN_CONNECT
Definition: CC3000.hh:750
Definition: CC3000.hh:38
static const uint16_t HCI_EVNT_CLOSE_SOCKET
Definition: CC3000.hh:1386
static const size_t HCI_CMND_WLAN_CONNECT_BSSID_MAX
Definition: CC3000.hh:752
int nvmem_read(uint8_t fileid, void *dst, uint32_t src, size_t n)
Definition: CC3000.cpp:523
int service(uint16_t timeout=100)
Definition: CC3000.cpp:352
static const uint16_t HCI_EVNT_NETAPP_PING_STOP
Definition: CC3000.hh:1425
static const uint16_t HCI_CMND_CLOSE_SOCKET
Definition: CC3000.hh:1072
virtual int datagram(uint8_t addr[4], uint16_t port)
Definition: CC3000.cpp:215
virtual int flush()
Definition: CC3000.cpp:155
uint8_t m_hndl
Definition: CC3000.hh:261
virtual int write(const void *buf, size_t size)
virtual int read(void *buf, size_t size)
#define NULL
Definition: Types.h:101
hci_cmnd_bind_t(int hndl, int port)
Definition: CC3000.hh:915
static const uint16_t HCI_CMND_WLAN_IOCTL_STATUSGET
Definition: CC3000.hh:856
static const uint16_t HCI_EVNT_DATA_SENDTO
Definition: CC3000.hh:1396
int wlan_ioctl_set_scanparam(const hci_cmnd_wlan_ioctl_set_scanparam_t *param=NULL)
Definition: CC3000.cpp:428
static const uint16_t HCI_EVNT_SELECT
Definition: CC3000.hh:1364
int bind(int hndl, int port)
Definition: CC3000.cpp:719
static const uint16_t HCI_CMND_NETAPP_PING_STOP
Definition: CC3000.hh:1104
Protocol
Definition: Socket.hh:37
virtual int disconnect()
Definition: CC3000.cpp:209
static const uint32_t HCI_CMND_WLAN_IOCTL_SET_SCANPARAM_MAGIC
Definition: CC3000.hh:423
bool is_socket(int hndl)
Definition: CC3000.hh:714
static const uint16_t HCI_CMND_NETAPP_GETIPCONFIG
Definition: CC3000.hh:1105
virtual int is_connected()
Definition: CC3000.cpp:203
static const size_t HCI_CMND_WLAN_CONNECT_SSID_MAX
Definition: CC3000.hh:753
static const uint16_t HCI_CMND_READ_SP_VERSION
Definition: CC3000.hh:884
int wlan_ioctl_get_scan_results(hci_evnt_wlan_ioctl_get_scan_results_t &ret)
Definition: CC3000.cpp:479
static const uint16_t HCI_CMND_WLAN_IOCTL_SMART_CONFIG_STOP
Definition: CC3000.hh:858
static const uint16_t HCI_CMND_SETSOCKOPT
Definition: CC3000.hh:1034
virtual int send(const void *buf, size_t len, bool progmem)
Definition: CC3000.cpp:248
static const uint16_t HCI_EVNT_WLAN_UNSOL_TCP_CLOSE_WAIT
Definition: CC3000.hh:1528
static const uint16_t HCI_EVNT_WLAN_IOCTL_DEL_PROFILE
Definition: CC3000.hh:1225
uint8_t m_subnet[4]
Definition: CC3000.hh:679
virtual int write_P(const void *buf, size_t size)
Definition: CC3000.hh:86
static const uint16_t HCI_CMND_WLAN_SET_EVENT_MASK
Definition: CC3000.hh:846
uint8_t m_dns[4]
Definition: CC3000.hh:685
static const uint16_t HCI_EVNT_WLAN_IOCTL_ADD_PROFILE
Definition: CC3000.hh:1219
static const uint16_t HCI_CMND_NETAPP_ARP_FLUSH
Definition: CC3000.hh:1106
static const uint32_t HCI_CMND_SELECT_MAGIC
Definition: CC3000.hh:1000
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)
Definition: CC3000.hh:803
static const uint16_t HCI_CMND_RECV
Definition: CC3000.hh:930
static const uint16_t HCI_CMND_GETHOSTBYNAME
Definition: CC3000.hh:1092
bool end()
Definition: CC3000.cpp:363
bool is_active(int hndl)
Definition: CC3000.hh:725
CC3000 * m_dev
Definition: CC3000.hh:258
static const uint16_t HCI_EVNT_RECV
Definition: CC3000.hh:1318
static const uint16_t HCI_EVNT_WLAN_IOCTL_SMART_CONFIG_SET_PREFIX
Definition: CC3000.hh:1258
static const uint16_t HCI_CMND_WLAN_IOCTL_SMART_CONFIG_SET_PREFIX
Definition: CC3000.hh:859
#define membersof(x)
Definition: Types.h:165
static const uint16_t HCI_EVNT_WLAN_UNSOL_KEEPALIVE
Definition: CC3000.hh:1519
UnsolicitedEvent(CC3000 *dev)
Definition: CC3000.hh:364
static const uint16_t HCI_CMND_SIMPLE_LINK_START
Definition: CC3000.hh:1113
hci_cmnd_select_t(uint32_t hndls, uint32_t readhndls, uint32_t writehndls, uint32_t errorhndls, uint32_t sec, uint32_t us)
Definition: CC3000.hh:1012
static const uint16_t HCI_CMND_WLAN_IOCTL_SMART_CONFIG_START
Definition: CC3000.hh:857
static const uint16_t HCI_EVNT_NVMEM_READ
Definition: CC3000.hh:1264
static const uint16_t HCI_EVNT_ANY
Definition: CC3000.hh:1176
static const uint32_t HCI_CMND_LISTEN_QUEUE_MAX
Definition: CC3000.hh:961
static const uint16_t HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY
Definition: CC3000.hh:798
int wlan_connect(Security type, str_P ssid, str_P bssid, str_P key)
Definition: CC3000.cpp:371
Socket * socket(Socket::Protocol proto, uint16_t port=0, uint8_t flag=0)
Definition: CC3000.cpp:315
static const uint16_t HCI_CMND_WLAN_IOCTL_SET_SCANPARAM
Definition: CC3000.hh:792
const class prog_str * str_P
Definition: Types.h:187
UnsolicitedEvent m_evnt_handler
Definition: CC3000.hh:670
static const uint16_t HCI_CMND_WLAN_DISCONNECT
Definition: CC3000.hh:786
OutputPin m_vbat
Definition: CC3000.hh:667
bool begin_P(str_P hostname, uint16_t timeout=5000)
Definition: CC3000.cpp:268
static const uint16_t HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS
Definition: CC3000.hh:833
static const uint16_t HCI_CMND_NVMEM_CREATE_ENTRY
Definition: CC3000.hh:878
static const uint16_t HCI_CMND_NVMEM_READ
Definition: CC3000.hh:865
uint16_t port() const
Definition: Socket.hh:78
static const uint32_t HCI_CMND_SETSOCKOPT_MAGIC
Definition: CC3000.hh:1035
static const uint16_t HCI_CMND_WLAN_IOCTL_DEL_PROFILE
Definition: CC3000.hh:820
static const uint16_t HCI_CMND_WLAN_IOCTL_ADD_PROFILE
Definition: CC3000.hh:814
static const uint16_t HCI_EVNT_BIND
Definition: CC3000.hh:1297
static const uint16_t HCI_EVNT_SIMPLE_LINK_START
Definition: CC3000.hh:1538
void dns_addr(uint8_t ip[4])
Definition: CC3000.hh:349
hci_cmnd_nvmem_read_t(uint8_t fileid, uint32_t offset, size_t length)
Definition: CC3000.hh:870
static const uint16_t HCI_EVNT_WLAN_UNSOL_CONNECT
Definition: CC3000.hh:1464
static const uint16_t HCI_CMND_NETAPP_PING_SEND
Definition: CC3000.hh:1102
static const uint16_t HCI_CMND_CONNECT
Definition: CC3000.hh:976
ExternalInterruptPin
Definition: ATmega1284P.hh:190
static const uint16_t HCI_EVNT_WLAN_UNSOL_SMART_CONFIG_DONE
Definition: CC3000.hh:1510
virtual int read(void *buf, size_t size)
Definition: CC3000.cpp:146
static const uint8_t HCI_DATA_SEND
Definition: CC3000.hh:1128
virtual int recv(void *buf, size_t len)
Definition: CC3000.cpp:223
void src(INET::addr_t &addr) const
Definition: Socket.hh:60
static const uint8_t HCI_DATA_NVMEM_WRITE
Definition: CC3000.hh:1161
#define swap(a, b)
Definition: Canvas.cpp:164
int read_sp_version(uint8_t &package_id, uint8_t &package_build_nr)
Definition: CC3000.cpp:594
static const uint16_t HCI_EVNT_WLAN_UNSOL_PING_REPORT
Definition: CC3000.hh:1496
static const uint16_t HCI_EVNT_WLAN_CONNECT
Definition: CC3000.hh:1182
static const uint16_t HCI_CMND_SOCKET
Definition: CC3000.hh:890
int simple_link_start(uint8_t src)
Definition: CC3000.cpp:544
uint32_t tcp_data_length
Definition: CC3000.hh:1133
static const uint16_t HCI_EVNT_NETAPP_PING_SEND
Definition: CC3000.hh:1407
#define bit_write(c, p, b)
Definition: Bits.h:38
static const int SOCKET_MAX
Definition: CC3000.hh:700
void event_handler(Event::Handler *handler)
Definition: HCI.hh:262
uint32_t tcp_data_length
Definition: CC3000.hh:1155
hci_cmnd_wlan_ioctl_del_profile_t(uint8_t index)
Definition: CC3000.hh:823
uint16_t BUFFER_MAX
Definition: CC3000.hh:691
static const uint16_t HCI_EVNT_LISTEN
Definition: CC3000.hh:1344
static const uint8_t HCI_DATA_RECV
Definition: CC3000.hh:1151
uint16_t protocol_family
Definition: CC3000.hh:912
hci_cmnd_accept_t(int hndl)
Definition: CC3000.hh:950
virtual int open(Protocol proto, uint16_t port, uint8_t flag)
Definition: CC3000.cpp:162
static const uint32_t HCI_CMND_WLAN_CONNECT_MAGIC
Definition: CC3000.hh:751
static const uint16_t HCI_EVNT_WLAN_UNSOL_DISCONNECT
Definition: CC3000.hh:1473
static const uint16_t HCI_EVNT_READ_BUFFER_SIZE
Definition: CC3000.hh:1547
hci_cmnd_connect_t(int hndl, uint8_t ip[4], int port)
Definition: CC3000.hh:984
virtual int listen()
Definition: CC3000.cpp:177
static const uint16_t HCI_EVNT_SEND
Definition: CC3000.hh:1307
virtual int available()
Definition: CC3000.cpp:127
Protocol proto() const
Definition: Socket.hh:69
static const uint32_t HCI_DATA_SEND_MAGIC
Definition: CC3000.hh:1129
static const uint16_t HCI_EVNT_WLAN_IOCTL_STATUSGET
Definition: CC3000.hh:1251
Driver m_socket[SOCKET_MAX]
Definition: CC3000.hh:703
uint8_t BUFFER_COUNT
Definition: CC3000.hh:694
static const uint16_t HCI_EVNT_WLAN_SET_EVENT_MASK
Definition: CC3000.hh:1241
static const uint16_t HCI_EVNT_PATCHES_REQ
Definition: CC3000.hh:1281
virtual int connect(uint8_t addr[4], uint16_t port)
Definition: CC3000.cpp:189
static const uint16_t HCI_EVNT_CONNECT
Definition: CC3000.hh:1354
uint8_t m_ip[4]
Definition: CC3000.hh:264
static const uint16_t HCI_CMND_LISTEN
Definition: CC3000.hh:960
int wlan_ioctl_statusget()
Definition: CC3000.cpp:446
hci_cmnd_wlan_ioctl_get_scan_results_t(uint32_t scan_timeout=0UL)
Definition: CC3000.hh:836
static const uint16_t HCI_CMND_NETAPP_PING_REPORT
Definition: CC3000.hh:1103
Definition: INET.hh:31
static const uint16_t HCI_CMND_GETHOSTBYNAME_MAGIC
Definition: CC3000.hh:1093
static const uint16_t DEFAULT_TIMEOUT
Definition: CC3000.hh:688
static const uint16_t HCI_EVNT_NETAPP_GETIPCONFIG
Definition: CC3000.hh:1434
uint16_t m_active_set
Definition: CC3000.hh:706
int wlan_set_event_mask(uint16_t mask)
Definition: CC3000.cpp:509
static const uint16_t HCI_EVNT_WLAN_IOCTL_GET_SCAN_RESULTS
Definition: CC3000.hh:1235
uint8_t m_buffer_avail
Definition: CC3000.hh:697
static const uint16_t HCI_EVNT_DATA_UNSOL_FREE_BUFF
Definition: CC3000.hh:1450
int read_buffer_size(uint8_t &count, uint16_t &size)
Definition: CC3000.cpp:579
Definition: HCI.hh:38
hci_cmnd_listen_t(int hndl)
Definition: CC3000.hh:965
static const uint16_t HCI_CMND_SELECT
Definition: CC3000.hh:999
uint8_t m_gateway[4]
Definition: CC3000.hh:682
Default clock rate.
Definition: SPI.hh:68
hci_data_send_t(int hndl, size_t size)
Definition: CC3000.hh:1135
int setsockopt(int hndl, int level, int optname, const void *optval, size_t optlen)
Definition: CC3000.cpp:624
static const uint16_t HCI_CMND_GETSOCKOPT
Definition: CC3000.hh:1061
CC3000(Board::DigitalPin cs, Board::ExternalInterruptPin irq, Board::DigitalPin vbat, SPI::Clock rate=SPI::DEFAULT_CLOCK)
Definition: CC3000.hh:279
virtual int close()
Definition: CC3000.cpp:171
void mac_addr(uint8_t mac[6])
Definition: CC3000.hh:339
size_t strlen_P(str_P s)
Definition: Types.h:254
int wlan_ioctl_del_profile(uint8_t index)
Definition: CC3000.cpp:492
hci_cmnd_wlan_connect_t(uint8_t type, str_P ssid, str_P bssid, str_P key)
Definition: CC3000.hh:765
int select(int hndls, uint32_t &readhnds, uint32_t &writehndls, uint32_t &errorhndls, uint32_t sec=0UL, uint32_t us=0UL)
Definition: CC3000.cpp:639
static const uint8_t HCI_DATA_SENDTO
Definition: CC3000.hh:1145
static const uint16_t HCI_CMND_NETAPP_SET_DEBUG_LEVEL
Definition: CC3000.hh:1107
static const uint16_t HCI_CMND_READ_BUFFER_SIZE
Definition: CC3000.hh:1122
uint8_t m_mac[6]
Definition: CC3000.hh:673
static const uint16_t HCI_EVNT_SETSOCKOPT
Definition: CC3000.hh:1376
static const uint16_t HCI_EVNT_READ_SP_VERSION
Definition: CC3000.hh:1273
virtual int accept()
Definition: CC3000.cpp:183
hci_cmnd_socket_t(int domain, int type, int protocol)
Definition: CC3000.hh:895
static const uint16_t HOSTNAME_MAX
Definition: CC3000.hh:1094
static const uint16_t HCI_EVNT_WLAN_IOCTL_SET_SCANPARAM
Definition: CC3000.hh:1202
bool socket_state(int hndl, bool state)
Definition: CC3000.hh:739