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
const GAP_SERVICE_ID = 0x1800; | |
const BATTERY_SERVICE_ID = 0x180F; | |
const DEVICE_NAME_CHAR_ID = 0x2A00; | |
const BATTERY_LEVEL_CHAR_ID = 0x2A19; | |
const CLIENT_CHAR_CONF_DESCR_ID = 0x2902; | |
const DEVICE_ADDRESS = '58:2D:34:35:D7:1D'; | |
const ENV_SENSORS_SERVICE_UUID = '226c0000-6476-4566-7562-66734470666d'; | |
const ENV_SENSORS_CHAR_UUID = '226caa55-6476-4566-7562-66734470666d'; | |
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
const net = require('net'); | |
const API_KEY = 'XXXXXXXXXXXXXXXX'; | |
function sendToThingSpeak(temp, hum) | |
{ | |
const uri = 'https://api.thingspeak.com/update.json'; | |
var httpRequest = new net.HTTPRequest('POST', uri); | |
httpRequest.parameters = { |
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
function mac2string(mac) | |
{ | |
var result = ''; | |
for (var i = 0; i < mac.length; i++) | |
{ | |
if (i > 0) result += ':'; | |
result += mac[i].toString(16).padStart(2, '0'); | |
} | |
return result; | |
} |
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
const https = require('https'); | |
const token = '<jwt>'; | |
const requestOptions = { | |
hostname: 'remote.macchina.io', | |
port: 443, | |
path: '/my-devices/api/devices?status=all', | |
method: 'GET', | |
headers: { |
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
var net = require('net'); | |
// | |
// An object for writing measurements to InfluxDB | |
// | |
const InfluxDB = { | |
formatValue: function(value) { | |
if (typeof value === 'number') | |
{ | |
return value.toString(); |
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
// g++ -o coap-server coap-server.cpp -lcoap-2-openssl -lPocoNet -lPocoFoundation | |
#include <Poco/Net/SocketAddress.h> | |
#include <Poco/Random.h> | |
#include <Poco/NumberFormatter.h> | |
#include <Poco/Exception.h> | |
#include <coap2/coap.h> | |
#include <iostream> |
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
// g++ -o coap-get coap-get.cpp -lcoap-2-openssl -lPocoNet -lPocoFoundation | |
#include <Poco/Net/SocketAddress.h> | |
#include <Poco/Exception.h> | |
#include <coap2/coap.h> | |
#include <cstring> | |
#include <iostream> | |
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
// | |
// SAXParser.cpp | |
// | |
// This sample demonstrates the SAXParser class. | |
// | |
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. | |
// and Contributors. | |
// | |
// SPDX-License-Identifier: BSL-1.0 | |
// |
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
var sensorRef = serviceRegistry.findByName('io.macchina.btle.peripheral.58:2D:34:35:D7:1D'); | |
var sensor = sensorRef.instance(); | |
const CHAR_BATTERY_LEVEL = 0x0018; // characteristic for reading battery level (0-99) | |
const CHAR_NOTIFICATION = 0x0010; // characteristic for enabling temperature/humidity notifications | |
console.log('connecting...'); | |
function parseValue(str) | |
{ |
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
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <unistd.h> | |
int main(int argc, char* argv[]) |
NewerOlder