This file contains 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
#include <stdio.h> | |
struct entry { | |
int value; | |
struct entry *next; | |
}; | |
static void out(struct entry *e) { | |
if (e->next != NULL) out(e->next); | |
printf("%d\n", e->value); |
This file contains 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
// Copyright (c) Cesanta Software Limited | |
// All rights reserved | |
#include "main.h" | |
#define REPORT_FREQUENCY_MS 5000 | |
// This function is called by the main superloop every 10ms. | |
// We trigger shadow update each REPORT_FREQUENCY_MS milliseconds. | |
// The other way to do it is to start a dedicated FreeRTOS task. |
This file contains 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
// Copyright (c) 2019 Sergey Lyubka | |
// All rights reserved | |
#include <stdio.h> | |
#include <string.h> | |
enum { TOK_EOF = '#', TOK_NUM = 'N', TOK_IDENT = 'I' }; | |
enum { ERR_OK, ERR_EXPECTED_NUM, ERR_EXPECTED_PAREN }; | |
//#define DEBUG(fmt, ...) printf("%s:" fmt "\n", __func__, __VA_ARGS__) | |
#define DEBUG(fmt, ...) |
This file contains 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> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>mDash Smart Light</title> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> |
This file contains 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
<html> | |
<head> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css"> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | |
<script src="https://unpkg.com/preact"></script> | |
</head> | |
<body> </body> | |
<script> | |
var h = preact.h; | |
var App = function(props) { |
This file contains 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
#include <mDash.h> | |
#include <BLEDevice.h> | |
#include <BLEUtils.h> | |
#include <BLEScan.h> | |
#include <BLEAdvertisedDevice.h> | |
#define WIFI_NAME "XX" | |
#define WIFI_PASS "YY" | |
#define DEVICE_ID "d1" |
This file contains 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
var https = require('https'); | |
// Same as: | |
// curl -H 'Content-Type: application-json' -d PARAMS | |
// https://mdash.net/api/v2/devices/DEVICE_ID/rpc/METHOD?access_token=TOKEN | |
var mdashRequest = function(apiToken, deviceID, method, params, func) { | |
return new Promise(function(resolve, reject) { | |
var received = ''; | |
var strParams = JSON.stringify(params || {}); | |
var url = 'https://mdash.net/api/v2/devices/' + deviceID + '/rpc/' + |
This file contains 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 | |
# Usage: | |
# sh bt.sh sketch_Apr25 400d4e36:0x3ffb1e50 0x400d1bce:0x3ffb1e90 0x400d1d96:0x3ffb1ee0 0x400d5a8d:0x3ffb1f30 | |
ARDUINO_DIR=$HOME/Documents/Arduino | |
A2LINE=$ARDUINO_DIR/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-addr2line | |
ELF=$(find /var/folders/ -name $INO.elf 2>/dev/null) | |
INO=$1 | |
shift |
This file contains 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
var http = require('http'); | |
var port = 8080; | |
var server = http.createServer(function(request, response) { | |
console.log('Requested URI:', request.url); | |
response.writeHead(200, {'Content-Type': 'application/json'}); | |
response.write(JSON.stringify({a: 1, b: 2}), 'utf-8'); | |
response.end(); | |
}); | |
server.listen(parseInt(port, 10)); |
This file contains 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
#include "mgos.h" | |
#include "mgos_rpc.h" | |
#include "mgos_shadow.h" | |
static void report_state_to_the_shadow(void) { | |
const struct mgos_conf_entry *schema = | |
mgos_conf_find_schema_entry("KEY", mgos_config_schema()); | |
struct mbuf mb; | |
mbuf_init(&mb, 0); | |
mgos_conf_emit_cb(&mgos_sys_config, NULL, schema, false, &mb, NULL, NULL); |