| 
						
						
							
								
							
						
						
					 | 
					@ -7,20 +7,18 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					#include "web_interface.h" | 
					 | 
					 | 
					#include "web_interface.h" | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					#include <SmingCore/SmingCore.h> | 
					 | 
					 | 
					#include <SmingCore/SmingCore.h> | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					
 | 
					 | 
					 | 
					#include <SmingCore/Network/WebConstants.h> | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					//TODO remove this
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					#include "ads101x.h" | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					namespace rijnfel { | 
					 | 
					 | 
					namespace rijnfel { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					cWebInterface *cWebInterface::s_instance = 0; | 
					 | 
					 | 
					cWebInterface *cWebInterface::s_instance = 0; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					static void onIndex(HttpRequest &request, HttpResponse &response) { | 
					 | 
					 | 
					static void onIndex(HttpRequest & i_request, HttpResponse & i_response) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						cWebInterface::GetInstance()->OnIndex(request, response); | 
					 | 
					 | 
						cWebInterface::GetInstance()->OnIndex(i_request, i_response); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					static void onRefresh(HttpRequest &request, HttpResponse &response) { | 
					 | 
					 | 
					static void onRefresh(HttpRequest & i_request, HttpResponse & i_response) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						cWebInterface::GetInstance()->OnRefresh(request, response); | 
					 | 
					 | 
						cWebInterface::GetInstance()->OnRefresh(i_request, i_response); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					static void onConfiguration(HttpRequest &request, HttpResponse &response) { | 
					 | 
					 | 
					static void onConfiguration(HttpRequest &request, HttpResponse &response) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -34,116 +32,134 @@ static void onConfiguration_json(HttpRequest &request, HttpResponse &response) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					cWebInterface::cWebInterface() : | 
					 | 
					 | 
					cWebInterface::cWebInterface() : | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							m_serverStarted(false) { | 
					 | 
					 | 
							m_serverStarted(false) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						for (int i = 0; i < 4; i++) { | 
					 | 
					 | 
						for (int i = 0; i < 4; i++) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							m_adc_value[i] = 0; | 
					 | 
					 | 
							m_adc_value_average[i] = 0; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						// Integer requires 8 digits, and one for the comma
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						m_jsonBuffer = new char[RAW_SAMPLES * 8 + RAW_SAMPLES * 2]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						if (m_jsonBuffer == NULL) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							Serial.print("Not enough ram"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						// TODO Auto-generated constructor stub
 | 
					 | 
					 | 
						// TODO Auto-generated constructor stub
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					void onFile(HttpRequest &request, HttpResponse &response) { | 
					 | 
					 | 
					void onFile(HttpRequest & i_request, HttpResponse & i_response) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						String file = request.getPath(); | 
					 | 
					 | 
						String file = i_request.getPath(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						if (file[0] == '/') | 
					 | 
					 | 
						if (file[0] == '/') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							file = file.substring(1); | 
					 | 
					 | 
							file = file.substring(1); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						if (file[0] == '.') | 
					 | 
					 | 
						if (file[0] == '.') | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							response.forbidden(); | 
					 | 
					 | 
							i_response.forbidden(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						else { | 
					 | 
					 | 
						else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							response.setCache(86400, true); // It's important to use cache for better performance.
 | 
					 | 
					 | 
							i_response.setCache(86400, true); // It's important to use cache for better performance.
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
							response.sendFile(file); | 
					 | 
					 | 
							i_response.sendFile(file); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					void cWebInterface::Start() { | 
					 | 
					 | 
					void cWebInterface::StartServer() { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						if (m_serverStarted) | 
					 | 
					 | 
						if (m_serverStarted) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							return; | 
					 | 
					 | 
							return; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						server.addPath("/", onIndex); | 
					 | 
					 | 
						m_server.addPath("/", onIndex); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						server.addPath("/state", onRefresh); | 
					 | 
					 | 
						m_server.addPath("/state", onRefresh); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						server.addPath("/config", onConfiguration); | 
					 | 
					 | 
						m_server.addPath("/config", onConfiguration); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						server.addPath("/config.json", onConfiguration_json); | 
					 | 
					 | 
						m_server.addPath("/config.json", onConfiguration_json); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						server.setDefaultHandler(onFile); | 
					 | 
					 | 
						m_server.setDefaultHandler(onFile); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						server.listen(80); | 
					 | 
					 | 
						m_server.listen(80); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					void cWebInterface::Stop() { | 
					 | 
					 | 
					void cWebInterface::StopServer() { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						if (!m_serverStarted) | 
					 | 
					 | 
						if (!m_serverStarted) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							return; | 
					 | 
					 | 
							return; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						m_serverStarted = false; | 
					 | 
					 | 
						m_serverStarted = false; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					void cWebInterface::OnIndex(HttpRequest &request, HttpResponse &response) { | 
					 | 
					 | 
					void cWebInterface::OnIndex(HttpRequest &i_request, HttpResponse & i_response) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						response.setCache(86400, true); // It's important to use cache for better performance.
 | 
					 | 
					 | 
						i_response.setCache(86400, true); // It's important to use cache for better performance.
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						response.sendFile("index.html"); | 
					 | 
					 | 
						i_response.sendFile("index.html"); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					void cWebInterface::OnRefresh(HttpRequest &request, HttpResponse &response) { | 
					 | 
					 | 
					void cWebInterface::OnRefresh(HttpRequest & i_request, HttpResponse & i_response) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						JsonObjectStream* stream = new JsonObjectStream(); | 
					 | 
					 | 
						JsonObjectStream* stream = new JsonObjectStream(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						JsonObject& json = stream->getRoot(); | 
					 | 
					 | 
						JsonObject& json = stream->getRoot(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						json["adc_1"] = m_adc_value[0]; | 
					 | 
					 | 
						json["adc_1"] = m_adc_value_average[0]; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						json["adc_2"] = m_adc_value[1]; | 
					 | 
					 | 
						json["adc_2"] = m_adc_value_average[1]; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					#ifdef REV_1 | 
					 | 
					 | 
					#ifdef REV_1 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						json["adc_3"] = m_adc_value[3]; | 
					 | 
					 | 
						json["adc_3"] = m_adc_value_average[3]; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						json["adc_4"] = m_adc_value[2]; | 
					 | 
					 | 
						json["adc_4"] = m_adc_value_average[2]; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					#else | 
					 | 
					 | 
					#else | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						json["adc_3"] = m_adc_value[2]; | 
					 | 
					 | 
						json["adc_3"] = m_adc_value_average[2]; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						json["adc_4"] = m_adc_value[3]; | 
					 | 
					 | 
						json["adc_4"] = m_adc_value_average[3]; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					#endif | 
					 | 
					 | 
					#endif | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						response.sendJsonObject(stream); | 
					 | 
					 | 
						char * writePos = m_jsonBuffer; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						for (int sample = 0; sample < m_adc_values_raw_cnt[RAW_CHANNEL]; sample++) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							const int pos = sprintf(writePos, "%d,", m_adc_values_raw[RAW_CHANNEL][sample]); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							writePos = &m_jsonBuffer[pos]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						}/*
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						 json["raw_adc"] = m_jsonBuffer; //ss.str();
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						 */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						i_response.sendJsonObject(stream); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						m_adc_values_raw_cnt[RAW_CHANNEL] = 0; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					void cWebInterface::OnRawUpdate(HttpRequest& i_request, HttpResponse& i_response) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					void cWebInterface::UpdateAdc(cADC<ads::ads_sample_t, int32_t> & adc, | 
					 | 
					 | 
					void cWebInterface::UpdateAdc(cADC<ads::ads_sample_t, int32_t> & i_adc, cDoubleBuffer<ads::ads_sample_t>& i_adcBuffer) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
							cDoubleBuffer<ads::ads_sample_t>& adcBuffer) { | 
					 | 
					 | 
						ads::ads_sample_t * buf = &i_adcBuffer.GetReadyBuffer()[0]; | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
						ads::ads_sample_t * buf = &adcBuffer.GetReadyBuffer()[0]; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						if (buf != NULL) { | 
					 | 
					 | 
						if (buf != NULL) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							ads::ads_sample_t averageSample; | 
					 | 
					 | 
							int pos = buf->mux - ads::eInputMux::AIN_0; | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
							averageSample.gain = buf->gain; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							averageSample.mux = buf->mux; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
							int64_t average = 0; | 
					 | 
					 | 
							int64_t average = 0; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							//Serial.printf("Channel: %d\n\r", buf->mux - ads::eInputMux::AIN_0);
 | 
					 | 
					 | 
							int size = i_adcBuffer.GetSize(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
							int size = adcBuffer.GetSize(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
							for (int i = 0; i < size; i++) { | 
					 | 
					 | 
							for (int i = 0; i < size; i++) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
								average += buf[i].rawSample; | 
					 | 
					 | 
								average += i_adc.ConvertSample(buf[i]); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
								//Serial.printf("%d ", buf[i].rawSample);
 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								if (pos == RAW_CHANNEL) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
									int idx = m_adc_values_raw_cnt[RAW_CHANNEL]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
									if (idx < RAW_SAMPLES) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
										m_adc_values_raw[RAW_CHANNEL][idx] = i_adc.ConvertSample(buf[i]); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
										m_adc_values_raw_cnt[RAW_CHANNEL]++; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
									} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							} | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							//Serial.printf("\n\r before: %d", average);
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							if (size != 0) { | 
					 | 
					 | 
							if (size != 0) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								average /= size; | 
					 | 
					 | 
								average /= size; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							} | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							//Serial.printf("after: %d [%d]\n\r", average, size);
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							averageSample.rawSample = static_cast<int16_t>(average); | 
					 | 
					 | 
							m_adc_value_average[pos] = static_cast<int32_t>(average); | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
							int pos = averageSample.mux - ads::eInputMux::AIN_0; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							m_adc_value[pos] = adc.ConvertSample(averageSample); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void cWebInterface::PrintValues() { | 
					 | 
					 | 
					void cWebInterface::PrintValues() { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						Serial.printf("c[0]: %d c[1]: %d c[2]: %d c[3]: %d\n\r", m_adc_value[0], | 
					 | 
					 | 
						Serial.printf("c[0]: %d c[1]: %d c[2]: %d c[3]: %d\n\r", m_adc_value_average[0], m_adc_value_average[1], | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
								m_adc_value[1], m_adc_value[2], m_adc_value[3]); | 
					 | 
					 | 
								m_adc_value_average[2], m_adc_value_average[3]); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					void cWebInterface::UpdateTemp(cDoubleBuffer<uint32_t>& adcBuffer) { | 
					 | 
					 | 
					void cWebInterface::UpdateTemp(cDoubleBuffer<uint32_t>& i_tempBuffer) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					cWebInterface::~cWebInterface() { | 
					 | 
					 | 
					cWebInterface::~cWebInterface() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						// TODO Auto-generated destructor stub
 | 
					 | 
					 | 
						// TODO Auto-generated destructor stub
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					void cWebInterface::OnConfiguration(HttpRequest &request, HttpResponse &response) | 
					 | 
					 | 
					void cWebInterface::ResetRawValues() { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					{ | 
					 | 
					 | 
						for (int channel = 0; channel < 4; channel++) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							for (int sample = 0; sample < 1000; sample++) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								m_adc_values_raw[channel][sample] = 0; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						if (request.method == HTTP_POST) | 
					 | 
					 | 
					void cWebInterface::OnConfiguration(HttpRequest &request, HttpResponse &response) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						{ | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
							debugf("Update config"); | 
					 | 
					 | 
						if (strcmp(request.getRequestMethod().c_str(), RequestMethod::POST) == 0) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							//debugf("Update config");
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							// Update config
 | 
					 | 
					 | 
							// Update config
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							if (request.getBody() == NULL) | 
					 | 
					 | 
							if (request.getBody() == NULL) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
							{ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
								Serial.println(request.getPostParameter("StaSSID")); | 
					 | 
					 | 
								Serial.println(request.getPostParameter("StaSSID")); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
								debugf("NULL bodyBuf"); | 
					 | 
					 | 
								//debugf("NULL bodyBuf");
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
								return; | 
					 | 
					 | 
								return; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
							} | 
					 | 
					 | 
							} else { | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
							else | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							{ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
								StaticJsonBuffer<200> jsonBuffer; | 
					 | 
					 | 
								StaticJsonBuffer<200> jsonBuffer; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								JsonObject& root = jsonBuffer.parseObject(request.getBody()); | 
					 | 
					 | 
								JsonObject& root = jsonBuffer.parseObject(request.getBody()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								//root.prettyPrintTo(Serial); //Uncomment it for debuging
 | 
					 | 
					 | 
								//root.prettyPrintTo(Serial); //Uncomment it for debuging
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -177,16 +193,13 @@ void cWebInterface::OnConfiguration(HttpRequest &request, HttpResponse &response | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								 }*/ | 
					 | 
					 | 
								 }*/ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							} | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							//saveConfig(ActiveConfig);
 | 
					 | 
					 | 
							//saveConfig(ActiveConfig);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						} | 
					 | 
					 | 
						} else { | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
						else | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
							response.setCache(86400, true); // It's important to use cache for better performance.
 | 
					 | 
					 | 
							response.setCache(86400, true); // It's important to use cache for better performance.
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							response.sendFile("config.html"); | 
					 | 
					 | 
							response.sendFile("config.html"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					void cWebInterface::OnConfiguration_json(HttpRequest &request, HttpResponse &response) | 
					 | 
					 | 
					void cWebInterface::OnConfiguration_json(HttpRequest &request, HttpResponse &response) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					{ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						JsonObjectStream* stream = new JsonObjectStream(); | 
					 | 
					 | 
						JsonObjectStream* stream = new JsonObjectStream(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						JsonObject& json = stream->getRoot(); | 
					 | 
					 | 
						JsonObject& json = stream->getRoot(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -194,9 +207,8 @@ void cWebInterface::OnConfiguration_json(HttpRequest &request, HttpResponse &res | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						json["StaPassword"] = 23; | 
					 | 
					 | 
						json["StaPassword"] = 23; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						json["StaEnable"] = 24; | 
					 | 
					 | 
						json["StaEnable"] = 24; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						response.sendDataStream(stream, MIME_JSON); | 
					 | 
					 | 
						response.sendDataStream(stream, ContentType::JSON); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} /* namespace rijnfel */ | 
					 | 
					 | 
					} /* namespace rijnfel */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					
  |