Dear Imp folk,
I love the Imp. And I built an Imp that reports 5 sensors and controls 4 relays for pumps.
Now, I have two programs that need to be combined. Each one works on its own very nicely, but I really need to have them both operating on my imp at the same time.
Kindly excuse my lack of programming vocabulary. I have begun a course of study to fix that. I mostly copied, cut, pasted and simplified the two programs from some example programs on Sparkfun. They were more specific than the examples on the Electric Imp website.
From the Imp website, I do understand that I can’t have two http.onrequest 's in one program, but that has not helped me figure out a solution.
The first program I used was found at: https://learn.sparkfun.com/tutorials/electric-imp-breakout-hookup-guide/example-2-web-control-request
The second program is found at: https://learn.sparkfun.com/tutorials/electric-imp-breakout-hookup-guide/example-3-web-response
The two programs:
The first of them uses a webpage to control some on/off switches and timers. It uses: http.onrequest(requestHandler); and it uses try, if, and catch stuff.
The second of them reads the pins and reports them to a webpage and it has: http.onrequest(respondImpValues); which calls up the function ‘respondImpValues(request,response){…’ and a whole lot of stuff to allow it to report the imp pins.
I’ve tried to combine the two by adding the stuff implemented by the respondImpValues stuff of the second program inside the try, if…stuff of the first program. That mostly doesn’t work. But… if I comment out either of the http.onrequest lines, then each of the others does work, …but just not at the same time.
Can someone suggest the solution. I apologize in advance for my ignorance.
Thank you.
Jeff