Issues with Lisp server examples ESP8266


#1

Windows 7
Arduino 1.8.6
Board: AdaFruit Feather HUZZAH ESP8266

Having some trouble running your examples. I’m trying to run a small web server on the HUZZAH that my Iphone can access web pages from. I set the connection up with the following commands

 (wifi-softap "Ford")
192.168.4.1

That gets me the IP address for the IPhone.

(wifi-server)

Start the wifi server

(with-client (s)
  (loop
   (let ((line (read-line s)))
     (when (null line) (return))
     (print line)))
  (println "HTTP/1.1 200 OK" s)
  (println "Content-Type: text/html" s)
  (println "Connection: close" s)
  (println "" s)
  (princ "<!DOCTYPE HTML><html><body><h1>ADC Value: " s)
  (princ (analogread 17) s)
  (println "</h1></body></html>" s)
  (println "" s))

From the examples page insert the above code. However it returns nil unless the Iphone web browser is trying to connect.
The results are as follows.

"GET / HTTP/1.1" 
"Host: 192.168.4.1" 
"Upgrade-Insecure-Requests: 1" 
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" 
"User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0 Mobile/15C202 Safari/604.1" 
"Accept-Language: en-ca" 
"Accept-Encoding: gzip, deflate" 
"Connection: keep-alive" 
"" 
Error: 'println' undefined

How do I find which "println is undefined and do I continually need to look for a connection for this to work?

Regards

Mark


#2

You need to define a function println. It’s defined earlier in the page:

(defun println (x s) (princ x s) (princ #\return s) (princ #\newline s))

If you’re running a web server on the ESP8266 it needs to stay in a loop waiting for a connection.