Shantam Raj
Published © LGPL

Obtaining data via CC3200 behind Squid Proxy Server

Talking on unrestricted internet is easy using CC3200 but what about if you are behind a proxy server? Things get a little messy!!

BeginnerProtip1 hour943
Obtaining data via CC3200 behind Squid Proxy Server

Things used in this project

Story

Read more

Code

Code snippet #1

Plain text
#ifndef __CC3200R1M1RGC__
#include <SPI.h>
#endif
#include <WiFi.h>

// your network name also called SSID
char ssid[] = "******";
// your network password
char password[] = "*****;

// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
IPAddress server(202,141,80,24);  // numeric IP for Google (no DNS)
WiFiClient client;

void setup() {
//Initialize serial and wait for port to open:
Serial.begin(115200);

// attempt to connect to Wifi network:
Serial.print("Attempting to connect to Network named: ");
// print the network name (SSID);
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED) {
// print dots while we wait to connect
Serial.print(".");
delay(300);
}

Serial.println("\nYou're connected to the network");
Serial.println("Waiting for an ip address");

while (WiFi.localIP() == INADDR_NONE) {
// print dots while we wait for an ip addresss
Serial.print(".");
delay(300);
}

Serial.println("\nIP Address obtained");
printWifiStatus();

Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
if (client.connect(server, 3128)) {
Serial.println("connected to server");
// Make a HTTP request:
client.println("GET /hello.html HTTP/1.1");
client.println("Host: energia.nu");
client.println("Connection: close");
client.println();
}
}

void loop() {
// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
char c = client.read();
Serial.write(c);
}

// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting from server.");
client.stop();

// do nothing forevermore:
while (true);
}
}


void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}

Code snippet #2

Plain text
client.println("GET http://energia.nu/hello.html HTTP/1.1");

Code snippet #3

Plain text
client.println("GET http://energia.nu/hello.html HTTP/1.1");
client.println("Host: energia.nu");
client.println("Proxy-Authorization: Basic your_base64_encoded_details_go_here");
client.println("Connection: close");
client.println();

Credits

Shantam Raj

Shantam Raj

3 projects • 11 followers
ECE Undergrad,Daydreamer & Maker. Electronics, Robotics & hardware hacking enthusiast. Die hard soccer fan. New found love = IoT

Comments