Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DS1820 SDFileSystem SLCD WIZnet_Library mbed
Diff: main.cpp
- Revision:
- 0:d02fb9a8c1ae
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Oct 16 09:36:53 2014 +0000
@@ -0,0 +1,143 @@
+//w5100
+#include "main.h"
+
+//Serial pc(USBTX, USBRX); // tx, rx
+void baud (int baudrate = 115200);
+
+char wartosc[20];
+float temperatura;
+
+int x;
+
+//******************
+
+void f_ethernet_init(void);
+
+const char * IP_Addr = "10.192.144.204";
+const char * IP_Subnet = "255.255.252.0";
+const char * IP_Gateway = "10.192.147.254";
+
+
+
+int ret,dummy;
+int lv=1;
+bool status;
+
+int sw11;
+int sw33;
+
+
+
+
+
+//================= main =======================================================================
+
+int main()
+{
+ pc.baud(BAUD);
+ f_ethernet_init();
+ TCPSocketServer server;
+ TCPSocketConnection client;
+ server.bind(ECHO_SERVER_PORT);
+ server.listen();
+
+
+
+ odczyt_z_SD(client, 2); //2 wyslij na com zawartosc karty SD
+ temperatura_f();
+ pc.printf("\nEsperando conexion con cliente...\n");
+
+ while(lv)
+ {
+ lv=server.accept(client);
+ if(!lv)
+ {
+ pc.printf("Cliente conectado: %s\n", client.get_address());
+ }
+ else
+ {
+ wait(1);
+ }
+ }
+ client.receive(data,sizeof(data));
+ // pc.printf("Adres: %c",data);
+
+
+ while(1)
+ {
+ sw11=myled;
+ sw33=myled2;
+ probe[0]->convertTemperature(true, DS1820::all_devices);
+ slcd.Home();
+ slcd.printf("%3.1f",probe[0]->temperature());
+ pc.printf("\n\rTemperatura: %3.2f\r\n",probe[0]->temperature() );
+
+ data_all[0]=0;
+ while(1)
+ {
+ data_rozmiar2=client.receive(data_all,data_rozmiar);
+ pc.printf("\n\r Zmienna\n\r %s",data_all); // wysyła dane na com
+
+ if (data_rozmiar2<data_rozmiar)
+ {
+ data_all[data_rozmiar2]=0;
+ break;
+ }
+ }
+ diody(); // funkcja do sterowania diodami
+
+ //fotka(client,1); // wczytuje zdjecie i wysyła na ETH, na końcu czyszci tablice
+
+ client.send(a,sizeof(a)); //nagłowek htm
+ client.send(b,sizeof(b));
+ sprintf(paq_en,"<center><table border=10><tr><td><h1>%3.2f oC</h1></td></tr></table></center>",probe[0]->temperature());
+ client.send(paq_en,sizeof(paq_en));
+ sprintf(paq_en,"<center><table border=10><tr><td><h1>P1:[%d]____P2:[%i]</h1></td></tr></table></center>",sw33,sw11);
+ client.send(paq_en,sizeof(paq_en));
+
+ odczyt_z_SD(client, 1); //1 wysyła na ETH, 2 wysyła na COM, 3 wysyła na ETH i COM
+ client.send(t,sizeof(t));
+
+ client.Socket::~Socket();
+ server.bind(ECHO_SERVER_PORT);
+ server.listen();
+ server.accept(client);
+ }
+}
+
+
+
+void f_ethernet_init()
+{
+ uint8_t mac[]={0x00,0x08,0x0C,0x1C,0xAA,0xCA};
+ // mbed_mac_address((char *)mac);
+ pc.printf("\tIniciando Servidor Ethernet...\n\r");
+ wait(1);
+ ret = eth.init(mac, IP_Addr, IP_Subnet, IP_Gateway);
+ if(!ret)
+ {
+ pc.printf("Inicializado, MAC= %s\n\r",eth.getMACAddress());
+ }
+ else
+ {
+ pc.printf("Fallo comunicacion... Reinicie dispositivos...\n\r");
+ }
+ pc.printf("Conectando.");
+ wait(0.5);
+ pc.printf(".");
+ wait(0.5);
+ pc.printf(".\n\r");
+ wait(0.5);
+ ret = eth.connect();
+ if(!ret)
+ {
+ pc.printf("Conexion Establecida!\n\n\r");
+ wait(1);
+ pc.printf("IP=%s\n\rMASK=%s\n\rGW=%s\n\r",eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
+ }
+ else
+ {
+ pc.printf("Fallo conexion... Reinicie dispositivos...\n\r");
+ }
+}
+
\ No newline at end of file