I'm trying to build a TCP server on Arduino and I use the library for the CC3000 WiFi module (Sparkfun) I am doing. Utility / code socket.h code snippet I have to set sck_addr.sin_addr but there is lack of inset_eeton function in these libraries. I have tried the DNS library from the RDIN ethernet library (defined INET_ATON in it), but inet_aton was still not recognized.
/ ***************************** ** * hardware connection: Mega pin CC3000 board function + 5V VCC or + 5V 5V GND GND GND 2 INT Interrupt 35 select N Wi-Fi enabled 53 CS SPI chip 51 MOSI SPI MOSI 50 MISO SPI MISO 52 SCK SPI clock ** ***** ********************************************************************************************* Include ****************** SFE_CC3000.h & gt; # Include & lt; Utility / socket H & gt; # Include & lt; Ethernet. H & gt; # Include & lt; Dns.h & gt; // Pins #define CC3000_INT need to be 2 // interrupt pin (D2 / D3) #define CC3000_EN 35 // any digital pin #define CC3000_CS pin 10 53 // favorite Uno // connection info # IP_ADDR_LEN length byte 4 defined // IP address length #define MAC_ADDR_LEN 6 // bytes #define localhost 2130706433 length of the MAC address // to 127.0.0.1 // be used 5100 // port long #define pORT Constant ap_ssid four [] = "HTC"; // ASPID ap-password of network characters [] = "123456789"; // Network's unsigned integer password ap_security = WLAN_SEC_WPA2; // Network security unsigned int timeout = 30000; // milliseconds // constant four static_ip_adder [] = "0.0.0.0"; Sockaddr_in sck_addr, client_addr; Int client_addr_len; // global variable SFE_CC3000 wifi = SFE_CC3000 (CC3000_INT, CC3000_EN, CC3000_CS); Zero setup () {ConnectionInfo connection_info; // initial serial port serial.bjin (115200); Serial.println (); Serial.println ("---------------------------------"); Serial.printline ("QuadCopter - BSD Socket Test"); Serial.println ("---------------------------------"); // Start CC 3000 (Configure SPI Communications) if (wifi.init ()) {Serial.println ("CC3000 Completed"); } Else {Serial.println ("something went wrong during CC3000 init!"); } // Using DHCP Serial Print ("Connecting:"); Serial.println (ap_ssid); If (! Wifi.connect (ap_ssid, ap_security, ap_password, timeout)) {serial.println ("error: could not connect to ap"); } // Print the connection details if (! Wifi.getConnectionInfo (connection_info)) {Serial.println ("Error: Could not get connection details"); } Else {Serial.println ("Connect!"); Serial.println (); } Mammetset (& amp; sck_addr, 0, sizeof sck_addr); Sck_addr.sin_family = AF_INET; Inet_aton ("127.0.0.1", and sck_addr.sin_addr); Sck_addr.sin_port = htons (PORT); Int sck = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); // disconnect // if (wifi.disconnect ()) {// serial.println ("disconnected"); //} else {// serial.println ("error: could not be disconnected from the network"); }} Zero loop () {// nothing delay (1000); }
typedef struct _in_addr_t {unsigned long s_addr; Inet_aton ()} // load with in_addr; Typedef struct _sockaddr_t {signed minor int sa_family; Unsigned char signature [14]; } Sokadar; Typedef struct _sockaddr_in_t {short sin_family; Eg eg Unsigned minor sin_port; Eg eg Htons (3490) in_addr sin_addr; // View the structure in_addr, sin_zero around [8]; // If you want, then do it zero sockaddr_in;
Comments
Post a Comment