• Content count

  • Joined

  • Last visited

  1. Thanks folks. As it turns out I was using the wrong port. Its supposed to be 8443 instead of 443. With that in place, everything worked great! I also had to modify the PostData format to match what AWS needs it to be.
  2. I've been tinkering with AWS IoT in conjunction with CC3200 + Energia for a while now with varying degrees of success. The purpose of this post is using the RESTful API to update a "thing" status in the cloud. The code is listed below and I'm seeing some authentication errors. I was hoping someone can correct me if there are any errors in the way I'm using "client.ssConnect". I used a slightly modified WiFiClient.cpp and WiFiClient.h from here. I know its not a library issue since I'm able to connect using MQTT. char aws_endpoint[] = "xxxxxxxxxxxxxx.iot.us-east-1.amazonaws.com"; if (client.sslConnect(aws_endpoint, 443)) { Serial.println("Connected to server"); String PostData = "{\"value1\" : \"testValue\", \"value2\" : \"Hello\", \"value3\" : \"World!\" }"; request = "POST /things/"; request += thingname; request += "/shadow"; request += " HTTP/1.1"; Serial.print("Request:\t"); Serial.println(request); Serial.print("Post data:\t"); Serial.println(PostData); client.println(request); client.println("Host: "); client.println(aws_endpoint); //client.println(":443"); client.println("User-Agent: Energia/1.1"); client.println("Connection: close"); client.println("Content-Type: application/json"); client.print("Content-Length: "); client.println(PostData.length()); client.println(); client.println(PostData); client.println(); } else { Serial.println("Connection failed"); } Serial.println(); // Capture response from the server. (10 second timeout) long timeOut = 5000; long lastTime = millis(); while((millis()-lastTime) < timeOut) { // Wait for incoming response from server while (client.available()) { // Characters incoming from the server char c = client.read(); // Read characters Serial.write(c); } } Here is the output that I see: RootCA found! Client certificates found! Device ID is: 3250763216 Attempting to connect to WiFi network . Connected to WiFi network: ABCDEFGH Waiting for IP IP is: Connected to server Request: POST /things/MyCC3200/shadow HTTP/1.1 Post data: {\"value1\" : \"testValue\", \"value2\" : \"Hello\", \"value3\" : \"World!\" } HTTP/1.1 403 Forbidden content-type: application/json content-length: 91 date: Tue, 26 Jul 2016 11:46:59 GMT x-amzn-RequestId: 4d5388a9-e3c4-460a-b674-c3f971f3330d connection: Keep-Alive x-amzn-ErrorType: ForbiddenException: {"message":"Missing Authentication Token","traceId":"4d5388a9-e3c4-460a-b674-c3f971f3330d"}
  3. OK I got this figured. The challenge was switching back to AP once STA mode was activated. This code switches back to AP from whatever earlier mode was set. 'ssid' and 'wifipw' is the SSID and password defined for the AP. extern "C" { #include "utility/udma_if.h" } void switchToAP() { UDMAInit(); sl_Start(NULL, NULL, NULL); sl_WlanDisconnect(); sl_NetAppMDNSUnRegisterService(0, 0); sl_WlanRxStatStart(); sl_WlanSetMode(ROLE_AP); sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(ssid), (unsigned char *)ssid); unsigned char val = SL_SEC_TYPE_WPA; sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (unsigned char *)&val); sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(wifipw), (unsigned char *)wifipw); /* Restart Network processor */ sl_Stop(30); sl_Start(NULL, NULL, NULL); } To switch to the STA mode it was suggested in an earlier post to add WiFi._initialized = false; and WiFi._connecting = false; before doing a WiFi.being() but this was a hit and miss with my LP (rev 4.1). So this code switches it to STA mode. This is still not very reliable. Out of every 6 attempts to connect to a WiFi network, 1 attempt fails but here is the code anyway: void switchToSTA() { UDMAInit(); sl_Start(NULL, NULL, NULL); sl_WlanDisconnect(); sl_NetAppMDNSUnRegisterService(0, 0); sl_WlanRxStatStart(); sl_WlanSetMode(ROLE_STA); /* Restart Network processor */ sl_Stop(30); sl_Start(NULL, NULL, NULL); }
  4. Can anyone help? I've gotten it working but when a power cycle occurs the device starts up again in AP mode and it freezes. I have to reflash the service pack to get it working again.
  5. I know this is an old topic but I'm facing similar issues. I started up in AP mode, started a webserver and got the network credentials from the user. Switched to STA mode (using the fixes listed earlier in this post) and then connected to my local wifi network. Now this works great till a power cycle happens. When that happens, the CC3200 is supposed to start back up in AP mode and this is where it freezes. I have to reflash the service pack and then it goes back to the AP mode. Any solutions or ideas?
  6. Been working on an application that would: 1. Start the CC3200 and setup a webserver on on port 80. 2. The user connects to the WiFi networks created by the CC3200 and subsequently this webserver and enters their network credentials. 3. The CC3200 parses these credentials and stores it in a buffer called credential_buffer and the SSID and password are pointed to by accSSID and accPWD. I now want to use these credentials to connect to the users WiFi network and this is where I run aground. I swtich the CC3200 from the AP to STN mode using sl_WlanSetMode(ROLE_STA) but that does not seem to be working. Any ideas? The code is listed below: EDIT: I kinda found the solution here: http://forum.43oh.com/topic/6250-cc3200-cant-connect-to-wlan-after-being-set-as-ap/. However, this is not implemented in the recent Energia release. Any particular reason? // AP credentials. const char ssid[] = "MyCC3200AP"; const char wifipw[] = "password"; // Buffer for the new credentials acquired from the user. char credential_buffer[MAX_STORE_BUFFER_LEN]; // pointers to the actual credential values in the buffer char *accSSID; char *accPWD; boolean isConnected; boolean connectCompleteFlag = false; WiFiServer server(SERVER_PORT); // Server port is defined as 80 void setup() { byte counter; unsigned long t_time; // Begin serial comms. Serial.begin(115200); // Switch OFF all LaunchPad LEDs. pinMode(RED_LED, OUTPUT); digitalWrite(RED_LED, LOW); pinMode(GREEN_LED, OUTPUT); digitalWrite(GREEN_LED, LOW); pinMode(YELLOW_LED, OUTPUT); digitalWrite(YELLOW_LED, LOW); // Setup an AP. Serial.print("Setting up Access Point named: "); Serial.println(ssid); Serial.print("AP uses WPA and password is: "); Serial.println(wifipw); WiFi.beginNetwork((char *)ssid, (char *)wifipw); while (WiFi.localIP() == INADDR_NONE) { // print dots while we wait for the AP config to complete Serial.print('.'); delay(500); } Serial.println("AP active."); // start the web server on port 80 server.begin(); Serial.print("Webserver started on http://"); Serial.print( WiFi.localIP() ); Serial.print(" port: "); Serial.println(SERVER_PORT); Serial.println("\n"); // Let the user connect to the webserver and enter their network credentials. // We exit this loop with the credentials stored in credential_buffer while (!connectCompleteFlag) { connectClient(); // This function reads credentials from the user and stores them in the credential_buffer. } // Try to connect to the new WiFi network counter = 0; // Disconnect first, if currently connected sl_WlanDisconnect(); sl_WlanSetMode(ROLE_STA); Serial.print("Attempting to connect to WiFi network..."); // Open connection to WiFi WiFi.begin(accSSID, accPWD); while ( WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); counter++; if(counter==10) { break; } } if(counter==10) { Serial.println("\nUnable to connect to wifi"); isConnected = false; failure_state(); // This function just blinks the red LED at 1 sec intervals indefinitely. } Serial.println("\nConnected to wifi"); isConnected = true; // Try to get local IP Serial.print("Waiting for IP..."); t_time = millis(); while( WiFi.localIP() == INADDR_NONE ) { Serial.print("."); delay(500); if( ( millis() - t_time ) > 5000 ) { Serial.println("Timeout! Unable to get IP..."); failure_state(); } } // Print out local IP Serial.print("\nMy IP is: "); Serial.println( WiFi.localIP() ); }
  7. Thanks!
  8. My subnet is and my broadcast IP is I'm trying to broadcast UDP packets using this code but I'm not sure its working. When I open my IP and port on SocketTest, I don't see anything on the console. What am I missing? unsigned int localPort = 2390; char sendBuffer[] = {"pullingyourhairoutisnotthesolution"}; WiFiUDP BroadcastSendUDP; void sendBroadcastPacket() { IPAddress sendIP(192, 168, 1, 101); int counter = (sizeof(sendBuffer)/sizeof(sendBuffer[0])); BroadcastSendUDP.beginPacket(sendIP, localPort); for (int i=0; i<counter; i++) { BroadcastSendUDP.write(sendBuffer[i]); } BroadcastSendUDP.endPacket(); Serial.print("Packet sent: "); Serial.println(sendBuffer); Serial.println(); }
  9. Thanks Robert. This however, returns the profile security type as a positive number. Is there any way to get the actual SSID? @@Rei Vilo, Could you walk me through how you've implemented this in real-life? Perhaps share the code? I thought of setting up the CC3200 in AP mode when its out of the box, and then connecting to it and sending it WiFi creds of the local network. However, after this it would switch to Station mode and my problem is how would it recognize the mobile app that sent it the creds in the first place. Essentially how would it communicate with the app after becoming another device on the local wifi network.
  10. I've been reading up on this and I was wondering if there is a way to access an already stored WiFi connection profile? Also, is the smartconfig production ready? I remember reading somewhere that it was not quite there yet and that it would not work with some networks.
  11. Hi @@Fmilburn, I think I've got this working for now. There seem to be two variants for the encrytionType function and the default Energia example is calling the one which does not accept arguments: uint8_t WiFiClass::encryptionType() { return 0; } I changed the return value to verify this and it is indeed this one that is being called. The other variant accepts an integer value as an argument presumably the SSID number. I borrowed code sections from the ScanNetworks example. I compared the string returned by WiFi.encryptionType with the defined SSID and when they matched I printed out the encryption type. int numSsid = WiFi.scanNetworks(); if (numSsid == -1) { Serial.println("Couldn't get a wifi connection"); while (true); } for (int thisNet = 0; thisNet < numSsid; thisNet++) { if (strcmp(WiFi.SSID(thisNet),ssid) == 0) { Serial.print("Encryption: "); printEncryptionType(WiFi.encryptionType(thisNet)); } } The printEncryptionType function is the same one from ScanNetworks example.
  12. Hi, I've been following the ConnectWithWPA example to see the encryption type. However, it keeps showing me "Encryption Type: 0". What does this mean? Also what does the AUTO return value mean? (from this reference: http://energia.nu/reference/wifi/wifi_encryptiontype)
  13. Can anyone point me to the location of .bin files generated by Energia on compilation? Could I use these files for flashing through Uniflash?
  14. Is there a way to wake the CC3200 via WiFi? I read this post but can someone let me know if this is operational in the latest version of Energia?
  15. Yeah I've seen folks posting similar issues as well. Also, I tried the SmartConfig exmaple and the same thing happened. The app timed out. I had to reflash the service pack and then it worked.