- Added messages

Fork of WiflyInterface by Damien Frost

Revision:
40:2bbc4753b23f
Parent:
39:2b8018d66b68
Child:
41:598257b3e319
--- a/Wifly/Wifly.cpp	Sun May 21 21:33:51 2017 +0000
+++ b/Wifly/Wifly.cpp	Mon May 22 11:51:24 2017 +0000
@@ -33,7 +33,7 @@
 Wifly * Wifly::inst;
 Serial * Wifly::SerialCommPort;
 
-Wifly::Wifly(   PinName tx, PinName rx, PinName _reset, PinName tcp_status, const char * ssid, const char * phrase, Security sec, Serial* messagesPort):
+Wifly::Wifly(   PinName tx, PinName rx, PinName _reset, PinName tcp_status, const char * ssid_input, const char * phrase_input, Security sec, Serial* messagesPort):
     wifi(tx, rx), reset_pin(_reset), tcp_status(tcp_status), buf_wifly(1024)
 {
     // Set the default baud rate:
@@ -43,13 +43,13 @@
     state.sec = sec;
 
     // change all ' ' in '$' in the ssid and the passphrase
-    strcpy(this->ssid, ssid);
-    for (int i = 0; i < strlen(ssid); i++) {
+    strcpy(this->ssid, ssid_input);
+    for (int i = 0; i < strlen(ssid_input); i++) {
         if (this->ssid[i] == ' ')
             this->ssid[i] = '$';
     }
-    strcpy(this->phrase, phrase);
-    for (int i = 0; i < strlen(phrase); i++) {
+    strcpy(this->phrase, phrase_input);
+    for (int i = 0; i < strlen(phrase_input); i++) {
         if (this->phrase[i] == ' ')
             this->phrase[i] = '$';
     }
@@ -61,6 +61,24 @@
     DBG(SerialCommPort, "Wifly Constructed");
 }
 
+void Wifly::setSsid(char * ssid_input){
+    strcpy(this->ssid, ssid_input);
+    for (int i = 0; i < strlen(ssid_input); i++) {
+        if (this->ssid[i] == ' ')
+            this->ssid[i] = '$';
+    }
+    return;
+}
+
+void Wifly::setPhrase(char * phrase_input){
+    strcpy(this->phrase, phrase_input);
+    for (int i = 0; i < strlen(phrase_input); i++) {
+        if (this->phrase[i] == ' ')
+            this->phrase[i] = '$';
+    }
+    return;
+}
+
 void Wifly::setBaud(int baudrate)
 {
     char cmd[28];
@@ -482,7 +500,8 @@
     if (!callback)
         wifi.attach(NULL);
     else
-        wifi.attach(this, &Wifly::handler_rx);
+        wifi.attach(this, &Wifly::handler_rx, Serial::RxIrq);
+        //wifi.attach(NULL);
 }