| 
						
						
							
								
							
						
						
					 | 
					@ -6,9 +6,14 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					#include "sensor_settings.h" | 
					 | 
					 | 
					#include "sensor_settings.h" | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					#include "double_buffer.h" | 
					 | 
					 | 
					#include "double_buffer.h" | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					#include "web_interface.h" | 
					 | 
					 | 
					#include "web_interface.h" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					
 | 
					 | 
					 | 
					#include <stdint.h> | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					#define LED_PIN 2 // GPIO2
 | 
					 | 
					 | 
					#define LED_PIN 2 // GPIO2
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					static const int HUB_PERIOD = 5; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					static const int ADC_TIMEBASE = 250; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					static const int ADC_PERIOD = 5; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					static const uint8_t ADC_ADDRESS = 0x48; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					using namespace rijnfel; | 
					 | 
					 | 
					using namespace rijnfel; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void STADisconnect(String ssid, uint8_t ssid_len, uint8_t bssid[6], | 
					 | 
					 | 
					void STADisconnect(String ssid, uint8_t ssid_len, uint8_t bssid[6], | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -16,22 +21,23 @@ void STADisconnect(String ssid, uint8_t ssid_len, uint8_t bssid[6], | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void STAGotIP(IPAddress ip, IPAddress mask, IPAddress gateway); | 
					 | 
					 | 
					void STAGotIP(IPAddress ip, IPAddress mask, IPAddress gateway); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					Timer procTimer; | 
					 | 
					 | 
					Timer procTimer; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					ads::cADS101x adc; | 
					 | 
					 | 
					ads::cADS101x adc(0, ADC_ADDRESS); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					uint8_t channel = 0; | 
					 | 
					 | 
					uint8_t channel = 0; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					cSensorHub hub(5); | 
					 | 
					 | 
					cSensorHub hub(HUB_PERIOD); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					int test = 0; | 
					 | 
					 | 
					int test = 0; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void updateSensorHub() { | 
					 | 
					 | 
					void updateSensorHub() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						hub.Update(); | 
					 | 
					 | 
						hub.Update(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void adcCallback(cDoubleBuffer<ads::ads_sample_t> & buffer) { | 
					 | 
					 | 
					void adcCallback(cDoubleBuffer<ads::ads_sample_t> & buffer) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						cWebInterface::GetInstance()->UpdateAdc(adc, buffer); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						adc.SetMux(static_cast<ads::eInputMux>(ads::eInputMux::AIN_0 + channel)); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						channel++; | 
					 | 
					 | 
						channel++; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						if (channel > 3) { | 
					 | 
					 | 
						if (channel > 3) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							channel = 0; | 
					 | 
					 | 
							channel = 0; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
							cWebInterface::GetInstance()->PrintValues(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						cWebInterface::GetInstance()->UpdateAdc(adc, buffer); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
						adc.SetMux(static_cast<ads::eInputMux>(ads::eInputMux::AIN_0 + channel)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void init() { | 
					 | 
					 | 
					void init() { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -49,16 +55,17 @@ void init() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						hub.SetAdc(&adc); | 
					 | 
					 | 
						hub.SetAdc(&adc); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						cSensorSettings<ads::ads_sample_t> * adcSettings; | 
					 | 
					 | 
						cSensorSettings<ads::ads_sample_t> * adcSettings; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						adcSettings = new cSensorSettings<ads::ads_sample_t>(&adcCallback, 250, 5); | 
					 | 
					 | 
						adcSettings = new cSensorSettings<ads::ads_sample_t>(&adcCallback, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
								ADC_TIMEBASE, ADC_PERIOD); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						hub.SetAdcSettings(adcSettings); | 
					 | 
					 | 
						hub.SetAdcSettings(adcSettings); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						WifiEvents.onStationDisconnect(STADisconnect); | 
					 | 
					 | 
						WifiEvents.onStationDisconnect(STADisconnect); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						WifiEvents.onStationGotIP(STAGotIP); | 
					 | 
					 | 
						WifiEvents.onStationGotIP(STAGotIP); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					/*	WifiAccessPoint.setIP(IPAddress(10, 0, 0, 1));		//TODO
 | 
					 | 
					 | 
						/*	WifiAccessPoint.setIP(IPAddress(10, 0, 0, 1));		//TODO
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
						WifiAccessPoint.config("Sensus", "", AUTH_OPEN, false, 3);*/ | 
					 | 
					 | 
						 WifiAccessPoint.config("Sensus", "", AUTH_OPEN, false, 3);*/ | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
						cWebInterface::GetInstance()->Start(); | 
					 | 
					 | 
						cWebInterface::GetInstance()->Start(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
						procTimer.initializeMs(100, updateSensorHub).start(); | 
					 | 
					 | 
						procTimer.initializeMs(HUB_PERIOD, updateSensorHub).start(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					void STADisconnect(String ssid, uint8_t ssid_len, uint8_t bssid[6], | 
					 | 
					 | 
					void STADisconnect(String ssid, uint8_t ssid_len, uint8_t bssid[6], | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |