Ahmed Popović Benjamin Ramić Tviter Projekat

Dependencies:   ESP8266 mbed

Fork of TwitterProjekat by Ahmed Popović

Files at this revision

API Documentation at this revision

Comitter:
2016US_BenjaminRamic
Date:
Thu May 26 19:18:22 2016 +0000
Parent:
1:51391e2303d7
Commit message:
Ahmed Popovi?; Benjamin Rami?; Projekat US

Changed in this revision

Twitter.h Show annotated file Show diff for this revision Revisions of this file
WiFi.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 51391e2303d7 -r 907b2a247aaa Twitter.h
--- a/Twitter.h	Fri May 20 16:07:30 2016 +0000
+++ b/Twitter.h	Thu May 26 19:18:22 2016 +0000
@@ -26,9 +26,9 @@
         {
             char c;
             pc->scanf("%c", &c);
-            if(c == '\n')
+            if(c == '\n' || c == '\r')
             {
-                poruka[i+1] = '\0';
+                poruka[i] = '\0';
                 break;
             }
             
diff -r 51391e2303d7 -r 907b2a247aaa WiFi.h
--- a/WiFi.h	Fri May 20 16:07:30 2016 +0000
+++ b/WiFi.h	Thu May 26 19:18:22 2016 +0000
@@ -1,5 +1,6 @@
 #include "ESP8266.h"
 #include <string>
+#include <cstdlib>
 
 using namespace std;
 
@@ -29,23 +30,35 @@
         esp->RcvReply(rcv, 400);
         pc->printf("%s", rcv);
         
+        char velChar[10];
+        int ukupnaVelicina = 4 + kveri.length() + 35;
         wait(2);
-        strcpy(snd, "AT+CIPSEND=0,39");
+        strcpy(snd, "AT+CIPSEND=0,");
+        sprintf(velChar, "%d", ukupnaVelicina);
+        strcpy(snd+13, velChar);
+        //pc->printf("sad saljem: %s\r\n\r\n", snd);
         esp->SendCMD(snd);
         esp->RcvReply(rcv, 2048);
-        pc->printf("%s", rcv);
+        //pc->printf("%s", rcv);
         wait(2);
         
         
         strcpy(snd, "GET ");
         strcpy(snd + 4, kveri.c_str());
-        strcpy(snd + 4 + kveri.length(), " HTTP/1.1\r\nHost: liliumdev.com\r\n\r\n");
+        strcpy(snd + 4 + kveri.length(), " HTTP/1.1\r\nHost: liliumdev.com\r\n\r\n\0");
+        string stringSndBuffer = snd;
+        
+       /* pc->printf("U bufferu je: \"");
+        pc->printf("%s", snd); 
+        pc->printf("\", velicina svega je: %d, a nasa je %d\r\n", snd, stringSndBuffer.length(), ukupnaVelicina);*/
         esp->SendCMD(snd);
-        while(true)
+       /* while(true)
         {
             esp->RcvReply(rcv, 2048);
             pc->printf("%s", rcv);   
-        }
+        }*/
+        
+        return "";
     }        
         
     bool SetupModule()
diff -r 51391e2303d7 -r 907b2a247aaa main.cpp
--- a/main.cpp	Fri May 20 16:07:30 2016 +0000
+++ b/main.cpp	Thu May 26 19:18:22 2016 +0000
@@ -16,11 +16,12 @@
        
     while(1)
     {
-        printf("Unesite poruku: (max 140 karaktera)");
+        pc.printf("Unesite poruku: (max 140 karaktera): ");
         
         tvit.unesiPoruku();
         string kveri("/tvitmanijak/?q=" + tvit.urlEncode(tvit.dajPoruku()));
         wifi.GetPage(kveri);
+        pc.printf("\r\nTwitao!\r\n");
         wait(2);
     }
 }