Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@sensebox/sketch-templater
Advanced tools
Arduino sketch templates used by the openSenseMap-API. The sketch-templater
creates a Arduino Sketch (.ino
) for the Arduino IDE based on the selected options and sensors during the registration process on openSenseMap.
The version of templates should always match the corresponding Version of the Board Support Package
See CHANGELOG.md
To create a new version, use npm version
.
CHANGELOG.md
. Make sure there are no uncommited changes in the worktree.npm version [major | minor | patch] -m "[v%s] Your commit message"
beta
release include the word beta
in the new version)git push --tags origin main
npm publish
Install via npm install --save @sensebox/sketch-templater
or yarn add @sensebox/sketch-templater
const Sketcher = require('@sensebox/sketch-templater');
const mySketcher = new Sketcher('<your api post domain>');
// generate Sketch
const mySketch = mySketcher.generateSketch(box);
const mySketchBase64 = mySketcher.generateSketch(box, { encoding: 'base64' });
In order to fill in the correct ingress domain, you have to specify a valid hostname. Do not specify a protocol (http or https)!
You can do this either in code when calling the new Sketcher('your domain here')
or through external configuration.
If your project is using lorenwest/node-config
, you can specify the ingress domain in your config file of your project like this:
{
... your other config
"sketch-templater": {
"ingress_domain": "ingress.example.com"
}
}
To add new templates, just create a new .tpl
file in the templates
directory. A template consists of two parts. The first line contains a JSON object for configuration. The second line until the end is used as the template text.
Specify a single model:
{ "model": "homeEthernet" }
Specify multiple models:
{ "models": ["homeWifi", "homeWifiFeinstaub"] }
The templater uses special transformers to process the templates. The transformers are applied through searching for @@SUB_TEMPLATE_KEY@@
occurrences in the template files. Each replacement starts and ends with a double @
. To specify a transformer, append a pipe (|
) and the transformer name. When no transformer is specified, it just returns the input variable. For adding new template transformers, see Adding Transformers.
As of writing this, the following replacements can be made:
Template text | Replacement |
---|---|
@@SENSEBOX_ID@@ | the senseBox ID |
@@SENSEBOX_NAME@@ | the senseBox Name |
@@SENSOR_IDS@@ | sensor IDs |
@@NUM_SENSORS@@ | the number of sensors |
@@INGRESS_DOMAIN@@ | the domain of your ingress server |
@@SERIAL_PORT@@ | Serial port for connected SDS011 (only Feinstaub models) |
@@SSID@@ | your WiFi SSID (only homeV2Wifi models) |
@@PASSWORD@@ | your WiFi Password (only homeV2Wifi models) |
@@ACCESS_TOKEN@@ | the access_token of wifi / ethernet boxes |
Additionally, the following transformers are implemented:
Transformer name | Description |
---|---|
as-is | Do nothing. |
toDefine | Transform an array of sensors to multiple #define statements. |
toProgmem | Transform an array of sensors to multiple const char xxSENSOR_ID[] PROGMEM = "<id>"; statements. |
digitalPortToPortNumber | Transform a digital port (A , B or C ) to a port number. You can add a offset parameter. |
In order to add a new transformer, just add a function in src/transformers.js
to the module.exports
. The function should return a string.
Add your additional replacements in src/index.js
in the method _cloneBox
to the second parameter of the Object.assign
call.
FAQs
nodejs library to create senseBox Arduino Sketches
We found that @sensebox/sketch-templater demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.