Jump to content
43oh

silverado

Members
  • Content Count

    8
  • Joined

  • Last visited

Reputation Activity

  1. Like
    silverado reacted to spirilis in CC3200 & SSL   
    It is probably possible but it would require retuning & testing of the Energia library code, probably only allow 1 socket, reduce buffer sizes per socket, etc. Probably doable.
     
    Sent from my Galaxy Note II with Tapatalk 4
  2. Like
    silverado got a reaction from spirilis in CC3200 & SSL   
    I'm really grateful for your SSL update!

    I've been trying to figure out how to send an email directly from my MSP430F5529/CC3100 boosterpack using a gmail SMTP server, and had come to the conclusion that it's not possible without an SSL connection. I was about to give up until I saw your post here.
     
    Having seen it, I updated my library (/msp430 instead of /cc3200) with the latest WiFiClient (cpp and h) from github and was able to write some code that successfully connected securely to the gmail server. Woohoo! Whatever may still be missing from your update doesn't appear to prevent my scenario from working, and I can now send an email directly from the CC3100 with a secure smtp connection authenticated against my gmail account. Outstanding, and thanks again!!

    In case it useful, here's my code:
    #include <WiFi.h>#include <SPI.h>#include <WiFiClient.h>#include <WiFiServer.h>const char ssid[] = "ssid";const char wifipw[] = "wifipswd";const char smpt_server[] = "smtp.gmail.com";const int smpt_port = 465;const char userid[] = "myuserid"; // gmail userid const char pswd[] = "mypassword";// gmail password const char mailTo[] = "<myuserid@gmail.com>";const char mailFrom[] = "<myuserid@gmail.com>";char base64_userid[64]; char base64_pswd[64];void setup(){ uint32_t msave; int i; Serial.begin(115200); delay(2000); Serial.println("WiFi:"); WiFi.begin((char *)ssid, (char *)wifipw); while (WiFi.status() != WL_CONNECTED) { Serial.print('.'); delay(150); } Serial.println(); Serial.println("Connected- waiting for IP"); msave = millis(); while (WiFi.localIP() == INADDR_NONE) { Serial.print('.'); delay(150); if (millis()-msave > 5000) { Serial.println("Timeout waiting for IP; disconnecting & reconnecting."); WiFi.disconnect(); WiFi.begin((char *)ssid, (char *)wifipw); msave = millis(); } } Serial.print(" done; IP="); IPAddress my_ip = WiFi.localIP(); Serial.println(my_ip); // encode the userid and password i = base64_encode(userid, (sizeof userid)-1, base64_userid, sizeof base64_userid); base64_userid[i] = '\0'; i = base64_encode(pswd, (sizeof pswd)-1, base64_pswd, sizeof base64_pswd); base64_pswd[i] = '\0'; Serial.print("userid "); Serial.print(userid); Serial.print(", base64: "); Serial.println(base64_userid); //Serial.print("password "); //Serial.print(pswd); //Serial.print(", base64: "); //Serial.println(base64_pswd);}void loop(){ char buf[1025]; int i; size_t total = 0; WiFiClient smtp; Serial.println("Attempting SSL connection to smtp server"); if (smtp.sslConnect(smpt_server, smpt_port)) { Serial.println("Connected"); getResponse(&smtp); Serial.println("Sending EHLO"); smtp.println("EHLO"); getResponse(&smtp); Serial.println("Sending AUTH LOGIN"); smtp.println("AUTH LOGIN"); getResponse(&smtp); Serial.println("Sending userid"); smtp.println(base64_userid); getResponse(&smtp); Serial.println("Sending pswd"); smtp.println(base64_pswd); getResponse(&smtp); Serial.println("Sending MAIL FROM"); smtp.print("MAIL FROM:"); // must be first smtp.println(mailFrom); getResponse(&smtp); Serial.println("Sending RCPT TO"); smtp.print("RCPT TO:"); smtp.println(mailTo); getResponse(&smtp); Serial.println("Sending DATA"); smtp.println("DATA"); getResponse(&smtp); Serial.println("Sending actual data..."); smtp.print("From: CC3100"); smtp.println(mailFrom); smtp.println("Subject: Wow!!"); smtp.print("To:"); smtp.println(mailTo); smtp.println(" "); smtp.println("Is this cool or what!"); smtp.println(" "); smtp.println("(Email sent directly from the TI CC3100 WiFi device)"); smtp.println("."); delay(1000); getResponse(&smtp); Serial.println("Sending QUIT"); smtp.println("QUIT"); getResponse(&smtp); Serial.println("Done"); delay(100000000); // dont really want to do it again! } else { Serial.println("Error connecting to smtp server"); }}/** * Read response * If not available immediately then wait a bit. If still not available, return */void getResponse(WiFiClient* client) { const int TIME_INCR = 10; const int TIME_MAX = 10000; char buf[1025]; int i; int time_elapsed = 0; WiFiClient smtp = *client; if (smtp.connected()) { while (!smtp.available() && time_elapsed < TIME_MAX) { delay(TIME_INCR); time_elapsed += TIME_INCR; } if (!smtp.available()) { Serial.print("No response ("); Serial.print(TIME_MAX); Serial.println("ms)"); return; } else { Serial.print("Server response ("); Serial.print(time_elapsed); Serial.println("ms):"); while (smtp.available()) { i = smtp.read((uint8_t *)buf, 1024); buf[i] = '\0'; Serial.print(buf); delay(100); } } } else { Serial.println("Server is not connected"); }}/* * The following is based largely on original code courtesy of Ren
  3. Like
    silverado reacted to spirilis in CC3200 & SSL   
    I got basic outbound SSL sockets working.  Wasn't that hard, although the File Writing process for uploading a root CA certificate doesn't seem to work so I axed it...
     
    Replace your energia-0101E0013/hardware/cc3200/libraries/WiFi/WiFiClient.cpp and WiFiClient.h files with these:
    https://raw.githubusercontent.com/energia/Energia/issue_472/hardware/cc3200/libraries/WiFi/WiFiClient.cpp
    and
    https://raw.githubusercontent.com/energia/Energia/issue_472/hardware/cc3200/libraries/WiFi/WiFiClient.h
     
    Syntax is just .sslConnect(hostname, port) or .sslConnect(IPAddress, port).
     
    Example sketch:
    #include <WiFiUdp.h> #include <WiFi.h> #include <WiFiClient.h> #include <WiFiServer.h> const char ssid[] = "myWifiSSID"; const char wifipw[] = "blahblahblah"; void setup() { uint32_t msave; Serial.begin(115200); delay(2000); Serial.println("WiFi:"); WiFi.begin((char *)ssid, (char *)wifipw); while (WiFi.status() != WL_CONNECTED) { Serial.print('.'); delay(150); } Serial.println(); Serial.println("Connected- waiting for IP"); msave = millis(); while (WiFi.localIP() == INADDR_NONE) { Serial.print('.'); delay(150); if (millis()-msave > 5000) { Serial.println("Timeout waiting for IP; disconnecting & reconnecting."); WiFi.disconnect(); WiFi.begin((char*)ssid); msave = millis(); } } Serial.print(" done; IP="); IPAddress my_ip = WiFi.localIP(); Serial.println(my_ip); } void loop() { char buf[1025]; int i; size_t total = 0; WiFiClient http; Serial.println("Attempting HTTPS request-"); if (http.sslConnect("www.ti.com", 443)) { Serial.println("Connected to www.ti.com- submitting GET / HTTP/1.0 request"); http.print("GET / HTTP/1.0\r\nHost: www.ti.com\r\n\r\n"); Serial.println("Waiting for response..."); while (http.connected()) { while (!http.available()) delay(50); i = http.read((uint8_t *)buf, 1024); buf[i] = '\0'; total += i; //Serial.print(buf); } Serial.println("Disconnected by remote host."); Serial.print(total); Serial.println(" bytes read in total."); delay(100000000); } else { Serial.println("Error connecting to www.ti.com"); } } Output from serial monitor:
    WiFi: .. Connected- waiting for IP ............... done; IP=192.168.0.195 Attempting HTTPS request- Connected to www.ti.com- submitting GET / HTTP/1.0 request Waiting for response... Disconnected by remote host. 87527 bytes read in total.
  4. Like
    silverado reacted to Lgbeno in How to drive multiple LEDs without sacrificing brightness   
    Shift register is not required, it is just a nice cheap method for driving many LEDs with a few pins of your microcontroller. The other nice thing is that the output pins of these logic devices have very robust drivers which can source or sink 20ma. For a shift reg though you will need a resistor to limit the amount of current through the led so 16 LEDs means also 16 resistors in parallel. Like I was saying before if you use a higher voltage then you can hook up the LEDs in series and save some resistors but a High enough voltage is required. About 2v per led if wired in series.
     
    Since the device is battery powered, I would recommend 2 alkaline cells and then that ti part suggested earlier in the thread. That part includes current control for each led so resistors are not required and you can use the low voltage supply provided by the batteries. Very easy to bread board with dips and th LEDs too. Good luck!
  5. Like
    silverado reacted to RobG in How to drive multiple LEDs without sacrificing brightness   
    Here are some code examples which can be used for G2211
×
×
  • Create New...