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: EthernetNetIf HTTPServer RPCInterface mbed
Fork of HTTPServerExample by
HTTPServerExample.cpp
00001 #include "mbed.h" 00002 #include "EthernetNetIf.h" 00003 #include "HTTPServer.h" 00004 #include "RPCVariable.h" 00005 #include "RPCFunction.h" 00006 00007 DigitalOut led1(LED1, "led1"); 00008 DigitalOut led2(LED2, "led2"); 00009 DigitalOut led3(LED3, "led3"); 00010 DigitalOut led4(LED4, "led4"); 00011 00012 void setBufferedVariables(); 00013 00014 int Flag = 0; 00015 00016 float SwitchingFrequency = 10; 00017 float FundamentalFrequency = 20; 00018 float ModulationIndex = 30; 00019 float PhaseShift12 = 40; 00020 float PhaseShift23 = 50; 00021 float DeadTime = 60; 00022 00023 float SwitchingFrequencyBuff = SwitchingFrequency; 00024 float FundamentalFrequencyBuff = FundamentalFrequency; 00025 float ModulationIndexBuff = ModulationIndex; 00026 float PhaseShift12Buff = PhaseShift12; 00027 float PhaseShift23Buff = PhaseShift23; 00028 float DeadTimeBuff = DeadTime; 00029 00030 RPCVariable<int> RPCFlag(&Flag, "Flag"); 00031 00032 RPCVariable<float> RPCSwitchingFrequency(&SwitchingFrequency, "SwitchingFrequency"); 00033 RPCVariable<float> RPCFundamentalFrequency(&FundamentalFrequency, "FundamentalFrequency"); 00034 RPCVariable<float> RPCModulationIndex(&ModulationIndex, "ModulationIndex"); 00035 RPCVariable<float> RPCPhaseShift12(&PhaseShift12, "PhaseShift12"); 00036 RPCVariable<float> RPCPhaseShift23(&PhaseShift23, "PhaseShift23"); 00037 RPCVariable<float> RPCDeadTime(&DeadTime, "DeadTime"); 00038 00039 RPCVariable<float> RPCSwitchingFrequencyBuff(&SwitchingFrequencyBuff, "SwitchingFrequencyBuff"); 00040 RPCVariable<float> RPCFundamentalFrequencyBuff(&FundamentalFrequencyBuff, "FundamentalFrequencyBuff"); 00041 RPCVariable<float> RPCModulationIndexBuff(&ModulationIndexBuff, "ModulationIndexBuff"); 00042 RPCVariable<float> RPCPhaseShift12Buff(&PhaseShift12Buff, "PhaseShift12Buff"); 00043 RPCVariable<float> RPCPhaseShift23Buff(&PhaseShift23Buff, "PhaseShift23Buff"); 00044 RPCVariable<float> RPCDeadTimeBuff(&DeadTimeBuff, "DeadTimeBuff"); 00045 00046 00047 00048 LocalFileSystem fs("webfs"); 00049 00050 EthernetNetIf eth( 00051 IpAddr( 192, 168, 0, 128 ), // IP Address 00052 IpAddr( 255, 255, 255, 0 ), // Network Mask 00053 IpAddr( 192, 168, 0, 254 ), // Gateway 00054 IpAddr( 10, 41, 196, 60) // DNS 00055 ); 00056 HTTPServer svr; 00057 00058 int main() { 00059 Base::add_rpc_class<DigitalOut>(); 00060 00061 printf("Setting up...\n"); 00062 EthernetErr ethErr = eth.setup(); 00063 if(ethErr) 00064 { 00065 printf("Error %d in setup.\n", ethErr); 00066 return -1; 00067 } 00068 printf("Setup OK\n"); 00069 00070 FSHandler::mount("/webfs", "/files"); //Mount /webfs path on /files web path 00071 FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path 00072 00073 svr.addHandler<SimpleHandler>("/hello"); 00074 svr.addHandler<RPCHandler>("/rpc"); 00075 svr.addHandler<FSHandler>("/files"); 00076 svr.addHandler<FSHandler>("/"); //Default handler 00077 //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm 00078 00079 svr.bind(80); 00080 00081 printf("Listening...\n"); 00082 00083 00084 Timer tm; 00085 tm.start(); 00086 //Listen indefinitely 00087 while(true) 00088 { 00089 Net::poll(); 00090 if(Flag==1){ 00091 setBufferedVariables(); 00092 printf("Switching Freq is: %f\n", SwitchingFrequency); 00093 printf("Fundamental Freq is: %f\n", FundamentalFrequency); 00094 printf("Modulation Index is: %f\n", ModulationIndex); 00095 printf("Phase Shift 1-2 is: %f\n", PhaseShift12); 00096 printf("Phase Shift 2-3 is: %f\n", PhaseShift23); 00097 printf("Deadtime is: %f\n", DeadTime); 00098 Flag = 0; 00099 } 00100 /* 00101 if(tm.read()>.1) 00102 { 00103 led2=!led2; //Show that we are alive 00104 00105 00106 tm.start(); 00107 00108 }*/ 00109 } 00110 00111 return 0; 00112 00113 } 00114 00115 void setBufferedVariables(){ 00116 SwitchingFrequency = SwitchingFrequencyBuff; 00117 FundamentalFrequency = FundamentalFrequencyBuff; 00118 ModulationIndex = ModulationIndexBuff; 00119 PhaseShift12 = PhaseShift12Buff; 00120 PhaseShift23 = PhaseShift23Buff; 00121 DeadTime = DeadTimeBuff; 00122 printf("Daten schreiben\n"); 00123 }
Generated on Wed Jul 27 2022 23:22:11 by
1.7.2
