2019/0408

Dependencies:   mbed-os

Files at this revision

API Documentation at this revision

Comitter:
jovanat
Date:
Mon Jan 17 16:01:28 2022 +0000
Commit message:
Jovana Trajkovic 2019/0408

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
main1.txt Show annotated file Show diff for this revision Revisions of this file
main2.txt Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed_app.json Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 21b40f6bfff0 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jan 17 16:01:28 2022 +0000
@@ -0,0 +1,71 @@
+
+// Uvoz biblioteka
+#include "mbed-os"
+#include "platform/mbed_thread.h"
+#include "MQTTClientMbedOs.h"
+
+// Definisanje direktiva
+  
+#define VOLTAGE_SCALER                                                    3.3f 
+#define YIELD_TIMEOUT_MS                                                1000
+#define MAX_HEIGHT                                                        64
+#define MAX_WIDTH                                                        128
+
+// Deklaracija glavnih promenljivih
+
+TCPSOcket socket;
+MQTTClient client(&socket);
+MQTT::Message message;
+
+WiFiInterface *wifi;
+WiFiAccessPoint *ap = new WiFiAccessPoint[count];
+
+Adafruit_SSD1306_I2c myOled(i2c, rst, i2c_adress, height, width);
+I2C i2c(PB_14, PB_13);
+// Pisanje sporednih funkcija
+
+
+
+// Pisanje glavne funkcije
+
+int main()
+{
+   while(1)
+   {
+       
+      wifi = WiFiInterface:;get_default_instance();
+      
+      int count = wifi->scan(NULL, 0);
+      count wifi->scan(ap,count);
+      
+      wifi->connect(MBED_CONF_APP_SSID, MBED_CONF_APP_WIFI_PASSWORD, 
+      NSAPI_SECURITY_WPA_WPA2);
+      
+      socket.open(wifi);
+      socket.connect(hostname, port);
+      
+      MQTTPacket_connectData = MQTT_Packet_connectData_initializer;
+      data.MQTTVersion = 3;
+      data.clientID.cstring = "custom_client_ID";
+      client.connect((data));
+      
+      client.subscribe(topic_sub, MQTT::QOS2, messageArrived));
+      
+      char buf[100];
+      sprintf(buf, "V(POT1) = %1.2f\r\n", pot1*VOLTAGE_SCALER);
+      
+      message.qos = MQTT::QOS0;
+      message.retained = false;
+      message.dup + false;
+      message.payload = (void*)buf;
+      message.payloadlen = strlen(buf)+1;
+      client.publish(topic, message);
+      
+      client.yield(YIELD_TIMEOUT_MS);    
+    
+    
+    
+}
+
+
+}
\ No newline at end of file
diff -r 000000000000 -r 21b40f6bfff0 main1.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main1.txt	Mon Jan 17 16:01:28 2022 +0000
@@ -0,0 +1,145 @@
+
+// Uvoz biblioteka
+#include "mbed"
+#include "platform/mbed_thread.h"
+
+// Definisanje direktiva
+#define LED_ON                                                                 1
+#define LED_OFF                                                                0
+#define PERIOD_MS                                                            250
+
+// Deklaracija glavnih promenljivih
+BusOut display(SEL1, SEL2, a, b, c, d, e, f, g);
+DigitalIn button_sw1(BUTTON1);
+
+
+// Pisanje sporednih funkcija
+
+// Pisanje glavne funkcije
+
+int main()
+{
+   while(1)
+   {
+       
+       if(BUTTON1 = 1){
+           SEL1.write(0);
+           b.write(0);
+           c.write(0);  
+           
+           wait_ms(PERIOD);
+        if(BUTTON1 = 1){   
+           SEL1.write(0);
+           a.write(0);
+           b.write(0); 
+           d.write(0);
+           g.write(0); 
+           e.write(0);
+           
+            wait_ms(PERIOD);
+          }
+          if(BUTTON1 = 1){ 
+           SEL1.write(0);
+           a.write(0); 
+           b.write(0);
+           c.write(0); 
+           d.write(0);
+           g.write(0); 
+           
+            wait_ms(PERIOD);
+           }
+           if(BUTTON1 = 1){
+           SEL1.write(0);
+           f.write(0); 
+           g.write(0);
+           c.write(0); 
+           b.write(0);
+           
+            wait_ms(PERIOD);
+           }
+           if(BUTTON1 = 1){
+           SEL1.write(0);
+           a.write(0); 
+           b.write(0);
+           g.write(0); 
+           e.write(0);
+           d.write(0); 
+           
+            wait_ms(PERIOD);
+           }
+           if(BUTTON1 = 1){
+           SEL1.write(0);
+           f.write(0); 
+           e.write(0);
+           e.write(0); 
+           d.write(0);
+           c.write(0); 
+           
+      wait_ms(PERIOD);
+     }
+     if(BUTTON1 = 1){
+           SEL1.write(0);
+           a.write(0); 
+           b.write(0);
+           c.write(0); 
+           
+            wait_ms(PERIOD);
+          }
+          
+          if(BUTTON1 = 1){ 
+           SEL1.write(0);
+           a.write(0); 
+           b.write(0);
+           c.write(0); 
+           d.write(0);
+           e.write(0); 
+           f.write(0);
+           g.write(0); 
+           
+            wait_ms(PERIOD);
+           }
+           
+           if(BUTTON1 = 1){
+           SEL1.write(0);
+           a.write(0); 
+           b.write(0);
+           c.write(0); 
+           d.write(0);
+           f.write(0); 
+           
+            wait_ms(PERIOD);
+           
+           }
+           if(BUTTON1 = 1)
+           
+           SEL2.write(0);
+           c.write(0); 
+           b.write(0);
+           SEL1.write(0); 
+           a.write(0);
+           c.write(0); 
+           b.write(0);
+           d.write(0); 
+           e.write(0);
+           f.write(0); 
+          
+           wait_ms(PERIOD);
+           }
+           if(BUTTON1 = 1){
+             SEL1.write(0); 
+           a.write(0);
+           c.write(0); 
+           b.write(0);
+           d.write(0); 
+           e.write(0);
+           f.write(0); 
+          
+           }
+    
+    
+    
+    
+    
+    
+    
+}
\ No newline at end of file
diff -r 000000000000 -r 21b40f6bfff0 main2.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main2.txt	Mon Jan 17 16:01:28 2022 +0000
@@ -0,0 +1,22 @@
+// Uvoz biblioteka
+#include "mbed"
+
+// Definisanje direktiva
+#define LED_ON                                                                 1
+#define LED_OFF                                                                0
+#define PERIOD_MS                                                            250
+
+// Deklaracija glavnih promenljivih
+BusOut display(SEL1, SEL2, a, b, c, d, e, f, g);
+DigitalIn button_sw1(BUTTON1);
+AnalogIn pot1(A0);
+AnalogIn pot2(A1);
+
+PwmOut zujalica(PA_11);
+
+
+// Pisanje sporednih funkcija
+
+// Pisanje glavne funkcije
+
+int main()
\ No newline at end of file
diff -r 000000000000 -r 21b40f6bfff0 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Mon Jan 17 16:01:28 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/bLandais/code/mbed-os/#4c0e0edd4545
diff -r 000000000000 -r 21b40f6bfff0 mbed_app.json
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json	Mon Jan 17 16:01:28 2022 +0000
@@ -0,0 +1,4 @@
+
+#define MBED_CONF_APP_WIFI_SSID             cvele97
+#define MBED_CONF_APP_WIFI_PASSWORD                  ekonomskitigar2022
+#define NSAPI_SECURITY_WPA_WPA2
\ No newline at end of file