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
Revision 0:d02fb9a8c1ae, committed 2014-10-16
- Comitter:
- slawcio
- Date:
- Thu Oct 16 09:36:53 2014 +0000
- Child:
- 1:cbd681a86f90
- Commit message:
- W5100, DS18B20, SD card, SLCD
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DS1820.lib Thu Oct 16 09:36:53 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/DS1820/#4ce921bcd1b7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Thu Oct 16 09:36:53 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/mbed/code/SDFileSystem/#7b35d1709458
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SLCD.lib Thu Oct 16 09:36:53 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/SLCD/#ef2b3b7f1b01
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WIZnet_Library.lib Thu Oct 16 09:36:53 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/teams/IPN-ESIME-ZACATENCO/code/WIZnet_Library/#3c94b1ba5411
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config.cpp Thu Oct 16 09:36:53 2014 +0000 @@ -0,0 +1,1 @@ +//#include "config.h" \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config.h Thu Oct 16 09:36:53 2014 +0000 @@ -0,0 +1,1 @@ +//#include "main.h" \ No newline at end of file
--- /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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.h Thu Oct 16 09:36:53 2014 +0000
@@ -0,0 +1,213 @@
+#include "mbed.h"
+#include "WIZnetInterface.h"
+#define ECHO_SERVER_PORT 80
+
+
+//******************
+#define MULTIPLE_PROBES
+#define DATA_PIN PTC10 //1wire
+
+
+
+#include "SerialBase.h"
+#include "mbed.h"
+#include "DS1820.h"
+#include "SLCD.h"
+#include "Serial.h"
+#define MAX_PROBES 64
+#define BAUD (115200)
+#include "SDFileSystem.h"
+
+char zp;
+char zpp[1001];
+int tt;
+//int ustaw;
+char data[8];
+char data_all[600]; //="komarowski";
+int data_rozmiar=599;
+int data_rozmiar2=599;
+int lenght;
+char zzpp[1001];
+
+
+DigitalOut myled(LED1);//PTD5
+DigitalOut myled2(LED2); //PTE29
+DigitalOut SD_SEL(PTA12);
+
+DigitalIn sw1(PTC3); //if(sw1) Release else Press
+DigitalIn sw3(PTC12); //while(sw3); wait for Press
+//DigitalIn sw4(PTD5);//dioda czerwona
+//DigitalIn sw5(PTE29);//dioda czerwona
+
+SLCD slcd;
+DS1820* probe[MAX_PROBES];
+
+
+SPI spi(PTD6, PTD7, PTD5); // mosi, miso, sclk
+WIZnetInterface eth(&spi, PTD4, PTA20); // spi, cs, reset
+SDFileSystem sd(PTD6, PTD7, PTD5, PTA4, "sd"); // MOSI, MISO, SCLK, SSEL
+
+Serial pc(PTA2,PTA1);
+DigitalOut led(PTB0);
+
+char a[]={"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n"};
+char aa[]={"HTTP/1.0 200 OK\r\nContent-Type: image/jpeg\r\nPragma: no-cache\r\n"};
+//char aa[]={"HTTP/1.0 200 OK\r\nContent-Type: image/jpg\r\nPragma: no-cache\r\n\r\n"};
+char b[]={"<html>\r\n<body>\r\n"};
+char bb[]={"<html>\r\n<body>\r\n"};
+//char ab[]={"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n"};
+//char b[]={"<meta http-equiv=refresh content=1>"};
+//char b[]={"<html>\r\n<body>\r\n"};
+char c[]={"<body bgcolor=\"green\">"};
+char c1[]={"<body bgcolor=\"000ff0\"></body>\r\n"};
+char d[]={"<H2>Test W5100 i DS18b20</H2>"};
+char e[]={"<form action=\"http://10.192.144.204/d\"><input type=\"submit\" value=\"Wylacz LED2\" /></form>"};
+char f[]={""};
+char g[]={"<form action=\"http://10.192.144.204/c\"><input type=\"submit\" value=\"Wlacz LED 2\" /></form>"};
+char h[]={"<H1>__________</H1>"};
+char i[]={"<form action=\"http://10.192.144.204/bb\"><input type=\"submit\" value=\"Wylacz LED1\" /></form>"};
+char j[]={"_"};
+char k[]={"<form action=\"http://10.192.144.204/aa\"><input type=\"submit\" value=\"Wlacz LED1\" /></form>"};
+char l[]={"<form action=http://10.192.144.204 method=post onsubmit><input type=text name=tekst /><input type=submit value=OK /></form>"};
+char m[]={"Temp"};
+//if (this.tekst2.value == '') { alert('Zanim wyślesz formularz, musisz wypełnić pole tekstem!'); return false }><input type=text name=tekst /><input type=submit value=OK /></form>"};
+//char g[]={"<FONT FACE=\"Arial\" SIZE=\"8\" COLOR=\"FF0000\">"};
+//char w[]={"<meta http-equiv=\"refresh\" content=\"10; url=/\">\r\n"};
+//char g[]={"<center><h2>Tutaj jestes -01 :)</h2>\r\n"};
+//char h[]={"<center><div STYLE=\"position:absolute;bgcolor:black; top:100px; left:200px;width:54px\">"};
+//char i[]={"<center><h2>Tutaj jestes :)</h2>\r\n"};
+//char s[]={"Content-Type: text/html\r\n"};
+char t[]={"Connection: close\r\n\r\n"};
+//char u[]={"Refresh content=5\r\n\r\n"};
+//char u[]={"<meta http-equiv=refresh content=1>"};
+//char v[]={"<!DOCTYOE HTML>\r\n"};
+//char y[]={"<html>\r\n"};
+
+
+char paq_en[128];
+
+
+void temperatura_f()
+{
+
+ int num_devices = 0;
+ while(DS1820::unassignedProbe(DATA_PIN))
+ {
+ probe[num_devices] = new DS1820(DATA_PIN);
+ num_devices++;
+ if (num_devices == MAX_PROBES)
+ break;
+ }
+}
+
+
+
+void odczyt_z_SD(TCPSocketConnection client, int ustaw)
+{
+ FILE *zw;
+ if(strstr(data_all, "zmiana")!=0)
+ zw = fopen("/sd/index_old.htm","r");
+ else
+ zw = fopen("/sd/index.htm","r");
+
+ if(zw==NULL)
+ {
+ printf("plik jest pusty, lub nie istnieje");
+ }
+ zp=0;
+ tt=0;
+
+ while(1) // aż napotka pusty znak
+ {
+ zp=fgetc(zw); // czytanie z pliku
+ if(feof(zw))//wychodzi z pętli gdy napotka nie zapisaną komórkę
+ break;
+
+ zpp[tt]=zp;
+ tt++;
+ if (tt==1000)
+ {
+ if (ustaw==1)
+ {
+ client.send(zpp,1001);
+ //zpp[1000]=0;
+ // printf("\r\n Wyslal \r\n %s",zpp);
+ }
+ else if (ustaw==2)
+ {
+ printf("\r\n Wyslal \r\n %s",zpp);
+ }
+
+ zpp[0]=0;//zerowanie tablicy
+ tt=0;
+ }
+ }
+
+ // tt=0;
+ zpp[tt]=0;
+ if (ustaw==1)
+ {
+ client.send(zpp,tt);
+ // printf("\n Doslal \r\n %s",zpp);
+ }
+ else if (ustaw==2)
+ {
+
+
+ printf("\n Doslal \r\n %s",zpp);
+ }
+
+ zpp[0]=0;//zerowanie tablicy
+
+ fclose(zw);
+
+}
+
+void diody()
+{
+
+ //zmiena dla funkcji POST
+ printf("%s ",a);
+ if (strstr(data_all,"komarowski") !=0)
+ {
+ myled2=0;
+ }
+ else if (strstr(data_all,"wotlinski") !=0)
+ {
+ myled2=1;
+ }
+ else if (strstr(data_all,"obojski") !=0)
+ {
+ myled2=!myled2;
+ }
+
+ //zmienne dla funkcji GET
+
+ if (data_all[6]=='a')
+ {
+ myled=0;
+ pc.printf("\r\n Myled=0");
+ }
+ else if (data_all[6]=='b')
+ {
+ myled=1;
+ pc.printf("\r\n Myled=1");
+ }
+
+ if (data_all[5]=='c')
+ {
+ myled2=0;
+ pc.printf("\r\n Myled2=0");
+ }
+ else if (data_all[5]=='d')
+ {
+ myled2=1;
+ pc.printf("\r\n Myled2=1");
+ }
+
+
+}
+
+
+
+//*******załącza i wyłącza diody
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Oct 16 09:36:53 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file