Do you think I could use a Google Apps Script function to get the daily calendar (as shown here https://www.youtube.com/watch?v=sm1-l5-z3ag
) and then call the script from Espruino?
I tried this:
var WIFI_NAME = "WIFI_NAME";
var WIFI_OPTIONS = { password : "WIFI_PASSWORD" };
var GsToken='YOUR GOOGLE APPS SCRIPT TOKEN HERE';
var wifi;
function getCalendar()
{
var options = {
host: 'https://script.google.com',
port: '443',
path:'/macros/s/'+GsToken+'/exec',
protocol: "https:",
method:'GET',
headers: {
"Content-Type":"application/x-www-form-urlencoded"
}
};
console.log("Connecting to Google");
require("http").request(options, function(res) {
console.log("Connected to Google");
var nRecv = 0;
res.on('data', function(data) { nRecv += data.length; });
res.on('close', function(data) {
console.log("Google connection closed, "+nRecv+" bytes received");
setTimeout(getCalendar, 10000); // once every 10 seconds
});
}).end();
}
function onConnected(err) {
if (err) throw err;
wifi.getIP(function(e,ip) {
console.log(ip);
getCalendar();
});
}
var Inited=false;
function Init()
{
if(!Inited)
{
Inited=true;
wifi = require("Wifi");
wifi.connect(WIFI_NAME, WIFI_OPTIONS, onConnected);
}
}
function onInit() {
setTimeout("Init();",1000);
}
Init();
The console output is
____ _
| __|___ ___ ___ _ _|_|___ ___
| __|_ -| . | _| | | | | . |
|____|___| _|_| |___|_|_|_|___|
|_| espruino.com
2v04 (c) 2019 G.Williams
Espruino is Open Source. Our work is supported
only by sales of official boards and donations:
http://espruino.com/Donate
Flash map 512KB:256/256, manuf 0xef chip 0x4015
>
{
"ip": "192.168.43.173",
"netmask": "255.255.255.0",
"gw": "192.168.43.1",
"mac": "18:fe:34:f5:6a:a9"
}
Connecting to Google
>
Then nothing happens. I think I am pretty close to have a solution not based on a third party service, but, well, it doesn't work as is... I don't know if ESP8266 can do https requests directly or if I need to use some kind of HTTPSRedirect library, used on the Arduino world...
If anyone has any hints to help me go a step further, that would be awesome :-)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Thanks @Ollie and @DamianMontero for your answers, I appreciate!
Do you think I could use a Google Apps Script function to get the daily calendar (as shown here https://www.youtube.com/watch?v=sm1-l5-z3ag
) and then call the script from Espruino?
I tried this:
The console output is
Then nothing happens. I think I am pretty close to have a solution not based on a third party service, but, well, it doesn't work as is... I don't know if ESP8266 can do
https
requests directly or if I need to use some kind of HTTPSRedirect library, used on the Arduino world...If anyone has any hints to help me go a step further, that would be awesome :-)