This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Compiling and starting server: | |
| // $ cc ian1.c mongoose/mongoose.c frozen/frozen.c -I mongoose/ -I frozen -o /tmp/a | |
| // $ /tmp/a | |
| // Starting web server on port 8001 | |
| // | |
| // Running the client: | |
| // $ curl -d '' 127.0.0.1:8001 | |
| // {"error": {"code": -1, "message": "Expected a, b"}} | |
| // $ curl -d '{"b": 34, "a": 12}' 127.0.0.1:8001 | |
| // {"result": 46} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load('api_aws.js'); | |
| load('api_gpio.js'); | |
| load('api_mqtt.js'); | |
| let state = { on: false, counter: 0 }; // device state: shadow metadata | |
| GPIO.set_button_handler(0, GPIO.PULL_UP, GPIO.INT_EDGE_NEG, 200, function() { | |
| AWS.Shadow.update(0, {desired: {on: state.on, counter: state.counter + 1}}); | |
| }, null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load('api_dht.js'); | |
| load('api_mqtt.js'); | |
| load('api_timer.js'); | |
| Timer.set(1000, true, function() { | |
| let data = { temperature: DHT.getTemp(), humidity: DHT.getHumidity() }; | |
| MQTT.pub('dev/1234', JSON.stringify(data), 1); | |
| }, null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //////// old | |
| function old1() { | |
| }; | |
| function old2() { | |
| old1(); | |
| } | |
| old2(); | |
| ////////// new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load('api_spi.js'); | |
| load('api_timer.js'); | |
| load('api_math.js'); | |
| let spi = SPI.get(); | |
| let light = function(ar) { | |
| let frame = '\x00\x00\x00\x00'; | |
| for (let i = 0; i < ar.length; i++) { | |
| print(typeof(ar[i]), ar[i]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let AWS = { | |
| Shadow: { | |
| _seth: ffi('void mgos_aws_shadow_set_state_handler_simple(int (*)(userdata, int, char *, char *, char *, char *), userdata)'), | |
| _upd: ffi('int mgos_aws_shadow_update_simple(double, char *)'), | |
| _scb: function(ud, ev, rep, des, rm, dm) { | |
| rep = rep !== "" ? JSON.parse(rep) : {}; | |
| des = des !== "" ? JSON.parse(des) : {}; | |
| ud.cb(ud.ud, ev, rep, des, rm, dm); | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "name_pattern": "*", | |
| "addr_pattern": "c2:*|01:*", | |
| "actions": { | |
| "00001530-1212-efde-1523-785feabcd123": { | |
| "00001111-2222-3456-6543-785feabcd456": { | |
| "notify": { | |
| "dst": { "type": "http", "url": "http://127.0.0.1:1234/bt/${name}" } | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <!-- Required meta tags --> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
| <!-- jQuery first, then Tether, then Bootstrap JS. --> | |
| <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example data upload: | |
| // curl -L -H 'Content-Type: application/json' -d '{"id":"sheet1","names":["timestamp","ram"],"points":[[1,2],[3,4]]}' THIS_SCRIPT_URL | |
| function doPost(e) { | |
| try { | |
| var obj = JSON.parse(e.postData.contents); | |
| var doc = SpreadsheetApp.getActiveSpreadsheet(); | |
| var name = obj.id || 'DATA'; | |
| var sheet = doc.getSheetByName(name); | |
| if (!sheet) { | |
| doc.insertSheet(name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| DESTDIR=~/esp | |
| IDF_PATH=$DESTDIR/esp-idf | |
| sudo easy_install pip | |
| sudo pip install pyserial | |
| mkdir -p $DESTDIR |