Add pubsub client
This commit is contained in:
@@ -0,0 +1 @@
|
||||
tests/bin
|
||||
@@ -0,0 +1,7 @@
|
||||
sudo: false
|
||||
language: cpp
|
||||
compiler:
|
||||
- g++
|
||||
script: cd tests && make && make test
|
||||
os:
|
||||
- linux
|
||||
@@ -0,0 +1,63 @@
|
||||
2.3
|
||||
* Add publish(topic,payload,retained) function
|
||||
|
||||
2.2
|
||||
* Change code layout to match Arduino Library reqs
|
||||
|
||||
2.1
|
||||
* Add MAX_TRANSFER_SIZE def to chunk messages if needed
|
||||
* Reject topic/payloads that exceed MQTT_MAX_PACKET_SIZE
|
||||
|
||||
2.0
|
||||
* Add (and default to) MQTT 3.1.1 support
|
||||
* Fix PROGMEM handling for Intel Galileo/ESP8266
|
||||
* Add overloaded constructors for convenience
|
||||
* Add chainable setters for server/callback/client/stream
|
||||
* Add state function to return connack return code
|
||||
|
||||
1.9
|
||||
* Do not split MQTT packets over multiple calls to _client->write()
|
||||
* API change: All constructors now require an instance of Client
|
||||
to be passed in.
|
||||
* Fixed example to match 1.8 api changes - dpslwk
|
||||
* Added username/password support - WilHall
|
||||
* Added publish_P - publishes messages from PROGMEM - jobytaffey
|
||||
|
||||
1.8
|
||||
* KeepAlive interval is configurable in PubSubClient.h
|
||||
* Maximum packet size is configurable in PubSubClient.h
|
||||
* API change: Return boolean rather than int from various functions
|
||||
* API change: Length parameter in message callback changed
|
||||
from int to unsigned int
|
||||
* Various internal tidy-ups around types
|
||||
1.7
|
||||
* Improved keepalive handling
|
||||
* Updated to the Arduino-1.0 API
|
||||
1.6
|
||||
* Added the ability to publish a retained message
|
||||
|
||||
1.5
|
||||
* Added default constructor
|
||||
* Fixed compile error when used with arduino-0021 or later
|
||||
|
||||
1.4
|
||||
* Fixed connection lost handling
|
||||
|
||||
1.3
|
||||
* Fixed packet reading bug in PubSubClient.readPacket
|
||||
|
||||
1.2
|
||||
* Fixed compile error when used with arduino-0016 or later
|
||||
|
||||
|
||||
1.1
|
||||
* Reduced size of library
|
||||
* Added support for Will messages
|
||||
* Clarified licensing - see LICENSE.txt
|
||||
|
||||
|
||||
1.0
|
||||
* Only Quality of Service (QOS) 0 messaging is supported
|
||||
* The maximum message size, including header, is 128 bytes
|
||||
* The keepalive interval is set to 30 seconds
|
||||
* No support for Will messages
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2008-2015 Nicholas O'Leary
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,47 @@
|
||||
# Arduino Client for MQTT
|
||||
|
||||
This library provides a client for doing simple publish/subscribe messaging with
|
||||
a server that supports MQTT.
|
||||
|
||||
## Examples
|
||||
|
||||
The library comes with a number of example sketches. See File > Examples > PubSubClient
|
||||
within the Arduino application.
|
||||
|
||||
Full API documentation is available here: http://pubsubclient.knolleary.net
|
||||
|
||||
## Limitations
|
||||
|
||||
- It can only publish QoS 0 messages. It can subscribe at QoS 0 or QoS 1.
|
||||
- The maximum message size, including header, is **128 bytes** by default. This
|
||||
is configurable via `MQTT_MAX_PACKET_SIZE` in `PubSubClient.h`.
|
||||
- The keepalive interval is set to 15 seconds by default. This is configurable
|
||||
via `MQTT_KEEPALIVE` in `PubSubClient.h`.
|
||||
- The client uses MQTT 3.1.1 by default. It can be changed to use MQTT 3.1 by
|
||||
changing value of `MQTT_VERSION` in `PubSubClient.h`.
|
||||
|
||||
|
||||
## Compatible Hardware
|
||||
|
||||
The library uses the Arduino Ethernet Client api for interacting with the
|
||||
underlying network hardware. This means it Just Works with a growing number of
|
||||
boards and shields, including:
|
||||
|
||||
- Arduino Ethernet
|
||||
- Arduino Ethernet Shield
|
||||
- Arduino YUN – use the included `YunClient` in place of `EthernetClient`, and
|
||||
be sure to do a `Bridge.begin()` first
|
||||
- Arduino WiFi Shield - if you want to send packets > 90 bytes with this shield,
|
||||
enable the `MQTT_MAX_TRANSFER_SIZE` define in `PubSubClient.h`.
|
||||
- Sparkfun WiFly Shield – [library](https://github.com/dpslwk/WiFly)
|
||||
- TI CC3000 WiFi - [library](https://github.com/sparkfun/SFE_CC3000_Library)
|
||||
- Intel Galileo/Edison
|
||||
- ESP8266
|
||||
|
||||
The library cannot currently be used with hardware based on the ENC28J60 chip –
|
||||
such as the Nanode or the Nuelectronics Ethernet Shield. For those, there is an
|
||||
[alternative library](https://github.com/njh/NanodeMQTT) available.
|
||||
|
||||
## License
|
||||
|
||||
This code is released under the MIT License.
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Basic MQTT example with Authentication
|
||||
|
||||
- connects to an MQTT server, providing username
|
||||
and password
|
||||
- publishes "hello world" to the topic "outTopic"
|
||||
- subscribes to the topic "inTopic"
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
// Update these with values suitable for your network.
|
||||
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
|
||||
IPAddress ip(172, 16, 0, 100);
|
||||
IPAddress server(172, 16, 0, 2);
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
// handle message arrived
|
||||
}
|
||||
|
||||
EthernetClient ethClient;
|
||||
PubSubClient client(server, 1883, callback, ethClient);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Ethernet.begin(mac, ip);
|
||||
// Note - the default maximum packet size is 128 bytes. If the
|
||||
// combined length of clientId, username and password exceed this,
|
||||
// you will need to increase the value of MQTT_MAX_PACKET_SIZE in
|
||||
// PubSubClient.h
|
||||
|
||||
if (client.connect("arduinoClient", "testuser", "testpass")) {
|
||||
client.publish("outTopic","hello world");
|
||||
client.subscribe("inTopic");
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
client.loop();
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Basic MQTT example
|
||||
|
||||
This sketch demonstrates the basic capabilities of the library.
|
||||
It connects to an MQTT server then:
|
||||
- publishes "hello world" to the topic "outTopic"
|
||||
- subscribes to the topic "inTopic", printing out any messages
|
||||
it receives. NB - it assumes the received payloads are strings not binary
|
||||
|
||||
It will reconnect to the server if the connection is lost using a blocking
|
||||
reconnect function. See the 'mqtt_reconnect_nonblocking' example for how to
|
||||
achieve the same result without blocking the main loop.
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
// Update these with values suitable for your network.
|
||||
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
|
||||
IPAddress ip(172, 16, 0, 100);
|
||||
IPAddress server(172, 16, 0, 2);
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
Serial.print("Message arrived [");
|
||||
Serial.print(topic);
|
||||
Serial.print("] ");
|
||||
for (int i=0;i<length;i++) {
|
||||
Serial.print((char)payload[i]);
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
EthernetClient ethClient;
|
||||
PubSubClient client(ethClient);
|
||||
|
||||
void reconnect() {
|
||||
// Loop until we're reconnected
|
||||
while (!client.connected()) {
|
||||
Serial.print("Attempting MQTT connection...");
|
||||
// Attempt to connect
|
||||
if (client.connect("arduinoClient")) {
|
||||
Serial.println("connected");
|
||||
// Once connected, publish an announcement...
|
||||
client.publish("outTopic","hello world");
|
||||
// ... and resubscribe
|
||||
client.subscribe("inTopic");
|
||||
} else {
|
||||
Serial.print("failed, rc=");
|
||||
Serial.print(client.state());
|
||||
Serial.println(" try again in 5 seconds");
|
||||
// Wait 5 seconds before retrying
|
||||
delay(5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(57600);
|
||||
|
||||
client.setServer(server, 1883);
|
||||
client.setCallback(callback);
|
||||
|
||||
Ethernet.begin(mac, ip);
|
||||
// Allow the hardware to sort itself out
|
||||
delay(1500);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (!client.connected()) {
|
||||
reconnect();
|
||||
}
|
||||
client.loop();
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
Basic ESP8266 MQTT example
|
||||
|
||||
This sketch demonstrates the capabilities of the pubsub library in combination
|
||||
with the ESP8266 board/library.
|
||||
|
||||
It connects to an MQTT server then:
|
||||
- publishes "hello world" to the topic "outTopic" every two seconds
|
||||
- subscribes to the topic "inTopic", printing out any messages
|
||||
it receives. NB - it assumes the received payloads are strings not binary
|
||||
- If the first character of the topic "inTopic" is an 1, switch ON the ESP Led,
|
||||
else switch it off
|
||||
|
||||
It will reconnect to the server if the connection is lost using a blocking
|
||||
reconnect function. See the 'mqtt_reconnect_nonblocking' example for how to
|
||||
achieve the same result without blocking the main loop.
|
||||
|
||||
To install the ESP8266 board, (using Arduino 1.6.4+):
|
||||
- Add the following 3rd party board manager under "File -> Preferences -> Additional Boards Manager URLs":
|
||||
http://arduino.esp8266.com/stable/package_esp8266com_index.json
|
||||
- Open the "Tools -> Board -> Board Manager" and click install for the ESP8266"
|
||||
- Select your ESP8266 in "Tools -> Board"
|
||||
|
||||
*/
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
// Update these with values suitable for your network.
|
||||
|
||||
const char* ssid = "........";
|
||||
const char* password = "........";
|
||||
const char* mqtt_server = "broker.mqtt-dashboard.com";
|
||||
|
||||
WiFiClient espClient;
|
||||
PubSubClient client(espClient);
|
||||
long lastMsg = 0;
|
||||
char msg[50];
|
||||
int value = 0;
|
||||
|
||||
void setup() {
|
||||
pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output
|
||||
Serial.begin(115200);
|
||||
setup_wifi();
|
||||
client.setServer(mqtt_server, 1883);
|
||||
client.setCallback(callback);
|
||||
}
|
||||
|
||||
void setup_wifi() {
|
||||
|
||||
delay(10);
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.println();
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
|
||||
Serial.println("");
|
||||
Serial.println("WiFi connected");
|
||||
Serial.println("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
Serial.print("Message arrived [");
|
||||
Serial.print(topic);
|
||||
Serial.print("] ");
|
||||
for (int i = 0; i < length; i++) {
|
||||
Serial.print((char)payload[i]);
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
// Switch on the LED if an 1 was received as first character
|
||||
if ((char)payload[0] == '1') {
|
||||
digitalWrite(BUILTIN_LED, LOW); // Turn the LED on (Note that LOW is the voltage level
|
||||
// but actually the LED is on; this is because
|
||||
// it is acive low on the ESP-01)
|
||||
} else {
|
||||
digitalWrite(BUILTIN_LED, HIGH); // Turn the LED off by making the voltage HIGH
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void reconnect() {
|
||||
// Loop until we're reconnected
|
||||
while (!client.connected()) {
|
||||
Serial.print("Attempting MQTT connection...");
|
||||
// Attempt to connect
|
||||
if (client.connect("ESP8266Client")) {
|
||||
Serial.println("connected");
|
||||
// Once connected, publish an announcement...
|
||||
client.publish("outTopic", "hello world");
|
||||
// ... and resubscribe
|
||||
client.subscribe("inTopic");
|
||||
} else {
|
||||
Serial.print("failed, rc=");
|
||||
Serial.print(client.state());
|
||||
Serial.println(" try again in 5 seconds");
|
||||
// Wait 5 seconds before retrying
|
||||
delay(5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
void loop() {
|
||||
|
||||
if (!client.connected()) {
|
||||
reconnect();
|
||||
}
|
||||
client.loop();
|
||||
|
||||
long now = millis();
|
||||
if (now - lastMsg > 2000) {
|
||||
lastMsg = now;
|
||||
++value;
|
||||
snprintf (msg, 75, "hello world #%ld", value);
|
||||
Serial.print("Publish message: ");
|
||||
Serial.println(msg);
|
||||
client.publish("outTopic", msg);
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Publishing in the callback
|
||||
|
||||
- connects to an MQTT server
|
||||
- subscribes to the topic "inTopic"
|
||||
- when a message is received, republishes it to "outTopic"
|
||||
|
||||
This example shows how to publish messages within the
|
||||
callback function. The callback function header needs to
|
||||
be declared before the PubSubClient constructor and the
|
||||
actual callback defined afterwards.
|
||||
This ensures the client reference in the callback function
|
||||
is valid.
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
// Update these with values suitable for your network.
|
||||
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
|
||||
IPAddress ip(172, 16, 0, 100);
|
||||
IPAddress server(172, 16, 0, 2);
|
||||
|
||||
// Callback function header
|
||||
void callback(char* topic, byte* payload, unsigned int length);
|
||||
|
||||
EthernetClient ethClient;
|
||||
PubSubClient client(server, 1883, callback, ethClient);
|
||||
|
||||
// Callback function
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
// In order to republish this payload, a copy must be made
|
||||
// as the orignal payload buffer will be overwritten whilst
|
||||
// constructing the PUBLISH packet.
|
||||
|
||||
// Allocate the correct amount of memory for the payload copy
|
||||
byte* p = (byte*)malloc(length);
|
||||
// Copy the payload to the new buffer
|
||||
memcpy(p,payload,length);
|
||||
client.publish("outTopic", p, length);
|
||||
// Free the memory
|
||||
free(p);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
Ethernet.begin(mac, ip);
|
||||
if (client.connect("arduinoClient")) {
|
||||
client.publish("outTopic","hello world");
|
||||
client.subscribe("inTopic");
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
client.loop();
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Reconnecting MQTT example - non-blocking
|
||||
|
||||
This sketch demonstrates how to keep the client connected
|
||||
using a non-blocking reconnect function. If the client loses
|
||||
its connection, it attempts to reconnect every 5 seconds
|
||||
without blocking the main loop.
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
// Update these with values suitable for your hardware/network.
|
||||
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
|
||||
IPAddress ip(172, 16, 0, 100);
|
||||
IPAddress server(172, 16, 0, 2);
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
// handle message arrived
|
||||
}
|
||||
|
||||
EthernetClient ethClient;
|
||||
PubSubClient client(ethClient);
|
||||
|
||||
long lastReconnectAttempt = 0;
|
||||
|
||||
boolean reconnect() {
|
||||
if (client.connect("arduinoClient")) {
|
||||
// Once connected, publish an announcement...
|
||||
client.publish("outTopic","hello world");
|
||||
// ... and resubscribe
|
||||
client.subscribe("inTopic");
|
||||
}
|
||||
return client.connected();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
client.setServer(server, 1883);
|
||||
client.setCallback(callback);
|
||||
|
||||
Ethernet.begin(mac, ip);
|
||||
delay(1500);
|
||||
lastReconnectAttempt = 0;
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (!client.connected()) {
|
||||
long now = millis();
|
||||
if (now - lastReconnectAttempt > 5000) {
|
||||
lastReconnectAttempt = now;
|
||||
// Attempt to reconnect
|
||||
if (reconnect()) {
|
||||
lastReconnectAttempt = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Client connected
|
||||
|
||||
client.loop();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Example of using a Stream object to store the message payload
|
||||
|
||||
Uses SRAM library: https://github.com/ennui2342/arduino-sram
|
||||
but could use any Stream based class such as SD
|
||||
|
||||
- connects to an MQTT server
|
||||
- publishes "hello world" to the topic "outTopic"
|
||||
- subscribes to the topic "inTopic"
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <PubSubClient.h>
|
||||
#include <SRAM.h>
|
||||
|
||||
// Update these with values suitable for your network.
|
||||
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
|
||||
IPAddress ip(172, 16, 0, 100);
|
||||
IPAddress server(172, 16, 0, 2);
|
||||
|
||||
SRAM sram(4, SRAM_1024);
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
sram.seek(1);
|
||||
|
||||
// do something with the message
|
||||
for(uint8_t i=0; i<length; i++) {
|
||||
Serial.write(sram.read());
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
// Reset position for the next message to be stored
|
||||
sram.seek(1);
|
||||
}
|
||||
|
||||
EthernetClient ethClient;
|
||||
PubSubClient client(server, 1883, callback, ethClient, sram);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Ethernet.begin(mac, ip);
|
||||
if (client.connect("arduinoClient")) {
|
||||
client.publish("outTopic","hello world");
|
||||
client.subscribe("inTopic");
|
||||
}
|
||||
|
||||
sram.begin();
|
||||
sram.seek(1);
|
||||
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
client.loop();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For PubSubClient
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
PubSubClient KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
connect KEYWORD2
|
||||
disconnect KEYWORD2
|
||||
publish KEYWORD2
|
||||
publish_P KEYWORD2
|
||||
subscribe KEYWORD2
|
||||
unsubscribe KEYWORD2
|
||||
loop KEYWORD2
|
||||
connected KEYWORD2
|
||||
setServer KEYWORD2
|
||||
setCallback KEYWORD2
|
||||
setClient KEYWORD2
|
||||
setStream KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
@@ -0,0 +1,9 @@
|
||||
name=PubSubClient
|
||||
version=2.3
|
||||
author=Nick O'Leary <nick.oleary@gmail.com>
|
||||
maintainer=Nick O'Leary <nick.oleary@gmail.com>
|
||||
sentence=A client library for MQTT messaging.
|
||||
paragraph=MQTT is a lightweight messaging protocol ideal for small devices. This library allows you to send and receive MQTT messages. It supports the latest MQTT 3.1.1 protocol and can be configured to use the older MQTT 3.1 if needed. It supports all Arduino Ethernet Client compatible hardware, including the Intel Galileo/Edison, ESP8266 and TI CC3000.
|
||||
category=Communication
|
||||
url=http://pubsubclient.knolleary.net
|
||||
architectures=*
|
||||
@@ -0,0 +1,571 @@
|
||||
/*
|
||||
PubSubClient.cpp - A simple client for MQTT.
|
||||
Nick O'Leary
|
||||
http://knolleary.net
|
||||
*/
|
||||
|
||||
#include "PubSubClient.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
PubSubClient::PubSubClient() {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
this->_client = NULL;
|
||||
this->stream = NULL;
|
||||
setCallback(NULL);
|
||||
}
|
||||
|
||||
PubSubClient::PubSubClient(Client& client) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setClient(client);
|
||||
this->stream = NULL;
|
||||
}
|
||||
|
||||
PubSubClient::PubSubClient(IPAddress addr, uint16_t port, Client& client) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(addr, port);
|
||||
setClient(client);
|
||||
this->stream = NULL;
|
||||
}
|
||||
PubSubClient::PubSubClient(IPAddress addr, uint16_t port, Client& client, Stream& stream) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(addr,port);
|
||||
setClient(client);
|
||||
setStream(stream);
|
||||
}
|
||||
PubSubClient::PubSubClient(IPAddress addr, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(addr, port);
|
||||
setCallback(callback);
|
||||
setClient(client);
|
||||
this->stream = NULL;
|
||||
}
|
||||
PubSubClient::PubSubClient(IPAddress addr, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client, Stream& stream) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(addr,port);
|
||||
setCallback(callback);
|
||||
setClient(client);
|
||||
setStream(stream);
|
||||
}
|
||||
|
||||
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, Client& client) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(ip, port);
|
||||
setClient(client);
|
||||
this->stream = NULL;
|
||||
}
|
||||
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, Client& client, Stream& stream) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(ip,port);
|
||||
setClient(client);
|
||||
setStream(stream);
|
||||
}
|
||||
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(ip, port);
|
||||
setCallback(callback);
|
||||
setClient(client);
|
||||
this->stream = NULL;
|
||||
}
|
||||
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client, Stream& stream) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(ip,port);
|
||||
setCallback(callback);
|
||||
setClient(client);
|
||||
setStream(stream);
|
||||
}
|
||||
|
||||
PubSubClient::PubSubClient(const char* domain, uint16_t port, Client& client) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(domain,port);
|
||||
setClient(client);
|
||||
this->stream = NULL;
|
||||
}
|
||||
PubSubClient::PubSubClient(const char* domain, uint16_t port, Client& client, Stream& stream) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(domain,port);
|
||||
setClient(client);
|
||||
setStream(stream);
|
||||
}
|
||||
PubSubClient::PubSubClient(const char* domain, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(domain,port);
|
||||
setCallback(callback);
|
||||
setClient(client);
|
||||
this->stream = NULL;
|
||||
}
|
||||
PubSubClient::PubSubClient(const char* domain, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client, Stream& stream) {
|
||||
this->_state = MQTT_DISCONNECTED;
|
||||
setServer(domain,port);
|
||||
setCallback(callback);
|
||||
setClient(client);
|
||||
setStream(stream);
|
||||
}
|
||||
|
||||
boolean PubSubClient::connect(const char *id) {
|
||||
return connect(id,NULL,NULL,0,0,0,0);
|
||||
}
|
||||
|
||||
boolean PubSubClient::connect(const char *id, const char *user, const char *pass) {
|
||||
return connect(id,user,pass,0,0,0,0);
|
||||
}
|
||||
|
||||
boolean PubSubClient::connect(const char *id, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage) {
|
||||
return connect(id,NULL,NULL,willTopic,willQos,willRetain,willMessage);
|
||||
}
|
||||
|
||||
boolean PubSubClient::connect(const char *id, const char *user, const char *pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage) {
|
||||
if (!connected()) {
|
||||
int result = 0;
|
||||
|
||||
if (domain != NULL) {
|
||||
result = _client->connect(this->domain, this->port);
|
||||
} else {
|
||||
result = _client->connect(this->ip, this->port);
|
||||
}
|
||||
if (result) {
|
||||
nextMsgId = 1;
|
||||
// Leave room in the buffer for header and variable length field
|
||||
uint16_t length = 5;
|
||||
unsigned int j;
|
||||
|
||||
#if MQTT_VERSION == MQTT_VERSION_3_1
|
||||
uint8_t d[9] = {0x00,0x06,'M','Q','I','s','d','p', MQTT_VERSION};
|
||||
#define MQTT_HEADER_VERSION_LENGTH 9
|
||||
#elif MQTT_VERSION == MQTT_VERSION_3_1_1
|
||||
uint8_t d[7] = {0x00,0x04,'M','Q','T','T',MQTT_VERSION};
|
||||
#define MQTT_HEADER_VERSION_LENGTH 7
|
||||
#endif
|
||||
for (j = 0;j<MQTT_HEADER_VERSION_LENGTH;j++) {
|
||||
buffer[length++] = d[j];
|
||||
}
|
||||
|
||||
uint8_t v;
|
||||
if (willTopic) {
|
||||
v = 0x06|(willQos<<3)|(willRetain<<5);
|
||||
} else {
|
||||
v = 0x02;
|
||||
}
|
||||
|
||||
if(user != NULL) {
|
||||
v = v|0x80;
|
||||
|
||||
if(pass != NULL) {
|
||||
v = v|(0x80>>1);
|
||||
}
|
||||
}
|
||||
|
||||
buffer[length++] = v;
|
||||
|
||||
buffer[length++] = ((MQTT_KEEPALIVE) >> 8);
|
||||
buffer[length++] = ((MQTT_KEEPALIVE) & 0xFF);
|
||||
length = writeString(id,buffer,length);
|
||||
if (willTopic) {
|
||||
length = writeString(willTopic,buffer,length);
|
||||
length = writeString(willMessage,buffer,length);
|
||||
}
|
||||
|
||||
if(user != NULL) {
|
||||
length = writeString(user,buffer,length);
|
||||
if(pass != NULL) {
|
||||
length = writeString(pass,buffer,length);
|
||||
}
|
||||
}
|
||||
|
||||
write(MQTTCONNECT,buffer,length-5);
|
||||
|
||||
lastInActivity = lastOutActivity = millis();
|
||||
|
||||
while (!_client->available()) {
|
||||
unsigned long t = millis();
|
||||
if (t-lastInActivity > MQTT_KEEPALIVE*1000UL) {
|
||||
_state = MQTT_CONNECTION_TIMEOUT;
|
||||
_client->stop();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
uint8_t llen;
|
||||
uint16_t len = readPacket(&llen);
|
||||
|
||||
if (len == 4) {
|
||||
if (buffer[3] == 0) {
|
||||
lastInActivity = millis();
|
||||
pingOutstanding = false;
|
||||
_state = MQTT_CONNECTED;
|
||||
return true;
|
||||
} else {
|
||||
_state = buffer[3];
|
||||
}
|
||||
}
|
||||
_client->stop();
|
||||
} else {
|
||||
_state = MQTT_CONNECT_FAILED;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t PubSubClient::readByte() {
|
||||
while(!_client->available()) {}
|
||||
return _client->read();
|
||||
}
|
||||
|
||||
uint16_t PubSubClient::readPacket(uint8_t* lengthLength) {
|
||||
uint16_t len = 0;
|
||||
buffer[len++] = readByte();
|
||||
bool isPublish = (buffer[0]&0xF0) == MQTTPUBLISH;
|
||||
uint32_t multiplier = 1;
|
||||
uint16_t length = 0;
|
||||
uint8_t digit = 0;
|
||||
uint16_t skip = 0;
|
||||
uint8_t start = 0;
|
||||
|
||||
do {
|
||||
digit = readByte();
|
||||
buffer[len++] = digit;
|
||||
length += (digit & 127) * multiplier;
|
||||
multiplier *= 128;
|
||||
} while ((digit & 128) != 0);
|
||||
*lengthLength = len-1;
|
||||
|
||||
if (isPublish) {
|
||||
// Read in topic length to calculate bytes to skip over for Stream writing
|
||||
buffer[len++] = readByte();
|
||||
buffer[len++] = readByte();
|
||||
skip = (buffer[*lengthLength+1]<<8)+buffer[*lengthLength+2];
|
||||
start = 2;
|
||||
if (buffer[0]&MQTTQOS1) {
|
||||
// skip message id
|
||||
skip += 2;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint16_t i = start;i<length;i++) {
|
||||
digit = readByte();
|
||||
if (this->stream) {
|
||||
if (isPublish && len-*lengthLength-2>skip) {
|
||||
this->stream->write(digit);
|
||||
}
|
||||
}
|
||||
if (len < MQTT_MAX_PACKET_SIZE) {
|
||||
buffer[len] = digit;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
|
||||
if (!this->stream && len > MQTT_MAX_PACKET_SIZE) {
|
||||
len = 0; // This will cause the packet to be ignored.
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
boolean PubSubClient::loop() {
|
||||
if (connected()) {
|
||||
unsigned long t = millis();
|
||||
if ((t - lastInActivity > MQTT_KEEPALIVE*1000UL) || (t - lastOutActivity > MQTT_KEEPALIVE*1000UL)) {
|
||||
if (pingOutstanding) {
|
||||
this->_state = MQTT_CONNECTION_TIMEOUT;
|
||||
_client->stop();
|
||||
return false;
|
||||
} else {
|
||||
buffer[0] = MQTTPINGREQ;
|
||||
buffer[1] = 0;
|
||||
_client->write(buffer,2);
|
||||
lastOutActivity = t;
|
||||
lastInActivity = t;
|
||||
pingOutstanding = true;
|
||||
}
|
||||
}
|
||||
if (_client->available()) {
|
||||
uint8_t llen;
|
||||
uint16_t len = readPacket(&llen);
|
||||
uint16_t msgId = 0;
|
||||
uint8_t *payload;
|
||||
if (len > 0) {
|
||||
lastInActivity = t;
|
||||
uint8_t type = buffer[0]&0xF0;
|
||||
if (type == MQTTPUBLISH) {
|
||||
if (callback) {
|
||||
uint16_t tl = (buffer[llen+1]<<8)+buffer[llen+2];
|
||||
char topic[tl+1];
|
||||
for (uint16_t i=0;i<tl;i++) {
|
||||
topic[i] = buffer[llen+3+i];
|
||||
}
|
||||
topic[tl] = 0;
|
||||
// msgId only present for QOS>0
|
||||
if ((buffer[0]&0x06) == MQTTQOS1) {
|
||||
msgId = (buffer[llen+3+tl]<<8)+buffer[llen+3+tl+1];
|
||||
payload = buffer+llen+3+tl+2;
|
||||
callback(topic,payload,len-llen-3-tl-2);
|
||||
|
||||
buffer[0] = MQTTPUBACK;
|
||||
buffer[1] = 2;
|
||||
buffer[2] = (msgId >> 8);
|
||||
buffer[3] = (msgId & 0xFF);
|
||||
_client->write(buffer,4);
|
||||
lastOutActivity = t;
|
||||
|
||||
} else {
|
||||
payload = buffer+llen+3+tl;
|
||||
callback(topic,payload,len-llen-3-tl);
|
||||
}
|
||||
}
|
||||
} else if (type == MQTTPINGREQ) {
|
||||
buffer[0] = MQTTPINGRESP;
|
||||
buffer[1] = 0;
|
||||
_client->write(buffer,2);
|
||||
} else if (type == MQTTPINGRESP) {
|
||||
pingOutstanding = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean PubSubClient::publish(const char* topic, const char* payload) {
|
||||
return publish(topic,(const uint8_t*)payload,strlen(payload),false);
|
||||
}
|
||||
|
||||
boolean PubSubClient::publish(const char* topic, const char* payload, boolean retained) {
|
||||
return publish(topic,(const uint8_t*)payload,strlen(payload),retained);
|
||||
}
|
||||
|
||||
boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength) {
|
||||
return publish(topic, payload, plength, false);
|
||||
}
|
||||
|
||||
boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength, boolean retained) {
|
||||
if (connected()) {
|
||||
if (MQTT_MAX_PACKET_SIZE < 5 + 2+strlen(topic) + plength) {
|
||||
// Too long
|
||||
return false;
|
||||
}
|
||||
// Leave room in the buffer for header and variable length field
|
||||
uint16_t length = 5;
|
||||
length = writeString(topic,buffer,length);
|
||||
uint16_t i;
|
||||
for (i=0;i<plength;i++) {
|
||||
buffer[length++] = payload[i];
|
||||
}
|
||||
uint8_t header = MQTTPUBLISH;
|
||||
if (retained) {
|
||||
header |= 1;
|
||||
}
|
||||
return write(header,buffer,length-5);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean PubSubClient::publish_P(const char* topic, const uint8_t* payload, unsigned int plength, boolean retained) {
|
||||
uint8_t llen = 0;
|
||||
uint8_t digit;
|
||||
unsigned int rc = 0;
|
||||
uint16_t tlen;
|
||||
unsigned int pos = 0;
|
||||
unsigned int i;
|
||||
uint8_t header;
|
||||
unsigned int len;
|
||||
|
||||
if (!connected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
tlen = strlen(topic);
|
||||
|
||||
header = MQTTPUBLISH;
|
||||
if (retained) {
|
||||
header |= 1;
|
||||
}
|
||||
buffer[pos++] = header;
|
||||
len = plength + 2 + tlen;
|
||||
do {
|
||||
digit = len % 128;
|
||||
len = len / 128;
|
||||
if (len > 0) {
|
||||
digit |= 0x80;
|
||||
}
|
||||
buffer[pos++] = digit;
|
||||
llen++;
|
||||
} while(len>0);
|
||||
|
||||
pos = writeString(topic,buffer,pos);
|
||||
|
||||
rc += _client->write(buffer,pos);
|
||||
|
||||
for (i=0;i<plength;i++) {
|
||||
rc += _client->write((char)pgm_read_byte_near(payload + i));
|
||||
}
|
||||
|
||||
lastOutActivity = millis();
|
||||
|
||||
return rc == tlen + 4 + plength;
|
||||
}
|
||||
|
||||
boolean PubSubClient::write(uint8_t header, uint8_t* buf, uint16_t length) {
|
||||
uint8_t lenBuf[4];
|
||||
uint8_t llen = 0;
|
||||
uint8_t digit;
|
||||
uint8_t pos = 0;
|
||||
uint8_t rc;
|
||||
uint16_t len = length;
|
||||
do {
|
||||
digit = len % 128;
|
||||
len = len / 128;
|
||||
if (len > 0) {
|
||||
digit |= 0x80;
|
||||
}
|
||||
lenBuf[pos++] = digit;
|
||||
llen++;
|
||||
} while(len>0);
|
||||
|
||||
buf[4-llen] = header;
|
||||
for (int i=0;i<llen;i++) {
|
||||
buf[5-llen+i] = lenBuf[i];
|
||||
}
|
||||
|
||||
#ifdef MQTT_MAX_TRANSFER_SIZE
|
||||
uint8_t* writeBuf = buf+(4-llen);
|
||||
uint8_t bytesRemaining = length+1+llen;
|
||||
uint8_t bytesToWrite;
|
||||
boolean result = true;
|
||||
while((bytesRemaining > 0) && result) {
|
||||
bytesToWrite = (bytesRemaining > MQTT_MAX_TRANSFER_SIZE)?MQTT_MAX_TRANSFER_SIZE:bytesRemaining;
|
||||
rc = _client->write(writeBuf,bytesToWrite);
|
||||
result = (rc == bytesToWrite);
|
||||
bytesRemaining -= rc;
|
||||
writeBuf += rc;
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
rc = _client->write(buf+(4-llen),length+1+llen);
|
||||
lastOutActivity = millis();
|
||||
return (rc == 1+llen+length);
|
||||
#endif
|
||||
}
|
||||
|
||||
boolean PubSubClient::subscribe(const char* topic) {
|
||||
return subscribe(topic, 0);
|
||||
}
|
||||
|
||||
boolean PubSubClient::subscribe(const char* topic, uint8_t qos) {
|
||||
if (qos < 0 || qos > 1) {
|
||||
return false;
|
||||
}
|
||||
if (MQTT_MAX_PACKET_SIZE < 9 + strlen(topic)) {
|
||||
// Too long
|
||||
return false;
|
||||
}
|
||||
if (connected()) {
|
||||
// Leave room in the buffer for header and variable length field
|
||||
uint16_t length = 5;
|
||||
nextMsgId++;
|
||||
if (nextMsgId == 0) {
|
||||
nextMsgId = 1;
|
||||
}
|
||||
buffer[length++] = (nextMsgId >> 8);
|
||||
buffer[length++] = (nextMsgId & 0xFF);
|
||||
length = writeString((char*)topic, buffer,length);
|
||||
buffer[length++] = qos;
|
||||
return write(MQTTSUBSCRIBE|MQTTQOS1,buffer,length-5);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean PubSubClient::unsubscribe(const char* topic) {
|
||||
if (MQTT_MAX_PACKET_SIZE < 9 + strlen(topic)) {
|
||||
// Too long
|
||||
return false;
|
||||
}
|
||||
if (connected()) {
|
||||
uint16_t length = 5;
|
||||
nextMsgId++;
|
||||
if (nextMsgId == 0) {
|
||||
nextMsgId = 1;
|
||||
}
|
||||
buffer[length++] = (nextMsgId >> 8);
|
||||
buffer[length++] = (nextMsgId & 0xFF);
|
||||
length = writeString(topic, buffer,length);
|
||||
return write(MQTTUNSUBSCRIBE|MQTTQOS1,buffer,length-5);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PubSubClient::disconnect() {
|
||||
buffer[0] = MQTTDISCONNECT;
|
||||
buffer[1] = 0;
|
||||
_client->write(buffer,2);
|
||||
_state = MQTT_DISCONNECTED;
|
||||
_client->stop();
|
||||
lastInActivity = lastOutActivity = millis();
|
||||
}
|
||||
|
||||
uint16_t PubSubClient::writeString(const char* string, uint8_t* buf, uint16_t pos) {
|
||||
const char* idp = string;
|
||||
uint16_t i = 0;
|
||||
pos += 2;
|
||||
while (*idp) {
|
||||
buf[pos++] = *idp++;
|
||||
i++;
|
||||
}
|
||||
buf[pos-i-2] = (i >> 8);
|
||||
buf[pos-i-1] = (i & 0xFF);
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
boolean PubSubClient::connected() {
|
||||
boolean rc;
|
||||
if (_client == NULL ) {
|
||||
rc = false;
|
||||
} else {
|
||||
rc = (int)_client->connected();
|
||||
if (!rc) {
|
||||
if (this->_state == MQTT_CONNECTED) {
|
||||
this->_state = MQTT_CONNECTION_LOST;
|
||||
_client->flush();
|
||||
_client->stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
PubSubClient& PubSubClient::setServer(uint8_t * ip, uint16_t port) {
|
||||
IPAddress addr(ip[0],ip[1],ip[2],ip[3]);
|
||||
return setServer(addr,port);
|
||||
}
|
||||
|
||||
PubSubClient& PubSubClient::setServer(IPAddress ip, uint16_t port) {
|
||||
this->ip = ip;
|
||||
this->port = port;
|
||||
this->domain = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PubSubClient& PubSubClient::setServer(const char * domain, uint16_t port) {
|
||||
this->domain = domain;
|
||||
this->port = port;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PubSubClient& PubSubClient::setCallback(void(*callback)(char*,uint8_t*,unsigned int)){
|
||||
this->callback = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PubSubClient& PubSubClient::setClient(Client& client){
|
||||
this->_client = &client;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PubSubClient& PubSubClient::setStream(Stream& stream){
|
||||
this->stream = &stream;
|
||||
return *this;
|
||||
}
|
||||
|
||||
int PubSubClient::state() {
|
||||
return this->_state;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
PubSubClient.h - A simple client for MQTT.
|
||||
Nick O'Leary
|
||||
http://knolleary.net
|
||||
*/
|
||||
|
||||
#ifndef PubSubClient_h
|
||||
#define PubSubClient_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "IPAddress.h"
|
||||
#include "Client.h"
|
||||
#include "Stream.h"
|
||||
|
||||
#define MQTT_VERSION_3_1 3
|
||||
#define MQTT_VERSION_3_1_1 4
|
||||
|
||||
// MQTT_VERSION : Pick the version
|
||||
//#define MQTT_VERSION MQTT_VERSION_3_1
|
||||
#define MQTT_VERSION MQTT_VERSION_3_1_1
|
||||
|
||||
// MQTT_MAX_PACKET_SIZE : Maximum packet size
|
||||
#define MQTT_MAX_PACKET_SIZE 128
|
||||
|
||||
// MQTT_KEEPALIVE : keepAlive interval in Seconds
|
||||
#define MQTT_KEEPALIVE 15
|
||||
|
||||
// MQTT_MAX_TRANSFER_SIZE : limit how much data is passed to the network client
|
||||
// in each write call. Needed for the Arduino Wifi Shield. Leave undefined to
|
||||
// pass the entire MQTT packet in each write call.
|
||||
//#define MQTT_MAX_TRANSFER_SIZE 80
|
||||
|
||||
// Possible values for client.state()
|
||||
#define MQTT_CONNECTION_TIMEOUT -4
|
||||
#define MQTT_CONNECTION_LOST -3
|
||||
#define MQTT_CONNECT_FAILED -2
|
||||
#define MQTT_DISCONNECTED -1
|
||||
#define MQTT_CONNECTED 0
|
||||
#define MQTT_CONNECT_BAD_PROTOCOL 1
|
||||
#define MQTT_CONNECT_BAD_CLIENT_ID 2
|
||||
#define MQTT_CONNECT_UNAVAILABLE 3
|
||||
#define MQTT_CONNECT_BAD_CREDENTIALS 4
|
||||
#define MQTT_CONNECT_UNAUTHORIZED 5
|
||||
|
||||
#define MQTTCONNECT 1 << 4 // Client request to connect to Server
|
||||
#define MQTTCONNACK 2 << 4 // Connect Acknowledgment
|
||||
#define MQTTPUBLISH 3 << 4 // Publish message
|
||||
#define MQTTPUBACK 4 << 4 // Publish Acknowledgment
|
||||
#define MQTTPUBREC 5 << 4 // Publish Received (assured delivery part 1)
|
||||
#define MQTTPUBREL 6 << 4 // Publish Release (assured delivery part 2)
|
||||
#define MQTTPUBCOMP 7 << 4 // Publish Complete (assured delivery part 3)
|
||||
#define MQTTSUBSCRIBE 8 << 4 // Client Subscribe request
|
||||
#define MQTTSUBACK 9 << 4 // Subscribe Acknowledgment
|
||||
#define MQTTUNSUBSCRIBE 10 << 4 // Client Unsubscribe request
|
||||
#define MQTTUNSUBACK 11 << 4 // Unsubscribe Acknowledgment
|
||||
#define MQTTPINGREQ 12 << 4 // PING Request
|
||||
#define MQTTPINGRESP 13 << 4 // PING Response
|
||||
#define MQTTDISCONNECT 14 << 4 // Client is Disconnecting
|
||||
#define MQTTReserved 15 << 4 // Reserved
|
||||
|
||||
#define MQTTQOS0 (0 << 1)
|
||||
#define MQTTQOS1 (1 << 1)
|
||||
#define MQTTQOS2 (2 << 1)
|
||||
|
||||
#define MQTT_CALLBACK_SIGNATURE void (*callback)(char*,uint8_t*,unsigned int)
|
||||
|
||||
class PubSubClient {
|
||||
private:
|
||||
Client* _client;
|
||||
uint8_t buffer[MQTT_MAX_PACKET_SIZE];
|
||||
uint16_t nextMsgId;
|
||||
unsigned long lastOutActivity;
|
||||
unsigned long lastInActivity;
|
||||
bool pingOutstanding;
|
||||
MQTT_CALLBACK_SIGNATURE;
|
||||
uint16_t readPacket(uint8_t*);
|
||||
uint8_t readByte();
|
||||
boolean write(uint8_t header, uint8_t* buf, uint16_t length);
|
||||
uint16_t writeString(const char* string, uint8_t* buf, uint16_t pos);
|
||||
IPAddress ip;
|
||||
const char* domain;
|
||||
uint16_t port;
|
||||
Stream* stream;
|
||||
int _state;
|
||||
public:
|
||||
PubSubClient();
|
||||
PubSubClient(Client& client);
|
||||
PubSubClient(IPAddress, uint16_t, Client& client);
|
||||
PubSubClient(IPAddress, uint16_t, Client& client, Stream&);
|
||||
PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
|
||||
PubSubClient(IPAddress, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
|
||||
PubSubClient(uint8_t *, uint16_t, Client& client);
|
||||
PubSubClient(uint8_t *, uint16_t, Client& client, Stream&);
|
||||
PubSubClient(uint8_t *, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
|
||||
PubSubClient(uint8_t *, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
|
||||
PubSubClient(const char*, uint16_t, Client& client);
|
||||
PubSubClient(const char*, uint16_t, Client& client, Stream&);
|
||||
PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client);
|
||||
PubSubClient(const char*, uint16_t, MQTT_CALLBACK_SIGNATURE,Client& client, Stream&);
|
||||
|
||||
PubSubClient& setServer(IPAddress ip, uint16_t port);
|
||||
PubSubClient& setServer(uint8_t * ip, uint16_t port);
|
||||
PubSubClient& setServer(const char * domain, uint16_t port);
|
||||
PubSubClient& setCallback(MQTT_CALLBACK_SIGNATURE);
|
||||
PubSubClient& setClient(Client& client);
|
||||
PubSubClient& setStream(Stream& stream);
|
||||
|
||||
boolean connect(const char* id);
|
||||
boolean connect(const char* id, const char* user, const char* pass);
|
||||
boolean connect(const char* id, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage);
|
||||
boolean connect(const char* id, const char* user, const char* pass, const char* willTopic, uint8_t willQos, boolean willRetain, const char* willMessage);
|
||||
void disconnect();
|
||||
boolean publish(const char* topic, const char* payload);
|
||||
boolean publish(const char* topic, const char* payload, boolean retained);
|
||||
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);
|
||||
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
|
||||
boolean publish_P(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
|
||||
boolean subscribe(const char* topic);
|
||||
boolean subscribe(const char* topic, uint8_t qos);
|
||||
boolean unsubscribe(const char* topic);
|
||||
boolean loop();
|
||||
boolean connected();
|
||||
int state();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,4 @@
|
||||
.build
|
||||
tmpbin
|
||||
logs
|
||||
*.pyc
|
||||
@@ -0,0 +1,25 @@
|
||||
SRC_PATH=./src
|
||||
OUT_PATH=./bin
|
||||
TEST_SRC=$(wildcard ${SRC_PATH}/*_spec.cpp)
|
||||
TEST_BIN= $(TEST_SRC:${SRC_PATH}/%.cpp=${OUT_PATH}/%)
|
||||
VPATH=${SRC_PATH}
|
||||
SHIM_FILES=${SRC_PATH}/lib/*.cpp
|
||||
PSC_FILE=../src/PubSubClient.cpp
|
||||
CC=g++
|
||||
CFLAGS=-I${SRC_PATH}/lib -I../src
|
||||
|
||||
all: $(TEST_BIN)
|
||||
|
||||
${OUT_PATH}/%: ${SRC_PATH}/%.cpp ${PSC_FILE} ${SHIM_FILES}
|
||||
mkdir -p ${OUT_PATH}
|
||||
${CC} ${CFLAGS} $^ -o $@
|
||||
|
||||
clean:
|
||||
@rm -rf ${OUT_PATH}
|
||||
|
||||
test:
|
||||
@bin/connect_spec
|
||||
@bin/publish_spec
|
||||
@bin/receive_spec
|
||||
@bin/subscribe_spec
|
||||
@bin/keepalive_spec
|
||||
@@ -0,0 +1,93 @@
|
||||
# Arduino Client for MQTT Test Suite
|
||||
|
||||
This is a regression test suite for the `PubSubClient` library.
|
||||
|
||||
There are two parts:
|
||||
|
||||
- Tests that can be compiled and run on any machine
|
||||
- Tests that build the example sketches using the Arduino IDE
|
||||
|
||||
|
||||
It is a work-in-progress and is subject to complete refactoring as the whim takes
|
||||
me.
|
||||
|
||||
|
||||
## Local tests
|
||||
|
||||
These are a set of executables that can be run to test specific areas of functionality.
|
||||
They do not require a real Arduino to be attached, nor the use of the Arduino IDE.
|
||||
|
||||
The tests include a set of mock files to stub out the parts of the Arduino environment the library
|
||||
depends on.
|
||||
|
||||
### Dependencies
|
||||
|
||||
- g++
|
||||
|
||||
### Running
|
||||
|
||||
Build the tests using the provided `Makefile`:
|
||||
|
||||
$ make
|
||||
|
||||
This will create a set of executables in `./bin/`. Run each of these executables to test the corresponding functionality.
|
||||
|
||||
*Note:* the `connect_spec` and `keepalive_spec` tests involve testing keepalive timers so naturally take a few minutes to run through.
|
||||
|
||||
## Arduino tests
|
||||
|
||||
*Note:* INO Tool doesn't currently play nicely with Arduino 1.5. This has broken this test suite.
|
||||
|
||||
Without a suitable arduino plugged in, the test suite will only check the
|
||||
example sketches compile cleanly against the library.
|
||||
|
||||
With an arduino plugged in, each sketch that has a corresponding python
|
||||
test case is built, uploaded and then the tests run.
|
||||
|
||||
### Dependencies
|
||||
|
||||
- Python 2.7+
|
||||
- [INO Tool](http://inotool.org/) - this provides command-line build/upload of Arduino sketches
|
||||
|
||||
### Running
|
||||
|
||||
The test suite _does not_ run an MQTT server - it is assumed to be running already.
|
||||
|
||||
$ python testsuite.py
|
||||
|
||||
A summary of activity is printed to the console. More comprehensive logs are written
|
||||
to the `logs` directory.
|
||||
|
||||
### What it does
|
||||
|
||||
For each sketch in the library's `examples` directory, e.g. `mqtt_basic.ino`, the suite looks for a matching test case
|
||||
`testcases/mqtt_basic.py`.
|
||||
|
||||
The test case must follow these conventions:
|
||||
- sub-class `unittest.TestCase`
|
||||
- provide the class methods `setUpClass` and `tearDownClass` (TODO: make this optional)
|
||||
- all test method names begin with `test_`
|
||||
|
||||
The suite will call the `setUpClass` method _before_ uploading the sketch. This
|
||||
allows any test setup to be performed before the sketch runs - such as connecting
|
||||
a client and subscribing to topics.
|
||||
|
||||
|
||||
### Settings
|
||||
|
||||
The file `testcases/settings.py` is used to config the test environment.
|
||||
|
||||
- `server_ip` - the IP address of the broker the client should connect to (the broker port is assumed to be 1883).
|
||||
- `arduino_ip` - the IP address the arduino should use (when not testing DHCP).
|
||||
|
||||
Before each sketch is compiled, these values are automatically substituted in. To
|
||||
do this, the suite looks for lines that _start_ with the following:
|
||||
|
||||
byte server[] = {
|
||||
byte ip[] = {
|
||||
|
||||
and replaces them with the appropriate values.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
#include "PubSubClient.h"
|
||||
#include "ShimClient.h"
|
||||
#include "Buffer.h"
|
||||
#include "BDDTest.h"
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
byte server[] = { 172, 16, 0, 2 };
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
// handle message arrived
|
||||
}
|
||||
|
||||
|
||||
int test_connect_fails_no_network() {
|
||||
IT("fails to connect if underlying client doesn't connect");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(false);
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_FALSE(rc);
|
||||
int state = client.state();
|
||||
IS_TRUE(state == MQTT_CONNECT_FAILED);
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_connect_fails_on_no_response() {
|
||||
IT("fails to connect if no response received after 15 seconds");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_FALSE(rc);
|
||||
int state = client.state();
|
||||
IS_TRUE(state == MQTT_CONNECTION_TIMEOUT);
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_connect_properly_formatted() {
|
||||
IT("sends a properly formatted connect packet and succeeds");
|
||||
ShimClient shimClient;
|
||||
|
||||
shimClient.setAllowConnect(true);
|
||||
byte expectServer[] = { 172, 16, 0, 2 };
|
||||
shimClient.expectConnect(expectServer,1883);
|
||||
byte connect[] = {0x10,0x18,0x0,0x4,0x4d,0x51,0x54,0x54,0x4,0x2,0x0,0xf,0x0,0xc,0x63,0x6c,0x69,0x65,0x6e,0x74,0x5f,0x74,0x65,0x73,0x74,0x31};
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
|
||||
shimClient.expect(connect,26);
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int state = client.state();
|
||||
IS_TRUE(state == MQTT_DISCONNECTED);
|
||||
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
state = client.state();
|
||||
IS_TRUE(state == MQTT_CONNECTED);
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_connect_properly_formatted_hostname() {
|
||||
IT("accepts a hostname");
|
||||
ShimClient shimClient;
|
||||
|
||||
shimClient.setAllowConnect(true);
|
||||
shimClient.expectConnect((char* const)"localhost",1883);
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client((char* const)"localhost", 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
|
||||
int test_connect_fails_on_bad_rc() {
|
||||
IT("fails to connect if a bad return code is received");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x01 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_FALSE(rc);
|
||||
|
||||
int state = client.state();
|
||||
IS_TRUE(state == 0x01);
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_connect_accepts_username_password() {
|
||||
IT("accepts a username and password");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connect[] = { 0x10,0x24,0x0,0x4,0x4d,0x51,0x54,0x54,0x4,0xc2,0x0,0xf,0x0,0xc,0x63,0x6c,0x69,0x65,0x6e,0x74,0x5f,0x74,0x65,0x73,0x74,0x31,0x0,0x4,0x75,0x73,0x65,0x72,0x0,0x4,0x70,0x61,0x73,0x73};
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.expect(connect,0x26);
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1",(char*)"user",(char*)"pass");
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_connect_accepts_username_no_password() {
|
||||
IT("accepts a username but no password");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connect[] = { 0x10,0x1e,0x0,0x4,0x4d,0x51,0x54,0x54,0x4,0x82,0x0,0xf,0x0,0xc,0x63,0x6c,0x69,0x65,0x6e,0x74,0x5f,0x74,0x65,0x73,0x74,0x31,0x0,0x4,0x75,0x73,0x65,0x72};
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.expect(connect,0x20);
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1",(char*)"user",0);
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_connect_ignores_password_no_username() {
|
||||
IT("ignores a password but no username");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connect[] = {0x10,0x18,0x0,0x4,0x4d,0x51,0x54,0x54,0x4,0x2,0x0,0xf,0x0,0xc,0x63,0x6c,0x69,0x65,0x6e,0x74,0x5f,0x74,0x65,0x73,0x74,0x31};
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.expect(connect,26);
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1",0,(char*)"pass");
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_connect_with_will() {
|
||||
IT("accepts a will");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connect[] = {0x10,0x30,0x0,0x4,0x4d,0x51,0x54,0x54,0x4,0xe,0x0,0xf,0x0,0xc,0x63,0x6c,0x69,0x65,0x6e,0x74,0x5f,0x74,0x65,0x73,0x74,0x31,0x0,0x9,0x77,0x69,0x6c,0x6c,0x54,0x6f,0x70,0x69,0x63,0x0,0xb,0x77,0x69,0x6c,0x6c,0x4d,0x65,0x73,0x73,0x61,0x67,0x65};
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.expect(connect,0x32);
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1",(char*)"willTopic",1,0,(char*)"willMessage");
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_connect_with_will_username_password() {
|
||||
IT("accepts a will, username and password");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connect[] = {0x10,0x40,0x0,0x4,0x4d,0x51,0x54,0x54,0x4,0xce,0x0,0xf,0x0,0xc,0x63,0x6c,0x69,0x65,0x6e,0x74,0x5f,0x74,0x65,0x73,0x74,0x31,0x0,0x9,0x77,0x69,0x6c,0x6c,0x54,0x6f,0x70,0x69,0x63,0x0,0xb,0x77,0x69,0x6c,0x6c,0x4d,0x65,0x73,0x73,0x61,0x67,0x65,0x0,0x4,0x75,0x73,0x65,0x72,0x0,0x8,0x70,0x61,0x73,0x73,0x77,0x6f,0x72,0x64};
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.expect(connect,0x42);
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1",(char*)"user",(char*)"password",(char*)"willTopic",1,0,(char*)"willMessage");
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_connect_disconnect_connect() {
|
||||
IT("connects, disconnects and connects again");
|
||||
ShimClient shimClient;
|
||||
|
||||
shimClient.setAllowConnect(true);
|
||||
byte expectServer[] = { 172, 16, 0, 2 };
|
||||
shimClient.expectConnect(expectServer,1883);
|
||||
byte connect[] = {0x10,0x18,0x0,0x4,0x4d,0x51,0x54,0x54,0x4,0x2,0x0,0xf,0x0,0xc,0x63,0x6c,0x69,0x65,0x6e,0x74,0x5f,0x74,0x65,0x73,0x74,0x31};
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
|
||||
shimClient.expect(connect,26);
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
|
||||
int state = client.state();
|
||||
IS_TRUE(state == MQTT_DISCONNECTED);
|
||||
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
state = client.state();
|
||||
IS_TRUE(state == MQTT_CONNECTED);
|
||||
|
||||
byte disconnect[] = {0xE0,0x00};
|
||||
shimClient.expect(disconnect,2);
|
||||
|
||||
client.disconnect();
|
||||
|
||||
IS_FALSE(client.connected());
|
||||
IS_FALSE(shimClient.connected());
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
state = client.state();
|
||||
IS_TRUE(state == MQTT_DISCONNECTED);
|
||||
|
||||
shimClient.expect(connect,28);
|
||||
shimClient.respond(connack,4);
|
||||
rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
state = client.state();
|
||||
IS_TRUE(state == MQTT_CONNECTED);
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
SUITE("Connect");
|
||||
test_connect_fails_no_network();
|
||||
test_connect_fails_on_no_response();
|
||||
|
||||
test_connect_properly_formatted();
|
||||
test_connect_accepts_username_password();
|
||||
test_connect_fails_on_bad_rc();
|
||||
test_connect_properly_formatted_hostname();
|
||||
|
||||
test_connect_accepts_username_no_password();
|
||||
test_connect_ignores_password_no_username();
|
||||
test_connect_with_will();
|
||||
test_connect_with_will_username_password();
|
||||
test_connect_disconnect_connect();
|
||||
FINISH
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
#include "PubSubClient.h"
|
||||
#include "ShimClient.h"
|
||||
#include "Buffer.h"
|
||||
#include "BDDTest.h"
|
||||
#include "trace.h"
|
||||
#include <unistd.h>
|
||||
|
||||
byte server[] = { 172, 16, 0, 2 };
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
// handle message arrived
|
||||
}
|
||||
|
||||
|
||||
int test_keepalive_pings_idle() {
|
||||
IT("keeps an idle connection alive (takes 1 minute)");
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte pingreq[] = { 0xC0,0x0 };
|
||||
shimClient.expect(pingreq,2);
|
||||
byte pingresp[] = { 0xD0,0x0 };
|
||||
shimClient.respond(pingresp,2);
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
sleep(1);
|
||||
if ( i == 15 || i == 31 || i == 47) {
|
||||
shimClient.expect(pingreq,2);
|
||||
shimClient.respond(pingresp,2);
|
||||
}
|
||||
rc = client.loop();
|
||||
IS_TRUE(rc);
|
||||
}
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_keepalive_pings_with_outbound_qos0() {
|
||||
IT("keeps a connection alive that only sends qos0 (takes 1 minute)");
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x30,0xe,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
TRACE(i<<":");
|
||||
shimClient.expect(publish,16);
|
||||
rc = client.publish((char*)"topic",(char*)"payload");
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
sleep(1);
|
||||
if ( i == 15 || i == 31 || i == 47) {
|
||||
byte pingreq[] = { 0xC0,0x0 };
|
||||
shimClient.expect(pingreq,2);
|
||||
byte pingresp[] = { 0xD0,0x0 };
|
||||
shimClient.respond(pingresp,2);
|
||||
}
|
||||
rc = client.loop();
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
}
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_keepalive_pings_with_inbound_qos0() {
|
||||
IT("keeps a connection alive that only receives qos0 (takes 1 minute)");
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x30,0xe,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
TRACE(i<<":");
|
||||
sleep(1);
|
||||
if ( i == 15 || i == 31 || i == 47) {
|
||||
byte pingreq[] = { 0xC0,0x0 };
|
||||
shimClient.expect(pingreq,2);
|
||||
byte pingresp[] = { 0xD0,0x0 };
|
||||
shimClient.respond(pingresp,2);
|
||||
}
|
||||
shimClient.respond(publish,16);
|
||||
rc = client.loop();
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
}
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_keepalive_no_pings_inbound_qos1() {
|
||||
IT("does not send pings for connections with inbound qos1 (takes 1 minute)");
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x32,0x10,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x12,0x34,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||
byte puback[] = {0x40,0x2,0x12,0x34};
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
shimClient.respond(publish,18);
|
||||
shimClient.expect(puback,4);
|
||||
sleep(1);
|
||||
rc = client.loop();
|
||||
IS_TRUE(rc);
|
||||
IS_FALSE(shimClient.error());
|
||||
}
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_keepalive_disconnects_hung() {
|
||||
IT("disconnects a hung connection (takes 30 seconds)");
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte pingreq[] = { 0xC0,0x0 };
|
||||
shimClient.expect(pingreq,2);
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
sleep(1);
|
||||
rc = client.loop();
|
||||
}
|
||||
IS_FALSE(rc);
|
||||
|
||||
int state = client.state();
|
||||
IS_TRUE(state == MQTT_CONNECTION_TIMEOUT);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
SUITE("Keep-alive");
|
||||
test_keepalive_pings_idle();
|
||||
test_keepalive_pings_with_outbound_qos0();
|
||||
test_keepalive_pings_with_inbound_qos0();
|
||||
test_keepalive_no_pings_inbound_qos1();
|
||||
test_keepalive_disconnects_hung();
|
||||
|
||||
FINISH
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef Arduino_h
|
||||
#define Arduino_h
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
extern "C"{
|
||||
typedef uint8_t byte ;
|
||||
typedef uint8_t boolean ;
|
||||
|
||||
/* sketch */
|
||||
extern void setup( void ) ;
|
||||
extern void loop( void ) ;
|
||||
uint32_t millis( void );
|
||||
}
|
||||
|
||||
#define PROGMEM
|
||||
#define pgm_read_byte_near(x) *(x)
|
||||
|
||||
#endif // Arduino_h
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "BDDTest.h"
|
||||
#include "trace.h"
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
int testCount = 0;
|
||||
int testPasses = 0;
|
||||
const char* testDescription;
|
||||
|
||||
std::list<std::string> failureList;
|
||||
|
||||
void bddtest_suite(const char* name) {
|
||||
LOG(name << "\n");
|
||||
}
|
||||
|
||||
int bddtest_test(const char* file, int line, const char* assertion, int result) {
|
||||
if (!result) {
|
||||
LOG("✗\n");
|
||||
std::ostringstream os;
|
||||
os << " ! "<<testDescription<<"\n " <<file << ":" <<line<<" : "<<assertion<<" ["<<result<<"]";
|
||||
failureList.push_back(os.str());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void bddtest_start(const char* description) {
|
||||
LOG(" - "<<description<<" ");
|
||||
testDescription = description;
|
||||
testCount ++;
|
||||
}
|
||||
void bddtest_end() {
|
||||
LOG("✓\n");
|
||||
testPasses ++;
|
||||
}
|
||||
|
||||
int bddtest_summary() {
|
||||
for (std::list<std::string>::iterator it = failureList.begin(); it != failureList.end(); it++) {
|
||||
LOG("\n");
|
||||
LOG(*it);
|
||||
LOG("\n");
|
||||
}
|
||||
|
||||
LOG(std::dec << testPasses << "/" << testCount << " tests passed\n\n");
|
||||
if (testPasses == testCount) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef bddtest_h
|
||||
#define bddtest_h
|
||||
|
||||
void bddtest_suite(const char* name);
|
||||
int bddtest_test(const char*, int, const char*, int);
|
||||
void bddtest_start(const char*);
|
||||
void bddtest_end();
|
||||
int bddtest_summary();
|
||||
|
||||
#define SUITE(x) { bddtest_suite(x); }
|
||||
#define TEST(x) { if (!bddtest_test(__FILE__, __LINE__, #x, (x))) return false; }
|
||||
|
||||
#define IT(x) { bddtest_start(x); }
|
||||
#define END_IT { bddtest_end();return true;}
|
||||
|
||||
#define FINISH { return bddtest_summary(); }
|
||||
|
||||
#define IS_TRUE(x) TEST(x)
|
||||
#define IS_FALSE(x) TEST(!(x))
|
||||
#define IS_EQUAL(x,y) TEST(x==y)
|
||||
#define IS_NOT_EQUAL(x,y) TEST(x!=y)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "Buffer.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
Buffer::Buffer() {
|
||||
}
|
||||
|
||||
Buffer::Buffer(uint8_t* buf, size_t size) {
|
||||
this->add(buf,size);
|
||||
}
|
||||
bool Buffer::available() {
|
||||
return this->pos < this->length;
|
||||
}
|
||||
|
||||
uint8_t Buffer::next() {
|
||||
if (this->available()) {
|
||||
return this->buffer[this->pos++];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Buffer::reset() {
|
||||
this->pos = 0;
|
||||
}
|
||||
|
||||
void Buffer::add(uint8_t* buf, size_t size) {
|
||||
uint16_t i = 0;
|
||||
for (;i<size;i++) {
|
||||
this->buffer[this->length++] = buf[i];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef buffer_h
|
||||
#define buffer_h
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
class Buffer {
|
||||
private:
|
||||
uint8_t buffer[1024];
|
||||
uint16_t pos;
|
||||
uint16_t length;
|
||||
|
||||
public:
|
||||
Buffer();
|
||||
Buffer(uint8_t* buf, size_t size);
|
||||
|
||||
virtual bool available();
|
||||
virtual uint8_t next();
|
||||
virtual void reset();
|
||||
|
||||
virtual void add(uint8_t* buf, size_t size);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef client_h
|
||||
#define client_h
|
||||
#include "IPAddress.h"
|
||||
|
||||
class Client {
|
||||
public:
|
||||
virtual int connect(IPAddress ip, uint16_t port) =0;
|
||||
virtual int connect(const char *host, uint16_t port) =0;
|
||||
virtual size_t write(uint8_t) =0;
|
||||
virtual size_t write(const uint8_t *buf, size_t size) =0;
|
||||
virtual int available() = 0;
|
||||
virtual int read() = 0;
|
||||
virtual int read(uint8_t *buf, size_t size) = 0;
|
||||
virtual int peek() = 0;
|
||||
virtual void flush() = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual uint8_t connected() = 0;
|
||||
virtual operator bool() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <IPAddress.h>
|
||||
|
||||
IPAddress::IPAddress()
|
||||
{
|
||||
memset(_address, 0, sizeof(_address));
|
||||
}
|
||||
|
||||
IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
|
||||
{
|
||||
_address[0] = first_octet;
|
||||
_address[1] = second_octet;
|
||||
_address[2] = third_octet;
|
||||
_address[3] = fourth_octet;
|
||||
}
|
||||
|
||||
IPAddress::IPAddress(uint32_t address)
|
||||
{
|
||||
memcpy(_address, &address, sizeof(_address));
|
||||
}
|
||||
|
||||
IPAddress::IPAddress(const uint8_t *address)
|
||||
{
|
||||
memcpy(_address, address, sizeof(_address));
|
||||
}
|
||||
|
||||
IPAddress& IPAddress::operator=(const uint8_t *address)
|
||||
{
|
||||
memcpy(_address, address, sizeof(_address));
|
||||
return *this;
|
||||
}
|
||||
|
||||
IPAddress& IPAddress::operator=(uint32_t address)
|
||||
{
|
||||
memcpy(_address, (const uint8_t *)&address, sizeof(_address));
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool IPAddress::operator==(const uint8_t* addr)
|
||||
{
|
||||
return memcmp(addr, _address, sizeof(_address)) == 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
*
|
||||
* MIT License:
|
||||
* Copyright (c) 2011 Adrian McEwen
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* adrianm@mcqn.com 1/1/2011
|
||||
*/
|
||||
|
||||
#ifndef IPAddress_h
|
||||
#define IPAddress_h
|
||||
|
||||
|
||||
// A class to make it easier to handle and pass around IP addresses
|
||||
|
||||
class IPAddress {
|
||||
private:
|
||||
uint8_t _address[4]; // IPv4 address
|
||||
// Access the raw byte array containing the address. Because this returns a pointer
|
||||
// to the internal structure rather than a copy of the address this function should only
|
||||
// be used when you know that the usage of the returned uint8_t* will be transient and not
|
||||
// stored.
|
||||
uint8_t* raw_address() { return _address; };
|
||||
|
||||
public:
|
||||
// Constructors
|
||||
IPAddress();
|
||||
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
|
||||
IPAddress(uint32_t address);
|
||||
IPAddress(const uint8_t *address);
|
||||
|
||||
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
|
||||
// to a four-byte uint8_t array is expected
|
||||
operator uint32_t() { return *((uint32_t*)_address); };
|
||||
bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
|
||||
bool operator==(const uint8_t* addr);
|
||||
|
||||
// Overloaded index operator to allow getting and setting individual octets of the address
|
||||
uint8_t operator[](int index) const { return _address[index]; };
|
||||
uint8_t& operator[](int index) { return _address[index]; };
|
||||
|
||||
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
|
||||
IPAddress& operator=(const uint8_t *address);
|
||||
IPAddress& operator=(uint32_t address);
|
||||
|
||||
|
||||
friend class EthernetClass;
|
||||
friend class UDP;
|
||||
friend class Client;
|
||||
friend class Server;
|
||||
friend class DhcpClass;
|
||||
friend class DNSClient;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,153 @@
|
||||
#include "ShimClient.h"
|
||||
#include "trace.h"
|
||||
#include <iostream>
|
||||
#include <Arduino.h>
|
||||
#include <ctime>
|
||||
|
||||
extern "C" {
|
||||
uint32_t millis(void) {
|
||||
return time(0)*1000;
|
||||
}
|
||||
}
|
||||
|
||||
ShimClient::ShimClient() {
|
||||
this->responseBuffer = new Buffer();
|
||||
this->expectBuffer = new Buffer();
|
||||
this->_allowConnect = true;
|
||||
this->_connected = false;
|
||||
this->_error = false;
|
||||
this->expectAnything = true;
|
||||
this->_received = 0;
|
||||
this->_expectedPort = 0;
|
||||
}
|
||||
|
||||
int ShimClient::connect(IPAddress ip, uint16_t port) {
|
||||
if (this->_allowConnect) {
|
||||
this->_connected = true;
|
||||
}
|
||||
if (this->_expectedPort !=0) {
|
||||
// if (memcmp(ip,this->_expectedIP,4) != 0) {
|
||||
// TRACE( "ip mismatch\n");
|
||||
// this->_error = true;
|
||||
// }
|
||||
if (port != this->_expectedPort) {
|
||||
TRACE( "port mismatch\n");
|
||||
this->_error = true;
|
||||
}
|
||||
}
|
||||
return this->_connected;
|
||||
}
|
||||
int ShimClient::connect(const char *host, uint16_t port) {
|
||||
if (this->_allowConnect) {
|
||||
this->_connected = true;
|
||||
}
|
||||
if (this->_expectedPort !=0) {
|
||||
if (strcmp(host,this->_expectedHost) != 0) {
|
||||
TRACE( "host mismatch\n");
|
||||
this->_error = true;
|
||||
}
|
||||
if (port != this->_expectedPort) {
|
||||
TRACE( "port mismatch\n");
|
||||
this->_error = true;
|
||||
}
|
||||
|
||||
}
|
||||
return this->_connected;
|
||||
}
|
||||
size_t ShimClient::write(uint8_t b) {
|
||||
this->_received += 1;
|
||||
TRACE(std::hex << (unsigned int)b);
|
||||
if (!this->expectAnything) {
|
||||
if (this->expectBuffer->available()) {
|
||||
uint8_t expected = this->expectBuffer->next();
|
||||
if (expected != b) {
|
||||
this->_error = true;
|
||||
TRACE("!=" << (unsigned int)expected);
|
||||
}
|
||||
} else {
|
||||
this->_error = true;
|
||||
}
|
||||
}
|
||||
TRACE("\n"<< std::dec);
|
||||
return 1;
|
||||
}
|
||||
size_t ShimClient::write(const uint8_t *buf, size_t size) {
|
||||
this->_received += size;
|
||||
TRACE( "[" << std::dec << (unsigned int)(size) << "] ");
|
||||
uint16_t i=0;
|
||||
for (;i<size;i++) {
|
||||
if (i>0) {
|
||||
TRACE(":");
|
||||
}
|
||||
TRACE(std::hex << (unsigned int)(buf[i]));
|
||||
|
||||
if (!this->expectAnything) {
|
||||
if (this->expectBuffer->available()) {
|
||||
uint8_t expected = this->expectBuffer->next();
|
||||
if (expected != buf[i]) {
|
||||
this->_error = true;
|
||||
TRACE("!=" << (unsigned int)expected);
|
||||
}
|
||||
} else {
|
||||
this->_error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
TRACE("\n"<<std::dec);
|
||||
return size;
|
||||
}
|
||||
int ShimClient::available() {
|
||||
return this->responseBuffer->available();
|
||||
}
|
||||
int ShimClient::read() { return this->responseBuffer->next(); }
|
||||
int ShimClient::read(uint8_t *buf, size_t size) {
|
||||
uint16_t i = 0;
|
||||
for (;i<size;i++) {
|
||||
buf[i] = this->read();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
int ShimClient::peek() { return 0; }
|
||||
void ShimClient::flush() {}
|
||||
void ShimClient::stop() {
|
||||
this->setConnected(false);
|
||||
}
|
||||
uint8_t ShimClient::connected() { return this->_connected; }
|
||||
ShimClient::operator bool() { return true; }
|
||||
|
||||
|
||||
ShimClient* ShimClient::respond(uint8_t *buf, size_t size) {
|
||||
this->responseBuffer->add(buf,size);
|
||||
return this;
|
||||
}
|
||||
|
||||
ShimClient* ShimClient::expect(uint8_t *buf, size_t size) {
|
||||
this->expectAnything = false;
|
||||
this->expectBuffer->add(buf,size);
|
||||
return this;
|
||||
}
|
||||
|
||||
void ShimClient::setConnected(bool b) {
|
||||
this->_connected = b;
|
||||
}
|
||||
void ShimClient::setAllowConnect(bool b) {
|
||||
this->_allowConnect = b;
|
||||
}
|
||||
|
||||
bool ShimClient::error() {
|
||||
return this->_error;
|
||||
}
|
||||
|
||||
uint16_t ShimClient::received() {
|
||||
return this->_received;
|
||||
}
|
||||
|
||||
void ShimClient::expectConnect(IPAddress ip, uint16_t port) {
|
||||
this->_expectedIP = ip;
|
||||
this->_expectedPort = port;
|
||||
}
|
||||
|
||||
void ShimClient::expectConnect(const char *host, uint16_t port) {
|
||||
this->_expectedHost = host;
|
||||
this->_expectedPort = port;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef shimclient_h
|
||||
#define shimclient_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "Client.h"
|
||||
#include "IPAddress.h"
|
||||
#include "Buffer.h"
|
||||
|
||||
|
||||
class ShimClient : public Client {
|
||||
private:
|
||||
Buffer* responseBuffer;
|
||||
Buffer* expectBuffer;
|
||||
bool _allowConnect;
|
||||
bool _connected;
|
||||
bool expectAnything;
|
||||
bool _error;
|
||||
uint16_t _received;
|
||||
IPAddress _expectedIP;
|
||||
uint16_t _expectedPort;
|
||||
const char* _expectedHost;
|
||||
|
||||
public:
|
||||
ShimClient();
|
||||
virtual int connect(IPAddress ip, uint16_t port);
|
||||
virtual int connect(const char *host, uint16_t port);
|
||||
virtual size_t write(uint8_t);
|
||||
virtual size_t write(const uint8_t *buf, size_t size);
|
||||
virtual int available();
|
||||
virtual int read();
|
||||
virtual int read(uint8_t *buf, size_t size);
|
||||
virtual int peek();
|
||||
virtual void flush();
|
||||
virtual void stop();
|
||||
virtual uint8_t connected();
|
||||
virtual operator bool();
|
||||
|
||||
virtual ShimClient* respond(uint8_t *buf, size_t size);
|
||||
virtual ShimClient* expect(uint8_t *buf, size_t size);
|
||||
|
||||
virtual void expectConnect(IPAddress ip, uint16_t port);
|
||||
virtual void expectConnect(const char *host, uint16_t port);
|
||||
|
||||
virtual uint16_t received();
|
||||
virtual bool error();
|
||||
|
||||
virtual void setAllowConnect(bool b);
|
||||
virtual void setConnected(bool b);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "Stream.h"
|
||||
#include "trace.h"
|
||||
#include <iostream>
|
||||
#include <Arduino.h>
|
||||
|
||||
Stream::Stream() {
|
||||
this->expectBuffer = new Buffer();
|
||||
this->_error = false;
|
||||
this->_written = 0;
|
||||
}
|
||||
|
||||
size_t Stream::write(uint8_t b) {
|
||||
this->_written++;
|
||||
TRACE(std::hex << (unsigned int)b);
|
||||
if (this->expectBuffer->available()) {
|
||||
uint8_t expected = this->expectBuffer->next();
|
||||
if (expected != b) {
|
||||
this->_error = true;
|
||||
TRACE("!=" << (unsigned int)expected);
|
||||
}
|
||||
} else {
|
||||
this->_error = true;
|
||||
}
|
||||
TRACE("\n"<< std::dec);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
bool Stream::error() {
|
||||
return this->_error;
|
||||
}
|
||||
|
||||
void Stream::expect(uint8_t *buf, size_t size) {
|
||||
this->expectBuffer->add(buf,size);
|
||||
}
|
||||
|
||||
uint16_t Stream::length() {
|
||||
return this->_written;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef Stream_h
|
||||
#define Stream_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "Buffer.h"
|
||||
|
||||
class Stream {
|
||||
private:
|
||||
Buffer* expectBuffer;
|
||||
bool _error;
|
||||
uint16_t _written;
|
||||
|
||||
public:
|
||||
Stream();
|
||||
virtual size_t write(uint8_t);
|
||||
|
||||
virtual bool error();
|
||||
virtual void expect(uint8_t *buf, size_t size);
|
||||
virtual uint16_t length();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef trace_h
|
||||
#define trace_h
|
||||
#include <iostream>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define LOG(x) {std::cout << x << std::flush; }
|
||||
#define TRACE(x) {if (getenv("TRACE")) { std::cout << x << std::flush; }}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,190 @@
|
||||
#include "PubSubClient.h"
|
||||
#include "ShimClient.h"
|
||||
#include "Buffer.h"
|
||||
#include "BDDTest.h"
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
byte server[] = { 172, 16, 0, 2 };
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
// handle message arrived
|
||||
}
|
||||
|
||||
int test_publish() {
|
||||
IT("publishes a null-terminated string");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x30,0xe,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||
shimClient.expect(publish,16);
|
||||
|
||||
rc = client.publish((char*)"topic",(char*)"payload");
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
|
||||
int test_publish_bytes() {
|
||||
IT("publishes a byte array");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte payload[] = { 0x01,0x02,0x03,0x0,0x05 };
|
||||
int length = 5;
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x30,0xc,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x1,0x2,0x3,0x0,0x5};
|
||||
shimClient.expect(publish,14);
|
||||
|
||||
rc = client.publish((char*)"topic",payload,length);
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
|
||||
int test_publish_retained() {
|
||||
IT("publishes retained - 1");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte payload[] = { 0x01,0x02,0x03,0x0,0x05 };
|
||||
int length = 5;
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x31,0xc,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x1,0x2,0x3,0x0,0x5};
|
||||
shimClient.expect(publish,14);
|
||||
|
||||
rc = client.publish((char*)"topic",payload,length,true);
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_publish_retained_2() {
|
||||
IT("publishes retained - 2");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x31,0xc,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,'A','B','C','D','E'};
|
||||
shimClient.expect(publish,14);
|
||||
|
||||
rc = client.publish((char*)"topic",(char*)"ABCDE",true);
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_publish_not_connected() {
|
||||
IT("publish fails when not connected");
|
||||
ShimClient shimClient;
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
|
||||
int rc = client.publish((char*)"topic",(char*)"payload");
|
||||
IS_FALSE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_publish_too_long() {
|
||||
IT("publish fails when topic/payload are too long");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2
|
||||
rc = client.publish((char*)"topic",(char*)"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
|
||||
IS_FALSE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_publish_P() {
|
||||
IT("publishes using PROGMEM");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte payload[] = { 0x01,0x02,0x03,0x0,0x05 };
|
||||
int length = 5;
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x31,0xc,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x1,0x2,0x3,0x0,0x5};
|
||||
shimClient.expect(publish,14);
|
||||
|
||||
rc = client.publish_P((char*)"topic",payload,length,true);
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
SUITE("Publish");
|
||||
test_publish();
|
||||
test_publish_bytes();
|
||||
test_publish_retained();
|
||||
test_publish_retained_2();
|
||||
test_publish_not_connected();
|
||||
test_publish_too_long();
|
||||
test_publish_P();
|
||||
|
||||
FINISH
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
#include "PubSubClient.h"
|
||||
#include "ShimClient.h"
|
||||
#include "Buffer.h"
|
||||
#include "BDDTest.h"
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
byte server[] = { 172, 16, 0, 2 };
|
||||
|
||||
bool callback_called = false;
|
||||
char lastTopic[1024];
|
||||
char lastPayload[1024];
|
||||
unsigned int lastLength;
|
||||
|
||||
void reset_callback() {
|
||||
callback_called = false;
|
||||
lastTopic[0] = '\0';
|
||||
lastPayload[0] = '\0';
|
||||
lastLength = 0;
|
||||
}
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
callback_called = true;
|
||||
strcpy(lastTopic,topic);
|
||||
memcpy(lastPayload,payload,length);
|
||||
lastLength = length;
|
||||
}
|
||||
|
||||
int test_receive_callback() {
|
||||
IT("receives a callback message");
|
||||
reset_callback();
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x30,0xe,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||
shimClient.respond(publish,16);
|
||||
|
||||
rc = client.loop();
|
||||
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_TRUE(callback_called);
|
||||
IS_TRUE(strcmp(lastTopic,"topic")==0);
|
||||
IS_TRUE(memcmp(lastPayload,"payload",7)==0);
|
||||
IS_TRUE(lastLength == 7);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_receive_stream() {
|
||||
IT("receives a streamed callback message");
|
||||
reset_callback();
|
||||
|
||||
Stream stream;
|
||||
stream.expect((uint8_t*)"payload",7);
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient, stream);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x30,0xe,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||
shimClient.respond(publish,16);
|
||||
|
||||
rc = client.loop();
|
||||
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_TRUE(callback_called);
|
||||
IS_TRUE(strcmp(lastTopic,"topic")==0);
|
||||
IS_TRUE(lastLength == 7);
|
||||
|
||||
IS_FALSE(stream.error());
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_receive_max_sized_message() {
|
||||
IT("receives an max-sized message");
|
||||
reset_callback();
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
int length = MQTT_MAX_PACKET_SIZE;
|
||||
byte publish[] = {0x30,length-2,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||
byte bigPublish[length];
|
||||
memset(bigPublish,'A',length);
|
||||
bigPublish[length] = 'B';
|
||||
memcpy(bigPublish,publish,16);
|
||||
shimClient.respond(bigPublish,length);
|
||||
|
||||
rc = client.loop();
|
||||
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_TRUE(callback_called);
|
||||
IS_TRUE(strcmp(lastTopic,"topic")==0);
|
||||
IS_TRUE(lastLength == length-9);
|
||||
IS_TRUE(memcmp(lastPayload,bigPublish+9,lastLength)==0);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_receive_oversized_message() {
|
||||
IT("drops an oversized message");
|
||||
reset_callback();
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
int length = MQTT_MAX_PACKET_SIZE+1;
|
||||
byte publish[] = {0x30,length-2,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||
byte bigPublish[length];
|
||||
memset(bigPublish,'A',length);
|
||||
bigPublish[length] = 'B';
|
||||
memcpy(bigPublish,publish,16);
|
||||
shimClient.respond(bigPublish,length);
|
||||
|
||||
rc = client.loop();
|
||||
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_FALSE(callback_called);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_receive_oversized_stream_message() {
|
||||
IT("drops an oversized message");
|
||||
reset_callback();
|
||||
|
||||
Stream stream;
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient, stream);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
int length = MQTT_MAX_PACKET_SIZE+1;
|
||||
byte publish[] = {0x30,length-2,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||
|
||||
byte bigPublish[length];
|
||||
memset(bigPublish,'A',length);
|
||||
bigPublish[length] = 'B';
|
||||
memcpy(bigPublish,publish,16);
|
||||
|
||||
shimClient.respond(bigPublish,length);
|
||||
stream.expect(bigPublish+9,length-9);
|
||||
|
||||
rc = client.loop();
|
||||
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_TRUE(callback_called);
|
||||
IS_TRUE(strcmp(lastTopic,"topic")==0);
|
||||
IS_TRUE(lastLength == length-9);
|
||||
|
||||
IS_FALSE(stream.error());
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_receive_qos1() {
|
||||
IT("receives a qos1 message");
|
||||
reset_callback();
|
||||
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte publish[] = {0x32,0x10,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x12,0x34,0x70,0x61,0x79,0x6c,0x6f,0x61,0x64};
|
||||
shimClient.respond(publish,18);
|
||||
|
||||
byte puback[] = {0x40,0x2,0x12,0x34};
|
||||
shimClient.expect(puback,4);
|
||||
|
||||
rc = client.loop();
|
||||
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_TRUE(callback_called);
|
||||
IS_TRUE(strcmp(lastTopic,"topic")==0);
|
||||
IS_TRUE(memcmp(lastPayload,"payload",7)==0);
|
||||
IS_TRUE(lastLength == 7);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
SUITE("Receive");
|
||||
test_receive_callback();
|
||||
test_receive_stream();
|
||||
test_receive_max_sized_message();
|
||||
test_receive_oversized_message();
|
||||
test_receive_oversized_stream_message();
|
||||
test_receive_qos1();
|
||||
|
||||
FINISH
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
#include "PubSubClient.h"
|
||||
#include "ShimClient.h"
|
||||
#include "Buffer.h"
|
||||
#include "BDDTest.h"
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
byte server[] = { 172, 16, 0, 2 };
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
// handle message arrived
|
||||
}
|
||||
|
||||
int test_subscribe_no_qos() {
|
||||
IT("subscribe without qos defaults to 0");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte subscribe[] = { 0x82,0xa,0x0,0x2,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x0 };
|
||||
shimClient.expect(subscribe,12);
|
||||
byte suback[] = { 0x90,0x3,0x0,0x2,0x0 };
|
||||
shimClient.respond(suback,5);
|
||||
|
||||
rc = client.subscribe((char*)"topic");
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_subscribe_qos_1() {
|
||||
IT("subscribes qos 1");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte subscribe[] = { 0x82,0xa,0x0,0x2,0x0,0x5,0x74,0x6f,0x70,0x69,0x63,0x1 };
|
||||
shimClient.expect(subscribe,12);
|
||||
byte suback[] = { 0x90,0x3,0x0,0x2,0x1 };
|
||||
shimClient.respond(suback,5);
|
||||
|
||||
rc = client.subscribe((char*)"topic",1);
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_subscribe_not_connected() {
|
||||
IT("subscribe fails when not connected");
|
||||
ShimClient shimClient;
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
|
||||
int rc = client.subscribe((char*)"topic");
|
||||
IS_FALSE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_subscribe_invalid_qos() {
|
||||
IT("subscribe fails with invalid qos values");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
rc = client.subscribe((char*)"topic",2);
|
||||
IS_FALSE(rc);
|
||||
rc = client.subscribe((char*)"topic",254);
|
||||
IS_FALSE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_subscribe_too_long() {
|
||||
IT("subscribe fails with too long topic");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
// max length should be allowed
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2
|
||||
rc = client.subscribe((char*)"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");
|
||||
IS_TRUE(rc);
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 0 1 2
|
||||
rc = client.subscribe((char*)"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
|
||||
IS_FALSE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
|
||||
int test_unsubscribe() {
|
||||
IT("unsubscribes");
|
||||
ShimClient shimClient;
|
||||
shimClient.setAllowConnect(true);
|
||||
|
||||
byte connack[] = { 0x20, 0x02, 0x00, 0x00 };
|
||||
shimClient.respond(connack,4);
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
int rc = client.connect((char*)"client_test1");
|
||||
IS_TRUE(rc);
|
||||
|
||||
byte unsubscribe[] = { 0xA2,0x9,0x0,0x2,0x0,0x5,0x74,0x6f,0x70,0x69,0x63 };
|
||||
shimClient.expect(unsubscribe,12);
|
||||
byte unsuback[] = { 0xB0,0x2,0x0,0x2 };
|
||||
shimClient.respond(unsuback,4);
|
||||
|
||||
rc = client.unsubscribe((char*)"topic");
|
||||
IS_TRUE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int test_unsubscribe_not_connected() {
|
||||
IT("unsubscribe fails when not connected");
|
||||
ShimClient shimClient;
|
||||
|
||||
PubSubClient client(server, 1883, callback, shimClient);
|
||||
|
||||
int rc = client.unsubscribe((char*)"topic");
|
||||
IS_FALSE(rc);
|
||||
|
||||
IS_FALSE(shimClient.error());
|
||||
|
||||
END_IT
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
SUITE("Subscribe");
|
||||
test_subscribe_no_qos();
|
||||
test_subscribe_qos_1();
|
||||
test_subscribe_not_connected();
|
||||
test_subscribe_invalid_qos();
|
||||
test_subscribe_too_long();
|
||||
test_unsubscribe();
|
||||
test_unsubscribe_not_connected();
|
||||
FINISH
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import unittest
|
||||
import settings
|
||||
|
||||
import time
|
||||
import mosquitto
|
||||
|
||||
import serial
|
||||
|
||||
def on_message(mosq, obj, msg):
|
||||
obj.message_queue.append(msg)
|
||||
|
||||
class mqtt_basic(unittest.TestCase):
|
||||
|
||||
message_queue = []
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
self.client = mosquitto.Mosquitto("pubsubclient_ut", clean_session=True,obj=self)
|
||||
self.client.connect(settings.server_ip)
|
||||
self.client.on_message = on_message
|
||||
self.client.subscribe("outTopic",0)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(self):
|
||||
self.client.disconnect()
|
||||
|
||||
def test_one(self):
|
||||
i=30
|
||||
while len(self.message_queue) == 0 and i > 0:
|
||||
self.client.loop()
|
||||
time.sleep(0.5)
|
||||
i -= 1
|
||||
self.assertTrue(i>0, "message receive timed-out")
|
||||
self.assertEqual(len(self.message_queue), 1, "unexpected number of messages received")
|
||||
msg = self.message_queue[0]
|
||||
self.assertEqual(msg.mid,0,"message id not 0")
|
||||
self.assertEqual(msg.topic,"outTopic","message topic incorrect")
|
||||
self.assertEqual(msg.payload,"hello world")
|
||||
self.assertEqual(msg.qos,0,"message qos not 0")
|
||||
self.assertEqual(msg.retain,False,"message retain flag incorrect")
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import unittest
|
||||
import settings
|
||||
|
||||
import time
|
||||
import mosquitto
|
||||
|
||||
import serial
|
||||
|
||||
def on_message(mosq, obj, msg):
|
||||
obj.message_queue.append(msg)
|
||||
|
||||
class mqtt_publish_in_callback(unittest.TestCase):
|
||||
|
||||
message_queue = []
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
self.client = mosquitto.Mosquitto("pubsubclient_ut", clean_session=True,obj=self)
|
||||
self.client.connect(settings.server_ip)
|
||||
self.client.on_message = on_message
|
||||
self.client.subscribe("outTopic",0)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(self):
|
||||
self.client.disconnect()
|
||||
|
||||
def test_connect(self):
|
||||
i=30
|
||||
while len(self.message_queue) == 0 and i > 0:
|
||||
self.client.loop()
|
||||
time.sleep(0.5)
|
||||
i -= 1
|
||||
self.assertTrue(i>0, "message receive timed-out")
|
||||
self.assertEqual(len(self.message_queue), 1, "unexpected number of messages received")
|
||||
msg = self.message_queue.pop(0)
|
||||
self.assertEqual(msg.mid,0,"message id not 0")
|
||||
self.assertEqual(msg.topic,"outTopic","message topic incorrect")
|
||||
self.assertEqual(msg.payload,"hello world")
|
||||
self.assertEqual(msg.qos,0,"message qos not 0")
|
||||
self.assertEqual(msg.retain,False,"message retain flag incorrect")
|
||||
|
||||
|
||||
def test_publish(self):
|
||||
self.assertEqual(len(self.message_queue), 0, "message queue not empty")
|
||||
payload = "abcdefghij"
|
||||
self.client.publish("inTopic",payload)
|
||||
|
||||
i=30
|
||||
while len(self.message_queue) == 0 and i > 0:
|
||||
self.client.loop()
|
||||
time.sleep(0.5)
|
||||
i -= 1
|
||||
|
||||
self.assertTrue(i>0, "message receive timed-out")
|
||||
self.assertEqual(len(self.message_queue), 1, "unexpected number of messages received")
|
||||
msg = self.message_queue.pop(0)
|
||||
self.assertEqual(msg.mid,0,"message id not 0")
|
||||
self.assertEqual(msg.topic,"outTopic","message topic incorrect")
|
||||
self.assertEqual(msg.payload,payload)
|
||||
self.assertEqual(msg.qos,0,"message qos not 0")
|
||||
self.assertEqual(msg.retain,False,"message retain flag incorrect")
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
server_ip = "172.16.0.2"
|
||||
arduino_ip = "172.16.0.100"
|
||||
@@ -0,0 +1,179 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import shutil
|
||||
from subprocess import call
|
||||
import importlib
|
||||
import unittest
|
||||
import re
|
||||
|
||||
from testcases import settings
|
||||
|
||||
class Workspace(object):
|
||||
|
||||
def __init__(self):
|
||||
self.root_dir = os.getcwd()
|
||||
self.build_dir = os.path.join(self.root_dir,"tmpbin");
|
||||
self.log_dir = os.path.join(self.root_dir,"logs");
|
||||
self.tests_dir = os.path.join(self.root_dir,"testcases");
|
||||
self.examples_dir = os.path.join(self.root_dir,"../PubSubClient/examples")
|
||||
self.examples = []
|
||||
self.tests = []
|
||||
if not os.path.isdir("../PubSubClient"):
|
||||
raise Exception("Cannot find PubSubClient library")
|
||||
try:
|
||||
import ino
|
||||
except:
|
||||
raise Exception("ino tool not installed")
|
||||
|
||||
def init(self):
|
||||
if os.path.isdir(self.build_dir):
|
||||
shutil.rmtree(self.build_dir)
|
||||
os.mkdir(self.build_dir)
|
||||
if os.path.isdir(self.log_dir):
|
||||
shutil.rmtree(self.log_dir)
|
||||
os.mkdir(self.log_dir)
|
||||
|
||||
os.chdir(self.build_dir)
|
||||
call(["ino","init"])
|
||||
|
||||
shutil.copytree("../../PubSubClient","lib/PubSubClient")
|
||||
|
||||
filenames = []
|
||||
for root, dirs, files in os.walk(self.examples_dir):
|
||||
filenames += [os.path.join(root,f) for f in files if f.endswith(".ino")]
|
||||
filenames.sort()
|
||||
for e in filenames:
|
||||
self.examples.append(Sketch(self,e))
|
||||
|
||||
filenames = []
|
||||
for root, dirs, files in os.walk(self.tests_dir):
|
||||
filenames += [os.path.join(root,f) for f in files if f.endswith(".ino")]
|
||||
filenames.sort()
|
||||
for e in filenames:
|
||||
self.tests.append(Sketch(self,e))
|
||||
|
||||
def clean(self):
|
||||
shutil.rmtree(self.build_dir)
|
||||
|
||||
class Sketch(object):
|
||||
def __init__(self,wksp,fn):
|
||||
self.w = wksp
|
||||
self.filename = fn
|
||||
self.basename = os.path.basename(self.filename)
|
||||
self.build_log = os.path.join(self.w.log_dir,"%s.log"%(os.path.basename(self.filename),))
|
||||
self.build_err_log = os.path.join(self.w.log_dir,"%s.err.log"%(os.path.basename(self.filename),))
|
||||
self.build_upload_log = os.path.join(self.w.log_dir,"%s.upload.log"%(os.path.basename(self.filename),))
|
||||
|
||||
def build(self):
|
||||
sys.stdout.write(" Build: ")
|
||||
sys.stdout.flush()
|
||||
|
||||
# Copy sketch over, replacing IP addresses as necessary
|
||||
fin = open(self.filename,"r")
|
||||
lines = fin.readlines()
|
||||
fin.close()
|
||||
fout = open(os.path.join(self.w.build_dir,"src","sketch.ino"),"w")
|
||||
for l in lines:
|
||||
if re.match(r"^byte server\[\] = {",l):
|
||||
fout.write("byte server[] = { %s };\n"%(settings.server_ip.replace(".",", "),))
|
||||
elif re.match(r"^byte ip\[\] = {",l):
|
||||
fout.write("byte ip[] = { %s };\n"%(settings.arduino_ip.replace(".",", "),))
|
||||
else:
|
||||
fout.write(l)
|
||||
fout.flush()
|
||||
fout.close()
|
||||
|
||||
# Run build
|
||||
fout = open(self.build_log, "w")
|
||||
ferr = open(self.build_err_log, "w")
|
||||
rc = call(["ino","build"],stdout=fout,stderr=ferr)
|
||||
fout.close()
|
||||
ferr.close()
|
||||
if rc == 0:
|
||||
sys.stdout.write("pass")
|
||||
sys.stdout.write("\n")
|
||||
return True
|
||||
else:
|
||||
sys.stdout.write("fail")
|
||||
sys.stdout.write("\n")
|
||||
with open(self.build_err_log) as f:
|
||||
for line in f:
|
||||
print " ",line,
|
||||
return False
|
||||
|
||||
def upload(self):
|
||||
sys.stdout.write(" Upload: ")
|
||||
sys.stdout.flush()
|
||||
fout = open(self.build_upload_log, "w")
|
||||
rc = call(["ino","upload"],stdout=fout,stderr=fout)
|
||||
fout.close()
|
||||
if rc == 0:
|
||||
sys.stdout.write("pass")
|
||||
sys.stdout.write("\n")
|
||||
return True
|
||||
else:
|
||||
sys.stdout.write("fail")
|
||||
sys.stdout.write("\n")
|
||||
with open(self.build_upload_log) as f:
|
||||
for line in f:
|
||||
print " ",line,
|
||||
return False
|
||||
|
||||
|
||||
def test(self):
|
||||
# import the matching test case, if it exists
|
||||
try:
|
||||
basename = os.path.basename(self.filename)[:-4]
|
||||
i = importlib.import_module("testcases."+basename)
|
||||
except:
|
||||
sys.stdout.write(" Test: no tests found")
|
||||
sys.stdout.write("\n")
|
||||
return
|
||||
c = getattr(i,basename)
|
||||
|
||||
testmethods = [m for m in dir(c) if m.startswith("test_")]
|
||||
testmethods.sort()
|
||||
tests = []
|
||||
for m in testmethods:
|
||||
tests.append(c(m))
|
||||
|
||||
result = unittest.TestResult()
|
||||
c.setUpClass()
|
||||
if self.upload():
|
||||
sys.stdout.write(" Test: ")
|
||||
sys.stdout.flush()
|
||||
for t in tests:
|
||||
t.run(result)
|
||||
print "%d/%d"%(result.testsRun-len(result.failures)-len(result.errors),result.testsRun)
|
||||
if not result.wasSuccessful():
|
||||
if len(result.failures) > 0:
|
||||
for f in result.failures:
|
||||
print "-- %s"%(str(f[0]),)
|
||||
print f[1]
|
||||
if len(result.errors) > 0:
|
||||
print " Errors:"
|
||||
for f in result.errors:
|
||||
print "-- %s"%(str(f[0]),)
|
||||
print f[1]
|
||||
c.tearDownClass()
|
||||
|
||||
if __name__ == '__main__':
|
||||
run_tests = True
|
||||
|
||||
w = Workspace()
|
||||
w.init()
|
||||
|
||||
for e in w.examples:
|
||||
print "--------------------------------------"
|
||||
print "[%s]"%(e.basename,)
|
||||
if e.build() and run_tests:
|
||||
e.test()
|
||||
for e in w.tests:
|
||||
print "--------------------------------------"
|
||||
print "[%s]"%(e.basename,)
|
||||
if e.build() and run_tests:
|
||||
e.test()
|
||||
|
||||
w.clean()
|
||||
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Connect the MQ2 sensor as follows :
|
||||
*
|
||||
* A H A >>> 5V
|
||||
* B >>> A0
|
||||
* H >>> GND
|
||||
* B >>> 10K ohm >>> GND
|
||||
*
|
||||
* Contribution: epierre
|
||||
* Based on http://sandboxelectronics.com/?p=165
|
||||
* License: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
|
||||
* Modified by HEK to work in 1.4
|
||||
*
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define CHILD_ID_MQ 0
|
||||
/************************Hardware Related Macros************************************/
|
||||
#define MQ_SENSOR_ANALOG_PIN (0) //define which analog input channel you are going to use
|
||||
#define RL_VALUE (5) //define the load resistance on the board, in kilo ohms
|
||||
#define RO_CLEAN_AIR_FACTOR (9.83) //RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO,
|
||||
//which is derived from the chart in datasheet
|
||||
/***********************Software Related Macros************************************/
|
||||
#define CALIBARAION_SAMPLE_TIMES (50) //define how many samples you are going to take in the calibration phase
|
||||
#define CALIBRATION_SAMPLE_INTERVAL (500) //define the time interal(in milisecond) between each samples in the
|
||||
//cablibration phase
|
||||
#define READ_SAMPLE_INTERVAL (50) //define how many samples you are going to take in normal operation
|
||||
#define READ_SAMPLE_TIMES (5) //define the time interal(in milisecond) between each samples in
|
||||
//normal operation
|
||||
/**********************Application Related Macros**********************************/
|
||||
#define GAS_LPG (0)
|
||||
#define GAS_CO (1)
|
||||
#define GAS_SMOKE (2)
|
||||
/*****************************Globals***********************************************/
|
||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||
//VARIABLES
|
||||
float Ro = 10000.0; // this has to be tuned 10K Ohm
|
||||
int val = 0; // variable to store the value coming from the sensor
|
||||
float valMQ =0.0;
|
||||
float lastMQ =0.0;
|
||||
float LPGCurve[3] = {2.3,0.21,-0.47}; //two points are taken from the curve.
|
||||
//with these two points, a line is formed which is "approximately equivalent"
|
||||
//to the original curve.
|
||||
//data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59)
|
||||
float COCurve[3] = {2.3,0.72,-0.34}; //two points are taken from the curve.
|
||||
//with these two points, a line is formed which is "approximately equivalent"
|
||||
//to the original curve.
|
||||
//data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000, 0.15)
|
||||
float SmokeCurve[3] ={2.3,0.53,-0.44}; //two points are taken from the curve.
|
||||
//with these two points, a line is formed which is "approximately equivalent"
|
||||
//to the original curve.
|
||||
//data format:{ x, y, slope}; point1: (lg200, 0.53), point2:(lg10000,-0.22)
|
||||
|
||||
|
||||
MyMessage msg(CHILD_ID_MQ, V_LEVEL);
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Air Quality Sensor", "1.0");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
present(CHILD_ID_MQ, S_AIR_QUALITY);
|
||||
|
||||
Ro = MQCalibration(MQ_SENSOR_ANALOG_PIN); //Calibrating the sensor. Please make sure the sensor is in clean air
|
||||
//when you perform the calibration
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint16_t valMQ = MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_CO);
|
||||
Serial.println(val);
|
||||
|
||||
Serial.print("LPG:");
|
||||
Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_LPG) );
|
||||
Serial.print( "ppm" );
|
||||
Serial.print(" ");
|
||||
Serial.print("CO:");
|
||||
Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_CO) );
|
||||
Serial.print( "ppm" );
|
||||
Serial.print(" ");
|
||||
Serial.print("SMOKE:");
|
||||
Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_SMOKE) );
|
||||
Serial.print( "ppm" );
|
||||
Serial.print("\n");
|
||||
|
||||
if (valMQ != lastMQ) {
|
||||
send(msg.set((int)ceil(valMQ)));
|
||||
lastMQ = ceil(valMQ);
|
||||
}
|
||||
|
||||
sleep(SLEEP_TIME); //sleep for: sleepTime
|
||||
}
|
||||
|
||||
/****************** MQResistanceCalculation ****************************************
|
||||
Input: raw_adc - raw value read from adc, which represents the voltage
|
||||
Output: the calculated sensor resistance
|
||||
Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage
|
||||
across the load resistor and its resistance, the resistance of the sensor
|
||||
could be derived.
|
||||
************************************************************************************/
|
||||
float MQResistanceCalculation(int raw_adc)
|
||||
{
|
||||
return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc));
|
||||
}
|
||||
|
||||
/***************************** MQCalibration ****************************************
|
||||
Input: mq_pin - analog channel
|
||||
Output: Ro of the sensor
|
||||
Remarks: This function assumes that the sensor is in clean air. It use
|
||||
MQResistanceCalculation to calculates the sensor resistance in clean air
|
||||
and then divides it with RO_CLEAN_AIR_FACTOR. RO_CLEAN_AIR_FACTOR is about
|
||||
10, which differs slightly between different sensors.
|
||||
************************************************************************************/
|
||||
float MQCalibration(int mq_pin)
|
||||
{
|
||||
int i;
|
||||
float val=0;
|
||||
|
||||
for (i=0;i<CALIBARAION_SAMPLE_TIMES;i++) { //take multiple samples
|
||||
val += MQResistanceCalculation(analogRead(mq_pin));
|
||||
delay(CALIBRATION_SAMPLE_INTERVAL);
|
||||
}
|
||||
val = val/CALIBARAION_SAMPLE_TIMES; //calculate the average value
|
||||
|
||||
val = val/RO_CLEAN_AIR_FACTOR; //divided by RO_CLEAN_AIR_FACTOR yields the Ro
|
||||
//according to the chart in the datasheet
|
||||
|
||||
return val;
|
||||
}
|
||||
/***************************** MQRead *********************************************
|
||||
Input: mq_pin - analog channel
|
||||
Output: Rs of the sensor
|
||||
Remarks: This function use MQResistanceCalculation to caculate the sensor resistenc (Rs).
|
||||
The Rs changes as the sensor is in the different consentration of the target
|
||||
gas. The sample times and the time interval between samples could be configured
|
||||
by changing the definition of the macros.
|
||||
************************************************************************************/
|
||||
float MQRead(int mq_pin)
|
||||
{
|
||||
int i;
|
||||
float rs=0;
|
||||
|
||||
for (i=0;i<READ_SAMPLE_TIMES;i++) {
|
||||
rs += MQResistanceCalculation(analogRead(mq_pin));
|
||||
delay(READ_SAMPLE_INTERVAL);
|
||||
}
|
||||
|
||||
rs = rs/READ_SAMPLE_TIMES;
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
/***************************** MQGetGasPercentage **********************************
|
||||
Input: rs_ro_ratio - Rs divided by Ro
|
||||
gas_id - target gas type
|
||||
Output: ppm of the target gas
|
||||
Remarks: This function passes different curves to the MQGetPercentage function which
|
||||
calculates the ppm (parts per million) of the target gas.
|
||||
************************************************************************************/
|
||||
int MQGetGasPercentage(float rs_ro_ratio, int gas_id)
|
||||
{
|
||||
if ( gas_id == GAS_LPG ) {
|
||||
return MQGetPercentage(rs_ro_ratio,LPGCurve);
|
||||
} else if ( gas_id == GAS_CO ) {
|
||||
return MQGetPercentage(rs_ro_ratio,COCurve);
|
||||
} else if ( gas_id == GAS_SMOKE ) {
|
||||
return MQGetPercentage(rs_ro_ratio,SmokeCurve);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************** MQGetPercentage **********************************
|
||||
Input: rs_ro_ratio - Rs divided by Ro
|
||||
pcurve - pointer to the curve of the target gas
|
||||
Output: ppm of the target gas
|
||||
Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm)
|
||||
of the line could be derived if y(rs_ro_ratio) is provided. As it is a
|
||||
logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic
|
||||
value.
|
||||
************************************************************************************/
|
||||
int MQGetPercentage(float rs_ro_ratio, float *pcurve)
|
||||
{
|
||||
return (pow(10,( ((log(rs_ro_ratio)-pcurve[1])/pcurve[2]) + pcurve[0])));
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* This is an example that demonstrates how to report the battery level for a sensor
|
||||
* Instructions for measuring battery capacity on A0 are available here:
|
||||
* http://www.mysensors.org/build/battery
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point
|
||||
|
||||
unsigned long SLEEP_TIME = 900000; // sleep time between reads (seconds * 1000 milliseconds)
|
||||
int oldBatteryPcnt = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// use the 1.1 V internal reference
|
||||
#if defined(__AVR_ATmega2560__)
|
||||
analogReference(INTERNAL1V1);
|
||||
#else
|
||||
analogReference(INTERNAL);
|
||||
#endif
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Battery Meter", "1.0");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// get the battery Voltage
|
||||
int sensorValue = analogRead(BATTERY_SENSE_PIN);
|
||||
#ifdef DEBUG
|
||||
Serial.println(sensorValue);
|
||||
#endif
|
||||
|
||||
// 1M, 470K divider across battery and using internal ADC ref of 1.1V
|
||||
// Sense point is bypassed with 0.1 uF cap to reduce noise at that point
|
||||
// ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
|
||||
// 3.44/1023 = Volts per bit = 0.003363075
|
||||
float batteryV = sensorValue * 0.003363075;
|
||||
int batteryPcnt = sensorValue / 10;
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.print("Battery Voltage: ");
|
||||
Serial.print(batteryV);
|
||||
Serial.println(" V");
|
||||
|
||||
Serial.print("Battery percent: ");
|
||||
Serial.print(batteryPcnt);
|
||||
Serial.println(" %");
|
||||
#endif
|
||||
|
||||
if (oldBatteryPcnt != batteryPcnt) {
|
||||
// Power up radio after sleep
|
||||
sendBatteryLevel(batteryPcnt);
|
||||
oldBatteryPcnt = batteryPcnt;
|
||||
}
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Simple binary switch example
|
||||
* Connect button or door/window reed switch between
|
||||
* digitial I/O pin 3 (BUTTON_PIN below) and GND.
|
||||
* http://www.mysensors.org/build/binary
|
||||
*/
|
||||
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <Bounce2.h>
|
||||
|
||||
#define CHILD_ID 3
|
||||
#define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
|
||||
|
||||
Bounce debouncer = Bounce();
|
||||
int oldValue=-1;
|
||||
|
||||
// Change to V_LIGHT if you use S_LIGHT in presentation below
|
||||
MyMessage msg(CHILD_ID,V_TRIPPED);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Setup the button
|
||||
pinMode(BUTTON_PIN,INPUT);
|
||||
// Activate internal pull-up
|
||||
digitalWrite(BUTTON_PIN,HIGH);
|
||||
|
||||
// After setting up the button, setup debouncer
|
||||
debouncer.attach(BUTTON_PIN);
|
||||
debouncer.interval(5);
|
||||
|
||||
// Register binary input sensor to gw (they will be created as child devices)
|
||||
// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
|
||||
// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
|
||||
present(CHILD_ID, S_DOOR);
|
||||
}
|
||||
|
||||
|
||||
// Check if digital input has changed and send in new value
|
||||
void loop()
|
||||
{
|
||||
debouncer.update();
|
||||
// Get the update value
|
||||
int value = debouncer.read();
|
||||
|
||||
if (value != oldValue) {
|
||||
// Send in the new value
|
||||
send(msg.set(value==HIGH ? 1 : 0));
|
||||
oldValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Interrupt driven binary switch example with dual interrupts
|
||||
* Author: Patrick 'Anticimex' Fallberg
|
||||
* Connect one button or door/window reed switch between
|
||||
* digitial I/O pin 3 (BUTTON_PIN below) and GND and the other
|
||||
* one in similar fashion on digital I/O pin 2.
|
||||
* This example is designed to fit Arduino Nano/Pro Mini
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define SKETCH_NAME "Binary Sensor"
|
||||
#define SKETCH_MAJOR_VER "1"
|
||||
#define SKETCH_MINOR_VER "0"
|
||||
|
||||
#define PRIMARY_CHILD_ID 3
|
||||
#define SECONDARY_CHILD_ID 4
|
||||
|
||||
#define PRIMARY_BUTTON_PIN 2 // Arduino Digital I/O pin for button/reed switch
|
||||
#define SECONDARY_BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
|
||||
|
||||
#if (PRIMARY_BUTTON_PIN < 2 || PRIMARY_BUTTON_PIN > 3)
|
||||
#error PRIMARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
|
||||
#endif
|
||||
#if (SECONDARY_BUTTON_PIN < 2 || SECONDARY_BUTTON_PIN > 3)
|
||||
#error SECONDARY_BUTTON_PIN must be either 2 or 3 for interrupts to work
|
||||
#endif
|
||||
#if (PRIMARY_BUTTON_PIN == SECONDARY_BUTTON_PIN)
|
||||
#error PRIMARY_BUTTON_PIN and BUTTON_PIN2 cannot be the same
|
||||
#endif
|
||||
#if (PRIMARY_CHILD_ID == SECONDARY_CHILD_ID)
|
||||
#error PRIMARY_CHILD_ID and SECONDARY_CHILD_ID cannot be the same
|
||||
#endif
|
||||
|
||||
|
||||
// Change to V_LIGHT if you use S_LIGHT in presentation below
|
||||
MyMessage msg(PRIMARY_CHILD_ID, V_TRIPPED);
|
||||
MyMessage msg2(SECONDARY_CHILD_ID, V_TRIPPED);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Setup the buttons
|
||||
pinMode(PRIMARY_BUTTON_PIN, INPUT);
|
||||
pinMode(SECONDARY_BUTTON_PIN, INPUT);
|
||||
|
||||
// Activate internal pull-ups
|
||||
digitalWrite(PRIMARY_BUTTON_PIN, HIGH);
|
||||
digitalWrite(SECONDARY_BUTTON_PIN, HIGH);
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);
|
||||
|
||||
// Register binary input sensor to sensor_node (they will be created as child devices)
|
||||
// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
|
||||
// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
|
||||
present(PRIMARY_CHILD_ID, S_DOOR);
|
||||
present(SECONDARY_CHILD_ID, S_DOOR);
|
||||
}
|
||||
|
||||
// Loop will iterate on changes on the BUTTON_PINs
|
||||
void loop()
|
||||
{
|
||||
uint8_t value;
|
||||
static uint8_t sentValue=2;
|
||||
static uint8_t sentValue2=2;
|
||||
|
||||
// Short delay to allow buttons to properly settle
|
||||
sleep(5);
|
||||
|
||||
value = digitalRead(PRIMARY_BUTTON_PIN);
|
||||
|
||||
if (value != sentValue) {
|
||||
// Value has changed from last transmission, send the updated value
|
||||
send(msg.set(value==HIGH ? 1 : 0));
|
||||
sentValue = value;
|
||||
}
|
||||
|
||||
value = digitalRead(SECONDARY_BUTTON_PIN);
|
||||
|
||||
if (value != sentValue2) {
|
||||
// Value has changed from last transmission, send the updated value
|
||||
send(msg2.set(value==HIGH ? 1 : 0));
|
||||
sentValue2 = value;
|
||||
}
|
||||
|
||||
// Sleep until something happens with the sensor
|
||||
sleep(PRIMARY_BUTTON_PIN-2, CHANGE, SECONDARY_BUTTON_PIN-2, CHANGE, 0);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* MH-Z14 CO2 sensor
|
||||
*
|
||||
* Wiring:
|
||||
* Pad 1, Pad 5: Vin (Voltage input 4.5V-6V)
|
||||
* Pad 2, Pad 3, Pad 12: GND
|
||||
* Pad 6: PWM output ==> pin 6
|
||||
*
|
||||
* From: http://davidegironi.blogspot.fr/2014/01/co2-meter-using-ndir-infrared-mh-z14.html
|
||||
* MH-Z14 has a PWM output, with a sensitivity range of 0ppm to 2000ppm CO2, an accurancy of ±200ppm.
|
||||
* The cycle is 1004ms±5%, given the duty cicle Th (pulse high), Tl is 1004-Th, we can convert it to CO2 value using the formula:
|
||||
* CO2ppm = 2000 * (Th - 2ms) /(Th + Tl - 4ms)
|
||||
* From: http://airqualityegg.wikispaces.com/Sensor+Tests
|
||||
* - response time is less than 30 s
|
||||
* - 3 minute warm up time
|
||||
* datasheet: http://www.futurlec.com/Datasheet/Sensor/MH-Z14.pdf
|
||||
* Contributor: epierre
|
||||
**/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define CHILD_ID_AIQ 0
|
||||
#define AIQ_SENSOR_ANALOG_PIN 6
|
||||
|
||||
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
||||
|
||||
float valAIQ =0.0;
|
||||
float lastAIQ =0.0;
|
||||
|
||||
MyMessage msg(CHILD_ID_AIQ, V_LEVEL);
|
||||
MyMessage msg2(CHILD_ID_AIQ, V_UNIT_PREFIX);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("AIQ Sensor CO2 MH-Z14", "1.0");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
present(CHILD_ID_AIQ, S_AIR_QUALITY);
|
||||
send(msg2.set("ppm"));
|
||||
|
||||
sleep(SLEEP_TIME);
|
||||
|
||||
pinMode(AIQ_SENSOR_ANALOG_PIN, INPUT);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
//unsigned long duration = pulseIn(AIQ_SENSOR_ANALOG_PIN, HIGH);
|
||||
while(digitalRead(AIQ_SENSOR_ANALOG_PIN) == HIGH) {;}
|
||||
//wait for the pin to go HIGH and measure HIGH time
|
||||
unsigned long duration = pulseIn(AIQ_SENSOR_ANALOG_PIN, HIGH);
|
||||
|
||||
//Serial.print(duration/1000); Serial.println(" ms ");
|
||||
//from datasheet
|
||||
//CO2 ppm = 2000 * (Th - 2ms) / (Th + Tl - 4ms)
|
||||
// given Tl + Th = 1004
|
||||
// Tl = 1004 - Th
|
||||
// = 2000 * (Th - 2ms) / (Th + 1004 - Th -4ms)
|
||||
// = 2000 * (Th - 2ms) / 1000 = 2 * (Th - 2ms)
|
||||
long co2ppm = 2 * ((duration/1000) - 2);
|
||||
//Serial.print(co2ppm);
|
||||
if ((co2ppm != lastAIQ)&&(abs(co2ppm-lastAIQ)>=10)) {
|
||||
send(msg.set((long)ceil(co2ppm)));
|
||||
lastAIQ = ceil(co2ppm);
|
||||
}
|
||||
|
||||
//Serial.println();
|
||||
|
||||
// Power down the radio. Note that the radio will get powered back up
|
||||
// on the next write() call.
|
||||
sleep(SLEEP_TIME); //sleep for: sleepTime
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* This sketch clears radioId, relayId and other routing information in EEPROM back to factory default
|
||||
*
|
||||
*/
|
||||
|
||||
#include <MyConfig.h>
|
||||
#include <EEPROM.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(MY_BAUD_RATE);
|
||||
Serial.println("Started clearing. Please wait...");
|
||||
for (int i=0;i<512;i++) {
|
||||
EEPROM.write(i, 0xff);
|
||||
}
|
||||
Serial.println("Clering done. You're ready to go!");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Nothing to do here...
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
|
||||
* http://www.mysensors.org/build/temp
|
||||
*/
|
||||
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <DallasTemperature.h>
|
||||
#include <OneWire.h>
|
||||
|
||||
#define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
|
||||
|
||||
#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected
|
||||
#define MAX_ATTACHED_DS18B20 16
|
||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
|
||||
DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature.
|
||||
float lastTemperature[MAX_ATTACHED_DS18B20];
|
||||
int numSensors=0;
|
||||
boolean receivedConfig = false;
|
||||
boolean metric = true;
|
||||
// Initialize temperature message
|
||||
MyMessage msg(0,V_TEMP);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Startup up the OneWire library
|
||||
sensors.begin();
|
||||
// requestTemperatures() will not block current thread
|
||||
sensors.setWaitForConversion(false);
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Temperature Sensor", "1.1");
|
||||
|
||||
// Fetch the number of attached temperature sensors
|
||||
numSensors = sensors.getDeviceCount();
|
||||
|
||||
// Present all sensors to controller
|
||||
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
|
||||
present(i, S_TEMP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Fetch temperatures from Dallas sensors
|
||||
sensors.requestTemperatures();
|
||||
|
||||
// query conversion time and sleep until conversion completed
|
||||
int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
|
||||
// sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
|
||||
sleep(conversionTime);
|
||||
|
||||
// Read temperatures and send them to controller
|
||||
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
|
||||
|
||||
// Fetch and round temperature to one decimal
|
||||
float temperature = static_cast<float>(static_cast<int>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
|
||||
|
||||
// Only send data if temperature has changed and no error
|
||||
#if COMPARE_TEMP == 1
|
||||
if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
|
||||
#else
|
||||
if (temperature != -127.00 && temperature != 85.00) {
|
||||
#endif
|
||||
|
||||
// Send in the new temperature
|
||||
send(msg.setSensor(i).set(temperature,1));
|
||||
// Save new temperatures for next compare
|
||||
lastTemperature[i]=temperature;
|
||||
}
|
||||
}
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - February 15, 2014 - Bruce Lacey
|
||||
* Version 1.1 - August 13, 2014 - Converted to 1.4 (hek)
|
||||
*
|
||||
* DESCRIPTION
|
||||
* This sketch provides a Dimmable LED Light using PWM and based Henrik Ekblad
|
||||
* <henrik.ekblad@gmail.com> Vera Arduino Sensor project.
|
||||
* Developed by Bruce Lacey, inspired by Hek's MySensor's example sketches.
|
||||
*
|
||||
* The circuit uses a MOSFET for Pulse-Wave-Modulation to dim the attached LED or LED strip.
|
||||
* The MOSFET Gate pin is connected to Arduino pin 3 (LED_PIN), the MOSFET Drain pin is connected
|
||||
* to the LED negative terminal and the MOSFET Source pin is connected to ground.
|
||||
*
|
||||
* This sketch is extensible to support more than one MOSFET/PWM dimmer per circuit.
|
||||
* http://www.mysensors.org/build/dimmer
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define SN "DimmableLED"
|
||||
#define SV "1.1"
|
||||
|
||||
#define LED_PIN 3 // Arduino pin attached to MOSFET Gate pin
|
||||
#define FADE_DELAY 10 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
|
||||
|
||||
static int currentLevel = 0; // Current dim level...
|
||||
MyMessage dimmerMsg(0, V_DIMMER);
|
||||
MyMessage lightMsg(0, V_LIGHT);
|
||||
|
||||
|
||||
/***
|
||||
* Dimmable LED initialization method
|
||||
*/
|
||||
void setup()
|
||||
{
|
||||
// Initialize library and add callback for incoming messages (signing is required)
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
// Register the LED Dimmable Light with the gateway
|
||||
present( 0, S_DIMMER );
|
||||
|
||||
sendSketchInfo(SN, SV);
|
||||
// Pull the gateway's current dim level - restore light level upon sendor node power-up
|
||||
request( 0, V_DIMMER );
|
||||
}
|
||||
|
||||
/***
|
||||
* Dimmable LED main processing loop
|
||||
*/
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
if (message.type == V_LIGHT || message.type == V_DIMMER) {
|
||||
|
||||
// Retrieve the power or dim level from the incoming request message
|
||||
int requestedLevel = atoi( message.data );
|
||||
|
||||
// Adjust incoming level if this is a V_LIGHT variable update [0 == off, 1 == on]
|
||||
requestedLevel *= ( message.type == V_LIGHT ? 100 : 1 );
|
||||
|
||||
// Clip incoming level to valid range of 0 to 100
|
||||
requestedLevel = requestedLevel > 100 ? 100 : requestedLevel;
|
||||
requestedLevel = requestedLevel < 0 ? 0 : requestedLevel;
|
||||
|
||||
Serial.print( "Changing level to " );
|
||||
Serial.print( requestedLevel );
|
||||
Serial.print( ", from " );
|
||||
Serial.println( currentLevel );
|
||||
|
||||
fadeToLevel( requestedLevel );
|
||||
|
||||
// Inform the gateway of the current DimmableLED's SwitchPower1 and LoadLevelStatus value...
|
||||
send(lightMsg.set(currentLevel > 0 ? 1 : 0));
|
||||
|
||||
// hek comment: Is this really nessesary?
|
||||
send( dimmerMsg.set(currentLevel) );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* This method provides a graceful fade up/down effect
|
||||
*/
|
||||
void fadeToLevel( int toLevel ) {
|
||||
|
||||
int delta = ( toLevel - currentLevel ) < 0 ? -1 : 1;
|
||||
|
||||
while ( currentLevel != toLevel ) {
|
||||
currentLevel += delta;
|
||||
analogWrite( LED_PIN, (int)(currentLevel / 100. * 255) );
|
||||
delay( FADE_DELAY );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - January 30, 2015 - Developed by GizMoCuz (Domoticz)
|
||||
*
|
||||
* DESCRIPTION
|
||||
* This sketch provides an example how to implement a Dimmable Light
|
||||
* It is pure virtual and it logs messages to the serial output
|
||||
* It can be used as a base sketch for actual hardware.
|
||||
* Stores the last light state and level in eeprom.
|
||||
*
|
||||
*/
|
||||
|
||||
// Enable debug prints
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define CHILD_ID_LIGHT 1
|
||||
|
||||
#define EPROM_LIGHT_STATE 1
|
||||
#define EPROM_DIMMER_LEVEL 2
|
||||
|
||||
#define LIGHT_OFF 0
|
||||
#define LIGHT_ON 1
|
||||
|
||||
#define SN "Dimable Light"
|
||||
#define SV "1.0"
|
||||
|
||||
int LastLightState=LIGHT_OFF;
|
||||
int LastDimValue=100;
|
||||
|
||||
MyMessage lightMsg(CHILD_ID_LIGHT, V_LIGHT);
|
||||
MyMessage dimmerMsg(CHILD_ID_LIGHT, V_DIMMER);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize library and add callback for incoming messages (signing is required)
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
// Send the Sketch Version Information to the Gateway
|
||||
sendSketchInfo(SN, SV);
|
||||
|
||||
present(CHILD_ID_LIGHT, S_DIMMER );
|
||||
|
||||
//Retreive our last light state from the eprom
|
||||
int LightState=loadState(EPROM_LIGHT_STATE);
|
||||
if (LightState<=1) {
|
||||
LastLightState=LightState;
|
||||
int DimValue=loadState(EPROM_DIMMER_LEVEL);
|
||||
if ((DimValue>0)&&(DimValue<=100)) {
|
||||
//There should be no Dim value of 0, this would mean LIGHT_OFF
|
||||
LastDimValue=DimValue;
|
||||
}
|
||||
}
|
||||
|
||||
//Here you actualy switch on/off the light with the last known dim level
|
||||
SetCurrentState2Hardware();
|
||||
|
||||
Serial.println( "Node ready to receive messages..." );
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message)
|
||||
{
|
||||
if (message.type == V_LIGHT) {
|
||||
Serial.println( "V_LIGHT command received..." );
|
||||
|
||||
int lstate= atoi( message.data );
|
||||
if ((lstate<0)||(lstate>1)) {
|
||||
Serial.println( "V_LIGHT data invalid (should be 0/1)" );
|
||||
return;
|
||||
}
|
||||
LastLightState=lstate;
|
||||
saveState(EPROM_LIGHT_STATE, LastLightState);
|
||||
|
||||
if ((LastLightState==LIGHT_ON)&&(LastDimValue==0)) {
|
||||
//In the case that the Light State = On, but the dimmer value is zero,
|
||||
//then something (probably the controller) did something wrong,
|
||||
//for the Dim value to 100%
|
||||
LastDimValue=100;
|
||||
saveState(EPROM_DIMMER_LEVEL, LastDimValue);
|
||||
}
|
||||
|
||||
//When receiving a V_LIGHT command we switch the light between OFF and the last received dimmer value
|
||||
//This means if you previously set the lights dimmer value to 50%, and turn the light ON
|
||||
//it will do so at 50%
|
||||
}
|
||||
else if (message.type == V_DIMMER) {
|
||||
Serial.println( "V_DIMMER command received..." );
|
||||
int dimvalue= atoi( message.data );
|
||||
if ((dimvalue<0)||(dimvalue>100)) {
|
||||
Serial.println( "V_DIMMER data invalid (should be 0..100)" );
|
||||
return;
|
||||
}
|
||||
if (dimvalue==0) {
|
||||
LastLightState=LIGHT_OFF;
|
||||
}
|
||||
else {
|
||||
LastLightState=LIGHT_ON;
|
||||
LastDimValue=dimvalue;
|
||||
saveState(EPROM_DIMMER_LEVEL, LastDimValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Serial.println( "Invalid command received..." );
|
||||
return;
|
||||
}
|
||||
|
||||
//Here you set the actual light state/level
|
||||
SetCurrentState2Hardware();
|
||||
}
|
||||
|
||||
void SetCurrentState2Hardware()
|
||||
{
|
||||
if (LastLightState==LIGHT_OFF) {
|
||||
Serial.println( "Light state: OFF" );
|
||||
}
|
||||
else {
|
||||
Serial.print( "Light state: ON, Level: " );
|
||||
Serial.println( LastDimValue );
|
||||
}
|
||||
|
||||
//Send current state to the controller
|
||||
SendCurrentState2Controller();
|
||||
}
|
||||
|
||||
void SendCurrentState2Controller()
|
||||
{
|
||||
if ((LastLightState==LIGHT_OFF)||(LastDimValue==0)) {
|
||||
send(dimmerMsg.set(0));
|
||||
}
|
||||
else {
|
||||
send(dimmerMsg.set(LastDimValue));
|
||||
}
|
||||
}
|
||||
|
||||
+240
@@ -0,0 +1,240 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Developed by Bruce Lacey and GizMoCuz (Domoticz)
|
||||
* Version 1.1 - Modified by hek to incorporate a rotary encode to adjust
|
||||
* light level locally at node
|
||||
*
|
||||
* DESCRIPTION
|
||||
* This sketch provides an example how to implement a dimmable led light node with a rotary
|
||||
* encoder connected for adjusting light level.
|
||||
* The encoder has a click button which turns on/off the light (and remembers last dim-level)
|
||||
* The sketch fades the light (non-blocking) to the desired level.
|
||||
*
|
||||
* Default MOSFET pin is 3
|
||||
*
|
||||
* Arduino Encoder module
|
||||
* ---------------------------
|
||||
* 5V 5V (+)
|
||||
* GND GND (-)
|
||||
* 4 CLK (or putput 1)
|
||||
* 5 DT (or output 1)
|
||||
* 6 SW (Switch/Click)
|
||||
*/
|
||||
|
||||
|
||||
// Enable debug prints
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <Bounce2.h>
|
||||
#include <Encoder.h>
|
||||
|
||||
#define LED_PIN 3 // Arduino pin attached to MOSFET Gate pin
|
||||
#define KNOB_ENC_PIN_1 4 // Rotary encoder input pin 1
|
||||
#define KNOB_ENC_PIN_2 5 // Rotary encoder input pin 2
|
||||
#define KNOB_BUTTON_PIN 6 // Rotary encoder button pin
|
||||
#define FADE_DELAY 10 // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
|
||||
#define SEND_THROTTLE_DELAY 400 // Number of milliseconds before sending after user stops turning knob
|
||||
#define SN "DimmableLED /w button"
|
||||
#define SV "1.2"
|
||||
|
||||
#define CHILD_ID_LIGHT 1
|
||||
|
||||
#define EEPROM_DIM_LEVEL_LAST 1
|
||||
#define EEPROM_DIM_LEVEL_SAVE 2
|
||||
|
||||
#define LIGHT_OFF 0
|
||||
#define LIGHT_ON 1
|
||||
|
||||
int dimValue;
|
||||
int fadeTo;
|
||||
int fadeDelta;
|
||||
byte oldButtonVal;
|
||||
bool changedByKnob=false;
|
||||
bool sendDimValue=false;
|
||||
unsigned long lastFadeStep;
|
||||
unsigned long sendDimTimeout;
|
||||
char convBuffer[10];
|
||||
|
||||
MyMessage dimmerMsg(CHILD_ID_LIGHT, V_DIMMER);
|
||||
Encoder knob(KNOB_ENC_PIN_1, KNOB_ENC_PIN_2);
|
||||
Bounce debouncer = Bounce();
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize library and add callback for incoming messages (signing is required)
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
// Set knob button pin as input (with debounce)
|
||||
pinMode(KNOB_BUTTON_PIN, INPUT);
|
||||
digitalWrite(KNOB_BUTTON_PIN, HIGH);
|
||||
debouncer.attach(KNOB_BUTTON_PIN);
|
||||
debouncer.interval(5);
|
||||
oldButtonVal = debouncer.read();
|
||||
|
||||
// Set analog led pin to off
|
||||
analogWrite( LED_PIN, 0);
|
||||
|
||||
// Send the Sketch Version Information to the Gateway
|
||||
present(CHILD_ID_LIGHT, S_DIMMER);
|
||||
sendSketchInfo(SN, SV);
|
||||
|
||||
// Retreive our last dim levels from the eprom
|
||||
fadeTo = dimValue = 0;
|
||||
byte oldLevel = loadLevelState(EEPROM_DIM_LEVEL_LAST);
|
||||
Serial.print("Sending in last known light level to controller: ");
|
||||
Serial.println(oldLevel);
|
||||
send(dimmerMsg.set(oldLevel), true);
|
||||
|
||||
Serial.println("Ready to receive messages...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Check if someone turned the rotary encode
|
||||
checkRotaryEncoder();
|
||||
|
||||
// Check if someone has pressed the knob button
|
||||
checkButtonClick();
|
||||
|
||||
// Fade light to new dim value
|
||||
fadeStep();
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message)
|
||||
{
|
||||
if (message.type == V_LIGHT) {
|
||||
// Incoming on/off command sent from controller ("1" or "0")
|
||||
int lightState = message.getString()[0] == '1';
|
||||
int newLevel = 0;
|
||||
if (lightState==LIGHT_ON) {
|
||||
// Pick up last saved dimmer level from the eeprom
|
||||
newLevel = loadLevelState(EEPROM_DIM_LEVEL_SAVE);
|
||||
}
|
||||
// Send dimmer level back to controller with ack enabled
|
||||
send(dimmerMsg.set(newLevel), true);
|
||||
// We do not change any levels here until ack comes back from gateway
|
||||
return;
|
||||
} else if (message.type == V_DIMMER) {
|
||||
// Incoming dim-level command sent from controller (or ack message)
|
||||
fadeTo = atoi(message.getString(convBuffer));
|
||||
// Save received dim value to eeprom (unless turned off). Will be
|
||||
// retreived when a on command comes in
|
||||
if (fadeTo != 0)
|
||||
saveLevelState(EEPROM_DIM_LEVEL_SAVE, fadeTo);
|
||||
}
|
||||
saveLevelState(EEPROM_DIM_LEVEL_LAST, fadeTo);
|
||||
|
||||
Serial.print("New light level received: ");
|
||||
Serial.println(fadeTo);
|
||||
|
||||
if (!changedByKnob)
|
||||
knob.write(fadeTo);
|
||||
|
||||
// Cancel send if user turns knob while message comes in
|
||||
changedByKnob = false;
|
||||
sendDimValue = false;
|
||||
|
||||
// Stard fading to new light level
|
||||
startFade();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void checkRotaryEncoder() {
|
||||
long encoderValue = knob.read();
|
||||
|
||||
if (encoderValue > 100) {
|
||||
encoderValue = 100;
|
||||
knob.write(100);
|
||||
} else if (encoderValue < 0) {
|
||||
encoderValue = 0;
|
||||
knob.write(0);
|
||||
}
|
||||
|
||||
if (encoderValue != fadeTo) {
|
||||
fadeTo = encoderValue;
|
||||
changedByKnob = true;
|
||||
startFade();
|
||||
}
|
||||
}
|
||||
|
||||
void checkButtonClick() {
|
||||
debouncer.update();
|
||||
byte buttonVal = debouncer.read();
|
||||
byte newLevel = 0;
|
||||
if (buttonVal != oldButtonVal && buttonVal == LOW) {
|
||||
if (dimValue==0) {
|
||||
// Turn on light. Set the level to last saved dim value
|
||||
int saved = loadLevelState(EEPROM_DIM_LEVEL_SAVE);
|
||||
newLevel = saved > 0 ? saved : 100;
|
||||
}
|
||||
send(dimmerMsg.set(newLevel),true);
|
||||
}
|
||||
oldButtonVal = buttonVal;
|
||||
}
|
||||
|
||||
void startFade() {
|
||||
fadeDelta = ( fadeTo - dimValue ) < 0 ? -1 : 1;
|
||||
lastFadeStep = millis();
|
||||
}
|
||||
|
||||
// This method provides a graceful none-blocking fade up/down effect
|
||||
void fadeStep() {
|
||||
unsigned long currentTime = millis();
|
||||
if ( dimValue != fadeTo && currentTime > lastFadeStep + FADE_DELAY) {
|
||||
dimValue += fadeDelta;
|
||||
analogWrite( LED_PIN, (int)(dimValue / 100. * 255) );
|
||||
lastFadeStep = currentTime;
|
||||
|
||||
Serial.print("Fading level: ");
|
||||
Serial.println(dimValue);
|
||||
|
||||
if (fadeTo == dimValue && changedByKnob) {
|
||||
sendDimValue = true;
|
||||
sendDimTimeout = currentTime;
|
||||
}
|
||||
}
|
||||
// Wait a few millisecs before sending in new value (if user still turns the knob)
|
||||
if (sendDimValue && currentTime > sendDimTimeout + SEND_THROTTLE_DELAY) {
|
||||
// We're done fading.. send in new dim-value to controller.
|
||||
// Send in new dim value with ack (will be picked up in incomingMessage)
|
||||
send(dimmerMsg.set(dimValue), true); // Send new dimmer value and request ack back
|
||||
sendDimValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure only to store/fetch values in the range 0-100 from eeprom
|
||||
int loadLevelState(byte pos) {
|
||||
return min(max(loadState(pos),0),100);
|
||||
}
|
||||
void saveLevelState(byte pos, byte data) {
|
||||
saveState(pos,min(max(data,0),100));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik EKblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* This sketch provides an example how to implement a distance sensor using HC-SR04
|
||||
* http://www.mysensors.org/build/distance
|
||||
*/
|
||||
|
||||
// Enable debug prints
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <NewPing.h>
|
||||
|
||||
#define CHILD_ID 1
|
||||
#define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor.
|
||||
#define ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor.
|
||||
#define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
|
||||
unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds)
|
||||
|
||||
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
|
||||
MyMessage msg(CHILD_ID, V_DISTANCE);
|
||||
int lastDist;
|
||||
boolean metric = true;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Distance Sensor", "1.0");
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
present(CHILD_ID, S_DISTANCE);
|
||||
metric = getConfig().isMetric;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
int dist = metric?sonar.ping_cm():sonar.ping_in();
|
||||
Serial.print("Ping: ");
|
||||
Serial.print(dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
|
||||
Serial.println(metric?" cm":" in");
|
||||
|
||||
if (dist != lastDist) {
|
||||
send(msg.set(dist));
|
||||
lastDist = dist;
|
||||
}
|
||||
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - epierre
|
||||
* Converted to 1.4 by Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Arduino Dust Sensort
|
||||
*
|
||||
* connect the sensor as follows :
|
||||
*
|
||||
* VCC >>> 5V
|
||||
* A >>> A0
|
||||
* GND >>> GND
|
||||
*
|
||||
* Based on: http://www.dfrobot.com/wiki/index.php/Sharp_GP2Y1010AU
|
||||
* Authors: Cyrille Médard de Chardon (serialC), Christophe Trefois (Trefex)
|
||||
*
|
||||
* http://www.mysensors.org/build/dust
|
||||
*
|
||||
*/
|
||||
|
||||
// Enable debug prints
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define CHILD_ID_DUST 0
|
||||
#define DUST_SENSOR_ANALOG_PIN 1
|
||||
|
||||
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
||||
//VARIABLES
|
||||
int val = 0; // variable to store the value coming from the sensor
|
||||
float valDUST =0.0;
|
||||
float lastDUST =0.0;
|
||||
int samplingTime = 280;
|
||||
int deltaTime = 40;
|
||||
int sleepTime = 9680;
|
||||
float voMeasured = 0;
|
||||
float calcVoltage = 0;
|
||||
float dustDensity = 0;
|
||||
|
||||
MyMessage dustMsg(CHILD_ID_DUST, V_LEVEL);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Dust Sensor", "1.1");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
present(CHILD_ID_DUST, S_DUST);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint16_t voMeasured = analogRead(DUST_SENSOR_ANALOG_PIN);// Get DUST value
|
||||
|
||||
// 0 - 5V mapped to 0 - 1023 integer values
|
||||
// recover voltage
|
||||
calcVoltage = voMeasured * (5.0 / 1024.0);
|
||||
|
||||
// linear eqaution taken from http://www.howmuchsnow.com/arduino/airquality/
|
||||
// Chris Nafis (c) 2012
|
||||
dustDensity = (0.17 * calcVoltage - 0.1)*1000;
|
||||
|
||||
Serial.print("Raw Signal Value (0-1023): ");
|
||||
Serial.print(voMeasured);
|
||||
|
||||
Serial.print(" - Voltage: ");
|
||||
Serial.print(calcVoltage);
|
||||
|
||||
Serial.print(" - Dust Density: ");
|
||||
Serial.println(dustDensity); // unit: ug/m3
|
||||
|
||||
if (ceil(dustDensity) != lastDUST) {
|
||||
send(dustMsg.set((int)ceil(dustDensity)));
|
||||
lastDUST = ceil(dustDensity);
|
||||
}
|
||||
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Dust Sensor for SamYoung DSM501
|
||||
* connect the sensor as follows :
|
||||
* Pin 2 of dust sensor PM1 -> Digital 3 (PMW)
|
||||
* Pin 3 of dust sensor -> +5V
|
||||
* Pin 4 of dust sensor PM2.5 -> Digital 6 (PWM)
|
||||
* Pin 5 of dust sensor -> Ground
|
||||
* Datasheet: http://www.samyoungsnc.com/products/3-1%20Specification%20DSM501.pdf
|
||||
* Contributor: epierre
|
||||
**/
|
||||
|
||||
// Enable debug prints
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define CHILD_ID_DUST_PM10 0
|
||||
#define CHILD_ID_DUST_PM25 1
|
||||
#define DUST_SENSOR_DIGITAL_PIN_PM10 6
|
||||
#define DUST_SENSOR_DIGITAL_PIN_PM25 3
|
||||
|
||||
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
||||
//VARIABLES
|
||||
int val = 0; // variable to store the value coming from the sensor
|
||||
float valDUSTPM25 =0.0;
|
||||
float lastDUSTPM25 =0.0;
|
||||
float valDUSTPM10 =0.0;
|
||||
float lastDUSTPM10 =0.0;
|
||||
unsigned long duration;
|
||||
unsigned long starttime;
|
||||
unsigned long endtime;
|
||||
unsigned long sampletime_ms = 30000;
|
||||
unsigned long lowpulseoccupancy = 0;
|
||||
float ratio = 0;
|
||||
long concentrationPM25 = 0;
|
||||
long concentrationPM10 = 0;
|
||||
|
||||
MyMessage dustMsgPM10(CHILD_ID_DUST_PM10, V_LEVEL);
|
||||
MyMessage msgPM10(CHILD_ID_DUST_PM10, V_UNIT_PREFIX);
|
||||
MyMessage dustMsgPM25(CHILD_ID_DUST_PM25, V_LEVEL);
|
||||
MyMessage msgPM25(CHILD_ID_DUST_PM25, V_UNIT_PREFIX);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Dust Sensor DSM501", "1.4");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
present(CHILD_ID_DUST_PM10, S_DUST);
|
||||
send(msgPM10.set("ppm"));
|
||||
present(CHILD_ID_DUST_PM25, S_DUST);
|
||||
send(msgPM25.set("ppm"));
|
||||
|
||||
pinMode(DUST_SENSOR_DIGITAL_PIN_PM10,INPUT);
|
||||
pinMode(DUST_SENSOR_DIGITAL_PIN_PM25,INPUT);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
//get PM 2.5 density of particles over 2.5 μm.
|
||||
concentrationPM25=(long)getPM(DUST_SENSOR_DIGITAL_PIN_PM25);
|
||||
Serial.print("PM25: ");
|
||||
Serial.println(concentrationPM25);
|
||||
Serial.print("\n");
|
||||
|
||||
if ((concentrationPM25 != lastDUSTPM25)&&(concentrationPM25>0)) {
|
||||
send(dustMsgPM25.set((long)ceil(concentrationPM25)));
|
||||
lastDUSTPM25 = ceil(concentrationPM25);
|
||||
}
|
||||
|
||||
//get PM 1.0 - density of particles over 1 μm.
|
||||
concentrationPM10=getPM(DUST_SENSOR_DIGITAL_PIN_PM10);
|
||||
Serial.print("PM10: ");
|
||||
Serial.println(concentrationPM10);
|
||||
Serial.print("\n");
|
||||
//ppmv=mg/m3 * (0.08205*Tmp)/Molecular_mass
|
||||
//0.08205 = Universal gas constant in atm·m3/(kmol·K)
|
||||
int temp=20; //external temperature, if you can replace this with a DHT11 or better
|
||||
long ppmv=(concentrationPM10*0.0283168/100/1000) * (0.08205*temp)/0.01;
|
||||
|
||||
if ((ceil(concentrationPM10) != lastDUSTPM10)&&((long)concentrationPM10>0)) {
|
||||
send(dustMsgPM10.set((long)ppmv));
|
||||
lastDUSTPM10 = ceil(concentrationPM10);
|
||||
}
|
||||
|
||||
//sleep to save on radio
|
||||
sleep(SLEEP_TIME);
|
||||
|
||||
}
|
||||
|
||||
|
||||
long getPM(int DUST_SENSOR_DIGITAL_PIN) {
|
||||
|
||||
starttime = millis();
|
||||
|
||||
while (1) {
|
||||
|
||||
duration = pulseIn(DUST_SENSOR_DIGITAL_PIN, LOW);
|
||||
lowpulseoccupancy += duration;
|
||||
endtime = millis();
|
||||
|
||||
if ((endtime-starttime) > sampletime_ms)
|
||||
{
|
||||
ratio = (lowpulseoccupancy-endtime+starttime)/(sampletime_ms*10.0); // Integer percentage 0=>100
|
||||
long concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
|
||||
//Serial.print("lowpulseoccupancy:");
|
||||
//Serial.print(lowpulseoccupancy);
|
||||
//Serial.print("\n");
|
||||
//Serial.print("ratio:");
|
||||
//Serial.print(ratio);
|
||||
//Serial.print("\n");
|
||||
//Serial.print("DSM501A:");
|
||||
//Serial.println(concentration);
|
||||
//Serial.print("\n");
|
||||
|
||||
lowpulseoccupancy = 0;
|
||||
return(concentration);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik EKblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* This sketch provides an example how to implement a distance sensor using HC-SR04
|
||||
* Use this sensor to measure KWH and Watt of your house meeter
|
||||
* You need to set the correct pulsefactor of your meeter (blinks per KWH).
|
||||
* The sensor starts by fetching current KWH value from gateway.
|
||||
* Reports both KWH and Watt back to gateway.
|
||||
*
|
||||
* Unfortunately millis() won't increment when the Arduino is in
|
||||
* sleepmode. So we cannot make this sensor sleep if we also want
|
||||
* to calculate/report watt-number.
|
||||
* http://www.mysensors.org/build/pulse_power
|
||||
*/
|
||||
|
||||
// Enable debug prints
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your light sensor. (Only 2 and 3 generates interrupt!)
|
||||
#define PULSE_FACTOR 1000 // Nummber of blinks per KWH of your meeter
|
||||
#define SLEEP_MODE false // Watt-value can only be reported when sleep mode is false.
|
||||
#define MAX_WATT 10000 // Max watt value to report. This filetrs outliers.
|
||||
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
|
||||
#define CHILD_ID 1 // Id of the sensor child
|
||||
|
||||
unsigned long SEND_FREQUENCY = 20000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
|
||||
double ppwh = ((double)PULSE_FACTOR)/1000; // Pulses per watt hour
|
||||
boolean pcReceived = false;
|
||||
volatile unsigned long pulseCount = 0;
|
||||
volatile unsigned long lastBlink = 0;
|
||||
volatile unsigned long watt = 0;
|
||||
unsigned long oldPulseCount = 0;
|
||||
unsigned long oldWatt = 0;
|
||||
double oldKwh;
|
||||
unsigned long lastSend;
|
||||
MyMessage wattMsg(CHILD_ID,V_WATT);
|
||||
MyMessage kwhMsg(CHILD_ID,V_KWH);
|
||||
MyMessage pcMsg(CHILD_ID,V_VAR1);
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize library and add callback for incoming messages (signing is required)
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Energy Meter", "1.0");
|
||||
|
||||
// Register this device as power sensor
|
||||
present(CHILD_ID, S_POWER);
|
||||
|
||||
// Fetch last known pulse count value from gw
|
||||
request(CHILD_ID, V_VAR1);
|
||||
|
||||
attachInterrupt(INTERRUPT, onPulse, RISING);
|
||||
lastSend=millis();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
unsigned long now = millis();
|
||||
// Only send values at a maximum frequency or woken up from sleep
|
||||
bool sendTime = now - lastSend > SEND_FREQUENCY;
|
||||
if (pcReceived && (SLEEP_MODE || sendTime)) {
|
||||
// New watt value has been calculated
|
||||
if (!SLEEP_MODE && watt != oldWatt) {
|
||||
// Check that we dont get unresonable large watt value.
|
||||
// could hapen when long wraps or false interrupt triggered
|
||||
if (watt<((unsigned long)MAX_WATT)) {
|
||||
send(wattMsg.set(watt)); // Send watt value to gw
|
||||
}
|
||||
Serial.print("Watt:");
|
||||
Serial.println(watt);
|
||||
oldWatt = watt;
|
||||
}
|
||||
|
||||
// Pulse cout has changed
|
||||
if (pulseCount != oldPulseCount) {
|
||||
send(pcMsg.set(pulseCount)); // Send pulse count value to gw
|
||||
double kwh = ((double)pulseCount/((double)PULSE_FACTOR));
|
||||
oldPulseCount = pulseCount;
|
||||
if (kwh != oldKwh) {
|
||||
send(kwhMsg.set(kwh, 4)); // Send kwh value to gw
|
||||
oldKwh = kwh;
|
||||
}
|
||||
}
|
||||
lastSend = now;
|
||||
} else if (sendTime && !pcReceived) {
|
||||
// No count received. Try requesting it again
|
||||
request(CHILD_ID, V_VAR1);
|
||||
lastSend=now;
|
||||
}
|
||||
|
||||
if (SLEEP_MODE) {
|
||||
sleep(SEND_FREQUENCY);
|
||||
}
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
if (message.type==V_VAR1) {
|
||||
pulseCount = oldPulseCount = message.getLong();
|
||||
Serial.print("Received last pulse count from gw:");
|
||||
Serial.println(pulseCount);
|
||||
pcReceived = true;
|
||||
}
|
||||
}
|
||||
|
||||
void onPulse()
|
||||
{
|
||||
if (!SLEEP_MODE) {
|
||||
unsigned long newBlink = micros();
|
||||
unsigned long interval = newBlink-lastBlink;
|
||||
if (interval<10000L) { // Sometimes we get interrupt on RISING
|
||||
return;
|
||||
}
|
||||
watt = (3600000000.0 /interval) / ppwh;
|
||||
lastBlink = newBlink;
|
||||
}
|
||||
pulseCount++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik EKblad
|
||||
* Contribution by a-lurker and Anticimex,
|
||||
* Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
|
||||
* Contribution by Ivo Pullens (ESP8266 support)
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The EthernetGateway sends data received from sensors to the WiFi link.
|
||||
* The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
|
||||
*
|
||||
* VERA CONFIGURATION:
|
||||
* Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin.
|
||||
* E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
|
||||
*
|
||||
* LED purposes:
|
||||
* - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
|
||||
* - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
|
||||
* - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
|
||||
* - ERR (red) - fast blink on error during transmission error or recieve crc error
|
||||
*
|
||||
* See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
|
||||
* The ESP8266 however requires different wiring:
|
||||
* nRF24L01+ ESP8266
|
||||
* VCC VCC
|
||||
* CE GPIO4
|
||||
* CSN/CS GPIO15
|
||||
* SCK GPIO14
|
||||
* MISO GPIO12
|
||||
* MOSI GPIO13
|
||||
*
|
||||
* Not all ESP8266 modules have all pins available on their external interface.
|
||||
* This code has been tested on an ESP-12 module.
|
||||
* The ESP8266 requires a certain pin configuration to download code, and another one to run code:
|
||||
* - Connect REST (reset) via 10K pullup resistor to VCC, and via switch to GND ('reset switch')
|
||||
* - Connect GPIO15 via 10K pulldown resistor to GND
|
||||
* - Connect CH_PD via 10K resistor to VCC
|
||||
* - Connect GPIO2 via 10K resistor to VCC
|
||||
* - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch')
|
||||
*
|
||||
* Inclusion mode button:
|
||||
* - Connect GPIO5 via switch to GND ('inclusion switch')
|
||||
*
|
||||
* Hardware SHA204 signing is currently not supported!
|
||||
*
|
||||
* Make sure to fill in your ssid and WiFi password below for ssid & pass.
|
||||
*/
|
||||
#define NO_PORTB_PINCHANGES
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
#include <MySigningNone.h>
|
||||
#include <MySigningAtsha204Soft.h>
|
||||
#include <MyTransportNRF24.h>
|
||||
#include <MyTransportRFM69.h>
|
||||
#include <EEPROM.h>
|
||||
#include <MyHwESP8266.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
#include <MyParserSerial.h>
|
||||
#include <MySensor.h>
|
||||
#include <stdarg.h>
|
||||
#include "GatewayUtil.h"
|
||||
|
||||
const char *ssid = "MySSID"; // cannot be longer than 32 characters!
|
||||
const char *pass = "MyVerySecretPassword"; //
|
||||
|
||||
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
|
||||
#define INCLUSION_MODE_PIN 5 // Digital pin used for inclusion mode button
|
||||
|
||||
#define RADIO_CE_PIN 4 // radio chip enable
|
||||
#define RADIO_SPI_SS_PIN 15 // radio SPI serial select
|
||||
|
||||
#ifdef WITH_LEDS_BLINKING
|
||||
#define RADIO_ERROR_LED_PIN 7 // Error led pin
|
||||
#define RADIO_RX_LED_PIN 8 // Receive led pin
|
||||
#define RADIO_TX_LED_PIN 9 // the PCB, on board LED
|
||||
#endif
|
||||
|
||||
|
||||
// NRFRF24L01 radio driver (set low transmit power by default)
|
||||
MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);
|
||||
//MyTransportRFM69 transport;
|
||||
|
||||
|
||||
// Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
|
||||
#ifdef MY_SIGNING_FEATURE
|
||||
MySigningNone signer;
|
||||
//MySigningAtsha204Soft signer;
|
||||
#endif
|
||||
|
||||
// Hardware profile
|
||||
MyHwESP8266 hw;
|
||||
|
||||
// Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
|
||||
// To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
|
||||
MySensor gw(transport, hw
|
||||
#ifdef MY_SIGNING_FEATURE
|
||||
, signer
|
||||
#endif
|
||||
#ifdef WITH_LEDS_BLINKING
|
||||
, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN
|
||||
#endif
|
||||
);
|
||||
|
||||
|
||||
#define IP_PORT 5003 // The port you want to open
|
||||
#define MAX_SRV_CLIENTS 5 // how many clients should be able to telnet to this ESP8266
|
||||
|
||||
// a R/W server on the port
|
||||
static WiFiServer server(IP_PORT);
|
||||
static WiFiClient clients[MAX_SRV_CLIENTS];
|
||||
static bool clientsConnected[MAX_SRV_CLIENTS];
|
||||
static inputBuffer inputString[MAX_SRV_CLIENTS];
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
|
||||
void output(const char *fmt, ... )
|
||||
{
|
||||
char serialBuffer[MAX_SEND_LENGTH];
|
||||
va_list args;
|
||||
va_start (args, fmt );
|
||||
vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
|
||||
va_end (args);
|
||||
Serial.print(serialBuffer);
|
||||
for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++)
|
||||
{
|
||||
if (clients[i] && clients[i].connected())
|
||||
{
|
||||
// Serial.print("Client "); Serial.print(i); Serial.println(" write");
|
||||
clients[i].write((uint8_t*)serialBuffer, strlen(serialBuffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Setup console
|
||||
hw_init();
|
||||
|
||||
Serial.println(); Serial.println();
|
||||
Serial.println("ESP8266 MySensors Gateway");
|
||||
Serial.print("Connecting to "); Serial.println(ssid);
|
||||
|
||||
(void)WiFi.begin(ssid, pass);
|
||||
while (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("Connected!");
|
||||
Serial.print("IP: "); Serial.println(WiFi.localIP());
|
||||
Serial.flush();
|
||||
|
||||
setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
|
||||
|
||||
// Initialize gateway at maximum PA level, channel 70 and callback for write operations
|
||||
gw.begin(incomingMessage, 0, true, 0);
|
||||
|
||||
// start listening for clients
|
||||
server.begin();
|
||||
server.setNoDelay(true);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
gw.process();
|
||||
|
||||
checkButtonTriggeredInclusion();
|
||||
checkInclusionFinished();
|
||||
|
||||
// Go over list of clients and stop any that are no longer connected.
|
||||
// If the server has a new client connection it will be assigned to a free slot.
|
||||
bool allSlotsOccupied = true;
|
||||
for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++)
|
||||
{
|
||||
if (!clients[i].connected())
|
||||
{
|
||||
if (clientsConnected[i])
|
||||
{
|
||||
Serial.print("Client "); Serial.print(i); Serial.println(" disconnected");
|
||||
clients[i].stop();
|
||||
}
|
||||
//check if there are any new clients
|
||||
if (server.hasClient())
|
||||
{
|
||||
clients[i] = server.available();
|
||||
inputString[i].idx = 0;
|
||||
Serial.print("Client "); Serial.print(i); Serial.println(" connected");
|
||||
output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"), C_INTERNAL, I_GATEWAY_READY);
|
||||
}
|
||||
}
|
||||
bool connected = clients[i].connected();
|
||||
clientsConnected[i] = connected;
|
||||
allSlotsOccupied &= connected;
|
||||
}
|
||||
if (allSlotsOccupied && server.hasClient())
|
||||
{
|
||||
//no free/disconnected spot so reject
|
||||
Serial.println("No free slot available");
|
||||
WiFiClient c = server.available();
|
||||
c.stop();
|
||||
}
|
||||
|
||||
// Loop over clients connect and read available data
|
||||
for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++)
|
||||
{
|
||||
while(clients[i].connected() && clients[i].available())
|
||||
{
|
||||
char inChar = clients[i].read();
|
||||
if ( inputString[i].idx < MAX_RECEIVE_LENGTH - 1 )
|
||||
{
|
||||
// if newline then command is complete
|
||||
if (inChar == '\n')
|
||||
{
|
||||
// a command was issued by the client
|
||||
// we will now try to send it to the actuator
|
||||
inputString[i].string[inputString[i].idx] = 0;
|
||||
|
||||
// echo the string to the serial port
|
||||
Serial.print("Client "); Serial.print(i); Serial.print(": "); Serial.println(inputString[i].string);
|
||||
|
||||
parseAndSend(gw, inputString[i].string);
|
||||
|
||||
// clear the string:
|
||||
inputString[i].idx = 0;
|
||||
// Finished with this client's message. Next loop() we'll see if there's more to read.
|
||||
break;
|
||||
} else {
|
||||
// add it to the inputString:
|
||||
inputString[i].string[inputString[i].idx++] = inChar;
|
||||
}
|
||||
} else {
|
||||
// Incoming message too long. Throw away
|
||||
Serial.print("Client "); Serial.print(i); Serial.println(": Message too long");
|
||||
inputString[i].idx = 0;
|
||||
// Finished with this client's message. Next loop() we'll see if there's more to read.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
#ifndef __GATEWAYUTIL_H__
|
||||
#define __GATEWAYUTIL_H__
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
static uint8_t inclusionTime = 1; // Number of minutes inclusion mode is enabled
|
||||
static uint8_t pinInclusion = 3; // Input pin that should trigger inclusion mode
|
||||
|
||||
#define MAX_RECEIVE_LENGTH 100 // Max buffersize needed for messages coming from controller
|
||||
#define MAX_SEND_LENGTH 120 // Max buffersize needed for messages destined for controller
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char string[MAX_RECEIVE_LENGTH];
|
||||
uint8_t idx;
|
||||
} inputBuffer;
|
||||
|
||||
static volatile boolean buttonTriggeredInclusion;
|
||||
static boolean inclusionMode; // Keeps track on inclusion mode
|
||||
bool inclusionButtonSupported = false;
|
||||
void (*serial)(const char *fmt, ... );
|
||||
|
||||
MyParserSerial parser;
|
||||
|
||||
void setInclusionMode(boolean newMode);
|
||||
|
||||
char convBuf[MAX_PAYLOAD*2+1];
|
||||
unsigned long inclusionStartTime;
|
||||
|
||||
|
||||
void startInclusionInterrupt() {
|
||||
buttonTriggeredInclusion = true;
|
||||
}
|
||||
|
||||
void setupGateway(uint8_t _inc, uint8_t _incTime, void (* _serial)(const char *, ... )) {
|
||||
inclusionMode = 0;
|
||||
buttonTriggeredInclusion = false;
|
||||
serial = _serial;
|
||||
|
||||
inclusionTime = _incTime;
|
||||
inclusionButtonSupported = (_inc != 255);
|
||||
if (inclusionButtonSupported)
|
||||
{
|
||||
pinInclusion = _inc;
|
||||
|
||||
// Setup digital in that triggers inclusion mode
|
||||
pinMode(pinInclusion, INPUT_PULLUP);
|
||||
|
||||
// Add interrupt for inclusion button to pin
|
||||
attachInterrupt(pinInclusion, startInclusionInterrupt, FALLING);
|
||||
}
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
// if (mGetCommand(message) == C_PRESENTATION && inclusionMode) {
|
||||
// gw.rxBlink(3);
|
||||
// } else {
|
||||
// gw.rxBlink(1);
|
||||
// }
|
||||
// Pass along the message from sensors to serial line
|
||||
serial(PSTR("%d;%d;%d;%d;%d;%s\n"),message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type, message.getString(convBuf));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void checkButtonTriggeredInclusion() {
|
||||
if (inclusionButtonSupported)
|
||||
{
|
||||
if (buttonTriggeredInclusion) {
|
||||
// Ok, someone pressed the inclusion button on the gateway
|
||||
// start inclusion mode for 1 munute.
|
||||
#ifdef DEBUG
|
||||
serial(PSTR("0;0;%d;0;%d;Inclusion started by button.\n"), C_INTERNAL, I_LOG_MESSAGE);
|
||||
#endif
|
||||
buttonTriggeredInclusion = false;
|
||||
setInclusionMode(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkInclusionFinished() {
|
||||
if (inclusionMode && millis()-inclusionStartTime>60000UL*inclusionTime) {
|
||||
// inclusionTimeInMinutes minute(s) has passed.. stop inclusion mode
|
||||
setInclusionMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
void parseAndSend(MySensor &gw, char *commandBuffer) {
|
||||
boolean ok;
|
||||
MyMessage &msg = gw.getLastMessage();
|
||||
|
||||
if (parser.parse(msg, commandBuffer)) {
|
||||
uint8_t command = mGetCommand(msg);
|
||||
|
||||
if (msg.destination==GATEWAY_ADDRESS && command==C_INTERNAL) {
|
||||
// Handle messages directed to gateway
|
||||
if (msg.type == I_VERSION) {
|
||||
// Request for version
|
||||
serial(PSTR("0;0;%d;0;%d;%s\n"), C_INTERNAL, I_VERSION, LIBRARY_VERSION);
|
||||
} else if (msg.type == I_INCLUSION_MODE) {
|
||||
// Request to change inclusion mode
|
||||
setInclusionMode(atoi(msg.data) == 1);
|
||||
}
|
||||
} else {
|
||||
#ifdef WITH_LEDS_BLINKING
|
||||
gw.txBlink(1);
|
||||
#endif
|
||||
ok = gw.sendRoute(msg);
|
||||
if (!ok) {
|
||||
#ifdef WITH_LEDS_BLINKING
|
||||
gw.errBlink(1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setInclusionMode(boolean newMode) {
|
||||
if (newMode != inclusionMode) {
|
||||
inclusionMode = newMode;
|
||||
// Send back mode change on serial line to ack command
|
||||
serial(PSTR("0;0;%d;0;%d;%d\n"), C_INTERNAL, I_INCLUSION_MODE, inclusionMode?1:0);
|
||||
|
||||
if (inclusionMode) {
|
||||
inclusionStartTime = millis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
#error This example is only for use on Arduino.
|
||||
#endif // ARDUINO
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik EKblad
|
||||
* Contribution by a-lurker and Anticimex,
|
||||
* Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
|
||||
* Contribution by Tomas Hozza <thozza@gmail.com>
|
||||
*
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The EthernetGateway sends data received from sensors to the ethernet link.
|
||||
* The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
|
||||
*
|
||||
* The GW code is designed for Arduino 328p / 16MHz. ATmega168 does not have enough memory to run this program.
|
||||
*
|
||||
*
|
||||
* COMPILING WIZNET (W5100) ETHERNET MODULE
|
||||
* > Edit MyConfig.h in (libraries\MySensors\) to enable softspi (remove // before "#define SOFTSPI").
|
||||
*
|
||||
* COMPILING ENC28J60 ETHERNET MODULE
|
||||
* > Use Arduino IDE 1.5.7 (or later)
|
||||
* > Disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch will probably not fit in program space when downloading.
|
||||
* > Remove Ethernet.h include below and include UIPEthernet.h
|
||||
* > Remove DigitalIO include
|
||||
* Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which means you have to choose a static IP for that module)
|
||||
*
|
||||
* VERA CONFIGURATION:
|
||||
* Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin.
|
||||
* E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
|
||||
*
|
||||
* LED purposes:
|
||||
* - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
|
||||
* - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
|
||||
* - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
|
||||
* - ERR (red) - fast blink on error during transmission error or recieve crc error
|
||||
*
|
||||
* See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
|
||||
*
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
// Enable gateway transportation type
|
||||
#define MY_GATEWAY_W5100
|
||||
//#define MY_GATEWAY_ENC28J60
|
||||
|
||||
// Enable Soft SPI for radio (note different radio wiring required)
|
||||
// Useful for W5100 which sometimes have hard time co-operate with radio on the same spi bus.
|
||||
//#define MY_SOFTSPI
|
||||
//#define MY_SOFT_SPI_SCK_PIN 14
|
||||
//#define MY_SOFT_SPI_MISO_PIN 16
|
||||
//#define MY_SOFT_SPI_MOSI_PIN 15
|
||||
|
||||
|
||||
// Enable to use UDP
|
||||
#define MY_USE_UDP
|
||||
|
||||
#define MY_IP_ADDRESS 192,168,178,66 // If this is disabled, DHCP is used to retrieve address
|
||||
// Renewal period if using DHCP
|
||||
//#define MY_IP_RENEWAL_INTERVAL 60000
|
||||
// The port to keep open on node server mode / or port to contact in client mode
|
||||
#define MY_PORT 5003
|
||||
|
||||
// Controller ip address (enables client mode). Undefine this to act as sever.
|
||||
#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
|
||||
|
||||
// The MAC address can be anything you want but should be unique on your network.
|
||||
// Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
|
||||
// Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address.
|
||||
#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
|
||||
|
||||
// Flash leds on rx/tx/err
|
||||
#define MY_LEDS_BLINKING_FEATURE
|
||||
// Set blinking period
|
||||
#define MY_DEFAULT_LED_BLINK_PERIOD 300
|
||||
|
||||
// Enable inclusion mode
|
||||
#define MY_INCLUSION_MODE_FEATURE
|
||||
// Enable Inclusion mode button on gateway
|
||||
#define MY_INCLUSION_BUTTON_FEATURE
|
||||
// Set inclusion mode duration (in seconds)
|
||||
#define MY_INCLUSION_MODE_DURATION 60
|
||||
// Digital pin used for inclusion mode button
|
||||
#define MY_INCLUSION_MODE_BUTTON_PIN 3
|
||||
|
||||
#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin
|
||||
#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
|
||||
#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED
|
||||
|
||||
#define MY_RADIO_CE_PIN 5 // radio chip enable
|
||||
#define MY_RADIO_SPI_SS_PIN 6 // radio SPI serial select
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik EKblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* This sketch provides an example how to implement a humidity/temperature
|
||||
* sensor using DHT11/DHT-22
|
||||
* http://www.mysensors.org/build/humidity
|
||||
*/
|
||||
|
||||
// Enable debug prints
|
||||
//#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <DHT.h>
|
||||
|
||||
#define CHILD_ID_HUM 0
|
||||
#define CHILD_ID_TEMP 1
|
||||
#define HUMIDITY_SENSOR_DIGITAL_PIN 3
|
||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||
|
||||
DHT dht;
|
||||
float lastTemp;
|
||||
float lastHum;
|
||||
boolean metric = true;
|
||||
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
|
||||
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
|
||||
|
||||
// Send the Sketch Version Information to the Gateway
|
||||
sendSketchInfo("Humidity", "1.0");
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
present(CHILD_ID_HUM, S_HUM);
|
||||
present(CHILD_ID_TEMP, S_TEMP);
|
||||
|
||||
metric = getConfig().isMetric;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
delay(dht.getMinimumSamplingPeriod());
|
||||
|
||||
float temperature = dht.getTemperature();
|
||||
if (isnan(temperature)) {
|
||||
Serial.println("Failed reading temperature from DHT");
|
||||
} else if (temperature != lastTemp) {
|
||||
lastTemp = temperature;
|
||||
if (!metric) {
|
||||
temperature = dht.toFahrenheit(temperature);
|
||||
}
|
||||
send(msgTemp.set(temperature, 1));
|
||||
Serial.print("T: ");
|
||||
Serial.println(temperature);
|
||||
}
|
||||
|
||||
float humidity = dht.getHumidity();
|
||||
if (isnan(humidity)) {
|
||||
Serial.println("Failed reading humidity from DHT");
|
||||
} else if (humidity != lastHum) {
|
||||
lastHum = humidity;
|
||||
send(msgHum.set(humidity, 1));
|
||||
Serial.print("H: ");
|
||||
Serial.println(humidity);
|
||||
}
|
||||
|
||||
sleep(SLEEP_TIME); //sleep a bit
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik EKblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Example sketch showing how to control ir devices
|
||||
* An IR LED must be connected to Arduino PWM pin 3.
|
||||
* An optional ir receiver can be connected to PWM pin 8.
|
||||
* All receied ir signals will be sent to gateway device stored in VAR_1.
|
||||
* When binary light on is clicked - sketch will send volume up ir command
|
||||
* When binary light off is clicked - sketch will send volume down ir command
|
||||
* http://www.mysensors.org/build/ir
|
||||
*/
|
||||
|
||||
// Enable debug prints
|
||||
//#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <IRLib.h>
|
||||
|
||||
int RECV_PIN = 8;
|
||||
|
||||
#define CHILD_1 3 // childId
|
||||
|
||||
IRsend irsend;
|
||||
IRrecv irrecv(RECV_PIN);
|
||||
IRdecode decoder;
|
||||
//decode_results results;
|
||||
unsigned int Buffer[RAWBUF];
|
||||
MyMessage msg(CHILD_1, V_VAR1);
|
||||
|
||||
void setup()
|
||||
{
|
||||
irrecv.enableIRIn(); // Start the ir receiver
|
||||
decoder.UseExtnBuf(Buffer);
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("IR Sensor", "1.0");
|
||||
|
||||
// Register a sensors to Use binary light for test purposes.
|
||||
present(CHILD_1, S_LIGHT);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (irrecv.GetResults(&decoder)) {
|
||||
irrecv.resume();
|
||||
decoder.decode();
|
||||
decoder.DumpResults();
|
||||
|
||||
char buffer[10];
|
||||
sprintf(buffer, "%08lx", decoder.value);
|
||||
// Send ir result to gw
|
||||
send(msg.set(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
// We only expect one type of message from controller. But we better check anyway.
|
||||
if (message.type==V_LIGHT) {
|
||||
int incomingRelayStatus = message.getInt();
|
||||
if (incomingRelayStatus == 1) {
|
||||
irsend.send(NEC, 0x1EE17887, 32); // Vol up yamaha ysp-900
|
||||
} else {
|
||||
irsend.send(NEC, 0x1EE1F807, 32); // Vol down yamaha ysp-900
|
||||
}
|
||||
// Start receiving ir again...
|
||||
irrecv.enableIRIn();
|
||||
}
|
||||
}
|
||||
|
||||
// Dumps out the decode_results structure.
|
||||
// Call this after IRrecv::decode()
|
||||
// void * to work around compiler issue
|
||||
//void dump(void *v) {
|
||||
// decode_results *results = (decode_results *)v
|
||||
/*void dump(decode_results *results) {
|
||||
int count = results->rawlen;
|
||||
if (results->decode_type == UNKNOWN) {
|
||||
Serial.print("Unknown encoding: ");
|
||||
}
|
||||
else if (results->decode_type == NEC) {
|
||||
Serial.print("Decoded NEC: ");
|
||||
}
|
||||
else if (results->decode_type == SONY) {
|
||||
Serial.print("Decoded SONY: ");
|
||||
}
|
||||
else if (results->decode_type == RC5) {
|
||||
Serial.print("Decoded RC5: ");
|
||||
}
|
||||
else if (results->decode_type == RC6) {
|
||||
Serial.print("Decoded RC6: ");
|
||||
}
|
||||
else if (results->decode_type == PANASONIC) {
|
||||
Serial.print("Decoded PANASONIC - Address: ");
|
||||
Serial.print(results->panasonicAddress,HEX);
|
||||
Serial.print(" Value: ");
|
||||
}
|
||||
else if (results->decode_type == JVC) {
|
||||
Serial.print("Decoded JVC: ");
|
||||
}
|
||||
Serial.print(results->value, HEX);
|
||||
Serial.print(" (");
|
||||
Serial.print(results->bits, DEC);
|
||||
Serial.println(" bits)");
|
||||
Serial.print("Raw (");
|
||||
Serial.print(count, DEC);
|
||||
Serial.print("): ");
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
if ((i % 2) == 1) {
|
||||
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
|
||||
}
|
||||
else {
|
||||
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
|
||||
}
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println("");
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,876 @@
|
||||
/*
|
||||
MySprinkler for MySensors
|
||||
|
||||
Arduino Multi-Zone Sprinkler Control
|
||||
|
||||
May 31, 2015
|
||||
|
||||
*** Version 2.0
|
||||
|
||||
*** Upgraded to http://MySensors.org version 1.4.1
|
||||
*** Expanded for up to 16 Valves
|
||||
*** Setup for active low relay board or comment out #define ACTIVE_LOW to switch to active high
|
||||
*** Switch to bitshift method vs byte arrays
|
||||
*** Changed RUN_ALL_ZONES Vera device to 0 (was highest valve)
|
||||
*** Added optional LCD display featuring remaining time, date last ran & current time
|
||||
*** Features 'raindrop' and 'clock' icons which indicate sensor is updating valve data and clock respectively
|
||||
*** Added single pushbutton menu to manually select which program to run (All Zones or a Single Zone)
|
||||
*** Added option of naming your Zones programmatically or with Vera (V_VAR3 used to store names)
|
||||
|
||||
Utilizing your Vera home automation controller and the MySensors.org gateway you can
|
||||
control up to a sixteen zone irrigation system with only three digital pins. This sketch
|
||||
will create NUMBER_OF_VALVES + 1 devices on your Vera controller
|
||||
|
||||
This sketch features the following:
|
||||
|
||||
* Allows you to cycle through All zones (RUN_ALL_ZONES) or individual zone (RUN_SINGLE_ZONE) control.
|
||||
* Use the 0th controller to activate RUN_ALL_ZONES (each zone in numeric sequence 1 to n)
|
||||
using Variable1 as the "ON" time in minutes in each of the vera devices created.
|
||||
* Use the individual zone controller to activate a single zone. This feature uses
|
||||
Variable2 as the "ON" time for each individual device/zone.
|
||||
* Connect according to pinout below and uses Shift Registers as to allow the MySensors
|
||||
standard radio configuration and still leave available digital pins
|
||||
* Turning on any zone will stop the current process and begin that particular process.
|
||||
* Turning off any zone will stop the current process and turn off all zones.
|
||||
* To push your new time intervals for your zones, simply change the variable on your Vera and
|
||||
your arduino will call to Vera once a minute and update accordingly. Variables will also be
|
||||
requested when the device is first powered on.
|
||||
* Pushbutton activation to RUN_ALL_ZONES, RUN_SINGLE_ZONE or halt the current program
|
||||
* LED status indicator
|
||||
|
||||
PARTS LIST:
|
||||
Available from the MySensors store - http://www.mysensors.org/store/
|
||||
* Relays (8 channel)
|
||||
* Female Pin Header Connector Strip
|
||||
* Prototype Universal Printed Circuit Boards (PCB)
|
||||
* NRF24L01 Radio
|
||||
* Arduino (I used a Pro Mini)
|
||||
* FTDI USB to TTL Serial Adapter
|
||||
* Capacitors (10uf and .1uf)
|
||||
* 3.3v voltage regulator
|
||||
* Resistors (270 & 10K)
|
||||
* Female Dupont Cables
|
||||
* 1602 LCD (with I2C Interface)
|
||||
* LED
|
||||
* Push button
|
||||
* Shift Register (SN74HC595)
|
||||
* 2 Pole 5mm Pitch PCB Mount Screw Terminal Block
|
||||
* 3 Pole 5mm Pitch PCB Mount Screw Terminal Block
|
||||
* 22-24 gauge wire or similar (I used Cat5/Cat6 cable)
|
||||
* 18 gauge wire (for relay)
|
||||
* Irrigation Power Supply (24-Volt/750 mA Transformer)
|
||||
|
||||
|
||||
INSTRUCTIONS:
|
||||
|
||||
* A step-by-step setup video is available here: http://youtu.be/l4GPRTsuHkI
|
||||
* After assembling your arduino, radio, decoupling capacitors, shift register(s), status LED, pushbutton LCD (I2C connected to
|
||||
A4 and A5) and relays, and load the sketch.
|
||||
* Following the instructions at https://MySensors.org include the device to your MySensors Gateway.
|
||||
* Verify that each new device has a Variable1, Variable2 and Variable3. Populate data accordingly with whole minutes for
|
||||
the RUN_ALL_ZONES routine (Variable1) and the RUN_SINGLE_ZONE routines (Variable 2). The values entered for times may be zero and
|
||||
you may use the defaulet zone names by leaving Variable3 blank.
|
||||
* Once you have entered values for each zone and each variable, save the settings by pressing the red save button on your Vera.
|
||||
* Restart your arduino; verify the settings are loaded into your arduino with the serial monitor; the array will be printed
|
||||
on the serial monitor.
|
||||
* Your arduino should slow-flash, indicating that it is in ready mode.
|
||||
* There are multiple debug serial prints that can be monitored to assure that it is operating properly.
|
||||
* ***THIS SHOULD NO LONGER BE NEEDED*** The standard MySensors library now works. https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads for the I2C library, or use yours
|
||||
|
||||
Contributed by Jim (BulldogLowell@gmail.com) with much contribution from Pete (pete.will@mysensors.org) and is released to the public domain
|
||||
*/
|
||||
//
|
||||
|
||||
// Enable debug prints
|
||||
//#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
//#define MY_NODE_ID 1 // Set this to fix your Radio ID or use Auto
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Time.h>
|
||||
#include <MySensor.h>
|
||||
#include <LiquidCrystal.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
|
||||
#define NUMBER_OF_VALVES 8 // Change this to set your valve count up to 16.
|
||||
#define VALVE_RESET_TIME 7500UL // Change this (in milliseconds) for the time you need your valves to hydraulically reset and change state
|
||||
|
||||
#define SKETCH_NAME "MySprinkler"
|
||||
#define SKETCH_VERSION "2.0"
|
||||
//
|
||||
#define CHILD_ID_SPRINKLER 0
|
||||
//
|
||||
#define ACTIVE_LOW // comment out this line if your relays are active high
|
||||
//
|
||||
#define DEBUG_ON // comment out to supress serial monitor output
|
||||
//
|
||||
#ifdef ACTIVE_LOW
|
||||
#define BITSHIFT_VALVE_NUMBER ~(1U << (valveNumber-1))
|
||||
#define ALL_VALVES_OFF 0xFFFF
|
||||
#else
|
||||
#define BITSHIFT_VALVE_NUMBER (1U << (valveNumber-1))
|
||||
#define ALL_VALVES_OFF 0U
|
||||
#endif
|
||||
//
|
||||
#ifdef DEBUG_ON
|
||||
#define DEBUG_PRINT(x) Serial.print(x)
|
||||
#define DEBUG_PRINTLN(x) Serial.println(x)
|
||||
#else
|
||||
#define DEBUG_PRINT(x)
|
||||
#define DEBUG_PRINTLN(x)
|
||||
#define SERIAL_START(x)
|
||||
#endif
|
||||
//
|
||||
typedef enum {
|
||||
STAND_BY_ALL_OFF, RUN_SINGLE_ZONE, RUN_ALL_ZONES, CYCLE_COMPLETE, ZONE_SELECT_MENU
|
||||
}
|
||||
SprinklerStates;
|
||||
//
|
||||
SprinklerStates state = STAND_BY_ALL_OFF;
|
||||
SprinklerStates lastState;
|
||||
byte menuState = 0;
|
||||
unsigned long menuTimer;
|
||||
byte countDownTime = 10;
|
||||
//
|
||||
int allZoneTime [NUMBER_OF_VALVES + 1];
|
||||
int valveSoloTime [NUMBER_OF_VALVES + 1];
|
||||
int valveNumber;
|
||||
int lastValve;
|
||||
unsigned long startMillis;
|
||||
const int ledPin = 5;
|
||||
const int waterButtonPin = 3;
|
||||
boolean buttonPushed = false;
|
||||
boolean showTime = true;
|
||||
boolean clockUpdating = false;
|
||||
boolean recentUpdate = true;
|
||||
const char *dayOfWeek[] = {
|
||||
"Null", "Sunday ", "Monday ", "Tuesday ", "Wednesday ", "Thursday ", "Friday ", "Saturday "
|
||||
};
|
||||
// Name your Zones here or use Vera to edit them by adding a name in Variable3...
|
||||
String valveNickName[17] = {
|
||||
"All Zones", "Zone 1", "Zone 2", "Zone 3", "Zone 4", "Zone 5", "Zone 6", "Zone 7", "Zone 8", "Zone 9", "Zone 10", "Zone 11", "Zone 12", "Zone 13", "Zone 14", "Zone 15", "Zone 16"
|
||||
};
|
||||
//
|
||||
time_t lastTimeRun = 0;
|
||||
//Setup Shift Register...
|
||||
const int latchPin = 8;
|
||||
const int clockPin = 4;
|
||||
const int dataPin = 7;
|
||||
//
|
||||
byte clock[8] = {0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0}; // fetching time indicator
|
||||
byte raindrop[8] = {0x4, 0x4, 0xA, 0xA, 0x11, 0xE, 0x0,}; // fetching Valve Data indicator
|
||||
// Set the pins on the I2C chip used for LCD connections:
|
||||
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
|
||||
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address to 0x27
|
||||
//
|
||||
MyMessage msg1valve(CHILD_ID_SPRINKLER, V_LIGHT);
|
||||
MyMessage var1valve(CHILD_ID_SPRINKLER, V_VAR1);
|
||||
MyMessage var2valve(CHILD_ID_SPRINKLER, V_VAR2);
|
||||
|
||||
bool receivedInitialValue = false;
|
||||
//
|
||||
void setup()
|
||||
{
|
||||
DEBUG_PRINTLN(F("Initialising..."));
|
||||
pinMode(latchPin, OUTPUT);
|
||||
pinMode(clockPin, OUTPUT);
|
||||
pinMode(dataPin, OUTPUT);
|
||||
pinMode(ledPin, OUTPUT);
|
||||
pinMode(waterButtonPin, INPUT_PULLUP);
|
||||
//pinMode(waterButtonPin, INPUT);
|
||||
attachInterrupt(1, PushButton, RISING); //May need to change for your Arduino model
|
||||
digitalWrite (ledPin, HIGH);
|
||||
DEBUG_PRINTLN(F("Turning All Valves Off..."));
|
||||
updateRelays(ALL_VALVES_OFF);
|
||||
//delay(5000);
|
||||
lcd.begin(16, 2); //(16 characters and 2 line display)
|
||||
lcd.clear();
|
||||
lcd.backlight();
|
||||
lcd.createChar(0, clock);
|
||||
lcd.createChar(1, raindrop);
|
||||
//
|
||||
//check for saved date in EEPROM
|
||||
DEBUG_PRINTLN(F("Checking EEPROM for stored date:"));
|
||||
delay(500);
|
||||
if (loadState(0) == 0xFF) // EEPROM flag
|
||||
{
|
||||
DEBUG_PRINTLN(F("Retreiving last run time from EEPROM..."));
|
||||
for (int i = 0; i < 4 ; i++)
|
||||
{
|
||||
lastTimeRun = lastTimeRun << 8;
|
||||
lastTimeRun = lastTimeRun | loadState(i + 1); // assemble 4 bytes into an ussigned long epoch timestamp
|
||||
}
|
||||
}
|
||||
setIncomingCallback(getVariables);
|
||||
sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
|
||||
for (byte i = 0; i <= NUMBER_OF_VALVES; i++)
|
||||
{
|
||||
present(i, S_LIGHT);
|
||||
}
|
||||
DEBUG_PRINTLN(F("Sensor Presentation Complete"));
|
||||
//
|
||||
digitalWrite (ledPin, LOW);
|
||||
DEBUG_PRINTLN(F("Ready..."));
|
||||
//
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print(F(" Syncing Time "));
|
||||
lcd.setCursor(15, 0);
|
||||
lcd.write(byte(0));
|
||||
lcd.setCursor(0, 1);
|
||||
int clockCounter = 0;
|
||||
while (timeStatus() == timeNotSet && clockCounter < 21)
|
||||
{
|
||||
requestTime(receiveTime);
|
||||
DEBUG_PRINTLN(F("Requesting time from Gateway:"));
|
||||
wait(1000);
|
||||
lcd.print(".");
|
||||
clockCounter++;
|
||||
if (clockCounter > 16)
|
||||
{
|
||||
DEBUG_PRINTLN(F("Failed initial clock synchronization!"));
|
||||
lcd.clear();
|
||||
lcd.print(F(" Failed Clock "));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F(" Syncronization "));
|
||||
wait(2000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
lcd.clear();
|
||||
//Update valve data when first powered on
|
||||
for (byte i = 0; i <= NUMBER_OF_VALVES; i++)
|
||||
{
|
||||
lcd.print(F(" Updating "));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F(" Valve Data: "));
|
||||
lcd.print(i);
|
||||
boolean flashIcon = false;
|
||||
DEBUG_PRINT(F("Calling for Valve "));
|
||||
DEBUG_PRINT(i);
|
||||
DEBUG_PRINTLN(F(" Data..."));
|
||||
while (!receivedInitialValue)
|
||||
{
|
||||
lcd.setCursor(15, 0);
|
||||
flashIcon = !flashIcon;
|
||||
flashIcon ? lcd.write(byte(1)) : lcd.print(F(" "));
|
||||
request(i, V_VAR1);
|
||||
wait(500);
|
||||
}
|
||||
receivedInitialValue = false;
|
||||
while (!receivedInitialValue)
|
||||
{
|
||||
lcd.setCursor(15, 0);
|
||||
flashIcon = !flashIcon;
|
||||
flashIcon ? lcd.write(byte(1)) : lcd.print(F(" "));
|
||||
request(i, V_VAR2);
|
||||
wait(500);
|
||||
}
|
||||
receivedInitialValue = false;
|
||||
while (!receivedInitialValue)
|
||||
{
|
||||
lcd.setCursor(15, 0);
|
||||
flashIcon = !flashIcon;
|
||||
flashIcon ? lcd.write(byte(1)) : lcd.print(F(" "));
|
||||
request(i, V_VAR3);
|
||||
wait(500);
|
||||
}
|
||||
}
|
||||
lcd.clear();
|
||||
}
|
||||
//
|
||||
void loop()
|
||||
{
|
||||
updateClock();
|
||||
updateDisplay();
|
||||
goGetValveTimes();
|
||||
//
|
||||
if (buttonPushed)
|
||||
{
|
||||
menuTimer = millis();
|
||||
DEBUG_PRINTLN(F("Button Pressed"));
|
||||
if (state == STAND_BY_ALL_OFF)
|
||||
{
|
||||
state = ZONE_SELECT_MENU;
|
||||
menuState = 0;
|
||||
}
|
||||
else if (state == ZONE_SELECT_MENU)
|
||||
{
|
||||
menuState++;
|
||||
if (menuState > NUMBER_OF_VALVES)
|
||||
{
|
||||
menuState = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
state = STAND_BY_ALL_OFF;
|
||||
}
|
||||
buttonPushed = false;
|
||||
}
|
||||
if (state == STAND_BY_ALL_OFF)
|
||||
{
|
||||
slowToggleLED ();
|
||||
if (state != lastState)
|
||||
{
|
||||
updateRelays(ALL_VALVES_OFF);
|
||||
DEBUG_PRINTLN(F("State Changed... all Zones off"));
|
||||
for (byte i = 0; i <= NUMBER_OF_VALVES; i++)
|
||||
{
|
||||
wait(50);
|
||||
send(msg1valve.setSensor(i).set(false), false);
|
||||
}
|
||||
lcd.clear();
|
||||
lcd.setCursor(0,0);
|
||||
lcd.print(F("** Irrigation **"));
|
||||
lcd.setCursor(0,1);
|
||||
lcd.print(F("** Halted **"));
|
||||
wait(2000);
|
||||
lastValve = -1;
|
||||
}
|
||||
}
|
||||
//
|
||||
else if (state == RUN_ALL_ZONES)
|
||||
{
|
||||
if (lastValve != valveNumber)
|
||||
{
|
||||
for (byte i = 0; i <= NUMBER_OF_VALVES; i++)
|
||||
{
|
||||
if (i == 0 || i == valveNumber)
|
||||
{
|
||||
send(msg1valve.setSensor(i).set(true), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
send(msg1valve.setSensor(i).set(false), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastValve = valveNumber;
|
||||
fastToggleLed();
|
||||
if (state != lastState)
|
||||
{
|
||||
valveNumber = 1;
|
||||
updateRelays(ALL_VALVES_OFF);
|
||||
DEBUG_PRINTLN(F("State Changed, Running All Zones..."));
|
||||
}
|
||||
unsigned long nowMillis = millis();
|
||||
if (nowMillis - startMillis < VALVE_RESET_TIME)
|
||||
{
|
||||
updateRelays(ALL_VALVES_OFF);
|
||||
}
|
||||
else if (nowMillis - startMillis < (allZoneTime[valveNumber] * 60000UL))
|
||||
{
|
||||
updateRelays(BITSHIFT_VALVE_NUMBER);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTLN(F("Changing Valves..."));
|
||||
updateRelays(ALL_VALVES_OFF);
|
||||
startMillis = millis();
|
||||
valveNumber++;
|
||||
if (valveNumber > NUMBER_OF_VALVES)
|
||||
{
|
||||
state = CYCLE_COMPLETE;
|
||||
startMillis = millis();
|
||||
lastValve = -1;
|
||||
lastTimeRun = now();
|
||||
saveDateToEEPROM(lastTimeRun);
|
||||
for (byte i = 0; i <= NUMBER_OF_VALVES; i++)
|
||||
{
|
||||
send(msg1valve.setSensor(i).set(false), false);
|
||||
}
|
||||
DEBUG_PRINT(F("State = "));
|
||||
DEBUG_PRINTLN(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
else if (state == RUN_SINGLE_ZONE)
|
||||
{
|
||||
fastToggleLed();
|
||||
if (state != lastState)
|
||||
{
|
||||
for (byte i = 0; i <= NUMBER_OF_VALVES; i++)
|
||||
{
|
||||
if (i == 0 || i == valveNumber)
|
||||
{
|
||||
send(msg1valve.setSensor(i).set(true), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
send(msg1valve.setSensor(i).set(false), false);
|
||||
}
|
||||
}
|
||||
DEBUG_PRINTLN(F("State Changed, Single Zone Running..."));
|
||||
DEBUG_PRINT(F("Zone: "));
|
||||
DEBUG_PRINTLN(valveNumber);
|
||||
}
|
||||
unsigned long nowMillis = millis();
|
||||
if (nowMillis - startMillis < VALVE_RESET_TIME)
|
||||
{
|
||||
updateRelays(ALL_VALVES_OFF);
|
||||
}
|
||||
else if (nowMillis - startMillis < (valveSoloTime [valveNumber] * 60000UL))
|
||||
{
|
||||
updateRelays(BITSHIFT_VALVE_NUMBER);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateRelays(ALL_VALVES_OFF);
|
||||
for (byte i = 0; i <= NUMBER_OF_VALVES; i++)
|
||||
{
|
||||
send(msg1valve.setSensor(i).set(false), false);
|
||||
}
|
||||
state = CYCLE_COMPLETE;
|
||||
startMillis = millis();
|
||||
DEBUG_PRINT(F("State = "));
|
||||
DEBUG_PRINTLN(state);
|
||||
}
|
||||
lastTimeRun = now();
|
||||
}
|
||||
else if (state == CYCLE_COMPLETE)
|
||||
{
|
||||
if (millis() - startMillis < 30000UL)
|
||||
{
|
||||
fastToggleLed();
|
||||
}
|
||||
else
|
||||
{
|
||||
state = STAND_BY_ALL_OFF;
|
||||
}
|
||||
}
|
||||
else if (state == ZONE_SELECT_MENU)
|
||||
{
|
||||
displayMenu();
|
||||
}
|
||||
lastState = state;
|
||||
}
|
||||
//
|
||||
void displayMenu(void)
|
||||
{
|
||||
static byte lastMenuState = -1;
|
||||
static int lastSecond;
|
||||
if (menuState != lastMenuState)
|
||||
{
|
||||
lcd.clear();
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print(valveNickName[menuState]);
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F("Starting"));
|
||||
DEBUG_PRINT(valveNickName[menuState]);
|
||||
Serial.print(F(" Starting Shortly"));
|
||||
}
|
||||
int thisSecond = (millis() - menuTimer) / 1000UL;
|
||||
if (thisSecond != lastSecond && thisSecond < 8)
|
||||
{
|
||||
lcd.print(F("."));
|
||||
Serial.print(".");
|
||||
}
|
||||
lastSecond = thisSecond;
|
||||
if (millis() - menuTimer > 10000UL)
|
||||
{
|
||||
startMillis = millis();
|
||||
if (menuState == 0)
|
||||
{
|
||||
valveNumber = 1;
|
||||
state = RUN_ALL_ZONES;
|
||||
}
|
||||
else
|
||||
{
|
||||
valveNumber = menuState;
|
||||
state = RUN_SINGLE_ZONE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
lastMenuState = menuState;
|
||||
}
|
||||
//
|
||||
void updateRelays(int value)
|
||||
{
|
||||
digitalWrite(latchPin, LOW);
|
||||
shiftOut(dataPin, clockPin, MSBFIRST, highByte(value));
|
||||
shiftOut(dataPin, clockPin, MSBFIRST, lowByte(value));
|
||||
digitalWrite(latchPin, HIGH);
|
||||
}
|
||||
//
|
||||
void PushButton() //interrupt with debounce
|
||||
{
|
||||
static unsigned long last_interrupt_time = 0;
|
||||
unsigned long interrupt_time = millis();
|
||||
if (interrupt_time - last_interrupt_time > 200)
|
||||
{
|
||||
buttonPushed = true;
|
||||
}
|
||||
last_interrupt_time = interrupt_time;
|
||||
}
|
||||
//
|
||||
void fastToggleLed()
|
||||
{
|
||||
static unsigned long fastLedTimer;
|
||||
if (millis() - fastLedTimer >= 100UL)
|
||||
{
|
||||
digitalWrite(ledPin, !digitalRead(ledPin));
|
||||
fastLedTimer = millis ();
|
||||
}
|
||||
}
|
||||
//
|
||||
void slowToggleLED ()
|
||||
{
|
||||
static unsigned long slowLedTimer;
|
||||
if (millis() - slowLedTimer >= 1250UL)
|
||||
{
|
||||
digitalWrite(ledPin, !digitalRead(ledPin));
|
||||
slowLedTimer = millis ();
|
||||
}
|
||||
}
|
||||
//
|
||||
void getVariables(const MyMessage &message)
|
||||
{
|
||||
boolean zoneTimeUpdate = false;
|
||||
if (message.isAck())
|
||||
{
|
||||
DEBUG_PRINTLN(F("This is an ack from gateway"));
|
||||
}
|
||||
for (byte i = 0; i <= NUMBER_OF_VALVES; i++)
|
||||
{
|
||||
if (message.sensor == i)
|
||||
{
|
||||
if (message.type == V_LIGHT)
|
||||
{
|
||||
int switchState = atoi(message.data);
|
||||
if (switchState == 0)
|
||||
{
|
||||
state = STAND_BY_ALL_OFF;
|
||||
DEBUG_PRINTLN(F("Recieved Instruction to Cancel..."));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
state = RUN_ALL_ZONES;
|
||||
valveNumber = 1;
|
||||
DEBUG_PRINTLN(F("Recieved Instruction to Run All Zones..."));
|
||||
}
|
||||
else
|
||||
{
|
||||
state = RUN_SINGLE_ZONE;
|
||||
valveNumber = i;
|
||||
DEBUG_PRINT(F("Recieved Instruction to Activate Zone: "));
|
||||
DEBUG_PRINTLN(i);
|
||||
}
|
||||
}
|
||||
startMillis = millis();
|
||||
}
|
||||
else if (message.type == V_VAR1)
|
||||
{
|
||||
int variable1 = atoi(message.data);// RUN_ALL_ZONES time
|
||||
DEBUG_PRINT(F("Recieved variable1 valve:"));
|
||||
DEBUG_PRINT(i);
|
||||
DEBUG_PRINT(F(" = "));
|
||||
DEBUG_PRINTLN(variable1);
|
||||
if (variable1 != allZoneTime[i])
|
||||
{
|
||||
allZoneTime[i] = variable1;
|
||||
|
||||
zoneTimeUpdate = true;
|
||||
}
|
||||
receivedInitialValue = true;
|
||||
}
|
||||
else if (message.type == V_VAR2)
|
||||
{
|
||||
int variable2 = atoi(message.data);// RUN_SINGLE_ZONE time
|
||||
DEBUG_PRINT(F("Recieved variable2 valve:"));
|
||||
DEBUG_PRINT(i);
|
||||
DEBUG_PRINT(F(" = "));
|
||||
DEBUG_PRINTLN(variable2);
|
||||
if (variable2 != valveSoloTime[i])
|
||||
{
|
||||
valveSoloTime[i] = variable2;
|
||||
zoneTimeUpdate = true;
|
||||
}
|
||||
receivedInitialValue = true;
|
||||
}
|
||||
else if (message.type == V_VAR3)
|
||||
{
|
||||
String newMessage = String(message.data);
|
||||
if (newMessage.length() == 0)
|
||||
{
|
||||
DEBUG_PRINT(F("No Name Recieved for zone "));
|
||||
DEBUG_PRINTLN(i);
|
||||
break;
|
||||
}
|
||||
if (newMessage.length() > 16)
|
||||
{
|
||||
newMessage.substring(0, 16);
|
||||
}
|
||||
valveNickName[i] = "";
|
||||
valveNickName[i] += newMessage;
|
||||
DEBUG_PRINT(F("Recieved new name for zone "));
|
||||
DEBUG_PRINT(i);
|
||||
DEBUG_PRINT(F(" and it is now called: "));
|
||||
DEBUG_PRINTLN(valveNickName[i]);
|
||||
}
|
||||
receivedInitialValue = true;
|
||||
}
|
||||
}
|
||||
if (zoneTimeUpdate)
|
||||
{
|
||||
//
|
||||
DEBUG_PRINTLN(F("New Zone Times Recieved..."));
|
||||
for (byte i = 0; i <= NUMBER_OF_VALVES; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
DEBUG_PRINT(F("Zone "));
|
||||
DEBUG_PRINT(i);
|
||||
DEBUG_PRINT(F(" individual time: "));
|
||||
DEBUG_PRINT(valveSoloTime[i]);
|
||||
DEBUG_PRINT(F(" group time: "));
|
||||
DEBUG_PRINTLN(allZoneTime[i]);
|
||||
recentUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
recentUpdate = false;
|
||||
}
|
||||
}
|
||||
//
|
||||
void updateDisplay()
|
||||
{
|
||||
static unsigned long lastUpdateTime;
|
||||
static boolean displayToggle = false;
|
||||
//static byte toggleCounter = 0;
|
||||
static SprinklerStates lastDisplayState;
|
||||
if (state != lastDisplayState || millis() - lastUpdateTime >= 3000UL)
|
||||
{
|
||||
displayToggle = !displayToggle;
|
||||
switch (state) {
|
||||
case STAND_BY_ALL_OFF:
|
||||
//
|
||||
fastClear();
|
||||
lcd.setCursor(0, 0);
|
||||
if (displayToggle)
|
||||
{
|
||||
lcd.print(F(" System Ready "));
|
||||
if (clockUpdating)
|
||||
{
|
||||
lcd.setCursor(15, 0);
|
||||
lcd.write(byte(0));
|
||||
}
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(hourFormat12() < 10 ? F(" ") : F(""));
|
||||
lcd.print(hourFormat12());
|
||||
lcd.print(minute() < 10 ? F(":0") : F(":"));
|
||||
lcd.print(minute());
|
||||
lcd.print(isAM() ? F("am") : F("pm"));
|
||||
lcd.print(month() < 10 ? F(" 0") : F(" "));
|
||||
lcd.print(month());
|
||||
lcd.print(day() < 10 ? F("/0") : F("/"));
|
||||
lcd.print(day());
|
||||
lcd.print(F("/"));
|
||||
lcd.print(year() % 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd.print(F(" Last Watered "));
|
||||
if (clockUpdating)
|
||||
{
|
||||
lcd.setCursor(15, 0);
|
||||
lcd.write(byte(0));
|
||||
}
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(dayOfWeek[weekday(lastTimeRun)]);
|
||||
lcd.setCursor(11, 1);
|
||||
lcd.print(month(lastTimeRun) < 10 ? F(" ") : F(""));
|
||||
lcd.print(month(lastTimeRun));
|
||||
lcd.print(day(lastTimeRun) < 10 ? F("/0") : F("/"));
|
||||
lcd.print(day(lastTimeRun));
|
||||
}
|
||||
break;
|
||||
case RUN_SINGLE_ZONE:
|
||||
//
|
||||
fastClear();
|
||||
lcd.setCursor(0, 0);
|
||||
if (displayToggle)
|
||||
{
|
||||
lcd.print(F("Single Zone Mode"));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F(" Zone:"));
|
||||
if (valveNumber < 10) lcd.print(F("0"));
|
||||
lcd.print(valveNumber);
|
||||
lcd.print(F(" Active"));
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd.print(F(" Time Remaining "));
|
||||
lcd.setCursor(0, 1);
|
||||
if (valveSoloTime[valveNumber] == 0)
|
||||
{
|
||||
lcd.print(F(" No Valve Time "));
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long timeRemaining = (valveSoloTime[valveNumber] * 60) - ((millis() - startMillis) / 1000);
|
||||
lcd.print(timeRemaining / 60 < 10 ? " 0" : " ");
|
||||
lcd.print(timeRemaining / 60);
|
||||
lcd.print("min");
|
||||
lcd.print(timeRemaining % 60 < 10 ? " 0" : " ");
|
||||
lcd.print(timeRemaining % 60);
|
||||
lcd.print("sec ");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RUN_ALL_ZONES:
|
||||
//
|
||||
fastClear();
|
||||
lcd.setCursor(0, 0);
|
||||
if (displayToggle)
|
||||
{
|
||||
lcd.print(F(" All-Zone Mode "));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F(" Zone:"));
|
||||
if (valveNumber < 10) lcd.print(F("0"));
|
||||
lcd.print(valveNumber);
|
||||
lcd.print(F(" Active "));
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd.print(F(" Time Remaining "));
|
||||
lcd.setCursor(0, 1);
|
||||
int timeRemaining = (allZoneTime[valveNumber] * 60) - ((millis() - startMillis) / 1000);
|
||||
lcd.print((timeRemaining / 60) < 10 ? " 0" : " ");
|
||||
lcd.print(timeRemaining / 60);
|
||||
lcd.print("min");
|
||||
lcd.print(timeRemaining % 60 < 10 ? " 0" : " ");
|
||||
lcd.print(timeRemaining % 60);
|
||||
lcd.print("sec ");
|
||||
}
|
||||
break;
|
||||
case CYCLE_COMPLETE:
|
||||
//
|
||||
if (displayToggle)
|
||||
{
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print(F(" Watering Cycle "));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F(" Complete "));
|
||||
}
|
||||
else
|
||||
{
|
||||
int totalTimeRan = 0;
|
||||
for (int i = 1; i < NUMBER_OF_VALVES + 1; i++)
|
||||
{
|
||||
totalTimeRan += allZoneTime[i];
|
||||
}
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print(F(" Total Time Run "));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(totalTimeRan < 10 ? " 0" : " ");
|
||||
lcd.print(totalTimeRan);
|
||||
lcd.print(" Minutes ");
|
||||
}
|
||||
default:
|
||||
// what of ZONE_SELECT_MENU?
|
||||
break;
|
||||
}
|
||||
lastUpdateTime = millis();
|
||||
}
|
||||
lastDisplayState = state;
|
||||
}
|
||||
void receiveTime(time_t newTime)
|
||||
{
|
||||
DEBUG_PRINTLN(F("Time value received and updated..."));
|
||||
int lastSecond = second();
|
||||
int lastMinute = minute();
|
||||
int lastHour = hour();
|
||||
setTime(newTime);
|
||||
if (((second() != lastSecond) || (minute() != lastMinute) || (hour() != lastHour)) || showTime)
|
||||
{
|
||||
DEBUG_PRINTLN(F("Clock updated...."));
|
||||
DEBUG_PRINT(F("Sensor's time currently set to:"));
|
||||
DEBUG_PRINT(hourFormat12() < 10 ? F(" 0") : F(" "));
|
||||
DEBUG_PRINT(hourFormat12());
|
||||
DEBUG_PRINT(minute() < 10 ? F(":0") : F(":"));
|
||||
DEBUG_PRINT(minute());
|
||||
DEBUG_PRINTLN(isAM() ? F("am") : F("pm"));
|
||||
DEBUG_PRINT(month());
|
||||
DEBUG_PRINT(F("/"));
|
||||
DEBUG_PRINT(day());
|
||||
DEBUG_PRINT(F("/"));
|
||||
DEBUG_PRINTLN(year());
|
||||
DEBUG_PRINTLN(dayOfWeek[weekday()]);
|
||||
showTime = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_PRINTLN(F("Sensor's time did NOT need adjustment greater than 1 second."));
|
||||
}
|
||||
clockUpdating = false;
|
||||
}
|
||||
void fastClear()
|
||||
{
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print(F(" "));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(F(" "));
|
||||
}
|
||||
//
|
||||
void updateClock()
|
||||
{
|
||||
static unsigned long lastVeraGetTime;
|
||||
if (millis() - lastVeraGetTime >= 3600000UL) // updates clock time and gets zone times from vera once every hour
|
||||
{
|
||||
DEBUG_PRINTLN(F("Requesting time and valve data from Gateway..."));
|
||||
lcd.setCursor(15, 0);
|
||||
lcd.write(byte(0));
|
||||
clockUpdating = true;
|
||||
requestTime(receiveTime);
|
||||
lastVeraGetTime = millis();
|
||||
}
|
||||
}
|
||||
//
|
||||
void saveDateToEEPROM(unsigned long theDate)
|
||||
{
|
||||
DEBUG_PRINTLN(F("Saving Last Run date"));
|
||||
if (loadState(0) != 0xFF)
|
||||
{
|
||||
saveState(0, 0xFF); // EEPROM flag for last date saved stored in EEPROM (location zero)
|
||||
}
|
||||
//
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
saveState(5 - i, byte(theDate >> 8 * (i - 1))); // store epoch datestamp in 4 bytes of EEPROM starting in location one
|
||||
}
|
||||
}
|
||||
//
|
||||
void goGetValveTimes()
|
||||
{
|
||||
static unsigned long valveUpdateTime;
|
||||
static byte valveIndex = 1;
|
||||
if (millis() - valveUpdateTime >= 300000UL / NUMBER_OF_VALVES)// update each valve once every 5 mins (distributes the traffic)
|
||||
{
|
||||
DEBUG_PRINTLN(F("Calling for Valve Data..."));
|
||||
lcd.setCursor(15, 0);
|
||||
lcd.write(byte(1)); //lcd.write(1);
|
||||
request(valveIndex, V_VAR1);
|
||||
request(valveIndex, V_VAR2);
|
||||
request(valveIndex, V_VAR3);
|
||||
valveUpdateTime = millis();
|
||||
valveIndex++;
|
||||
if (valveIndex > NUMBER_OF_VALVES + 1)
|
||||
{
|
||||
valveIndex = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - idefix
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Arduino BH1750FVI Light sensor
|
||||
* communicate using I2C Protocol
|
||||
* this library enable 2 slave device addresses
|
||||
* Main address 0x23
|
||||
* secondary address 0x5C
|
||||
* connect the sensor as follows :
|
||||
*
|
||||
* VCC >>> 5V
|
||||
* Gnd >>> Gnd
|
||||
* ADDR >>> NC or GND
|
||||
* SCL >>> A5
|
||||
* SDA >>> A4
|
||||
* http://www.mysensors.org/build/light
|
||||
*/
|
||||
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <BH1750.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#define CHILD_ID_LIGHT 0
|
||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||
|
||||
BH1750 lightSensor;
|
||||
|
||||
// V_LIGHT_LEVEL should only be used for uncalibrated light level 0-100%.
|
||||
// If your controller supports the new V_LEVEL variable, use this instead for
|
||||
// transmitting LUX light level.
|
||||
MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
|
||||
// MyMessage msg(CHILD_ID_LIGHT, V_LEVEL);
|
||||
uint16_t lastlux;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Light Lux Sensor", "1.0");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
|
||||
|
||||
lightSensor.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint16_t lux = lightSensor.readLightLevel();// Get Lux value
|
||||
Serial.println(lux);
|
||||
if (lux != lastlux) {
|
||||
send(msg.set(lux));
|
||||
lastlux = lux;
|
||||
}
|
||||
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik EKblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Example sketch showing how to measue light level using a LM393 photo-resistor
|
||||
* http://www.mysensors.org/build/light
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define CHILD_ID_LIGHT 0
|
||||
#define LIGHT_SENSOR_ANALOG_PIN 0
|
||||
|
||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||
|
||||
MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
|
||||
int lastLightLevel;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Light Sensor", "1.0");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
|
||||
Serial.println(lightLevel);
|
||||
if (lightLevel != lastLightLevel) {
|
||||
send(msg.set(lightLevel));
|
||||
lastLightLevel = lightLevel;
|
||||
}
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
// This sketch is to integrate the Playing With Fusion AXS3935 Lightning Sensor Breakout Board
|
||||
// with the MySensors environment and is based on a sketch provided by Playing With Fusion
|
||||
// http://playingwithfusion.com/productview.php?pdid=22&catid=1001
|
||||
//
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include "MySensor.h"
|
||||
// include Playing With Fusion AXS3935 libraries
|
||||
#include "PWFusion_AS3935.h"
|
||||
|
||||
// setup CS pins used for the connection with the lightning sensor
|
||||
// other connections are controlled by the SPI library)
|
||||
int8_t CS_PIN = 8;
|
||||
int8_t SI_PIN = 7;
|
||||
int8_t IRQ_PIN = 3;
|
||||
volatile int8_t AS3935_ISR_Trig = 0;
|
||||
|
||||
// #defines
|
||||
#define AS3935_INDOORS 1
|
||||
#define AS3935_OUTDOORS 0
|
||||
#define AS3935_DIST_DIS 0
|
||||
#define AS3935_DIST_EN 1
|
||||
#define AS3935_CAPACITANCE 96 // <-- SET THIS VALUE TO THE NUMBER LISTED ON YOUR BOARD
|
||||
// prototypes
|
||||
void AS3935_ISR();
|
||||
|
||||
PWF_AS3935 lightning0(CS_PIN, IRQ_PIN, SI_PIN);
|
||||
|
||||
#define CHILD_ID_DISTANCE 1
|
||||
#define CHILD_ID_INTENSITY 2
|
||||
MyMessage msgDist(CHILD_ID_DISTANCE, V_DISTANCE);
|
||||
MyMessage msgInt(CHILD_ID_INTENSITY, V_VAR1);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Lightning Sensor", "1.1");
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
present(CHILD_ID_DISTANCE, S_DISTANCE);
|
||||
present(CHILD_ID_INTENSITY, S_CUSTOM);
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.println("Playing With Fusion: AS3935 Lightning Sensor, SEN-39001");
|
||||
Serial.println("beginning boot procedure....");
|
||||
|
||||
// setup for the the SPI library:
|
||||
SPI.begin(); // begin SPI
|
||||
SPI.setClockDivider(SPI_CLOCK_DIV4); // SPI speed to SPI_CLOCK_DIV16/1MHz (max 2MHz, NEVER 500kHz!)
|
||||
SPI.setDataMode(SPI_MODE1); // MAX31855 is a Mode 1 device
|
||||
// --> clock starts low, read on rising edge
|
||||
SPI.setBitOrder(MSBFIRST); // data sent to chip MSb first
|
||||
|
||||
lightning0.AS3935_DefInit(); // set registers to default
|
||||
// now update sensor cal for your application and power up chip
|
||||
lightning0.AS3935_ManualCal(AS3935_CAPACITANCE, AS3935_OUTDOORS, AS3935_DIST_EN);
|
||||
// AS3935_ManualCal Parameters:
|
||||
// --> capacitance, in pF (marked on package)
|
||||
// --> indoors/outdoors (AS3935_INDOORS:0 / AS3935_OUTDOORS:1)
|
||||
// --> disturbers (AS3935_DIST_EN:1 / AS3935_DIST_DIS:2)
|
||||
// function also powers up the chip
|
||||
|
||||
// enable interrupt (hook IRQ pin to Arduino Uno/Mega interrupt input: 1 -> pin 3 )
|
||||
attachInterrupt(1, AS3935_ISR, RISING);
|
||||
// dump the registry data to the serial port for troubleshooting purposes
|
||||
lightning0.AS3935_PrintAllRegs();
|
||||
|
||||
// delay execution to allow chip to stabilize.
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
// This program only handles an AS3935 lightning sensor. It does nothing until
|
||||
// an interrupt is detected on the IRQ pin.
|
||||
while(0 == AS3935_ISR_Trig){}
|
||||
|
||||
// reset interrupt flag
|
||||
AS3935_ISR_Trig = 0;
|
||||
|
||||
// now get interrupt source
|
||||
uint8_t int_src = lightning0.AS3935_GetInterruptSrc();
|
||||
if(0 == int_src)
|
||||
{
|
||||
Serial.println("Unknown interrupt source");
|
||||
}
|
||||
else if(1 == int_src)
|
||||
{
|
||||
uint8_t lightning_dist_km = lightning0.AS3935_GetLightningDistKm();
|
||||
uint32_t lightning_intensity = lightning0.AS3935_GetStrikeEnergyRaw();
|
||||
|
||||
Serial.print("Lightning detected! Distance to strike: ");
|
||||
Serial.print(lightning_dist_km);
|
||||
Serial.println(" kilometers");
|
||||
Serial.print("Lightning detected! Lightning Intensity: ");
|
||||
Serial.println(lightning_intensity);
|
||||
send(msgDist.set(lightning_dist_km));
|
||||
send(msgInt.set(lightning_intensity));
|
||||
}
|
||||
else if(2 == int_src)
|
||||
{
|
||||
Serial.println("Disturber detected");
|
||||
}
|
||||
else if(3 == int_src)
|
||||
{
|
||||
Serial.println("Noise level too high");
|
||||
}
|
||||
}
|
||||
|
||||
// this is irq handler for AS3935 interrupts, has to return void and take no arguments
|
||||
// always make code in interrupt handlers fast and short
|
||||
void AS3935_ISR()
|
||||
{
|
||||
AS3935_ISR_Trig = 1;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - MrLynx
|
||||
*
|
||||
* DESCRIPTION
|
||||
* MAX6875 High temperature sensor with range: -200 degC - +1300 degC
|
||||
* http://forum.mysensors.org/topic/641/max6675
|
||||
*
|
||||
* Connect MAX6675 - Arduino
|
||||
* CS0 - 4
|
||||
* SO - 3
|
||||
* SCLK - 5
|
||||
* VCC - 5V
|
||||
* GND - GND
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <MAX6675.h>
|
||||
|
||||
uint8_t CS0 = 4; // CS pin on MAX6675
|
||||
uint8_t SO = 3; // SO pin of MAX6675
|
||||
uint8_t SCLK = 5; // SCK pin of MAX6675
|
||||
uint8_t units = 1; // Units to readout temp (0 = ˚F, 1 = ˚C)
|
||||
float temperature = 0.0; // Temperature output variable
|
||||
float lastTemperature;
|
||||
unsigned long SLEEP_TIME = 30000;
|
||||
boolean metric = true;
|
||||
|
||||
MyMessage msg(0, V_TEMP);
|
||||
|
||||
// Initialize the MAX6675 Library for our chip
|
||||
|
||||
MAX6675 temp0(CS0, SO, SCLK, units);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Max6675 Temp Sensor", "1.0");
|
||||
|
||||
// Present all sensors to controller
|
||||
present(0, S_TEMP);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
temperature = temp0.read_temp(); // Read the temp
|
||||
|
||||
if (temperature < 0) { // If there is an error with the TC, temperature will be < 0
|
||||
Serial.println("Thermocouple Error!!"); // There is a thermocouple error
|
||||
} else {
|
||||
Serial.print("Current Temperature: ");
|
||||
Serial.println( temperature ); // Print the temperature to Serial
|
||||
if (temperature != lastTemperature)
|
||||
send(msg.setSensor(0).set(temperature, 1));
|
||||
lastTemperature = temperature;
|
||||
}
|
||||
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
@@ -0,0 +1,614 @@
|
||||
/* MyMQTT Client Gateway 0.1b
|
||||
Created by Norbert Truchsess <norbert.truchsess@t-online.de>
|
||||
Based on MyMQTT-broker gateway created by Daniel Wiegert <daniel.wiegert@gmail.com>
|
||||
Based on MySensors Ethernet Gateway by Henrik Ekblad <henrik.ekblad@gmail.com>
|
||||
http://www.mysensors.org
|
||||
|
||||
Changes by Thomas Krebs <thkrebs@gmx.de>
|
||||
- Add signing support from MySensors 1.5 and update for MySensors 1.5;
|
||||
- Restructured code back to a C like implementation following the existing MQTTGateway
|
||||
Requires MySensors lib 1.5
|
||||
|
||||
* Change below; TCP_IP, TCP_PORT, TCP_MAC
|
||||
This will listen on your selected TCP_IP:TCP_PORT below, Please change TCP_MAC your liking also.
|
||||
*1 -> NOTE: Keep first byte at x2, x6, xA or xE (replace x with any hex value) for using Local Ranges.
|
||||
*2 You can use standard pin set-up as MySensors recommends or if you own a IBOARD you may change
|
||||
the radio-pins below if you hardware mod your iBoard. see [URL BELOW] for more details.
|
||||
http://forum.mysensors.org/topic/224/iboard-cheap-single-board-ethernet-arduino-with-radio/5
|
||||
* Don't forget to look at the definitions in libraries\MySensors\MyMQTT.h!
|
||||
define TCPDUMP and connect serial interface if you have problems, please write on
|
||||
http://forum.mysensors.org/ and explain your problem, include serial output. Don't forget to
|
||||
turn on DEBUG in libraries\MySensors\MyConfig.h also.
|
||||
MQTT_FIRST_SENSORID is for 'DHCP' server in MyMQTT. You may limit the ID's with FIRST and LAST definition.
|
||||
If you want your manually configured below 20 set MQTT_FIRST_SENSORID to 20.
|
||||
To disable: set MQTT_FIRST_SENSORID to 255.
|
||||
MQTT_BROKER_PREFIX is the leading prefix for your nodes. This can be only one char if like.
|
||||
MQTT_SEND_SUBSCRIPTION is if you want the MyMQTT to send a empty payload message to your nodes.
|
||||
This can be useful if you want to send latest state back to the MQTT client. Just check if incoming
|
||||
message has any length or not.
|
||||
Example: if (msg.type==V_LIGHT && strlen(msg.getString())>0) otherwise the code might do strange things.
|
||||
* Address-layout is : [MQTT_BROKER_PREFIX]/[NodeID]/[SensorID]/V_[SensorType][/set | /get]
|
||||
NodeID and SensorID is uint8 (0-255) number.
|
||||
Segment after SensorID is translation of the sensor type, look inside MyMQTT.cpp for the definitions.
|
||||
User can change this to their needs. We have also left some space for custom types.
|
||||
Special: (sensor 255 reserved for special commands)
|
||||
|
||||
The last seqment is a command to to be send down to the sensor. The gateway is subscribed to topics which have
|
||||
a command present! This is to avoid that a publish by the gateway will end up in the gateway via it subsription.
|
||||
You can receive a node sketch name with MyMQTT/20/255/V_Sketch_name (or version with _version)
|
||||
|
||||
So far tested in openhab and MyMQTT for Android (Not my creation)
|
||||
- http://www.openhab.org/
|
||||
* How to set-up Openhab and MQTTGateway:
|
||||
http://forum.mysensors.org/topic/303/mqtt-broker-gateway
|
||||
|
||||
*/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <MySensor.h>
|
||||
#include <MyTransport.h>
|
||||
#include <PubSubClient.h>
|
||||
#include <Ethernet.h>
|
||||
#include <DigitalIO.h>
|
||||
#include <MsTimer2.h>
|
||||
#include <Time.h>
|
||||
|
||||
#include "MyMQTTClient.h"
|
||||
|
||||
#ifdef MY_SIGNING_FEATURE
|
||||
#include <MySigningNone.h>
|
||||
#include <MySigningAtsha204Soft.h>
|
||||
#include <MySigningAtsha204.h>
|
||||
#endif
|
||||
|
||||
//#define DSRTC
|
||||
#ifdef DSRTC
|
||||
#include <Wire.h>
|
||||
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
|
||||
#endif
|
||||
|
||||
/*
|
||||
* To configure MQTTClientGateway.ino to use an ENC28J60 based board include
|
||||
* 'UIPEthernet.h' (SPI.h required for MySensors anyway). The UIPEthernet-library can be downloaded
|
||||
* from: https://github.com/ntruchsess/arduino_uip
|
||||
*/
|
||||
|
||||
//#include <UIPEthernet.h>
|
||||
/*
|
||||
* To execute MQTTClientGateway.ino on Yun uncomment Bridge.h and YunClient.h.
|
||||
* Do not include Ethernet.h or SPI.h in this case.
|
||||
* On Yun there's no need to configure local_ip and mac in the sketch
|
||||
* as this is configured on the linux-side of Yun.
|
||||
*/
|
||||
|
||||
//#include <Bridge.h>
|
||||
//#include <YunClient.h>
|
||||
// * Use this for IBOARD modded to use standard MISO/MOSI/SCK, see note *1 above!
|
||||
/*
|
||||
#define RADIO_CE_PIN 3 // radio chip enable
|
||||
#define RADIO_SPI_SS_PIN 8 // radio SPI serial select
|
||||
#define RADIO_ERROR_LED_PIN A2 // Error led pin
|
||||
#define RADIO_RX_LED_PIN A1 // Receive led pin
|
||||
#define RADIO_TX_LED_PIN A0 // the PCB, on board LED*/
|
||||
|
||||
// * Use this for default configured pro mini / nano etc :
|
||||
//
|
||||
|
||||
//#define RADIO_CE_PIN 5 // radio chip enable
|
||||
//#define RADIO_SPI_SS_PIN 6 // radio SPI serial select
|
||||
//#define RADIO_ERROR_LED_PIN 7 // Error led pin
|
||||
//#define RADIO_RX_LED_PIN 8 // Receive led pin
|
||||
//#define RADIO_TX_LED_PIN 9 // the PCB, on board LED*/
|
||||
|
||||
// CE_PIN and SPI_SS_PIN for Mega
|
||||
#define RADIO_CE_PIN 48 // radio chip enable
|
||||
#define RADIO_SPI_SS_PIN 49 // radio SPI serial select
|
||||
#define RADIO_ERROR_LED_PIN A2 // Error led pin
|
||||
#define RADIO_RX_LED_PIN A1 // Receive led pin
|
||||
#define RADIO_TX_LED_PIN A0 // the PCB, on board LED*/
|
||||
|
||||
//replace with ip of server you want to connect to, comment out if using 'remote_host'
|
||||
uint8_t remote_ip[] = { 192, 168, 178, 74 }; // Mosquitto broker
|
||||
|
||||
//replace with hostname of server you want to connect to, comment out if using 'remote_ip'
|
||||
//char* remote_ip = "server.local";
|
||||
//replace with the port that your server is listening on
|
||||
#define remote_port 1883
|
||||
//replace with arduinos ip-address. Comment out if Ethernet-startup should use dhcp. Is ignored on Yun
|
||||
uint8_t local_ip[] = {192, 168, 178, 11};
|
||||
//replace with ethernet shield mac. It's mandatory every device is assigned a unique mac. Is ignored on Yun
|
||||
uint8_t mac[] = { 0xA2, 0xAE, 0xAD, 0xA0, 0xA0, 0xA2 };
|
||||
|
||||
#if defined remote_ip && defined remote_host
|
||||
#error "cannot define both remote_ip and remote_host at the same time!"
|
||||
#endif
|
||||
|
||||
#ifdef _YUN_CLIENT_H_
|
||||
YunClient ethClient;
|
||||
#else
|
||||
EthernetClient ethClient;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// NRFRF24L01 radio driver (set low transmit power by default)
|
||||
MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);
|
||||
//MyTransportRFM69 transport;
|
||||
|
||||
// Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
|
||||
//MySigningNone signer;
|
||||
//MySigningAtsha204Soft signer(true);
|
||||
//MySigningAtsha204 signer;
|
||||
|
||||
// Hardware profile
|
||||
MyHwATMega328 hw;
|
||||
|
||||
MyMessage msg;
|
||||
char convBuf[MAX_PAYLOAD * 2 + 1];
|
||||
uint8_t buffsize;
|
||||
char buffer[MQTT_MAX_PACKET_SIZE];
|
||||
char user[sizeof(MQTT_USER)]; // introduced the bufs to get rid of compiler warnings
|
||||
char pwd[sizeof(MQTT_PWD)]; // see above
|
||||
char connID[sizeof(MQTT_CONN_ID)]; // see above
|
||||
char mqttTopicMask[sizeof(MQTT_TOPIC_MASK)]; // see above
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
volatile uint8_t countRx;
|
||||
volatile uint8_t countTx;
|
||||
volatile uint8_t countErr;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void processMQTTMessages(char* topic, byte* payload, unsigned int length);
|
||||
PubSubClient client(remote_ip, remote_port, processMQTTMessages, ethClient);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Declare and initialize MySensor instance
|
||||
// Construct MyMQTTClient (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h, if signing
|
||||
// feature not to be used, uncomment)
|
||||
// To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
|
||||
MySensor gw(transport, hw
|
||||
#ifdef MY_SIGNING_FEATURE
|
||||
, signer
|
||||
#endif
|
||||
#ifdef WITH_LEDS_BLINKING
|
||||
, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN
|
||||
#endif
|
||||
);
|
||||
|
||||
/*
|
||||
* setup
|
||||
*/
|
||||
void setup()
|
||||
{
|
||||
strcpy(connID,MQTT_CONN_ID);
|
||||
strcpy(mqttTopicMask,MQTT_TOPIC_MASK);
|
||||
|
||||
countRx = 0;
|
||||
countTx = 0;
|
||||
countErr = 0;
|
||||
|
||||
Ethernet.begin(mac, local_ip);
|
||||
//Bridge.begin();
|
||||
delay(1000); // Wait for Ethernet to get configured.
|
||||
|
||||
begin();
|
||||
}
|
||||
|
||||
/*
|
||||
* loop
|
||||
*/
|
||||
void loop()
|
||||
{
|
||||
if (!client.connected())
|
||||
{
|
||||
boolean ret;
|
||||
#ifdef MQTT_AUTH_REQUIRED
|
||||
strcpy(user, MQTT_USER);
|
||||
strcpy(pwd, MQTT_PWD);
|
||||
ret = client.connect(connID, user,pwd);
|
||||
#else
|
||||
ret = client.connect(connID);
|
||||
#endif
|
||||
if (ret) {
|
||||
Serial.println("Connected to MQTT broker");
|
||||
} else {
|
||||
Serial.println("Connection to MQTT broker failed");
|
||||
}
|
||||
client.subscribe(mqttTopicMask);
|
||||
}
|
||||
client.loop();
|
||||
gw.process();
|
||||
}
|
||||
|
||||
/*
|
||||
* processRadioMessage
|
||||
*
|
||||
* Receives radio message, parses it and forwards it to the MQTT broker
|
||||
*/
|
||||
void processRadioMessage(const MyMessage &message)
|
||||
{
|
||||
rxBlink(1);
|
||||
sendMQTT(message);
|
||||
}
|
||||
|
||||
/*
|
||||
* sendMQTT
|
||||
* Handles processing of radio messages and eventually publishes it to the MQTT broker
|
||||
*/
|
||||
void sendMQTT(const MyMessage &inMsg)
|
||||
{
|
||||
MyMessage msg = inMsg;
|
||||
buffsize = 0;
|
||||
if (!client.connected())
|
||||
return; //We have no connections - return
|
||||
if (msg.isAck())
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Serial.println("msg is ack!");
|
||||
#endif
|
||||
if (msg.sender == 255 && mGetCommand(msg) == C_INTERNAL
|
||||
&& msg.type == I_ID_REQUEST)
|
||||
{
|
||||
// TODO: sending ACK request on id_response fucks node up. doesn't work.
|
||||
// The idea was to confirm id and save to EEPROM_LATEST_NODE_ADDRESS.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have to check every message if its a newly assigned id or not.
|
||||
// Ack on I_ID_RESPONSE does not work, and checking on C_PRESENTATION isn't reliable.
|
||||
uint8_t newNodeID = gw.loadState(EEPROM_LATEST_NODE_ADDRESS) + 1;
|
||||
if (newNodeID <= MQTT_FIRST_SENSORID)
|
||||
newNodeID = MQTT_FIRST_SENSORID;
|
||||
if (msg.sender == newNodeID)
|
||||
{
|
||||
gw.saveState(EEPROM_LATEST_NODE_ADDRESS, newNodeID);
|
||||
}
|
||||
if (mGetCommand(msg) == C_INTERNAL)
|
||||
{
|
||||
if (msg.type == I_CONFIG)
|
||||
{
|
||||
txBlink(1);
|
||||
if (!gw.sendRoute(
|
||||
build(msg, GATEWAY_ADDRESS, msg.sender, 255, C_INTERNAL,
|
||||
I_CONFIG, 0).set("M")))
|
||||
errBlink(1);
|
||||
}
|
||||
else if (msg.type == I_TIME)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Serial.println("I_TIME requested!");
|
||||
#endif
|
||||
txBlink(1);
|
||||
if (!gw.sendRoute(
|
||||
build(msg, GATEWAY_ADDRESS, msg.sender, 255, C_INTERNAL,
|
||||
I_TIME, 0).set(now())))
|
||||
errBlink(1);
|
||||
}
|
||||
else if (msg.type == I_ID_REQUEST && msg.sender == 255)
|
||||
{
|
||||
uint8_t newNodeID = gw.loadState(EEPROM_LATEST_NODE_ADDRESS) + 1;
|
||||
if (newNodeID <= MQTT_FIRST_SENSORID)
|
||||
newNodeID = MQTT_FIRST_SENSORID;
|
||||
if (newNodeID >= MQTT_LAST_SENSORID)
|
||||
return; // Sorry no more id's left :(
|
||||
txBlink(1);
|
||||
if (!gw.sendRoute(
|
||||
build(msg, GATEWAY_ADDRESS, msg.sender, 255, C_INTERNAL,
|
||||
I_ID_RESPONSE, 0).set(newNodeID)))
|
||||
errBlink(1);
|
||||
}
|
||||
else if (msg.type == I_BATTERY_LEVEL)
|
||||
{
|
||||
strcpy_P(buffer, mqtt_prefix);
|
||||
buffsize += strlen_P(mqtt_prefix);
|
||||
buffsize += sprintf(&buffer[buffsize], "/%i/255/BATTERY_LEVEL", msg.sender );
|
||||
msg.getString(convBuf);
|
||||
#ifdef DEBUG
|
||||
Serial.print("publish: ");
|
||||
Serial.print((char*) buffer);
|
||||
Serial.print(" ");
|
||||
Serial.println((char*) convBuf);
|
||||
#endif
|
||||
client.publish(buffer, convBuf);
|
||||
}
|
||||
else if (msg.type == I_SKETCH_NAME)
|
||||
{
|
||||
strcpy_P(buffer, mqtt_prefix);
|
||||
buffsize += strlen_P(mqtt_prefix);
|
||||
buffsize += sprintf(&buffer[buffsize], "/%i/255/SKETCH_NAME", msg.sender );
|
||||
msg.getString(convBuf);
|
||||
#ifdef DEBUG
|
||||
Serial.print("publish: ");
|
||||
Serial.print((char*) buffer);
|
||||
Serial.print(" ");
|
||||
Serial.println((char*) convBuf);
|
||||
#endif
|
||||
client.publish(buffer, convBuf);
|
||||
}
|
||||
else if (msg.type == I_SKETCH_VERSION)
|
||||
{
|
||||
strcpy_P(buffer, mqtt_prefix);
|
||||
buffsize += strlen_P(mqtt_prefix);
|
||||
buffsize += sprintf(&buffer[buffsize], "/%i/255/SKETCH_VERSION", msg.sender );
|
||||
msg.getString(convBuf);
|
||||
#ifdef DEBUG
|
||||
Serial.print("publish: ");
|
||||
Serial.print((char*) buffer);
|
||||
Serial.print(" ");
|
||||
Serial.println((char*) convBuf);
|
||||
#endif
|
||||
client.publish(buffer, convBuf);
|
||||
}
|
||||
|
||||
}
|
||||
else if (mGetCommand(msg) != 0)
|
||||
{
|
||||
if (mGetCommand(msg) == 3)
|
||||
msg.type = msg.type + (S_FIRSTCUSTOM - 10); //Special message
|
||||
|
||||
if (msg.type > VAR_TOTAL)
|
||||
msg.type = VAR_TOTAL; // If type > defined types set to unknown.
|
||||
strcpy_P(buffer, mqtt_prefix);
|
||||
buffsize += strlen_P(mqtt_prefix);
|
||||
buffsize += sprintf(&buffer[buffsize], "/%i/%i/V_%s", msg.sender,
|
||||
msg.sensor, getType(convBuf, &VAR_Type[msg.type]));
|
||||
msg.getString(convBuf);
|
||||
#ifdef DEBUG
|
||||
Serial.print("publish: ");
|
||||
Serial.print((char*) buffer);
|
||||
Serial.print(" ");
|
||||
Serial.println((char*) convBuf);
|
||||
#endif
|
||||
client.publish(buffer, convBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* build
|
||||
* Constructs a radio message
|
||||
*/
|
||||
inline MyMessage& build(MyMessage &msg, uint8_t sender, uint8_t destination, uint8_t sensor,
|
||||
uint8_t command, uint8_t type, bool enableAck)
|
||||
{
|
||||
msg.destination = destination;
|
||||
msg.sender = sender;
|
||||
msg.sensor = sensor;
|
||||
msg.type = type;
|
||||
mSetCommand(msg, command);
|
||||
mSetRequestAck(msg, enableAck);
|
||||
mSetAck(msg, false);
|
||||
return msg;
|
||||
}
|
||||
|
||||
/*
|
||||
* getType
|
||||
*/
|
||||
char *getType(char *b, const char **index)
|
||||
{
|
||||
char *q = b;
|
||||
char *p = (char *) pgm_read_word(index);
|
||||
while (*q++ = pgm_read_byte(p++))
|
||||
;
|
||||
*q = 0;
|
||||
return b;
|
||||
}
|
||||
|
||||
/*
|
||||
* begin
|
||||
* wraps MySensors begin method; setup of RTC and led timers interrupt
|
||||
*/
|
||||
void begin()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
Serial.begin(BAUD_RATE);
|
||||
#endif
|
||||
#ifdef DSRTC
|
||||
// Attach RTC
|
||||
setSyncProvider(RTC.get); // the function to get the time from the RTC
|
||||
setSyncInterval(60);
|
||||
#endif
|
||||
|
||||
gw.begin(processRadioMessage, 0, true, 0);
|
||||
|
||||
MsTimer2::set(200, ledTimersInterrupt);
|
||||
MsTimer2::start();
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.print(getType(convBuf, &VAR_Type[S_FIRSTCUSTOM]));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* processMQTTMessages
|
||||
* message handler for the PubSubClient
|
||||
*/
|
||||
void processMQTTMessages(char* topic, byte* payload, unsigned int length)
|
||||
{
|
||||
processMQTTMessage(topic, payload, length);
|
||||
}
|
||||
|
||||
/*
|
||||
* processMQTTMessage
|
||||
* processes MQTT messages, parses the topic, extracts radio address out of topic and sends them
|
||||
* to the respective radio
|
||||
*/
|
||||
void processMQTTMessage(char* topic, byte* payload,
|
||||
unsigned int length)
|
||||
{
|
||||
char *str, *p;
|
||||
uint8_t i = 0;
|
||||
buffer[0] = 0;
|
||||
buffsize = 0;
|
||||
int8_t cmd = -1;
|
||||
|
||||
for (str = strtok_r(topic, "/", &p); str && i < 5;
|
||||
str = strtok_r(NULL, "/", &p))
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (strcmp_P(str, mqtt_prefix) != 0)
|
||||
{ //look for MQTT_PREFIX
|
||||
return; //Message not for us or malformatted!
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
msg.destination = atoi(str); //NodeID
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
msg.sensor = atoi(str); //SensorID
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
char match = 0; //SensorType
|
||||
//strcpy(str,(char*)&str[2]); //Strip VAR_
|
||||
|
||||
for (uint8_t j = 0;
|
||||
strcpy_P(convBuf, (char*) pgm_read_word(&(VAR_Type[j]))); j++)
|
||||
{
|
||||
if (strcmp((char*) &str[2], convBuf) == 0)
|
||||
{ //Strip VAR_ and compare
|
||||
match = j;
|
||||
break;
|
||||
}
|
||||
if (j >= VAR_TOTAL)
|
||||
{ // No match found!
|
||||
match = VAR_TOTAL; // last item.
|
||||
break;
|
||||
}
|
||||
}
|
||||
msg.type = match;
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
// support the command get and set; get will be mapped to a C_REQ and set to C_SET
|
||||
if (strcmp(str,MQTT_CMD_SET) == 0)
|
||||
{
|
||||
cmd = C_SET;
|
||||
}
|
||||
else if (strcmp(str,MQTT_CMD_GET) == 0) {
|
||||
cmd = C_REQ;
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG
|
||||
Serial.print("Received unsupported command - ignore: ");
|
||||
Serial.println(str);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
} //Check if packge has payload
|
||||
|
||||
if (cmd != -1) {
|
||||
char* ca;
|
||||
ca = (char *)payload;
|
||||
ca += length;
|
||||
*ca = '\0';
|
||||
|
||||
msg.set((const char*)payload); //Payload
|
||||
|
||||
txBlink(1);
|
||||
// inject time
|
||||
if ((msg.destination == 0) && (msg.sensor == 199)) {
|
||||
unsigned long epoch = atol((char*)payload);
|
||||
if (epoch > 10000) {
|
||||
#ifdef DSRTC
|
||||
RTC.set(epoch); // this sets the RTC to the time from controller - which we do want periodically
|
||||
#endif
|
||||
setTime(epoch);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
Serial.print("Time received ");
|
||||
Serial.println(epoch);
|
||||
#endif
|
||||
}
|
||||
//
|
||||
if (!gw.sendRoute(
|
||||
build(msg, GATEWAY_ADDRESS, msg.destination, msg.sensor, C_SET, msg.type,
|
||||
0)))
|
||||
errBlink(1);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Led handling
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* ledTimersIntterupt
|
||||
*/
|
||||
void ledTimersInterrupt() {
|
||||
if (countRx && countRx != 255) {
|
||||
// switch led on
|
||||
digitalWrite(RADIO_RX_LED_PIN, LOW);
|
||||
} else if (!countRx) {
|
||||
// switching off
|
||||
digitalWrite(RADIO_RX_LED_PIN, HIGH);
|
||||
}
|
||||
if (countRx != 255) {
|
||||
countRx--;
|
||||
}
|
||||
|
||||
if (countTx && countTx != 255) {
|
||||
// switch led on
|
||||
digitalWrite(RADIO_TX_LED_PIN, LOW);
|
||||
} else if (!countTx) {
|
||||
// switching off
|
||||
digitalWrite(RADIO_TX_LED_PIN, HIGH);
|
||||
}
|
||||
if (countTx != 255) {
|
||||
countTx--;
|
||||
}
|
||||
|
||||
if (countErr && countErr != 255) {
|
||||
// switch led on
|
||||
digitalWrite(RADIO_ERROR_LED_PIN, LOW);
|
||||
} else if (!countErr) {
|
||||
// switching off
|
||||
digitalWrite(RADIO_ERROR_LED_PIN, HIGH);
|
||||
}
|
||||
if (countErr != 255) {
|
||||
countErr--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void rxBlink(uint8_t cnt)
|
||||
{
|
||||
if (countRx == 255)
|
||||
{
|
||||
countRx = cnt;
|
||||
}
|
||||
}
|
||||
|
||||
void txBlink(uint8_t cnt)
|
||||
{
|
||||
if (countTx == 255)
|
||||
{
|
||||
countTx = cnt;
|
||||
}
|
||||
}
|
||||
|
||||
void errBlink(uint8_t cnt)
|
||||
{
|
||||
if (countErr == 255)
|
||||
{
|
||||
countErr = cnt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
The MySensors library adds a new layer on top of the RF24 library.
|
||||
It handles radio network routing, relaying and ids.
|
||||
Created by Henrik Ekblad <henrik.ekblad@gmail.com>
|
||||
Modified by Daniel Wiegert
|
||||
Modified by Norbert Truchsess <norbert.truchsess@t-online.de>
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MyMQTTClient_h
|
||||
#define MyMQTTClient_h
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef DEBUG
|
||||
#define TCPDUMP // Dump TCP packages.
|
||||
#endif
|
||||
#define MQTT_FIRST_SENSORID 20 // If you want manually configured nodes below this value. 255 = Disable
|
||||
#define MQTT_LAST_SENSORID 254 // 254 is max! 255 reserved.
|
||||
#define MQTT_PREFIX "MyMQTT" // First prefix in MQTT tree, keep short!
|
||||
#define MQTT_TOPIC_MASK "MyMQTT/+/+/+/+" // Topic mask the client will subscribe to. This ensures that it will not receive any sensor data send by sensors
|
||||
// the following topic structure is assumed: MyMQTT/<node-id>/<child_id>/<sensor-type>/<cmd>
|
||||
#define MQTT_SEND_SUBSCRIPTION 1 // Send empty payload (request) to node upon MQTT client subscribe request.
|
||||
#define MQTT_CMD_SET "set" // command (see MQTT_TOPIC_MASK); mapped to C_SET command type of sensor network
|
||||
#define MQTT_CMD_GET "get" // command (see MQTT_TOPIC_MASK); mapped to C_REQ command type of sensor network
|
||||
|
||||
|
||||
#define MQTT_AUTH_REQUIRED // if your broker has anonymous access uncomment
|
||||
#define MQTT_USER "user" // username on MQTT broker
|
||||
#define MQTT_PWD "pwd" // password for MQTT username above
|
||||
#define MQTT_CONN_ID "MySensors" // passed as id to the MQTT broker
|
||||
|
||||
|
||||
// NOTE above : Beware to check if there is any length on payload in your incommingMessage code:
|
||||
// Example: if (msg.type==V_LIGHT && strlen(msg.getString())>0) otherwise the code might do strange things.
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
char VAR_0[] PROGMEM = "TEMP"; //V_TEMP
|
||||
char VAR_1[] PROGMEM = "HUM"; //V_HUM
|
||||
char VAR_2[] PROGMEM = "LIGHT"; //V_LIGHT
|
||||
char VAR_3[] PROGMEM = "DIMMER"; //V_DIMMER
|
||||
char VAR_4[] PROGMEM = "PRESSURE"; //V_PRESSURE
|
||||
char VAR_5[] PROGMEM = "FORECAST"; //V_FORECAST
|
||||
char VAR_6[] PROGMEM = "RAIN"; //V_RAIN
|
||||
char VAR_7[] PROGMEM = "RAINRATE"; //V_RAINRATE
|
||||
char VAR_8[] PROGMEM = "WIND"; //V_WIND
|
||||
char VAR_9[] PROGMEM = "GUST"; //V_GUST
|
||||
char VAR_10[] PROGMEM = "DIRECTON"; //V_DIRECTON
|
||||
char VAR_11[] PROGMEM = "UV"; //V_UV
|
||||
char VAR_12[] PROGMEM = "WEIGHT"; //V_WEIGHT
|
||||
char VAR_13[] PROGMEM = "DISTANCE"; //V_DISTANCE
|
||||
char VAR_14[] PROGMEM = "IMPEDANCE"; //V_IMPEDANCE
|
||||
char VAR_15[] PROGMEM = "ARMED"; //V_ARMED
|
||||
char VAR_16[] PROGMEM = "TRIPPED"; //V_TRIPPED
|
||||
char VAR_17[] PROGMEM = "WATT"; //V_WATT
|
||||
char VAR_18[] PROGMEM = "KWH"; //V_KWH
|
||||
char VAR_19[] PROGMEM = "SCENE_ON"; //V_SCENE_ON
|
||||
char VAR_20[] PROGMEM = "SCENE_OFF"; //V_SCENE_OFF
|
||||
char VAR_21[] PROGMEM = "HEATER"; //V_HEATER
|
||||
char VAR_22[] PROGMEM = "HEATER_SW"; //V_HEATER_SW
|
||||
char VAR_23[] PROGMEM = "LIGHT_LEVEL"; //V_LIGHT_LEVEL
|
||||
char VAR_24[] PROGMEM = "VAR1"; //V_VAR1
|
||||
char VAR_25[] PROGMEM = "VAR2"; //V_VAR2
|
||||
char VAR_26[] PROGMEM = "VAR3"; //V_VAR3
|
||||
char VAR_27[] PROGMEM = "VAR4"; //V_VAR4
|
||||
char VAR_28[] PROGMEM = "VAR5"; //V_VAR5
|
||||
char VAR_29[] PROGMEM = "UP"; //V_UP
|
||||
char VAR_30[] PROGMEM = "DOWN"; //V_DOWN
|
||||
char VAR_31[] PROGMEM = "STOP"; //V_STOP
|
||||
char VAR_32[] PROGMEM = "IR_SEND"; //V_IR_SEND
|
||||
char VAR_33[] PROGMEM = "IR_RECEIVE"; //V_IR_RECEIVE
|
||||
char VAR_34[] PROGMEM = "FLOW"; //V_FLOW
|
||||
char VAR_35[] PROGMEM = "VOLUME"; //V_VOLUME
|
||||
char VAR_36[] PROGMEM = "LOCK_STATUS"; //V_LOCK_STATUS
|
||||
char VAR_37[] PROGMEM = "LEVEL"; // S_DUST, S_LIGHT_LEVEL, ...
|
||||
char VAR_38[] PROGMEM = "VOLTAGE"; //V_VOLTAGE
|
||||
char VAR_39[] PROGMEM = "CURRENT"; //V_CURRENT
|
||||
char VAR_40[] PROGMEM = "RGB"; //V_RGB
|
||||
char VAR_41[] PROGMEM = ""; //
|
||||
char VAR_42[] PROGMEM = ""; //
|
||||
char VAR_43[] PROGMEM = ""; //
|
||||
char VAR_44[] PROGMEM = ""; //
|
||||
char VAR_45[] PROGMEM = ""; //
|
||||
char VAR_46[] PROGMEM = ""; //
|
||||
char VAR_47[] PROGMEM = ""; //
|
||||
char VAR_48[] PROGMEM = ""; //
|
||||
char VAR_49[] PROGMEM = ""; //
|
||||
char VAR_50[] PROGMEM = ""; //
|
||||
char VAR_51[] PROGMEM = ""; //
|
||||
char VAR_52[] PROGMEM = ""; //
|
||||
char VAR_53[] PROGMEM = ""; //
|
||||
char VAR_54[] PROGMEM = ""; //
|
||||
char VAR_55[] PROGMEM = ""; //
|
||||
char VAR_56[] PROGMEM = ""; //
|
||||
char VAR_57[] PROGMEM = ""; //
|
||||
char VAR_58[] PROGMEM = ""; //
|
||||
char VAR_59[] PROGMEM = ""; //
|
||||
char VAR_60[] PROGMEM = "Started!\n"; //Custom for MQTTGateway
|
||||
char VAR_61[] PROGMEM = "SKETCH_NAME"; //Custom for MQTTGateway
|
||||
char VAR_62[] PROGMEM = "SKETCH_VERSION"; //Custom for MQTTGateway
|
||||
char VAR_63[] PROGMEM = "UNKNOWN"; //Custom for MQTTGateway
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
PROGMEM const char *VAR_Type[] =
|
||||
{ VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13,
|
||||
VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19, VAR_20, VAR_21, VAR_22, VAR_23, VAR_24, VAR_25,
|
||||
VAR_26, VAR_27, VAR_28, VAR_29, VAR_30, VAR_31, VAR_32, VAR_33, VAR_34, VAR_35, VAR_36, VAR_37,
|
||||
VAR_38, VAR_39, VAR_40, VAR_41, VAR_42, VAR_43, VAR_44, VAR_45, VAR_46, VAR_47, VAR_48, VAR_49,
|
||||
VAR_50, VAR_51, VAR_52, VAR_53, VAR_54, VAR_55, VAR_56, VAR_57, VAR_58, VAR_59, VAR_60, VAR_61,
|
||||
VAR_62, VAR_63
|
||||
};
|
||||
|
||||
char mqtt_prefix[] PROGMEM = MQTT_PREFIX;
|
||||
|
||||
#define S_FIRSTCUSTOM 60
|
||||
#define TYPEMAXLEN 20
|
||||
#define VAR_TOTAL (sizeof(VAR_Type)/sizeof(char *))-1
|
||||
|
||||
|
||||
#define EEPROM_LATEST_NODE_ADDRESS ((uint8_t)EEPROM_LOCAL_CONFIG_ADDRESS)
|
||||
|
||||
//#define DSRTC // RTC Dallas support -> disable debug and use isp programmer to free memory
|
||||
#endif
|
||||
@@ -0,0 +1,474 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Created by Daniel Wiegert <daniel.wiegert@gmail.com>
|
||||
*
|
||||
* DESCRIPTION
|
||||
* MyMQTT Broker Gateway 0.1b
|
||||
* Latest instructions found here:
|
||||
* http://www.mysensors.org/build/mqtt_gateway
|
||||
* http://www.mysensors.org/build/ethernet_gateway
|
||||
*
|
||||
* Change below; TCP_IP, TCP_PORT, TCP_MAC
|
||||
* This will listen on your selected TCP_IP:TCP_PORT below, Please change TCP_MAC your liking also.
|
||||
* 1 -> NOTE: Keep first byte at x2, x6, xA or xE (replace x with any hex value) for using Local Ranges.
|
||||
* 2 You can use standard pin set-up as MySensors recommends or if you own a IBOARD you may change
|
||||
* the radio-pins below if you hardware mod your iBoard. see [URL BELOW] for more details.
|
||||
* http://forum.mysensors.org/topic/224/iboard-cheap-single-board-ethernet-arduino-with-radio/5
|
||||
*
|
||||
* Don't forget to look at the definitions in MyMQTT.h!
|
||||
*
|
||||
* define TCPDUMP and connect serial interface if you have problems, please write on
|
||||
* http://forum.mysensors.org/ and explain your problem, include serial output. Don't forget to
|
||||
* turn on DEBUG in libraries\MySensors\MyConfig.h also.
|
||||
*
|
||||
* MQTT_FIRST_SENSORID is for 'DHCP' server in MyMQTT. You may limit the ID's with FIRST and LAST definition.
|
||||
* If you want your manually configured below 20 set MQTT_FIRST_SENSORID to 20.
|
||||
* To disable: set MQTT_FIRST_SENSORID to 255.
|
||||
*
|
||||
* MQTT_BROKER_PREFIX is the leading prefix for your nodes. This can be only one char if like.
|
||||
*
|
||||
* MQTT_SEND_SUBSCRIPTION is if you want the MyMQTT to send a empty payload message to your nodes.
|
||||
* This can be useful if you want to send latest state back to the MQTT client. Just check if incoming
|
||||
* message has any length or not.
|
||||
* Example: if (msg.type==V_LIGHT && strlen(msg.getString())>0) otherwise the code might do strange things.
|
||||
*
|
||||
* (*) Address-layout is : [MQTT_BROKER_PREFIX]/[NodeID]/[SensorID]/V_[SensorType]
|
||||
* NodeID and SensorID is uint8 (0-255) number.
|
||||
* Last segment is translation of the sensor type, look inside MyMQTT.cpp for the definitions.
|
||||
* User can change this to their needs. We have also left some space for custom types.
|
||||
*
|
||||
* Special: (sensor 255 reserved for special commands)
|
||||
* You can receive a node sketch name with MyMQTT/20/255/V_Sketch_name (or version with _version)
|
||||
*
|
||||
* To-do:
|
||||
* Special commands : clear or set EEPROM Values, Send REBOOT and Receive reboot for MyMQTT itself.
|
||||
* Be able to send ACK so client returns the data being sent.
|
||||
* ... Please come with ideas!
|
||||
* What to do with publish messages.
|
||||
*
|
||||
* Test in more MQTT clients, So far tested in openhab and MyMQTT for Android (Not my creation)
|
||||
* - http://www.openhab.org/
|
||||
* - https://play.google.com/store/apps/details?id=at.tripwire.mqtt.client&hl=en
|
||||
* ... Please notify me if you use this broker with other software.
|
||||
*
|
||||
* How to set-up Openhab and MQTTGateway:
|
||||
* http://forum.mysensors.org/topic/303/mqtt-broker-gateway
|
||||
*/
|
||||
|
||||
#include <DigitalIO.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#include <MySigningNone.h>
|
||||
#include <MyTransportRFM69.h>
|
||||
#include <MyTransportNRF24.h>
|
||||
#include <MyHwATMega328.h>
|
||||
#include <MySigningAtsha204Soft.h>
|
||||
#include <MySigningAtsha204.h>
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <MsTimer2.h>
|
||||
#include <Ethernet.h>
|
||||
#include "MyMQTT.h"
|
||||
|
||||
|
||||
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
|
||||
#define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button
|
||||
|
||||
// * Use this for IBOARD modded to use standard MISO/MOSI/SCK, see note *1 above!
|
||||
/*
|
||||
#define RADIO_CE_PIN 3 // radio chip enable
|
||||
#define RADIO_SPI_SS_PIN 8 // radio SPI serial select
|
||||
#define RADIO_ERROR_LED_PIN A2 // Error led pin
|
||||
#define RADIO_RX_LED_PIN A1 // Receive led pin
|
||||
#define RADIO_TX_LED_PIN A0 // the PCB, on board LED
|
||||
*/
|
||||
|
||||
// * Use this for default configured pro mini / nano etc :
|
||||
///*
|
||||
|
||||
#define RADIO_CE_PIN 5 // radio chip enable
|
||||
#define RADIO_SPI_SS_PIN 6 // radio SPI serial select
|
||||
#define RADIO_ERROR_LED_PIN 7 // Error led pin
|
||||
#define RADIO_RX_LED_PIN 8 // Receive led pin
|
||||
#define RADIO_TX_LED_PIN 9 // the PCB, on board LED*/
|
||||
|
||||
#define TCP_PORT 1883 // Set your MQTT Broker Listening port.
|
||||
IPAddress TCP_IP ( 192, 168, 0, 234 ); // Configure your static ip-address here
|
||||
byte TCP_MAC[] = { 0x02, 0xDE, 0xAD, 0x00, 0x00, 0x42 }; // Mac-address - You should change this! see note *2 above!
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
// NRFRF24L01 radio driver (set low transmit power by default)
|
||||
MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);
|
||||
//MyTransportRFM69 transport;
|
||||
|
||||
// Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
|
||||
//MySigningNone signer;
|
||||
//MySigningAtsha204Soft signer;
|
||||
//MySigningAtsha204 signer;
|
||||
|
||||
// Hardware profile
|
||||
MyHwATMega328 hw;
|
||||
|
||||
// Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
|
||||
MySensor gw(transport, hw /*, signer*/);
|
||||
|
||||
|
||||
EthernetServer server = EthernetServer(TCP_PORT);
|
||||
EthernetClient *currentClient = NULL;
|
||||
MyMessage msg;
|
||||
char convBuf[MAX_PAYLOAD*2+1];
|
||||
char broker[] PROGMEM = MQTT_BROKER_PREFIX;
|
||||
bool MQTTClientConnected = false;
|
||||
uint8_t buffsize;
|
||||
char buffer[MQTT_MAX_PACKET_SIZE];
|
||||
volatile uint8_t countRx;
|
||||
volatile uint8_t countTx;
|
||||
volatile uint8_t countErr;
|
||||
|
||||
|
||||
void writeEthernet(const char *writeBuffer, uint8_t *writeSize) {
|
||||
#ifdef TCPDUMP
|
||||
Serial.print(">>");
|
||||
char buf[4];
|
||||
for (uint8_t a=0; a<*writeSize; a++) { sprintf(buf,"%02X ",(uint8_t)writeBuffer[a]); Serial.print(buf); } Serial.println("");
|
||||
#endif
|
||||
server.write((const uint8_t *)writeBuffer, *writeSize);
|
||||
}
|
||||
|
||||
|
||||
void processEthernetMessages() {
|
||||
char inputString[MQTT_MAX_PACKET_SIZE] = "";
|
||||
byte inputSize = 0;
|
||||
byte readCnt = 0;
|
||||
byte length = 0;
|
||||
|
||||
EthernetClient client = server.available();
|
||||
if (client) {
|
||||
while (client.available()) {
|
||||
// Save the current client we are talking with
|
||||
currentClient = &client;
|
||||
byte inByte = client.read();
|
||||
readCnt++;
|
||||
|
||||
if (inputSize < MQTT_MAX_PACKET_SIZE) {
|
||||
inputString[inputSize] = (char)inByte;
|
||||
inputSize++;
|
||||
}
|
||||
|
||||
if (readCnt == 2) {
|
||||
length = (inByte & 127) * 1;
|
||||
}
|
||||
if (readCnt == (length+2)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef TCPDUMP
|
||||
Serial.print("<<");
|
||||
char buf[4];
|
||||
for (byte a=0; a<inputSize; a++) { sprintf(buf, "%02X ", (byte)inputString[a]); Serial.print(buf); } Serial.println();
|
||||
#endif
|
||||
processMQTTMessage(inputString, inputSize);
|
||||
currentClient = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
rxBlink(1);
|
||||
sendMQTT(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Ethernet.begin(TCP_MAC, TCP_IP);
|
||||
|
||||
|
||||
countRx = 0;
|
||||
countTx = 0;
|
||||
countErr = 0;
|
||||
|
||||
// Setup led pins
|
||||
pinMode(RADIO_RX_LED_PIN, OUTPUT);
|
||||
pinMode(RADIO_TX_LED_PIN, OUTPUT);
|
||||
pinMode(RADIO_ERROR_LED_PIN, OUTPUT);
|
||||
digitalWrite(RADIO_RX_LED_PIN, LOW);
|
||||
digitalWrite(RADIO_TX_LED_PIN, LOW);
|
||||
digitalWrite(RADIO_ERROR_LED_PIN, LOW);
|
||||
|
||||
|
||||
// Set initial state of leds
|
||||
digitalWrite(RADIO_RX_LED_PIN, HIGH);
|
||||
digitalWrite(RADIO_TX_LED_PIN, HIGH);
|
||||
digitalWrite(RADIO_ERROR_LED_PIN, HIGH);
|
||||
|
||||
|
||||
// Add led timer interrupt
|
||||
MsTimer2::set(300, ledTimersInterrupt);
|
||||
MsTimer2::start();
|
||||
|
||||
|
||||
// give the Ethernet interface a second to initialize
|
||||
delay(1000);
|
||||
|
||||
|
||||
// Initialize gateway at maximum PA level, channel 70 and callback for write operations
|
||||
gw.begin(incomingMessage, 0, true, 0);
|
||||
|
||||
// start listening for clients
|
||||
server.begin();
|
||||
|
||||
Serial.println("Ok!");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
gw.process();
|
||||
|
||||
processEthernetMessages();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inline MyMessage& build (MyMessage &msg, uint8_t destination, uint8_t sensor, uint8_t command, uint8_t type, bool enableAck) {
|
||||
msg.destination = destination;
|
||||
msg.sender = GATEWAY_ADDRESS;
|
||||
msg.sensor = sensor;
|
||||
msg.type = type;
|
||||
mSetCommand(msg,command);
|
||||
mSetRequestAck(msg,enableAck);
|
||||
mSetAck(msg,false);
|
||||
return msg;
|
||||
}
|
||||
|
||||
char *getType(char *b, const char **index) {
|
||||
char *q = b;
|
||||
char *p = (char *)pgm_read_word(index);
|
||||
while (*q++ = pgm_read_byte(p++));
|
||||
*q=0;
|
||||
return b;
|
||||
}
|
||||
|
||||
void processMQTTMessage(char *inputString, uint8_t inputPos) {
|
||||
char *str, *p;
|
||||
uint8_t i = 0;
|
||||
buffer[0]= 0;
|
||||
buffsize = 0;
|
||||
(void)inputPos;
|
||||
|
||||
if ((uint8_t)inputString[0] >> 4 == MQTTCONNECT) {
|
||||
buffer[buffsize++] = MQTTCONNACK << 4;
|
||||
buffer[buffsize++] = 0x02; // Remaining length
|
||||
buffer[buffsize++] = 0x00; // Connection accepted
|
||||
buffer[buffsize++] = 0x00; // Reserved
|
||||
MQTTClientConnected=true; // We have connection!
|
||||
}
|
||||
if ((uint8_t)inputString[0] >> 4 == MQTTPINGREQ) {
|
||||
buffer[buffsize++] = MQTTPINGRESP << 4;
|
||||
buffer[buffsize++] = 0x00;
|
||||
}
|
||||
if ((uint8_t)inputString[0] >> 4 == MQTTSUBSCRIBE) {
|
||||
buffer[buffsize++] = MQTTSUBACK << 4; // Just ack everything, we actually dont really care!
|
||||
buffer[buffsize++] = 0x03; // Remaining length
|
||||
buffer[buffsize++] = (uint8_t)inputString[2]; // Message ID MSB
|
||||
buffer[buffsize++] = (uint8_t)inputString[3]; // Message ID LSB
|
||||
buffer[buffsize++] = MQTTQOS0; // QOS level
|
||||
}
|
||||
if ((uint8_t)inputString[0] >> 4 == MQTTUNSUBSCRIBE) {
|
||||
buffer[buffsize++] = MQTTUNSUBACK << 4;
|
||||
buffer[buffsize++] = 0x02; // Remaining length
|
||||
buffer[buffsize++] = (uint8_t)inputString[2]; // Message ID MSB
|
||||
buffer[buffsize++] = (uint8_t)inputString[3]; // Message ID LSB
|
||||
}
|
||||
if ((uint8_t)inputString[0] >> 4 == MQTTDISCONNECT) {
|
||||
MQTTClientConnected=false; // We lost connection!
|
||||
}
|
||||
if (buffsize > 0) {
|
||||
writeEthernet(buffer,&buffsize);
|
||||
}
|
||||
|
||||
// We publish everything we get, we dont care if its subscribed or not!
|
||||
if ((uint8_t)inputString[0] >> 4 == MQTTPUBLISH || (MQTT_SEND_SUBSCRIPTION && (uint8_t)inputString[0] >> 4 == MQTTSUBSCRIBE)) {
|
||||
buffer[0]= 0;
|
||||
buffsize = 0;
|
||||
// Cut out address and payload depending on message type.
|
||||
if ((uint8_t)inputString[0] >> 4 == MQTTSUBSCRIBE) {
|
||||
strncat(buffer,inputString+6,inputString[5]);
|
||||
} else {
|
||||
strncat(buffer,inputString+4,inputString[3]);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.println(buffer);
|
||||
#endif
|
||||
// TODO: Check if we should send ack or not.
|
||||
for (str = strtok_r(buffer,"/",&p) ; str && i<4 ; str = strtok_r(NULL,"/",&p)) {
|
||||
if (i == 0) {
|
||||
if (strcmp_P(str,broker)!=0) { //look for MQTT_BROKER_PREFIX
|
||||
return; //Message not for us or malformatted!
|
||||
}
|
||||
} else if (i==1) {
|
||||
msg.destination = atoi(str); //NodeID
|
||||
} else if (i==2) {
|
||||
msg.sensor = atoi(str); //SensorID
|
||||
} else if (i==3) {
|
||||
unsigned char match=255; //SensorType
|
||||
#ifdef MQTT_TRANSLATE_TYPES
|
||||
|
||||
for (uint8_t j=0; strcpy_P(convBuf, (char*)pgm_read_word(&(vType[j]))) ; j++) {
|
||||
if (strcmp((char*)&str[2],convBuf)==0) { //Strip V_ and compare
|
||||
match=j;
|
||||
break;
|
||||
}
|
||||
if (j >= V_TOTAL) break;
|
||||
}
|
||||
|
||||
#endif
|
||||
if ( atoi(str)!=0 || (str[0]=='0' && str[1] =='\0') ) {
|
||||
match=atoi(str);
|
||||
}
|
||||
|
||||
if (match==255) {
|
||||
match=V_UNKNOWN;
|
||||
}
|
||||
msg.type = match;
|
||||
}
|
||||
i++;
|
||||
} //Check if packge has payload
|
||||
if ((uint8_t)inputString[1] > (uint8_t)(inputString[3]+2) && !((uint8_t)inputString[0] >> 4 == MQTTSUBSCRIBE)) {
|
||||
strcpy(convBuf,inputString+(inputString[3]+4));
|
||||
msg.set(convBuf); //Payload
|
||||
} else {
|
||||
msg.set(""); //No payload
|
||||
}
|
||||
txBlink(1);
|
||||
if (!gw.sendRoute(build(msg, msg.destination, msg.sensor, C_SET, msg.type, 0))) errBlink(1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void sendMQTT(const MyMessage &inMsg) {
|
||||
MyMessage msg = inMsg;
|
||||
buffsize = 0;
|
||||
if (!MQTTClientConnected) return; //We have no connections - return
|
||||
if (msg.isAck()) {
|
||||
// if (msg.sender==255 && mGetCommand(msg)==C_INTERNAL && msg.type==I_ID_REQUEST) {
|
||||
// TODO: sending ACK request on id_response fucks node up. doesn't work.
|
||||
// The idea was to confirm id and save to EEPROM_LATEST_NODE_ADDRESS.
|
||||
// }
|
||||
} else {
|
||||
// we have to check every message if its a newly assigned id or not.
|
||||
// Ack on I_ID_RESPONSE does not work, and checking on C_PRESENTATION isn't reliable.
|
||||
uint8_t newNodeID = gw.loadState(EEPROM_LATEST_NODE_ADDRESS)+1;
|
||||
if (newNodeID <= MQTT_FIRST_SENSORID) newNodeID = MQTT_FIRST_SENSORID;
|
||||
if (msg.sender==newNodeID) {
|
||||
gw.saveState(EEPROM_LATEST_NODE_ADDRESS,newNodeID);
|
||||
}
|
||||
if (mGetCommand(msg)==C_INTERNAL) {
|
||||
if (msg.type==I_CONFIG) {
|
||||
txBlink(1);
|
||||
if (!gw.sendRoute(build(msg, msg.sender, 255, C_INTERNAL, I_CONFIG, 0).set(MQTT_UNIT))) errBlink(1);
|
||||
return;
|
||||
} else if (msg.type==I_ID_REQUEST && msg.sender==255) {
|
||||
uint8_t newNodeID = gw.loadState(EEPROM_LATEST_NODE_ADDRESS)+1;
|
||||
if (newNodeID <= MQTT_FIRST_SENSORID) newNodeID = MQTT_FIRST_SENSORID;
|
||||
if (newNodeID >= MQTT_LAST_SENSORID) return; // Sorry no more id's left :(
|
||||
txBlink(1);
|
||||
if (!gw.sendRoute(build(msg, msg.sender, 255, C_INTERNAL, I_ID_RESPONSE, 0).set(newNodeID))) errBlink(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mGetCommand(msg)!=C_PRESENTATION) {
|
||||
if (mGetCommand(msg)==C_INTERNAL) msg.type=msg.type+(S_FIRSTCUSTOM-10); //Special message
|
||||
buffer[buffsize++] = MQTTPUBLISH << 4; // 0:
|
||||
buffer[buffsize++] = 0x09; // 1: Remaining length with no payload, we'll set this later to correct value, buffsize -2
|
||||
buffer[buffsize++] = 0x00; // 2: Length MSB (Remaing length can never exceed ff,so MSB must be 0!)
|
||||
buffer[buffsize++] = 0x08; // 3: Length LSB (ADDR), We'll set this later
|
||||
strcpy_P(buffer+4, broker);
|
||||
buffsize+=strlen_P(broker);
|
||||
#ifdef MQTT_TRANSLATE_TYPES
|
||||
if (msg.type > V_TOTAL) msg.type=V_UNKNOWN;// If type > defined types set to unknown.
|
||||
buffsize+=sprintf(&buffer[buffsize],"/%i/%i/V_%s",msg.sender,msg.sensor,getType(convBuf, &vType[msg.type]));
|
||||
#else
|
||||
buffsize+=sprintf(&buffer[buffsize],"/%i/%i/%i",msg.sender,msg.sensor,msg.type);
|
||||
#endif
|
||||
buffer[3]=buffsize-4; // Set correct address length on byte 4.
|
||||
#ifdef DEBUG
|
||||
Serial.println((char*)&buffer[4]);
|
||||
#endif
|
||||
msg.getString(convBuf);
|
||||
for (uint8_t a=0; a<strlen(convBuf); a++) {// Payload
|
||||
buffer[buffsize++] = convBuf[a];
|
||||
}
|
||||
buffer[1]=buffsize-2; // Set correct Remaining length on byte 2.
|
||||
writeEthernet(buffer,&buffsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ledTimersInterrupt() {
|
||||
if(countRx && countRx != 255) {
|
||||
// switch led on
|
||||
digitalWrite(RADIO_RX_LED_PIN, LOW);
|
||||
} else if(!countRx) {
|
||||
// switching off
|
||||
digitalWrite(RADIO_RX_LED_PIN, HIGH);
|
||||
}
|
||||
if(countRx != 255) { countRx--; }
|
||||
|
||||
if(countTx && countTx != 255) {
|
||||
// switch led on
|
||||
digitalWrite(RADIO_TX_LED_PIN, LOW);
|
||||
} else if(!countTx) {
|
||||
// switching off
|
||||
digitalWrite(RADIO_TX_LED_PIN, HIGH);
|
||||
}
|
||||
if(countTx != 255) { countTx--; }
|
||||
|
||||
if(countErr && countErr != 255) {
|
||||
// switch led on
|
||||
digitalWrite(RADIO_ERROR_LED_PIN, LOW);
|
||||
} else if(!countErr) {
|
||||
// switching off
|
||||
digitalWrite(RADIO_ERROR_LED_PIN, HIGH);
|
||||
}
|
||||
if(countErr != 255) { countErr--; }
|
||||
|
||||
}
|
||||
|
||||
void rxBlink(uint8_t cnt) {
|
||||
if(countRx == 255) { countRx = cnt; }
|
||||
}
|
||||
void txBlink(uint8_t cnt) {
|
||||
if(countTx == 255) { countTx = cnt; }
|
||||
}
|
||||
void errBlink(uint8_t cnt) {
|
||||
if(countErr == 255) { countErr = cnt; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
The MySensors library adds a new layer on top of the RF24 library.
|
||||
It handles radio network routing, relaying and ids.
|
||||
|
||||
Created by Henrik Ekblad <henrik.ekblad@gmail.com>
|
||||
Modified by Daniel Wiegert
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
version 2 as published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
#define TCPDUMP // Dump TCP packages
|
||||
#endif
|
||||
|
||||
#define MQTT_FIRST_SENSORID 20 // If you want manually configured nodes below this value. 255 = Disable
|
||||
#define MQTT_LAST_SENSORID 254 // 254 is max! 255 reserved.
|
||||
#define MQTT_BROKER_PREFIX "MyMQTT" // First prefix in MQTT tree, keep short!
|
||||
#define MQTT_SEND_SUBSCRIPTION 1 // Send empty payload (request) to node upon MQTT client subscribe request.
|
||||
// NOTE above : Beware to check if there is any length on payload in your incommingMessage code:
|
||||
// Example: if (msg.type==V_LIGHT && strlen(msg.getString())>0) otherwise the code might do strange things.
|
||||
#define MQTT_UNIT "M" // Select M for metric or I for imperial.
|
||||
#define MQTT_TRANSLATE_TYPES // V_TYPE in address, Comment if you want all numbers (MyMQTT/01/01/01)
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
#define EEPROM_LATEST_NODE_ADDRESS ((uint8_t)EEPROM_LOCAL_CONFIG_ADDRESS)
|
||||
#define MQTT_MAX_PACKET_SIZE 100
|
||||
|
||||
#define MQTTPROTOCOLVERSION 3
|
||||
#define MQTTCONNECT 1 // Client request to connect to Server
|
||||
#define MQTTCONNACK 2 // Connect Acknowledgment
|
||||
#define MQTTPUBLISH 3 // Publish message
|
||||
#define MQTTPUBACK 4 // Publish Acknowledgment
|
||||
#define MQTTPUBREC 5 // Publish Received (assured delivery part 1)
|
||||
#define MQTTPUBREL 6 // Publish Release (assured delivery part 2)
|
||||
#define MQTTPUBCOMP 7 // Publish Complete (assured delivery part 3)
|
||||
#define MQTTSUBSCRIBE 8 // Client Subscribe request
|
||||
#define MQTTSUBACK 9 // Subscribe Acknowledgment
|
||||
#define MQTTUNSUBSCRIBE 10 // Client Unsubscribe request
|
||||
#define MQTTUNSUBACK 11 // Unsubscribe Acknowledgment
|
||||
#define MQTTPINGREQ 12 // PING Request
|
||||
#define MQTTPINGRESP 13 // PING Response
|
||||
#define MQTTDISCONNECT 14 // Client is Disconnecting
|
||||
#define MQTTReserved 15 // Reserved
|
||||
|
||||
#define MQTTQOS0 (0 << 1)
|
||||
#define MQTTQOS1 (1 << 1)
|
||||
#define MQTTQOS2 (2 << 1)
|
||||
|
||||
#ifdef MQTT_TRANSLATE_TYPES
|
||||
|
||||
char V_0[] PROGMEM = "TEMP"; //V_TEMP
|
||||
char V_1[] PROGMEM = "HUM"; //V_HUM
|
||||
char V_2[] PROGMEM = "LIGHT"; //V_LIGHT
|
||||
char V_3[] PROGMEM = "DIMMER"; //V_DIMMER
|
||||
char V_4[] PROGMEM = "PRESSURE"; //V_PRESSURE
|
||||
char V_5[] PROGMEM = "FORECAST"; //V_FORECAST
|
||||
char V_6[] PROGMEM = "RAIN"; //V_RAIN
|
||||
char V_7[] PROGMEM = "RAINRATE"; //V_RAINRATE
|
||||
char V_8[] PROGMEM = "WIND"; //V_WIND
|
||||
char V_9[] PROGMEM = "GUST"; //V_GUST
|
||||
char V_10[] PROGMEM = "DIRECTON"; //V_DIRECTON
|
||||
char V_11[] PROGMEM = "UV"; //V_UV
|
||||
char V_12[] PROGMEM = "WEIGHT"; //V_WEIGHT
|
||||
char V_13[] PROGMEM = "DISTANCE"; //V_DISTANCE
|
||||
char V_14[] PROGMEM = "IMPEDANCE"; //V_IMPEDANCE
|
||||
char V_15[] PROGMEM = "ARMED"; //V_ARMED
|
||||
char V_16[] PROGMEM = "TRIPPED"; //V_TRIPPED
|
||||
char V_17[] PROGMEM = "WATT"; //V_WATT
|
||||
char V_18[] PROGMEM = "KWH"; //V_KWH
|
||||
char V_19[] PROGMEM = "SCENE_ON"; //V_SCENE_ON
|
||||
char V_20[] PROGMEM = "SCENE_OFF"; //V_SCENE_OFF
|
||||
char V_21[] PROGMEM = "HEATER"; //V_HEATER
|
||||
char V_22[] PROGMEM = "HEATER_SW"; //V_HEATER_SW
|
||||
char V_23[] PROGMEM = "LIGHT_LEVEL"; //V_LIGHT_LEVEL
|
||||
char V_24[] PROGMEM = "VAR1"; //V_VAR1
|
||||
char V_25[] PROGMEM = "VAR2"; //V_VAR2
|
||||
char V_26[] PROGMEM = "VAR3"; //V_VAR3
|
||||
char V_27[] PROGMEM = "VAR4"; //V_VAR4
|
||||
char V_28[] PROGMEM = "VAR5"; //V_VAR5
|
||||
char V_29[] PROGMEM = "UP"; //V_UP
|
||||
char V_30[] PROGMEM = "DOWN"; //V_DOWN
|
||||
char V_31[] PROGMEM = "STOP"; //V_STOP
|
||||
char V_32[] PROGMEM = "IR_SEND"; //V_IR_SEND
|
||||
char V_33[] PROGMEM = "IR_RECEIVE"; //V_IR_RECEIVE
|
||||
char V_34[] PROGMEM = "FLOW"; //V_FLOW
|
||||
char V_35[] PROGMEM = "VOLUME"; //V_VOLUME
|
||||
char V_36[] PROGMEM = "LOCK_STATUS"; //V_LOCK_STATUS
|
||||
char V_37[] PROGMEM = "DUST_LEVEL"; //V_DUST_LEVEL
|
||||
char V_38[] PROGMEM = "VOLTAGE"; //V_VOLTAGE
|
||||
char V_39[] PROGMEM = "CURRENT"; //V_CURRENT
|
||||
char V_40[] PROGMEM = ""; //
|
||||
char V_41[] PROGMEM = ""; //
|
||||
char V_42[] PROGMEM = ""; //
|
||||
char V_43[] PROGMEM = ""; //
|
||||
char V_44[] PROGMEM = ""; //
|
||||
char V_45[] PROGMEM = ""; //
|
||||
char V_46[] PROGMEM = ""; //
|
||||
char V_47[] PROGMEM = ""; //
|
||||
char V_48[] PROGMEM = ""; //
|
||||
char V_49[] PROGMEM = ""; //
|
||||
char V_50[] PROGMEM = ""; //
|
||||
char V_51[] PROGMEM = ""; //
|
||||
char V_52[] PROGMEM = ""; //
|
||||
char V_53[] PROGMEM = ""; //
|
||||
char V_54[] PROGMEM = ""; //
|
||||
char V_55[] PROGMEM = ""; //
|
||||
char V_56[] PROGMEM = ""; //
|
||||
char V_57[] PROGMEM = ""; //
|
||||
char V_58[] PROGMEM = ""; //
|
||||
char V_59[] PROGMEM = ""; //
|
||||
char V_60[] PROGMEM = "DEFAULT"; //Custom for MQTTGateway
|
||||
char V_61[] PROGMEM = "SKETCH_NAME"; //Custom for MQTTGateway
|
||||
char V_62[] PROGMEM = "SKETCH_VERSION"; //Custom for MQTTGateway
|
||||
char V_63[] PROGMEM = "UNKNOWN"; //Custom for MQTTGateway
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
PROGMEM const char *vType[] = {
|
||||
V_0, V_1, V_2, V_3, V_4, V_5, V_6, V_7, V_8, V_9, V_10,
|
||||
V_11, V_12, V_13, V_14, V_15, V_16, V_17, V_18, V_19, V_20,
|
||||
V_21, V_22, V_23, V_24, V_25, V_26, V_27, V_28, V_29, V_30,
|
||||
V_31, V_32, V_33, V_34, V_35, V_36, V_37, V_38, V_39, V_40,
|
||||
V_41, V_42, V_43, V_44, V_45, V_46, V_47, V_48, V_49, V_50,
|
||||
V_51, V_52, V_53, V_54, V_55, V_56, V_57, V_58, V_59, V_60,
|
||||
V_61, V_62, V_63
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define S_FIRSTCUSTOM 60
|
||||
#define V_TOTAL (sizeof(vType)/sizeof(char *))-1
|
||||
|
||||
#endif
|
||||
|
||||
#define S_FIRSTCUSTOM 60
|
||||
#define V_UNKNOWN 63
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
# MockMySensors
|
||||
Arduino sketch to fake sensor for the MySensors Library
|
||||
|
||||
This skecth is intended to crate fake sensors which register and respond to the controller
|
||||
|
||||
Barduino, GizMoCuz 2015
|
||||
-----------------
|
||||
|
||||
Comment/Uncomment the sensors you would like to test
|
||||
|
||||
Arduino Uno R3 can support about 12 sensors before it runs out of memory.
|
||||
(turning off the MySensors debug helps if you are memory limited)
|
||||
|
||||
With a Mega you can have them all
|
||||
|
||||
|
||||
Changes Log
|
||||
-----------------
|
||||
|
||||
2015-09-07
|
||||
Five more sensors
|
||||
S_RGB_LIGHT
|
||||
S_RGBW_LIGHT
|
||||
S_COLOR_SENSOR
|
||||
S_HVAC
|
||||
S_MULTIMETER
|
||||
Consolidated HVAC and HEATER incoming message
|
||||
|
||||
2015-09-06
|
||||
|
||||
Merge with Gizmocuz (implementation of S_HEATER & S_MOISTURE
|
||||
Implementation of S_COVER, S_IR, S_SCENE_CONTROLLER
|
||||
|
||||
|
||||
2015-08-19
|
||||
|
||||
Removed the load/save to eeprom
|
||||
Touched the heater sensor
|
||||
Created a pseudo sensor to handle the V_ARMED message.
|
||||
All sensors which support V_ARMED will arm/disarm at the same time
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Motion Sensor example using HC-SR501
|
||||
* http://www.mysensors.org/build/motion
|
||||
*
|
||||
*/
|
||||
|
||||
// Enable debug prints
|
||||
//#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
|
||||
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
|
||||
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
|
||||
#define CHILD_ID 1 // Id of the sensor child
|
||||
|
||||
// Initialize motion message
|
||||
MyMessage msg(CHILD_ID, V_TRIPPED);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Motion Sensor", "1.0");
|
||||
|
||||
pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
present(CHILD_ID, S_MOTION);
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Read digital motion value
|
||||
boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
|
||||
|
||||
Serial.println(tripped);
|
||||
send(msg.set(tripped?"1":"0")); // Send tripped value to gw
|
||||
|
||||
// Sleep until interrupt comes in on motion sensor. Send update every two minute.
|
||||
sleep(INTERRUPT,CHANGE, SLEEP_TIME);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Created by Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Parking sensor using a neopixel led ring and distance sensor (HC-SR04).
|
||||
* Configure the digital pins used for distance sensor and neopixels below.
|
||||
* NOTE! Remeber to feed leds and distance sensor serparatly from your Arduino.
|
||||
* It will probably not survive feeding more than a couple of LEDs. You
|
||||
* can also adjust intesity below to reduce the power requirements.
|
||||
*
|
||||
* Sends parking status to the controller as a DOOR sensor if SEND_STATUS_TO_CONTROLLER
|
||||
* is defined below. You can also use this _standalone_ without any radio by
|
||||
* removing the SEND_STATUS_TO_CONTROLLER define.
|
||||
*/
|
||||
|
||||
#define SEND_STATUS_TO_CONTROLLER // Put a comment on this line for standalone mode
|
||||
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#include <NewPing.h>
|
||||
|
||||
#ifdef SEND_STATUS_TO_CONTROLLER
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#endif
|
||||
|
||||
#define NEO_PIN 4 // NeoPixels input pin
|
||||
|
||||
#define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor.
|
||||
#define ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor.
|
||||
|
||||
#define NUMPIXELS 24 // Number of nexpixels in ring/strip
|
||||
#define MAX_INTESITY 20 // Intesity of leds (in percentage). Remeber more intesity requires more power.
|
||||
|
||||
// The maximum rated measuring range for the HC-SR04 is about 400-500cm.
|
||||
#define MAX_DISTANCE 100 // Max distance we want to start indicating green (in cm)
|
||||
#define PANIC_DISTANCE 5 // Mix distance we red warning indication should be active (in cm)
|
||||
#define PARKED_DISTANCE 20 // Distance when "parked signal" should be sent to controller (in cm)
|
||||
|
||||
#define PARK_OFF_TIMEOUT 20000 // Number of milliseconds until turning off light when parked.
|
||||
|
||||
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
|
||||
// example for more information on possible values.
|
||||
|
||||
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, NEO_PIN, NEO_GRB + NEO_KHZ400);
|
||||
|
||||
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
|
||||
|
||||
#ifdef SEND_STATUS_TO_CONTROLLER
|
||||
#define CHILD_ID 1
|
||||
MyMessage msg(CHILD_ID,V_TRIPPED);
|
||||
#endif
|
||||
unsigned long sendInterval = 5000; // Send park status at maximum every 5 second.
|
||||
unsigned long lastSend;
|
||||
|
||||
int oldParkedStatus=-1;
|
||||
|
||||
unsigned long blinkInterval = 100; // blink interval (milliseconds)
|
||||
unsigned long lastBlinkPeriod;
|
||||
bool blinkColor = true;
|
||||
|
||||
// To make a fading motion on the led ring/tape we only move one pixel/distDebounce time
|
||||
unsigned long distDebounce = 30;
|
||||
unsigned long lastDebouncePeriod;
|
||||
int numLightPixels=0;
|
||||
int skipZero=0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("Starting distance sensor");
|
||||
pixels.begin(); // This initializes the NeoPixel library.
|
||||
Serial.println("Neopixels initialized");
|
||||
#ifdef SEND_STATUS_TO_CONTROLLER
|
||||
sendSketchInfo("Parking Sensor", "1.0");
|
||||
present(CHILD_ID, S_DOOR, "Parking Status");
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
unsigned long now = millis();
|
||||
|
||||
unsigned int fullDist = (sonar.ping_median() / US_ROUNDTRIP_CM);
|
||||
// Serial.println(fullDist);
|
||||
int displayDist = min(fullDist, MAX_DISTANCE);
|
||||
if (displayDist == 0 && skipZero<10) {
|
||||
// Try to filter zero readings
|
||||
skipZero++;
|
||||
return;
|
||||
}
|
||||
// Check if it is time to alter the leds
|
||||
if (now-lastDebouncePeriod > distDebounce) {
|
||||
lastDebouncePeriod = now;
|
||||
|
||||
// Update parked status
|
||||
int parked = displayDist != 0 && displayDist<PARKED_DISTANCE;
|
||||
if (parked != oldParkedStatus && now-lastSend > sendInterval) {
|
||||
if (parked)
|
||||
Serial.println("Car Parked");
|
||||
else
|
||||
Serial.println("Car Gone");
|
||||
#ifdef SEND_STATUS_TO_CONTROLLER
|
||||
send(msg.set(parked));
|
||||
#endif
|
||||
oldParkedStatus = parked;
|
||||
lastSend = now;
|
||||
}
|
||||
|
||||
if (parked && now-lastSend > PARK_OFF_TIMEOUT) {
|
||||
// We've been parked for a while now. Turn off all pixels
|
||||
for(int i=0;i<NUMPIXELS;i++){
|
||||
pixels.setPixelColor(i, pixels.Color(0,0,0));
|
||||
}
|
||||
} else {
|
||||
if (displayDist == 0) {
|
||||
// No reading from sensor, assume no object found
|
||||
numLightPixels--;
|
||||
} else {
|
||||
skipZero = 0;
|
||||
int newLightPixels = NUMPIXELS - (NUMPIXELS*(displayDist-PANIC_DISTANCE)/(MAX_DISTANCE-PANIC_DISTANCE));
|
||||
if (newLightPixels>numLightPixels) {
|
||||
// Fast raise
|
||||
numLightPixels += max((newLightPixels - numLightPixels) / 2, 1);
|
||||
} else if (newLightPixels<numLightPixels) {
|
||||
// Slow decent
|
||||
numLightPixels--;
|
||||
}
|
||||
}
|
||||
|
||||
if (numLightPixels>=NUMPIXELS) {
|
||||
// Do some intense red blinking
|
||||
if (now-lastBlinkPeriod > blinkInterval) {
|
||||
blinkColor = !blinkColor;
|
||||
lastBlinkPeriod = now;
|
||||
}
|
||||
for(int i=0;i<numLightPixels;i++){
|
||||
pixels.setPixelColor(i, pixels.Color(blinkColor?255*MAX_INTESITY/100:0,0,0));
|
||||
}
|
||||
} else {
|
||||
for(int i=0;i<numLightPixels;i++){
|
||||
int r = 255 * i/NUMPIXELS;
|
||||
int g = 255 - r;
|
||||
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
|
||||
pixels.setPixelColor(i, pixels.Color(r*MAX_INTESITY/100,g*MAX_INTESITY/100,0));
|
||||
}
|
||||
// Turn off the rest
|
||||
for(int i=numLightPixels;i<NUMPIXELS;i++){
|
||||
pixels.setPixelColor(i, pixels.Color(0,0,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
pixels.show(); // This sends the updated pixel color to the hardware.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/****
|
||||
* Formatted logging to the Serial console.
|
||||
* Compiled in by setting LOGDEBUG
|
||||
*
|
||||
* 2015-05-25 Bruce Lacey V1.0
|
||||
*
|
||||
* Based upon Arduino Playground prior art and should be moved to
|
||||
* the MySensors library at some point as a common debug logging facility
|
||||
*/
|
||||
#ifndef MYSLog_h
|
||||
#define MYSLog_h
|
||||
|
||||
#define LOGDEBUG 1
|
||||
|
||||
#if defined ( LOGDEBUG )
|
||||
#define LOG(fmt, args... ) log( fmt, ## args );
|
||||
#else
|
||||
#define log(fmt, args... )
|
||||
#endif
|
||||
|
||||
void log(const char *fmt, ... ) {
|
||||
char buff[128];
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
vsnprintf(buff, sizeof(buff), fmt, args);
|
||||
va_end (args);
|
||||
buff[sizeof(buff)/sizeof(buff[0])-1]='\0';
|
||||
Serial.print(buff);
|
||||
}
|
||||
|
||||
void log(const __FlashStringHelper *fmt, ... ){
|
||||
char buf[128]; // resulting string limited to 128 chars
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
#ifdef __AVR__
|
||||
vsnprintf_P(buf, sizeof(buf), (const char *)fmt, args); // progmem for AVR
|
||||
#else
|
||||
vsnprintf(buf, sizeof(buf), (const char *)fmt, args); // for the rest of the world
|
||||
#endif
|
||||
va_end(args);
|
||||
Serial.print(buf);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,97 @@
|
||||
/***
|
||||
* This is a simple sketch used to demenstrate and test node-to-node MySensor's communication.
|
||||
* To use this sketch, assemble MySensors nodes - they need nothing more than a radio
|
||||
* 1. Flash each node with the same sketch, open the console and type either 0 or 1 to the respective nodes to set thei ID
|
||||
* 2. You only need to set the node id once, and restart the nodes
|
||||
* 3. To being a ping-pong test, simply type T in the console for one of the nodes.
|
||||
*
|
||||
* 2015-05-25 Bruce Lacey v1.0
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include "MYSLog.h"
|
||||
|
||||
#define VSN "v1.0"
|
||||
|
||||
// Define two generic nodes with a single child
|
||||
#define YING 200
|
||||
#define YANG 201
|
||||
#define CHILD 1
|
||||
|
||||
MyMessage mPing(CHILD, V_VAR1); //Ping message
|
||||
MyMessage mPong(CHILD, V_VAR2); //Pong message
|
||||
|
||||
void setup() {
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
present(CHILD, S_CUSTOM); //
|
||||
|
||||
sendSketchInfo( nodeTypeAsCharRepresentation( getNodeId() ), VSN );
|
||||
LOG(F("\n%sReady.\n"), nodeTypeAsCharRepresentation(getNodeId()));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Interactive command and control
|
||||
// Entering a number from 0 or 1 will write the node 200 (YING) or 201 (YANG) to EEPROM
|
||||
// Entering T on either node will initiatve a ping-pong test.
|
||||
if (Serial.available()) {
|
||||
byte inChar = Serial.read();
|
||||
uint8_t node = getNodeId();
|
||||
|
||||
// Manual Test Mode
|
||||
if (inChar == 'T' || inChar == 't') {
|
||||
LOG(F("T received - starting test...\n"));
|
||||
MyMessage msg = mPong;
|
||||
msg.sender = (node == YING ? YANG : YING);
|
||||
sendPingOrPongResponse( msg );
|
||||
}
|
||||
else if (inChar == '0' or inChar == '1') {
|
||||
byte nodeID = 200 + (inChar - '0');
|
||||
setNodeId(nodeID);
|
||||
}
|
||||
else {
|
||||
LOG("Invalid input\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
|
||||
LOG(F("Received %s from %s\n"), msgTypeAsCharRepresentation((mysensor_data)message.type), nodeTypeAsCharRepresentation(message.sender));
|
||||
|
||||
delay(250);
|
||||
sendPingOrPongResponse( message );
|
||||
}
|
||||
|
||||
void sendPingOrPongResponse( MyMessage msg ) {
|
||||
|
||||
MyMessage response = (msg.type == V_VAR1 ? mPong : mPing);
|
||||
|
||||
LOG(F("Sending %s to %s\n"), msgTypeAsCharRepresentation( (mysensor_data)response.type ), nodeTypeAsCharRepresentation(msg.sender));
|
||||
|
||||
// Set payload to current time in millis to ensure each message is unique
|
||||
response.set( millis() );
|
||||
response.setDestination(msg.sender);
|
||||
send(response);
|
||||
}
|
||||
|
||||
void setNodeId(byte nodeID) {
|
||||
LOG(F("Setting node id to: %i.\n***Please restart the node for changes to take effect.\n"), nodeID);
|
||||
eeprom_write_byte((uint8_t*)EEPROM_NODE_ID_ADDRESS, (byte)nodeID);
|
||||
}
|
||||
|
||||
const char * msgTypeAsCharRepresentation( mysensor_data mType ) {
|
||||
return mType == V_VAR1 ? "Ping" : "Pong";
|
||||
}
|
||||
|
||||
const char * nodeTypeAsCharRepresentation( uint8_t node ) {
|
||||
return node == YING ? "Ying Node" : "Yang Node";
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Pressure sensor example using BMP085 module
|
||||
* http://www.mysensors.org/build/pressure
|
||||
*
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_BMP085.h>
|
||||
|
||||
#define BARO_CHILD 0
|
||||
#define TEMP_CHILD 1
|
||||
|
||||
const float ALTITUDE = 688; // <-- adapt this value to your own location's altitude.
|
||||
|
||||
// Sleep time between reads (in seconds). Do not change this value as the forecast algorithm needs a sample every minute.
|
||||
const unsigned long SLEEP_TIME = 60000;
|
||||
|
||||
const char *weather[] = { "stable", "sunny", "cloudy", "unstable", "thunderstorm", "unknown" };
|
||||
enum FORECAST
|
||||
{
|
||||
STABLE = 0, // "Stable Weather Pattern"
|
||||
SUNNY = 1, // "Slowly rising Good Weather", "Clear/Sunny "
|
||||
CLOUDY = 2, // "Slowly falling L-Pressure ", "Cloudy/Rain "
|
||||
UNSTABLE = 3, // "Quickly rising H-Press", "Not Stable"
|
||||
THUNDERSTORM = 4, // "Quickly falling L-Press", "Thunderstorm"
|
||||
UNKNOWN = 5 // "Unknown (More Time needed)
|
||||
};
|
||||
|
||||
Adafruit_BMP085 bmp = Adafruit_BMP085(); // Digital Pressure Sensor
|
||||
|
||||
float lastPressure = -1;
|
||||
float lastTemp = -1;
|
||||
int lastForecast = -1;
|
||||
|
||||
const int LAST_SAMPLES_COUNT = 5;
|
||||
float lastPressureSamples[LAST_SAMPLES_COUNT];
|
||||
|
||||
// this CONVERSION_FACTOR is used to convert from Pa to kPa in forecast algorithm
|
||||
// get kPa/h be dividing hPa by 10
|
||||
#define CONVERSION_FACTOR (1.0/10.0)
|
||||
|
||||
int minuteCount = 0;
|
||||
bool firstRound = true;
|
||||
// average value is used in forecast algorithm.
|
||||
float pressureAvg;
|
||||
// average after 2 hours is used as reference value for the next iteration.
|
||||
float pressureAvg2;
|
||||
|
||||
float dP_dt;
|
||||
boolean metric;
|
||||
MyMessage tempMsg(TEMP_CHILD, V_TEMP);
|
||||
MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
|
||||
MyMessage forecastMsg(BARO_CHILD, V_FORECAST);
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Pressure Sensor", "1.1");
|
||||
|
||||
if (!bmp.begin())
|
||||
{
|
||||
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
// Register sensors to gw (they will be created as child devices)
|
||||
present(BARO_CHILD, S_BARO);
|
||||
present(TEMP_CHILD, S_TEMP);
|
||||
metric = getConfig().isMetric;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
float pressure = bmp.readSealevelPressure(ALTITUDE) / 100.0;
|
||||
float temperature = bmp.readTemperature();
|
||||
|
||||
if (!metric)
|
||||
{
|
||||
// Convert to fahrenheit
|
||||
temperature = temperature * 9.0 / 5.0 + 32.0;
|
||||
}
|
||||
|
||||
int forecast = sample(pressure);
|
||||
|
||||
Serial.print("Temperature = ");
|
||||
Serial.print(temperature);
|
||||
Serial.println(metric ? " *C" : " *F");
|
||||
Serial.print("Pressure = ");
|
||||
Serial.print(pressure);
|
||||
Serial.println(" hPa");
|
||||
Serial.print("Forecast = ");
|
||||
Serial.println(weather[forecast]);
|
||||
|
||||
|
||||
if (temperature != lastTemp)
|
||||
{
|
||||
send(tempMsg.set(temperature, 1));
|
||||
lastTemp = temperature;
|
||||
}
|
||||
|
||||
if (pressure != lastPressure)
|
||||
{
|
||||
send(pressureMsg.set(pressure, 0));
|
||||
lastPressure = pressure;
|
||||
}
|
||||
|
||||
if (forecast != lastForecast)
|
||||
{
|
||||
send(forecastMsg.set(weather[forecast]));
|
||||
lastForecast = forecast;
|
||||
}
|
||||
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
|
||||
float getLastPressureSamplesAverage()
|
||||
{
|
||||
float lastPressureSamplesAverage = 0;
|
||||
for (int i = 0; i < LAST_SAMPLES_COUNT; i++)
|
||||
{
|
||||
lastPressureSamplesAverage += lastPressureSamples[i];
|
||||
}
|
||||
lastPressureSamplesAverage /= LAST_SAMPLES_COUNT;
|
||||
|
||||
return lastPressureSamplesAverage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Algorithm found here
|
||||
// http://www.freescale.com/files/sensors/doc/app_note/AN3914.pdf
|
||||
// Pressure in hPa --> forecast done by calculating kPa/h
|
||||
int sample(float pressure)
|
||||
{
|
||||
// Calculate the average of the last n minutes.
|
||||
int index = minuteCount % LAST_SAMPLES_COUNT;
|
||||
lastPressureSamples[index] = pressure;
|
||||
|
||||
minuteCount++;
|
||||
if (minuteCount > 185)
|
||||
{
|
||||
minuteCount = 6;
|
||||
}
|
||||
|
||||
if (minuteCount == 5)
|
||||
{
|
||||
pressureAvg = getLastPressureSamplesAverage();
|
||||
}
|
||||
else if (minuteCount == 35)
|
||||
{
|
||||
float lastPressureAvg = getLastPressureSamplesAverage();
|
||||
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
|
||||
if (firstRound) // first time initial 3 hour
|
||||
{
|
||||
dP_dt = change * 2; // note this is for t = 0.5hour
|
||||
}
|
||||
else
|
||||
{
|
||||
dP_dt = change / 1.5; // divide by 1.5 as this is the difference in time from 0 value.
|
||||
}
|
||||
}
|
||||
else if (minuteCount == 65)
|
||||
{
|
||||
float lastPressureAvg = getLastPressureSamplesAverage();
|
||||
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
|
||||
if (firstRound) //first time initial 3 hour
|
||||
{
|
||||
dP_dt = change; //note this is for t = 1 hour
|
||||
}
|
||||
else
|
||||
{
|
||||
dP_dt = change / 2; //divide by 2 as this is the difference in time from 0 value
|
||||
}
|
||||
}
|
||||
else if (minuteCount == 95)
|
||||
{
|
||||
float lastPressureAvg = getLastPressureSamplesAverage();
|
||||
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
|
||||
if (firstRound) // first time initial 3 hour
|
||||
{
|
||||
dP_dt = change / 1.5; // note this is for t = 1.5 hour
|
||||
}
|
||||
else
|
||||
{
|
||||
dP_dt = change / 2.5; // divide by 2.5 as this is the difference in time from 0 value
|
||||
}
|
||||
}
|
||||
else if (minuteCount == 125)
|
||||
{
|
||||
float lastPressureAvg = getLastPressureSamplesAverage();
|
||||
pressureAvg2 = lastPressureAvg; // store for later use.
|
||||
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
|
||||
if (firstRound) // first time initial 3 hour
|
||||
{
|
||||
dP_dt = change / 2; // note this is for t = 2 hour
|
||||
}
|
||||
else
|
||||
{
|
||||
dP_dt = change / 3; // divide by 3 as this is the difference in time from 0 value
|
||||
}
|
||||
}
|
||||
else if (minuteCount == 155)
|
||||
{
|
||||
float lastPressureAvg = getLastPressureSamplesAverage();
|
||||
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
|
||||
if (firstRound) // first time initial 3 hour
|
||||
{
|
||||
dP_dt = change / 2.5; // note this is for t = 2.5 hour
|
||||
}
|
||||
else
|
||||
{
|
||||
dP_dt = change / 3.5; // divide by 3.5 as this is the difference in time from 0 value
|
||||
}
|
||||
}
|
||||
else if (minuteCount == 185)
|
||||
{
|
||||
float lastPressureAvg = getLastPressureSamplesAverage();
|
||||
float change = (lastPressureAvg - pressureAvg) * CONVERSION_FACTOR;
|
||||
if (firstRound) // first time initial 3 hour
|
||||
{
|
||||
dP_dt = change / 3; // note this is for t = 3 hour
|
||||
}
|
||||
else
|
||||
{
|
||||
dP_dt = change / 4; // divide by 4 as this is the difference in time from 0 value
|
||||
}
|
||||
pressureAvg = pressureAvg2; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past.
|
||||
firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop.
|
||||
}
|
||||
|
||||
int forecast = UNKNOWN;
|
||||
if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval.
|
||||
{
|
||||
forecast = UNKNOWN;
|
||||
}
|
||||
else if (dP_dt < (-0.25))
|
||||
{
|
||||
forecast = THUNDERSTORM;
|
||||
}
|
||||
else if (dP_dt > 0.25)
|
||||
{
|
||||
forecast = UNSTABLE;
|
||||
}
|
||||
else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05)))
|
||||
{
|
||||
forecast = CLOUDY;
|
||||
}
|
||||
else if ((dP_dt > 0.05) && (dP_dt < 0.25))
|
||||
{
|
||||
forecast = SUNNY;
|
||||
}
|
||||
else if ((dP_dt >(-0.05)) && (dP_dt < 0.05))
|
||||
{
|
||||
forecast = STABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
forecast = UNKNOWN;
|
||||
}
|
||||
|
||||
// uncomment when debugging
|
||||
//Serial.print(F("Forecast at minute "));
|
||||
//Serial.print(minuteCount);
|
||||
//Serial.print(F(" dP/dt = "));
|
||||
//Serial.print(dP_dt);
|
||||
//Serial.print(F("kPa/h --> "));
|
||||
//Serial.println(weather[forecast]);
|
||||
|
||||
return forecast;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* This sketch demonstrates how to use InterruptChain to receive and
|
||||
* decode remote switches (old and new) and remote sensors.
|
||||
*
|
||||
* Basically, this sketch combines the features of the ShowReceivedCode
|
||||
* and ShowReceivedCodeNewKaku examples of RemoteSwitch and the
|
||||
* ThermoHygroReceiver of RemoteSensor all at the same time!
|
||||
*
|
||||
* After uploading, enable the serial monitor at 115200 baud.
|
||||
* When you press buttons on a 433MHz remote control, as supported by
|
||||
* RemoteSwitch or NewRemoteSwitch, the code will be echoed.
|
||||
* At the same time, if data of a remote thermo/hygro-sensor is
|
||||
* received, as supported by RemoteSensor, it will be echoed as well.
|
||||
*
|
||||
* Setup:
|
||||
* - connect a 433MHz receiver on digital pin 2.
|
||||
*
|
||||
* MySensor note: This example has not yet been adopted but can be used as an example
|
||||
* of receiving 433Mhz stuff.
|
||||
*
|
||||
* One idea could be to echo received 433 codes back to gateway to be able to pick up and
|
||||
* handle data over there.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <RemoteReceiver.h>
|
||||
#include <NewRemoteReceiver.h>
|
||||
#include <SensorReceiver.h>
|
||||
#include <InterruptChain.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
// Interrupt -1 to indicate you will call the interrupt handler with InterruptChain
|
||||
RemoteReceiver::init(-1, 2, showOldCode);
|
||||
|
||||
// Again, interrupt -1 to indicate you will call the interrupt handler with InterruptChain
|
||||
NewRemoteReceiver::init(-1, 2, showNewCode);
|
||||
|
||||
// And once more, interrupt -1 to indicate you will call the interrupt handler with InterruptChain
|
||||
SensorReceiver::init(-1, showTempHumi);
|
||||
|
||||
// On interrupt, call the interrupt handlers of remote and sensor receivers
|
||||
InterruptChain::addInterruptCallback(0, RemoteReceiver::interruptHandler);
|
||||
InterruptChain::addInterruptCallback(0, NewRemoteReceiver::interruptHandler);
|
||||
InterruptChain::addInterruptCallback(0, SensorReceiver::interruptHandler);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// You can do other stuff here!
|
||||
}
|
||||
|
||||
// shows the received code sent from an old-style remote switch
|
||||
void showOldCode(unsigned long receivedCode, unsigned int period) {
|
||||
// Print the received code.
|
||||
Serial.print("Code: ");
|
||||
Serial.print(receivedCode);
|
||||
Serial.print(", period: ");
|
||||
Serial.print(period);
|
||||
Serial.println("us.");
|
||||
}
|
||||
|
||||
// Shows the received code sent from an new-style remote switch
|
||||
void showNewCode(NewRemoteCode receivedCode) {
|
||||
// Print the received code.
|
||||
Serial.print("Addr ");
|
||||
Serial.print(receivedCode.address);
|
||||
|
||||
if (receivedCode.groupBit) {
|
||||
Serial.print(" group");
|
||||
} else {
|
||||
Serial.print(" unit ");
|
||||
Serial.print(receivedCode.unit);
|
||||
}
|
||||
|
||||
switch (receivedCode.switchType) {
|
||||
case NewRemoteCode::off:
|
||||
Serial.print(" off");
|
||||
break;
|
||||
case NewRemoteCode::on:
|
||||
Serial.print(" on");
|
||||
break;
|
||||
case NewRemoteCode::dim:
|
||||
Serial.print(" dim level ");
|
||||
Serial.print(receivedCode.dimLevel);
|
||||
break;
|
||||
case NewRemoteCode::on_with_dim:
|
||||
Serial.print(" on with dim level ");
|
||||
Serial.print(receivedCode.dimLevel);
|
||||
break;
|
||||
}
|
||||
|
||||
Serial.print(", period: ");
|
||||
Serial.print(receivedCode.period);
|
||||
Serial.println("us.");
|
||||
}
|
||||
|
||||
// Shows the received sensor data
|
||||
void showTempHumi(byte *data) {
|
||||
// is data a ThermoHygro-device?
|
||||
if ((data[3] & 0x1f) == 0x1e) {
|
||||
// Yes!
|
||||
byte channel, randomId;
|
||||
int temp;
|
||||
byte humidity;
|
||||
|
||||
// Decode the data
|
||||
SensorReceiver::decodeThermoHygro(data, channel, randomId, temp, humidity);
|
||||
|
||||
// Print temperature. Note: temp is 10x the actual temperature!
|
||||
Serial.print("Temperature: ");
|
||||
Serial.print(temp / 10); // units
|
||||
Serial.print('.');
|
||||
Serial.println(temp % 10); // decimal
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* RFID Lock sensor/actuator
|
||||
*
|
||||
* Use RFID tag to lock/unlock a door or trigger a scene on your controller.
|
||||
* This example sketch allows you to add an optional relay or solenoid
|
||||
* which can be activated/opened by RFID or controller.
|
||||
*
|
||||
* Use the I2C wiring option for your RFID module and connect to the following Arduino pins.
|
||||
*
|
||||
* RFID Arduino
|
||||
* ----- -------
|
||||
* GND -> GND
|
||||
* VCC -> +5V
|
||||
* SCL -> A5
|
||||
* SDA -> A4
|
||||
*
|
||||
* Use normal wiring for NRF24L01 radio
|
||||
*
|
||||
* Attach a optional relay or solonoid lock to pin 4
|
||||
* http://www.mysensors.org/build/rfid
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <Wire.h>
|
||||
#include <PN532_I2C.h>
|
||||
#include <PN532.h>
|
||||
|
||||
|
||||
// Add your valid rfid keys here. To find you your key just run sketch; hold your new RFID tag in fron ot the reader;
|
||||
// and copy the key from serial output of this sketch.
|
||||
const uint8_t maxKeyLength = 7;
|
||||
uint8_t validKeys[][maxKeyLength] = {
|
||||
{ 0xB3, 0xC6, 0xD9, 0x80, 0x00, 0x00, 0x00 },
|
||||
{ 0, 0, 0, 0, 0, 0, 0 }, // ADD YOUR KEYS HERE!
|
||||
{ 0, 0, 0, 0, 0, 0, 0 }};
|
||||
int keyCount = sizeof validKeys / maxKeyLength;
|
||||
|
||||
|
||||
#define CHILD_ID 99 // Id of the sensor child
|
||||
|
||||
// Pin definition
|
||||
const int lockPin = 4; // (Digital 4) The pin that activates the relay/solenoid lock.
|
||||
bool lockStatus;
|
||||
MyMessage lockMsg(CHILD_ID, V_LOCK_STATUS);
|
||||
PN532_I2C pn532i2c(Wire);
|
||||
PN532 nfc(pn532i2c);
|
||||
|
||||
void setup() {
|
||||
|
||||
pinMode(lockPin, OUTPUT);
|
||||
|
||||
nfc.begin();
|
||||
uint32_t versiondata = nfc.getFirmwareVersion();
|
||||
if (! versiondata) {
|
||||
Serial.print("Couldn't find PN53x board");
|
||||
while (1); // halt
|
||||
}
|
||||
Serial.print("Found NFC chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
|
||||
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
|
||||
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
|
||||
// Set the max number of retry attempts to read from a card
|
||||
// This prevents us from waiting forever for a card, which is
|
||||
// the default behaviour of the PN532.
|
||||
nfc.setPassiveActivationRetries(0x3);
|
||||
|
||||
// configure board to read RFID tags
|
||||
nfc.SAMConfig();
|
||||
|
||||
// Add callback for incoming messages
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
sendSketchInfo("RFID Lock", "1.0");
|
||||
present(CHILD_ID, S_LOCK);
|
||||
|
||||
lockStatus = loadState(0); // Read last lock status from eeprom
|
||||
setLockState(lockStatus, true); // Now set the last known state and send it to controller
|
||||
}
|
||||
|
||||
void loop() {
|
||||
boolean success;
|
||||
uint8_t key[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
|
||||
uint8_t currentKeyLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
|
||||
|
||||
|
||||
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
|
||||
// 'uid' will be populated with the UID, and uidLength will indicate
|
||||
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
|
||||
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], ¤tKeyLength);
|
||||
|
||||
if (success) {
|
||||
Serial.print("Found tag id: ");
|
||||
for (uint8_t i=0; i < currentKeyLength; i++)
|
||||
{
|
||||
if (i>0) Serial.print(",");
|
||||
Serial.print("0x");Serial.print(key[i], HEX);
|
||||
}
|
||||
for (uint8_t i=currentKeyLength; i < maxKeyLength; i++)
|
||||
{
|
||||
Serial.print(",0x00");
|
||||
}
|
||||
|
||||
|
||||
Serial.println("");
|
||||
|
||||
boolean valid = false;
|
||||
// Compare this key to the valid once registered here in sketch
|
||||
for (int i=0;i<keyCount && !valid;i++) {
|
||||
for (int j=0;i<currentKeyLength && !valid;j++) {
|
||||
if (key[j] != validKeys[i][j]) {
|
||||
break;
|
||||
}
|
||||
if (j==currentKeyLength-1) {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (valid) {
|
||||
// Switch lock status
|
||||
setLockState(!lockStatus, true);
|
||||
}
|
||||
|
||||
// Wait for card/tag to leave reader
|
||||
while(nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &key[0], ¤tKeyLength));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Unlocks the door.
|
||||
void setLockState(bool state, bool doSend){
|
||||
if (state)
|
||||
Serial.println("open lock");
|
||||
else
|
||||
Serial.println("close lock");
|
||||
if (doSend)
|
||||
send(lockMsg.set(state));
|
||||
digitalWrite(lockPin, state);
|
||||
saveState(0,state);
|
||||
lockStatus = state;
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
// We only expect one type of message from controller. But we better check anyway.
|
||||
if (message.type==V_LOCK_STATUS) {
|
||||
// Change relay state
|
||||
setLockState(message.getBool(), false);
|
||||
|
||||
// Write some debug info
|
||||
Serial.print("Incoming lock status:");
|
||||
Serial.println(message.getBool());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,304 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Created by vil1driver
|
||||
*
|
||||
* DESCRIPTION
|
||||
* RGB led strip controled with three dimmers + one On/Off for run/stop rgb color cycle :p
|
||||
*
|
||||
*/
|
||||
|
||||
#define SN "RGB Led strip 3D"
|
||||
#define SV "v1"
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
// Arduino pin attached to MOSFET Gate pin
|
||||
#define RED_PIN 3
|
||||
#define GREEN_PIN 5
|
||||
#define BLUE_PIN 6
|
||||
|
||||
// Define message name and type to send sensor info
|
||||
MyMessage RedStatus(RED_PIN, V_DIMMER);
|
||||
MyMessage GreenStatus(GREEN_PIN, V_DIMMER);
|
||||
MyMessage BlueStatus(BLUE_PIN, V_DIMMER);
|
||||
MyMessage Status(1, V_DIMMER);
|
||||
MyMessage rgbShowState(0, V_LIGHT);
|
||||
|
||||
// Serial.print translate sensor id to sensor name
|
||||
char color[][6] = {"","","","RED","","GREEN","BLUE"};
|
||||
|
||||
// Vars for rgbShow function
|
||||
int redval = 0;
|
||||
int greenval = 0;
|
||||
int blueval = 0;
|
||||
long time=0;
|
||||
int isShow;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Add callback for incoming messages
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
// Present sketch (name, version)
|
||||
sendSketchInfo(SN, SV);
|
||||
|
||||
// Register sensors (id, type, description, ack back)
|
||||
present(RED_PIN, S_DIMMER, "present RED light", false);
|
||||
present(GREEN_PIN, S_DIMMER, "present GREEN light", false);
|
||||
present(BLUE_PIN, S_DIMMER, "present BLUE light", false);
|
||||
present(0, S_LIGHT, "present Show button", false);
|
||||
|
||||
// Define pin mode (pin number, type)
|
||||
pinMode(RED_PIN, OUTPUT);
|
||||
pinMode(GREEN_PIN, OUTPUT);
|
||||
pinMode(BLUE_PIN, OUTPUT);
|
||||
|
||||
// Correct saved RGB value for first start
|
||||
saveState(RED_PIN, constrain((int8_t)loadState(RED_PIN), 0, 100));
|
||||
saveState(GREEN_PIN, constrain((int8_t)loadState(GREEN_PIN), 0, 100));
|
||||
saveState(BLUE_PIN, constrain((int8_t)loadState(BLUE_PIN), 0, 100));
|
||||
|
||||
// Get value from eeprom and write to output
|
||||
analogWrite(RED_PIN, 255 * loadState(RED_PIN) / 100);
|
||||
analogWrite(GREEN_PIN, 255 * loadState(GREEN_PIN) / 100);
|
||||
analogWrite(BLUE_PIN, 255 * loadState(BLUE_PIN) / 100);
|
||||
|
||||
// Write some debug info
|
||||
Serial.print("Load from eeprom RED: ");
|
||||
Serial.print(loadState(RED_PIN));
|
||||
Serial.println("%");
|
||||
Serial.print("Load from eeprom GREEN: ");
|
||||
Serial.print(loadState(GREEN_PIN));
|
||||
Serial.println("%");
|
||||
Serial.print("Load from eeprom BLUE: ");
|
||||
Serial.print(loadState(BLUE_PIN));
|
||||
Serial.println("%");
|
||||
|
||||
// Send RGB value to controler (request ack back: true/false)
|
||||
Serial.println("Send eeprom value to controler");
|
||||
send( RedStatus.set(loadState(RED_PIN)), false );
|
||||
send( GreenStatus.set(loadState(GREEN_PIN)), false );
|
||||
send( BlueStatus.set(loadState(BLUE_PIN)), false );
|
||||
|
||||
// Correct RGB show state for first start and load it (set to 'On' at first start)
|
||||
saveState(0, constrain((int8_t)loadState(0), 0, 1));
|
||||
isShow=loadState(0);
|
||||
|
||||
// Send RGB show state to controler (request ack back: true/false)
|
||||
send( rgbShowState.set(isShow), false);
|
||||
|
||||
if (isShow==1){Serial.println("RGB show running..."); }
|
||||
Serial.println("Ready to receive messages...");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Run RGB show if is set
|
||||
if (isShow==1)
|
||||
{
|
||||
rgbShow();
|
||||
analogWrite(RED_PIN, redval);
|
||||
analogWrite(GREEN_PIN, greenval);
|
||||
analogWrite(BLUE_PIN, blueval);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void incomingMessage(const MyMessage &message)
|
||||
{
|
||||
if (message.isAck())
|
||||
{
|
||||
Serial.println("Got ack from gateway");
|
||||
}
|
||||
if (message.type == V_LIGHT)
|
||||
{
|
||||
// Incoming on/off command sent from controller ("1" or "0")
|
||||
int lightState = message.getString()[0] == '1';
|
||||
|
||||
// if receive RGB Show On commands, start the show
|
||||
if (message.sensor==0 && lightState==1){ rgbShowOn(); }
|
||||
// if receive RGB Show Off commands, stop the show
|
||||
else if (message.sensor==0 && lightState==0){ rgbShowOff(); }
|
||||
|
||||
// if receive RGB switch On command
|
||||
else if (lightState==1)
|
||||
{
|
||||
// Write some debug info
|
||||
Serial.print("Incoming change for ");
|
||||
Serial.print(color[message.sensor]);
|
||||
Serial.println(": On");
|
||||
Serial.print("Load from eeprom: ");
|
||||
|
||||
if ( loadState(message.sensor) == 0)
|
||||
{
|
||||
// Pick up last saved dimmer level from the eeprom
|
||||
analogWrite(message.sensor, 255 * loadState(10*message.sensor) / 100);
|
||||
// Save loaded value to current
|
||||
saveState(message.sensor, loadState(10*message.sensor));
|
||||
Serial.print(loadState(10*message.sensor));
|
||||
Serial.println("%");
|
||||
// Send value to controler
|
||||
Serial.println("Send value to controler");
|
||||
send(Status.setSensor(message.sensor).set(loadState(10*message.sensor)),false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pick up last saved dimmer level from the eeprom
|
||||
analogWrite(message.sensor, 255 * loadState(message.sensor) / 100);
|
||||
Serial.print(loadState(message.sensor));
|
||||
Serial.println("%");
|
||||
// Send value to controler
|
||||
Serial.println("Send value to controler");
|
||||
send(Status.setSensor(message.sensor).set(loadState(message.sensor)),false);
|
||||
}
|
||||
// Stop the show if it's running
|
||||
if (isShow==1){ rgbShowStop(message.sensor); }
|
||||
}
|
||||
// if recieve switch Off command
|
||||
else if (lightState==0)
|
||||
{
|
||||
// Write output to 0 (Off)
|
||||
analogWrite(message.sensor, 0);
|
||||
// Save old value to eeprom if it'was not zero
|
||||
if ( loadState(message.sensor) != 0 )
|
||||
{
|
||||
saveState(10*message.sensor, constrain((int8_t)loadState(message.sensor), 0, 100));
|
||||
}
|
||||
// Save new value to eeprom
|
||||
saveState(message.sensor, 0);
|
||||
// Write some debug info
|
||||
Serial.print("Incoming change for ");
|
||||
Serial.print(color[message.sensor]);
|
||||
Serial.print(": ");
|
||||
Serial.println("Off");
|
||||
Serial.print("Store old value: ");
|
||||
Serial.print(loadState(10*message.sensor));
|
||||
Serial.println("%");
|
||||
// Send value to controler
|
||||
Serial.println("Send value to controler");
|
||||
send(Status.setSensor(message.sensor).set(loadState(message.sensor)),false);
|
||||
// Stop the show if it's running
|
||||
if (isShow==1){ rgbShowStop(message.sensor); }
|
||||
}
|
||||
}
|
||||
else if (message.type == V_DIMMER)
|
||||
{
|
||||
uint8_t incomingDimmerStatus = message.getByte();
|
||||
// limits range of sensor values to between 0 and 100
|
||||
incomingDimmerStatus = constrain((int8_t)incomingDimmerStatus, 0, 100);
|
||||
// Change Dimmer level
|
||||
analogWrite(message.sensor, 255 * incomingDimmerStatus / 100);
|
||||
//Save value to eeprom
|
||||
saveState(message.sensor, incomingDimmerStatus);
|
||||
// Write some debug info
|
||||
Serial.print("Incoming change for ");
|
||||
Serial.print(color[message.sensor]);
|
||||
Serial.print(": ");
|
||||
Serial.print(incomingDimmerStatus);
|
||||
Serial.println("%");
|
||||
// Send value to controler
|
||||
Serial.println("Send value to controler");
|
||||
send(Status.setSensor(message.sensor).set(loadState(message.sensor)),false);
|
||||
// Stop the show if it's running
|
||||
if (isShow==1){ rgbShowStop(message.sensor); }
|
||||
}
|
||||
}
|
||||
|
||||
void rgbShow()
|
||||
{
|
||||
time = millis();
|
||||
redval = 128+250*cos(2*PI/300000*time);
|
||||
greenval = 128+250*cos(2*PI/300000*time-222);
|
||||
blueval = 128+250*cos(2*PI/300000*time-111);
|
||||
// limits range of sensor values to between 0 and 255
|
||||
redval = constrain(redval, 0, 255);
|
||||
greenval = constrain(greenval, 0, 255);
|
||||
blueval = constrain(blueval, 0, 255);
|
||||
}
|
||||
|
||||
void rgbShowOn()
|
||||
{
|
||||
// define show On
|
||||
isShow=1;
|
||||
// Save state
|
||||
saveState(0, 1);
|
||||
// Write some debug info
|
||||
Serial.println("Show must go on");
|
||||
}
|
||||
|
||||
void rgbShowOff()
|
||||
{
|
||||
// define show Off
|
||||
isShow=0;
|
||||
// Save state
|
||||
saveState(0, 0);
|
||||
// Save RGB value to eeprom
|
||||
saveState(RED_PIN, 100 * redval / 255);
|
||||
saveState(GREEN_PIN, 100 * greenval / 255);
|
||||
saveState(BLUE_PIN, 100 * blueval / 255);
|
||||
// Write some debug info
|
||||
Serial.println("Stop the show");
|
||||
// Send actual RGB value and state to controler and request ack back (true/false)
|
||||
Serial.println("Send eeprom value to controler");
|
||||
send( RedStatus.set(loadState(RED_PIN)), false );
|
||||
send( GreenStatus.set(loadState(GREEN_PIN)), false );
|
||||
send( BlueStatus.set(loadState(BLUE_PIN)), false );
|
||||
send( rgbShowState.set(0), false);
|
||||
}
|
||||
|
||||
void rgbShowStop(int sensor)
|
||||
{
|
||||
// define show Off
|
||||
isShow=0;
|
||||
// Save state
|
||||
saveState(0, 0);
|
||||
// Write some debug info
|
||||
Serial.println("Stop the show");
|
||||
// Send actual RGB value and state to controler and request ack back (true/false)
|
||||
Serial.println("Send eeprom value to controler");
|
||||
if (sensor != RED_PIN)
|
||||
{
|
||||
saveState(RED_PIN, 100 * redval / 255);
|
||||
send( RedStatus.set(loadState(RED_PIN)), false );
|
||||
}
|
||||
if (sensor != GREEN_PIN)
|
||||
{
|
||||
saveState(GREEN_PIN, 100 * greenval / 255);
|
||||
send( GreenStatus.set(loadState(GREEN_PIN)), false );
|
||||
}
|
||||
if (sensor != BLUE_PIN)
|
||||
{
|
||||
saveState(BLUE_PIN, 100 * blueval / 255);
|
||||
send( BlueStatus.set(loadState(BLUE_PIN)), false );
|
||||
}
|
||||
send( rgbShowState.set(0), false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,599 @@
|
||||
/*
|
||||
Arduino Tipping Bucket Rain Gauge
|
||||
|
||||
April 26, 2015
|
||||
|
||||
Version 1.4.1 alpha
|
||||
|
||||
Arduino Tipping Bucket Rain Gauge
|
||||
|
||||
Utilizing a tipping bucket sensor, your Vera home automation controller and the MySensors.org
|
||||
gateway you can measure and sense local rain. This sketch will create two devices on your
|
||||
Vera controller. One will display your total precipitation for the last 5 days. The other,
|
||||
a sensor that changes state if there is recent rain (up to last 120 hours) above a threshold.
|
||||
Both these settings are user definable.
|
||||
|
||||
There is a build overview video here: https://youtu.be/1eMfKQaLROo
|
||||
|
||||
This sketch features the following:
|
||||
|
||||
* Allows you to set the rain threshold in mm
|
||||
* Allows you to determine the tripped indicator window up to 120 hours.
|
||||
* Displays the last 5 days of rain in Variable1 through Variable5
|
||||
of the Rain Sensor device
|
||||
* Configuration changes to Sensor device updated every hour
|
||||
* Should run on any Arduino
|
||||
* Will retain Tripped/Not Tripped status and data in a power interruption, saving small amount
|
||||
of data to EEPROM (Circular Buffer to maximize life of EEPROM)
|
||||
* LED status indicator
|
||||
* Optional Temp/Humidity (DHT-22 or DHT-11) and Light LUX (BH1750) sensors. To use, uncomment
|
||||
#define DHT_ON and/or #define LUX_ON
|
||||
* Optionally send total accumulation of each day's rainfall or send only individual days rainfall totals.
|
||||
Comment out #define USE_DAILY to display individual daily rainfall.
|
||||
|
||||
by @BulldogLowell and @PeteWill for free public use
|
||||
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
//#define MY_NODE_ID 7
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <math.h>
|
||||
#include <Time.h>
|
||||
|
||||
#define SKETCH_NAME "Rain Gauge"
|
||||
#define SKETCH_VERSION "1.4.1a"
|
||||
|
||||
#define DWELL_TIME 125 // this allows for radio to come back to power after a transmission, ideally 0
|
||||
|
||||
//#define DEBUG_ON // comment out this line to disable serial debug
|
||||
#define DHT_ON // uncomment out this line to enable DHT sensor
|
||||
#define LUX_ON // uncomment out this line to enable BH1750 sensor
|
||||
//#define USE_DAILY // displays each time segment as an accumulation of prior periods inclusive. Comment out to display individual daily rainfall totals in the variables sent to your controller.
|
||||
|
||||
#define CALIBRATE_FACTOR 60 // amount of rain per rain bucket tip e.g. 5 is .05mm
|
||||
#define DHT_LUX_DELAY 300000 //Delay in milliseconds that the DHT and LUX sensors will wait before sending data
|
||||
|
||||
#define CHILD_ID_RAIN_LOG 3 // Keeps track of accumulated rainfall
|
||||
#define CHILD_ID_TRIPPED_INDICATOR 4 // Indicates Tripped when rain detected
|
||||
#define EEPROM_BUFFER_LOCATION 0 // location of the EEPROM circular buffer
|
||||
#define E_BUFFER_LENGTH 240
|
||||
#define RAIN_BUCKET_SIZE 120
|
||||
|
||||
#ifdef DEBUG_ON
|
||||
#define DEBUG_PRINT(x) Serial.print(x)
|
||||
#define DEBUG_PRINTLN(x) Serial.println(x)
|
||||
#define SERIAL_START(x) Serial.begin(x)
|
||||
#else
|
||||
#define DEBUG_PRINT(x)
|
||||
#define DEBUG_PRINTLN(x)
|
||||
#define SERIAL_START(x)
|
||||
#endif
|
||||
//
|
||||
MyMessage msgRainRate(CHILD_ID_RAIN_LOG, V_RAINRATE);
|
||||
MyMessage msgRain(CHILD_ID_RAIN_LOG, V_RAIN);
|
||||
//
|
||||
MyMessage msgRainVAR1(CHILD_ID_RAIN_LOG, V_VAR1);
|
||||
MyMessage msgRainVAR2(CHILD_ID_RAIN_LOG, V_VAR2);
|
||||
MyMessage msgRainVAR3(CHILD_ID_RAIN_LOG, V_VAR3);
|
||||
MyMessage msgRainVAR4(CHILD_ID_RAIN_LOG, V_VAR4);
|
||||
MyMessage msgRainVAR5(CHILD_ID_RAIN_LOG, V_VAR5);
|
||||
//
|
||||
MyMessage msgTripped(CHILD_ID_TRIPPED_INDICATOR, V_TRIPPED);
|
||||
MyMessage msgTrippedVar1(CHILD_ID_TRIPPED_INDICATOR, V_VAR1);
|
||||
MyMessage msgTrippedVar2(CHILD_ID_TRIPPED_INDICATOR, V_VAR2);
|
||||
//
|
||||
#ifdef DHT_ON
|
||||
#include <DHT.h>
|
||||
#define CHILD_ID_HUM 0
|
||||
#define CHILD_ID_TEMP 1
|
||||
#define HUMIDITY_SENSOR_DIGITAL_PIN 8
|
||||
DHT dht;
|
||||
float lastTemp;
|
||||
float lastHum;
|
||||
boolean metric = true;
|
||||
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
|
||||
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
|
||||
#endif
|
||||
//
|
||||
#ifdef LUX_ON
|
||||
//BH1750 is connected to SCL (analog input A5) and SDA (analog input A4)
|
||||
#include <BH1750.h>
|
||||
#include <Wire.h>
|
||||
#define CHILD_ID_LIGHT 2
|
||||
BH1750 lightSensor;
|
||||
MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
|
||||
unsigned int lastlux;
|
||||
byte heartbeat = 10; //Used to send the light lux to gateway as soon as the device is restarted and after the DHT_LUX_DELAY has happened 10 times
|
||||
#endif
|
||||
unsigned long sensorPreviousMillis;
|
||||
int eepromIndex;
|
||||
int tipSensorPin = 3; // Pin the tipping bucket is connected to. Must be interrupt capable pin
|
||||
int ledPin = 5; // Pin the LED is connected to. PWM capable pin required
|
||||
unsigned long dataMillis;
|
||||
unsigned long serialInterval = 600000UL;
|
||||
const unsigned long oneHour = 3600000UL;
|
||||
unsigned long lastTipTime;
|
||||
unsigned long lastRainTime; //Used for rainRate calculation
|
||||
unsigned int rainBucket [RAIN_BUCKET_SIZE] ; /* 24 hours x 5 Days = 120 hours */
|
||||
unsigned int rainRate = 0;
|
||||
byte rainWindow = 72; //default rain window in hours. Will be overwritten with msgTrippedVar1.
|
||||
volatile int wasTippedBuffer = 0;
|
||||
int rainSensorThreshold = 50; //default rain sensor sensitivity in hundredths. Will be overwritten with msgTrippedVar2.
|
||||
byte state = 0;
|
||||
byte oldState = -1;
|
||||
unsigned int lastRainRate = 0;
|
||||
int lastMeasure = 0;
|
||||
boolean gotTime = false;
|
||||
byte lastHour;
|
||||
byte currentHour;
|
||||
//
|
||||
void setup()
|
||||
{
|
||||
SERIAL_START(115200);
|
||||
//
|
||||
// Set up the IO
|
||||
pinMode(tipSensorPin, INPUT_PULLUP);
|
||||
attachInterrupt (1, sensorTipped, FALLING); // depending on location of the hall effect sensor may need CHANGE
|
||||
pinMode(ledPin, OUTPUT);
|
||||
digitalWrite(ledPin, HIGH);
|
||||
//
|
||||
//Let's get the controller talking to the Arduino
|
||||
setIncomingCallback(getVariables);
|
||||
|
||||
sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
|
||||
wait(DWELL_TIME);
|
||||
present(CHILD_ID_RAIN_LOG, S_RAIN);
|
||||
wait(DWELL_TIME);
|
||||
present(CHILD_ID_TRIPPED_INDICATOR, S_MOTION);
|
||||
wait(DWELL_TIME);
|
||||
DEBUG_PRINTLN(F("Sensor Presentation Complete"));
|
||||
//
|
||||
//Sync time with the server, this will be called hourly in order to keep time from creeping with the crystal
|
||||
//
|
||||
unsigned long functionTimeout = millis();
|
||||
while (timeStatus() == timeNotSet && millis() - functionTimeout < 30000UL)
|
||||
{
|
||||
requestTime(receiveTime);
|
||||
DEBUG_PRINTLN(F("Getting Time"));
|
||||
wait(1000); // call once per second
|
||||
DEBUG_PRINTLN(F("."));
|
||||
}
|
||||
currentHour = hour();
|
||||
lastHour = hour();
|
||||
//
|
||||
//retrieve from EEPROM stored values on a power cycle.
|
||||
//
|
||||
boolean isDataOnEeprom = false;
|
||||
for (int i = 0; i < E_BUFFER_LENGTH; i++)
|
||||
{
|
||||
byte locator = loadState(EEPROM_BUFFER_LOCATION + i);
|
||||
if (locator == 0xFE) // found the EEPROM circular buffer index
|
||||
{
|
||||
eepromIndex = EEPROM_BUFFER_LOCATION + i;
|
||||
DEBUG_PRINT(F("EEPROM Index "));
|
||||
DEBUG_PRINTLN(eepromIndex);
|
||||
//Now that we have the buffer index let's populate the rainBucket[] with data from eeprom
|
||||
loadRainArray(eepromIndex);
|
||||
isDataOnEeprom = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (!isDataOnEeprom) // Added for the first time it is run on a new Arduino
|
||||
{
|
||||
DEBUG_PRINTLN(F("I didn't find valid EEPROM Index, so I'm writing one to location 0"));
|
||||
eepromIndex = EEPROM_BUFFER_LOCATION;
|
||||
saveState(eepromIndex, 0xFE);
|
||||
saveState(eepromIndex + 1, 0xFE);
|
||||
//then I will clear out any bad data
|
||||
for (int i = 2; i <= E_BUFFER_LENGTH; i++)
|
||||
{
|
||||
saveState(i, 0x00);
|
||||
}
|
||||
}
|
||||
dataMillis = millis();
|
||||
lastTipTime = millis() - oneHour; //why is this -oneHour?? Doesn't millis() start at 0 when first powered on?
|
||||
//
|
||||
request(CHILD_ID_TRIPPED_INDICATOR, V_VAR1);
|
||||
wait(DWELL_TIME);
|
||||
request(CHILD_ID_TRIPPED_INDICATOR, V_VAR2);
|
||||
wait(DWELL_TIME);
|
||||
//
|
||||
#ifdef DHT_ON
|
||||
dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
present(CHILD_ID_HUM, S_HUM);
|
||||
wait(DWELL_TIME);
|
||||
present(CHILD_ID_TEMP, S_TEMP);
|
||||
wait(DWELL_TIME);
|
||||
metric = getConfig().isMetric;
|
||||
wait(DWELL_TIME);
|
||||
#endif
|
||||
//
|
||||
#ifdef LUX_ON
|
||||
present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
|
||||
wait(DWELL_TIME);
|
||||
lightSensor.begin();
|
||||
#endif
|
||||
//
|
||||
DEBUG_PRINTLN(F("Radio Setup Complete!"));
|
||||
transmitRainData();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
prettyFade(); // breathe if tripped
|
||||
}
|
||||
else
|
||||
{
|
||||
slowFlash(); // blink if not tripped
|
||||
}
|
||||
#ifdef DEBUG_ON // Serial Debug Block
|
||||
if ( (millis() - dataMillis) >= serialInterval)
|
||||
{
|
||||
for (int i = 24; i <= 120; i = i + 24)
|
||||
{
|
||||
updateSerialData(i);
|
||||
}
|
||||
dataMillis = millis();
|
||||
}
|
||||
#endif
|
||||
//
|
||||
// let's constantly check to see if the rain in the past rainWindow hours is greater than rainSensorThreshold
|
||||
//
|
||||
int measure = 0; // Check to see if we need to show sensor tripped in this block
|
||||
for (int i = 0; i < rainWindow; i++)
|
||||
{
|
||||
measure += rainBucket [i];
|
||||
if (measure != lastMeasure)
|
||||
{
|
||||
// DEBUG_PRINT(F("measure value (total rainBucket within rainWindow): "));
|
||||
// DEBUG_PRINTLN(measure);
|
||||
lastMeasure = measure;
|
||||
}
|
||||
}
|
||||
//
|
||||
state = (measure >= (rainSensorThreshold * 100));
|
||||
if (state != oldState)
|
||||
{
|
||||
send(msgTripped.set(state));
|
||||
wait(DWELL_TIME);
|
||||
DEBUG_PRINT(F("New Sensor State... Sensor: "));
|
||||
DEBUG_PRINTLN(state ? "Tripped" : "Not Tripped");
|
||||
oldState = state;
|
||||
}
|
||||
//
|
||||
unsigned long tipDelay = millis() - lastRainTime;
|
||||
if (wasTippedBuffer) // if was tipped, then update the 24hour total and transmit to Vera
|
||||
{
|
||||
DEBUG_PRINTLN(F("Sensor Tipped"));
|
||||
DEBUG_PRINT(F("rainBucket [0] value: "));
|
||||
DEBUG_PRINTLN(rainBucket [0]);
|
||||
send(msgRain.set((float)rainTotal(currentHour) / 100, 1)); //Calculate the total rain for the day
|
||||
wait(DWELL_TIME);
|
||||
wasTippedBuffer--;
|
||||
rainRate = ((oneHour) / tipDelay);
|
||||
if (rainRate != lastRainRate)
|
||||
{
|
||||
send(msgRainRate.set(rainRate, 1));
|
||||
wait(DWELL_TIME);
|
||||
DEBUG_PRINT(F("RainRate= "));
|
||||
DEBUG_PRINTLN(rainRate);
|
||||
lastRainRate = rainRate;
|
||||
}
|
||||
lastRainTime = lastTipTime;
|
||||
}
|
||||
//
|
||||
currentHour = hour();
|
||||
if (currentHour != lastHour)
|
||||
{
|
||||
DEBUG_PRINTLN(F("One hour elapsed."));
|
||||
send(msgRain.set((float)rainTotal(currentHour) / 100, 1)); // send today's rainfall
|
||||
wait(DWELL_TIME);
|
||||
saveState(eepromIndex, highByte(rainBucket[0]));
|
||||
saveState(eepromIndex + 1, lowByte(rainBucket[0]));
|
||||
DEBUG_PRINT(F("Saving rainBucket[0] to eeprom. rainBucket[0] = "));
|
||||
DEBUG_PRINTLN(rainBucket[0]);
|
||||
for (int i = RAIN_BUCKET_SIZE - 1; i >= 0; i--)//cascade an hour of values back into the array
|
||||
{
|
||||
rainBucket [i + 1] = rainBucket [i];
|
||||
}
|
||||
request(CHILD_ID_TRIPPED_INDICATOR, V_VAR1);
|
||||
wait(DWELL_TIME);
|
||||
request(CHILD_ID_TRIPPED_INDICATOR, V_VAR2);
|
||||
wait(DWELL_TIME);
|
||||
rainBucket[0] = 0;
|
||||
eepromIndex = eepromIndex + 2;
|
||||
if (eepromIndex > EEPROM_BUFFER_LOCATION + E_BUFFER_LENGTH)
|
||||
{
|
||||
eepromIndex = EEPROM_BUFFER_LOCATION;
|
||||
}
|
||||
DEBUG_PRINT(F("Writing to EEPROM. Index: "));
|
||||
DEBUG_PRINTLN(eepromIndex);
|
||||
saveState(eepromIndex, 0xFE);
|
||||
saveState(eepromIndex + 1, 0xFE);
|
||||
requestTime(receiveTime); // sync the time every hour
|
||||
wait(DWELL_TIME);
|
||||
transmitRainData();
|
||||
rainRate = 0;
|
||||
send(msgRainRate.set(rainRate, 1));
|
||||
wait(DWELL_TIME);
|
||||
DEBUG_PRINTLN(F("Sending rainRate is 0 to controller"));
|
||||
lastHour = currentHour;
|
||||
}
|
||||
if (millis() - sensorPreviousMillis > DHT_LUX_DELAY)
|
||||
{
|
||||
#ifdef DHT_ON //DHT Code
|
||||
doDHT();
|
||||
#endif
|
||||
#ifdef LUX_ON
|
||||
doLUX();
|
||||
#endif
|
||||
sensorPreviousMillis = millis();
|
||||
}
|
||||
}
|
||||
//
|
||||
#ifdef DHT_ON
|
||||
void doDHT(void)
|
||||
{
|
||||
float temperature = dht.getTemperature();
|
||||
if (isnan(temperature))
|
||||
{
|
||||
DEBUG_PRINTLN(F("Failed reading temperature from DHT"));
|
||||
} else if (temperature != lastTemp)
|
||||
{
|
||||
lastTemp = temperature;
|
||||
if (!metric)
|
||||
{
|
||||
temperature = dht.toFahrenheit(temperature);
|
||||
}
|
||||
send(msgTemp.set(temperature, 1));
|
||||
wait(DWELL_TIME);
|
||||
DEBUG_PRINT(F("Temperature is: "));
|
||||
DEBUG_PRINTLN(temperature);
|
||||
}
|
||||
float humidity = dht.getHumidity();;
|
||||
if (isnan(humidity))
|
||||
{
|
||||
DEBUG_PRINTLN(F("Failed reading humidity from DHT"));
|
||||
} else if (humidity != lastHum)
|
||||
{
|
||||
lastHum = humidity;
|
||||
send(msgHum.set(humidity, 1));
|
||||
wait(DWELL_TIME);
|
||||
DEBUG_PRINT(F("Humidity is: "));
|
||||
DEBUG_PRINTLN(humidity);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//
|
||||
#ifdef LUX_ON
|
||||
void doLUX(void)
|
||||
{
|
||||
unsigned int lux = lightSensor.readLightLevel();// Get Lux value
|
||||
DEBUG_PRINT(F("Current LUX Level: "));
|
||||
DEBUG_PRINTLN(lux);
|
||||
heartbeat++;
|
||||
if (lux != lastlux || heartbeat > 10)
|
||||
{
|
||||
send(msg.set(lux));
|
||||
lastlux = lux;
|
||||
}
|
||||
if (heartbeat > 10)
|
||||
{
|
||||
heartbeat = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//
|
||||
void sensorTipped()
|
||||
{
|
||||
unsigned long thisTipTime = millis();
|
||||
if (thisTipTime - lastTipTime > 100UL)
|
||||
{
|
||||
rainBucket[0] += CALIBRATE_FACTOR; // adds CALIBRATE_FACTOR hundredths of unit each tip
|
||||
wasTippedBuffer++;
|
||||
}
|
||||
lastTipTime = thisTipTime;
|
||||
}
|
||||
//
|
||||
int rainTotal(int hours)
|
||||
{
|
||||
int total = 0;
|
||||
for ( int i = 0; i <= hours; i++)
|
||||
{
|
||||
total += rainBucket [i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
void updateSerialData(int x)
|
||||
{
|
||||
DEBUG_PRINT(F("Rain last "));
|
||||
DEBUG_PRINT(x);
|
||||
DEBUG_PRINTLN(F(" hours: "));
|
||||
float tipCount = 0;
|
||||
for (int i = 0; i < x; i++)
|
||||
{
|
||||
tipCount = tipCount + rainBucket [i];
|
||||
}
|
||||
tipCount = tipCount / 100;
|
||||
DEBUG_PRINTLN(tipCount);
|
||||
}
|
||||
|
||||
void loadRainArray(int value) // retrieve stored rain array from EEPROM on powerup
|
||||
{
|
||||
for (int i = 0; i < RAIN_BUCKET_SIZE; i++)
|
||||
{
|
||||
value = value - 2;
|
||||
if (value < EEPROM_BUFFER_LOCATION)
|
||||
{
|
||||
value = EEPROM_BUFFER_LOCATION + E_BUFFER_LENGTH;
|
||||
}
|
||||
DEBUG_PRINT(F("EEPROM location: "));
|
||||
DEBUG_PRINTLN(value);
|
||||
byte rainValueHigh = loadState(value);
|
||||
byte rainValueLow = loadState(value + 1);
|
||||
unsigned int rainValue = rainValueHigh << 8;
|
||||
rainValue |= rainValueLow;
|
||||
rainBucket[i + 1] = rainValue;
|
||||
//
|
||||
DEBUG_PRINT(F("rainBucket[ value: "));
|
||||
DEBUG_PRINT(i + 1);
|
||||
DEBUG_PRINT(F("] value: "));
|
||||
DEBUG_PRINTLN(rainBucket[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
void transmitRainData(void)
|
||||
{
|
||||
DEBUG_PRINT(F("In transmitRainData. currentHour = "));
|
||||
DEBUG_PRINTLN(currentHour);
|
||||
int rainUpdateTotal = 0;
|
||||
for (int i = currentHour; i >= 0; i--)
|
||||
{
|
||||
rainUpdateTotal += rainBucket[i];
|
||||
DEBUG_PRINT(F("Adding rainBucket["));
|
||||
DEBUG_PRINT(i);
|
||||
DEBUG_PRINTLN(F("] to rainUpdateTotal."));
|
||||
}
|
||||
DEBUG_PRINT(F("TX Day 1: rainUpdateTotal = "));
|
||||
DEBUG_PRINTLN((float)rainUpdateTotal / 100.0);
|
||||
send(msgRainVAR1.set((float)rainUpdateTotal / 100.0, 1)); //Send current day rain totals (resets at midnight)
|
||||
wait(DWELL_TIME);
|
||||
#ifdef USE_DAILY
|
||||
rainUpdateTotal = 0;
|
||||
#endif
|
||||
for (int i = currentHour + 24; i > currentHour; i--)
|
||||
{
|
||||
rainUpdateTotal += rainBucket[i];
|
||||
DEBUG_PRINT(F("Adding rainBucket["));
|
||||
DEBUG_PRINT(i);
|
||||
DEBUG_PRINTLN(F("] to rainUpdateTotal."));
|
||||
}
|
||||
DEBUG_PRINT(F("TX Day 2: rainUpdateTotal = "));
|
||||
DEBUG_PRINTLN((float)rainUpdateTotal / 100.0);
|
||||
send(msgRainVAR2.set((float)rainUpdateTotal / 100.0, 1));
|
||||
wait(DWELL_TIME);
|
||||
#ifdef USE_DAILY
|
||||
rainUpdateTotal = 0;
|
||||
#endif
|
||||
for (int i = currentHour + 48; i > currentHour + 24; i--)
|
||||
{
|
||||
rainUpdateTotal += rainBucket[i];
|
||||
DEBUG_PRINT(F("Adding rainBucket["));
|
||||
DEBUG_PRINT(i);
|
||||
DEBUG_PRINTLN(F("] to rainUpdateTotal."));
|
||||
}
|
||||
DEBUG_PRINT(F("TX Day 3: rainUpdateTotal = "));
|
||||
DEBUG_PRINTLN((float)rainUpdateTotal / 100.0);
|
||||
send(msgRainVAR3.set((float)rainUpdateTotal / 100.0, 1));
|
||||
wait(DWELL_TIME);
|
||||
#ifdef USE_DAILY
|
||||
rainUpdateTotal = 0;
|
||||
#endif
|
||||
for (int i = currentHour + 72; i > currentHour + 48; i--)
|
||||
{
|
||||
rainUpdateTotal += rainBucket[i];
|
||||
DEBUG_PRINT(F("Adding rainBucket["));
|
||||
DEBUG_PRINT(i);
|
||||
DEBUG_PRINTLN(F("] to rainUpdateTotal."));
|
||||
}
|
||||
DEBUG_PRINT(F("TX Day 4: rainUpdateTotal = "));
|
||||
DEBUG_PRINTLN((float)rainUpdateTotal / 100.0);
|
||||
send(msgRainVAR4.set((float)rainUpdateTotal / 100.0, 1));
|
||||
wait(DWELL_TIME);
|
||||
#ifdef USE_DAILY
|
||||
rainUpdateTotal = 0;
|
||||
#endif
|
||||
for (int i = currentHour + 96; i > currentHour + 72; i--)
|
||||
{
|
||||
rainUpdateTotal += rainBucket[i];
|
||||
DEBUG_PRINT(F("Adding rainBucket["));
|
||||
DEBUG_PRINT(i);
|
||||
DEBUG_PRINTLN(F("] to rainUpdateTotal."));
|
||||
}
|
||||
DEBUG_PRINT(F("TX Day 5: rainUpdateTotal = "));
|
||||
DEBUG_PRINTLN((float)rainUpdateTotal / 100.0);
|
||||
send(msgRainVAR5.set((float)rainUpdateTotal / 100.0, 1));
|
||||
wait(DWELL_TIME);
|
||||
}
|
||||
|
||||
void getVariables(const MyMessage &message)
|
||||
{
|
||||
if (message.sensor == CHILD_ID_RAIN_LOG)
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
else if (message.sensor == CHILD_ID_TRIPPED_INDICATOR)
|
||||
{
|
||||
if (message.type == V_VAR1)
|
||||
{
|
||||
rainWindow = atoi(message.data);
|
||||
if (rainWindow > 120)
|
||||
{
|
||||
rainWindow = 120;
|
||||
}
|
||||
else if (rainWindow < 1)
|
||||
{
|
||||
rainWindow = 1;
|
||||
}
|
||||
if (rainWindow != atoi(message.data)) // if I changed the value back inside the boundries, push that number back to Vera
|
||||
{
|
||||
send(msgTrippedVar1.set(rainWindow));
|
||||
}
|
||||
}
|
||||
else if (message.type == V_VAR2)
|
||||
{
|
||||
rainSensorThreshold = atoi(message.data);
|
||||
if (rainSensorThreshold > 10000)
|
||||
{
|
||||
rainSensorThreshold = 10000;
|
||||
}
|
||||
else if (rainSensorThreshold < 1)
|
||||
{
|
||||
rainSensorThreshold = 1;
|
||||
}
|
||||
if (rainSensorThreshold != atoi(message.data)) // if I changed the value back inside the boundries, push that number back to Vera
|
||||
{
|
||||
send(msgTrippedVar2.set(rainSensorThreshold));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void prettyFade(void)
|
||||
{
|
||||
float val = (exp(sin(millis() / 2000.0 * PI)) - 0.36787944) * 108.0;
|
||||
analogWrite(ledPin, val);
|
||||
}
|
||||
|
||||
void slowFlash(void)
|
||||
{
|
||||
static boolean ledState = true;
|
||||
static unsigned long pulseStart = millis();
|
||||
if (millis() - pulseStart < 100UL)
|
||||
{
|
||||
digitalWrite(ledPin, !ledState);
|
||||
pulseStart = millis();
|
||||
}
|
||||
}
|
||||
|
||||
void receiveTime(unsigned long time)
|
||||
{
|
||||
DEBUG_PRINTLN(F("Time received..."));
|
||||
setTime(time);
|
||||
char theTime[6];
|
||||
sprintf(theTime, "%d:%2d", hour(), minute());
|
||||
DEBUG_PRINTLN(theTime);
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Example sketch showing how to request time from controller which is stored in RTC module
|
||||
* The time and temperature (DS3231/DS3232) is shown on an attached Crystal LCD display
|
||||
*
|
||||
*
|
||||
* Wiring (radio wiring on www.mysensors.org)
|
||||
* ------------------------------------
|
||||
* Arduino RTC-Module I2C Display
|
||||
* ------------------------------------
|
||||
* GND GND GND
|
||||
* +5V VCC VCC
|
||||
* A4 SDA SDA
|
||||
* A5 SCL SCL
|
||||
*
|
||||
* http://www.mysensors.org/build/display
|
||||
*
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <Time.h>
|
||||
#include <DS3232RTC.h> // A DS3231/DS3232 library
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
boolean timeReceived = false;
|
||||
unsigned long lastUpdate=0, lastRequest=0;
|
||||
|
||||
// Initialize display. Google the correct settings for your display.
|
||||
// The follwoing setting should work for the recommended display in the MySensors "shop".
|
||||
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("RTC Clock", "1.0");
|
||||
|
||||
// the function to get the time from the RTC
|
||||
setSyncProvider(RTC.get);
|
||||
|
||||
// Request latest time from controller at startup
|
||||
requestTime(receiveTime);
|
||||
|
||||
// initialize the lcd for 16 chars 2 lines and turn on backlight
|
||||
lcd.begin(16,2);
|
||||
}
|
||||
|
||||
// This is called when a new time value was received
|
||||
void receiveTime(unsigned long controllerTime) {
|
||||
// Ok, set incoming time
|
||||
Serial.print("Time value received: ");
|
||||
Serial.println(controllerTime);
|
||||
RTC.set(controllerTime); // this sets the RTC to the time from controller - which we do want periodically
|
||||
timeReceived = true;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
unsigned long now = millis();
|
||||
|
||||
// If no time has been received yet, request it every 10 second from controller
|
||||
// When time has been received, request update every hour
|
||||
if ((!timeReceived && (now-lastRequest) > (10UL*1000UL))
|
||||
|| (timeReceived && (now-lastRequest) > (60UL*1000UL*60UL))) {
|
||||
// Request time from controller.
|
||||
Serial.println("requesting time");
|
||||
requestTime(receiveTime);
|
||||
lastRequest = now;
|
||||
}
|
||||
|
||||
// Update display every second
|
||||
if (now-lastUpdate > 1000) {
|
||||
updateDisplay();
|
||||
lastUpdate = now;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void updateDisplay(){
|
||||
tmElements_t tm;
|
||||
RTC.read(tm);
|
||||
|
||||
// Print date and time
|
||||
lcd.home();
|
||||
lcd.print(tm.Day);
|
||||
lcd.print("/");
|
||||
lcd.print(tm.Month);
|
||||
// lcd.print(" ");
|
||||
// lcd.print(tmYearToCalendar(tm.Year)-2000);
|
||||
|
||||
lcd.print(" ");
|
||||
printDigits(tm.Hour);
|
||||
lcd.print(":");
|
||||
printDigits(tm.Minute);
|
||||
lcd.print(":");
|
||||
printDigits(tm.Second);
|
||||
|
||||
// Go to next line and print temperature
|
||||
lcd.setCursor ( 0, 1 );
|
||||
lcd.print("Temp: ");
|
||||
lcd.print(RTC.temperature()/4);
|
||||
lcd.write(223); // Degree-sign
|
||||
lcd.print("C");
|
||||
}
|
||||
|
||||
|
||||
void printDigits(int digits){
|
||||
if(digits < 10)
|
||||
lcd.print('0');
|
||||
lcd.print(digits);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Example sketch showing how to control physical relays.
|
||||
* This example will remember relay state after power failure.
|
||||
* http://www.mysensors.org/build/relay
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
// Enable repeater functionality for this node
|
||||
#define MY_REPEATER_FEATURE
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
|
||||
#define NUMBER_OF_RELAYS 1 // Total number of attached relays
|
||||
#define RELAY_ON 1 // GPIO value to write to turn on attached relay
|
||||
#define RELAY_OFF 0 // GPIO value to write to turn off attached relay
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize library and add callback for incoming messages
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Relay", "1.0");
|
||||
|
||||
// Fetch relay status
|
||||
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
present(sensor, S_LIGHT);
|
||||
// Then set relay pins in output mode
|
||||
pinMode(pin, OUTPUT);
|
||||
// Set relay to last known state (using eeprom storage)
|
||||
digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
// We only expect one type of message from controller. But we better check anyway.
|
||||
if (message.type==V_LIGHT) {
|
||||
// Change relay state
|
||||
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
|
||||
// Store state in eeprom
|
||||
saveState(message.sensor, message.getBool());
|
||||
// Write some debug info
|
||||
Serial.print("Incoming change for sensor:");
|
||||
Serial.print(message.sensor);
|
||||
Serial.print(", New status: ");
|
||||
Serial.println(message.getBool());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Example sketch for a "light switch" where you can control light or something
|
||||
* else from both HA controller and a local physical button
|
||||
* (connected between digital pin 3 and GND).
|
||||
* This node also works as a repeader for other nodes
|
||||
* http://www.mysensors.org/build/relay
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
// Enabled repeater feature for this node
|
||||
#define MY_REPEATER_FEATURE
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <Bounce2.h>
|
||||
|
||||
#define RELAY_PIN 4 // Arduino Digital I/O pin number for relay
|
||||
#define BUTTON_PIN 3 // Arduino Digital I/O pin number for button
|
||||
#define CHILD_ID 1 // Id of the sensor child
|
||||
#define RELAY_ON 1
|
||||
#define RELAY_OFF 0
|
||||
|
||||
Bounce debouncer = Bounce();
|
||||
int oldValue=0;
|
||||
bool state;
|
||||
|
||||
MyMessage msg(CHILD_ID,V_LIGHT);
|
||||
|
||||
void setup()
|
||||
{
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Relay & Button", "1.0");
|
||||
|
||||
// Setup the button
|
||||
pinMode(BUTTON_PIN,INPUT);
|
||||
// Activate internal pull-up
|
||||
digitalWrite(BUTTON_PIN,HIGH);
|
||||
|
||||
// After setting up the button, setup debouncer
|
||||
debouncer.attach(BUTTON_PIN);
|
||||
debouncer.interval(5);
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
present(CHILD_ID, S_LIGHT);
|
||||
|
||||
// Make sure relays are off when starting up
|
||||
digitalWrite(RELAY_PIN, RELAY_OFF);
|
||||
// Then set relay pins in output mode
|
||||
pinMode(RELAY_PIN, OUTPUT);
|
||||
|
||||
// Set relay to last known state (using eeprom storage)
|
||||
state = loadState(CHILD_ID);
|
||||
digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Example on how to asynchronously check for new messages from gw
|
||||
*/
|
||||
void loop()
|
||||
{
|
||||
debouncer.update();
|
||||
// Get the update value
|
||||
int value = debouncer.read();
|
||||
if (value != oldValue && value==0) {
|
||||
send(msg.set(state?false:true), true); // Send new state and request ack back
|
||||
}
|
||||
oldValue = value;
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
// We only expect one type of message from controller. But we better check anyway.
|
||||
if (message.isAck()) {
|
||||
Serial.println("This is an ack from gateway");
|
||||
}
|
||||
|
||||
if (message.type == V_LIGHT) {
|
||||
// Change relay state
|
||||
state = message.getBool();
|
||||
digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
|
||||
// Store state in eeprom
|
||||
saveState(CHILD_ID, state);
|
||||
|
||||
// Write some debug info
|
||||
Serial.print("Incoming change for sensor:");
|
||||
Serial.print(message.sensor);
|
||||
Serial.print(", New status: ");
|
||||
Serial.println(message.getBool());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Example sketch showing how to create a node thay repeates messages
|
||||
* from nodes far from gateway back to gateway.
|
||||
* It is important that nodes that has enabled repeater mode calls
|
||||
* process() frequently. Repeaters should never sleep.
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
// Enabled repeater feature for this node
|
||||
#define MY_REPEATER_FEATURE
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
//Send the sensor node sketch version information to the gateway
|
||||
sendSketchInfo("Repeater Node", "1.0");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,379 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Secret Knock Sensor
|
||||
* http://www.mysensors.org/build/knock
|
||||
*
|
||||
* See original instructions here (note: The MySensors adopted code might differ in wiring. The instructions below is correct):
|
||||
* https://learn.adafruit.com/secret-knock-activated-drawer-lock/
|
||||
* Version 13.10.31 Built with Arduino IDE 1.0.5
|
||||
*
|
||||
* By Steve Hoefer http://grathio.com
|
||||
* Adapted to MySensors by Henrik Ekblad
|
||||
*
|
||||
* Licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0
|
||||
* http://creativecommons.org/licenses/by-nc-sa/3.0/us/
|
||||
* (In short: Do what you want, as long as you credit me, don't relicense it, and don't sell it or use it in anything you sell without contacting me.)
|
||||
*
|
||||
* ------Wiring------
|
||||
* Pin 0: Program button used for recording a new Knock (connect Pin0 -> button -> GND)
|
||||
* Pin 1: Optional: Connect LED here (remember resisor in series)
|
||||
* Pin 2: Optional: Piezo element (for beeps).
|
||||
* Pin 5: A sound sensor (digital output) for sensing knocks. See MySensors purchase guide. I used this: http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=2&pub=5575069610&toolid=10001&campid=5337433187&customid=&icep_item=200941260251&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg
|
||||
* Pin 4: Connects to either 1. Relay which open door or lock or
|
||||
* 2. transistor that opens a solenoid lock when HIGH (see adafruit guide for this option).
|
||||
*
|
||||
*
|
||||
* Connect radio according as usual(you can skip IRQ pin)
|
||||
* http://www.mysensors.org/build/connect_radio
|
||||
*/
|
||||
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
|
||||
#define CHILD_ID 99 // Id of the sensor child
|
||||
|
||||
const byte eepromValid = 121; // If the first byte in eeprom is this then the data is valid.
|
||||
|
||||
/*Pin definitions*/
|
||||
const int programButton = 0; // (Digital 0) Record A New Knock button.
|
||||
const int ledPin = 1; // (Digital 1) The LED pin (if any)
|
||||
const int knockSensor = 5; // (Digital 5) for using the microphone digital output (tune knob to register knock)
|
||||
const int audioOut = 2; // (Digital 2) for using the peizo as an output device. (Thing that goes beep.)
|
||||
const int lockPin = 4; // (Digital 4) The pin that activates the relay/solenoid lock.
|
||||
|
||||
/*Tuning constants. Changing the values below changes the behavior of the device.*/
|
||||
int threshold = 3; // Minimum signal from the piezo to register as a knock. Higher = less sensitive. Typical values 1 - 10
|
||||
const int rejectValue = 25; // If an individual knock is off by this percentage of a knock we don't unlock. Typical values 10-30
|
||||
const int averageRejectValue = 15; // If the average timing of all the knocks is off by this percent we don't unlock. Typical values 5-20
|
||||
const int knockFadeTime = 150; // Milliseconds we allow a knock to fade before we listen for another one. (Debounce timer.)
|
||||
const int lockOperateTime = 2500; // Milliseconds that we operate the lock solenoid latch before releasing it.
|
||||
const int maximumKnocks = 20; // Maximum number of knocks to listen for.
|
||||
const int knockComplete = 1200; // Longest time to wait for a knock before we assume that it's finished. (milliseconds)
|
||||
|
||||
byte secretCode[maximumKnocks] = {50, 25, 25, 50, 100, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // Initial setup: "Shave and a Hair Cut, two bits."
|
||||
int knockReadings[maximumKnocks]; // When someone knocks this array fills with the delays between knocks.
|
||||
int knockSensorValue = 0; // Last reading of the knock sensor.
|
||||
boolean programModeActive = false; // True if we're trying to program a new knock.
|
||||
|
||||
bool lockStatus;
|
||||
|
||||
MyMessage lockMsg(CHILD_ID, V_LOCK_STATUS);
|
||||
|
||||
void setup() {
|
||||
|
||||
pinMode(ledPin, OUTPUT);
|
||||
pinMode(knockSensor, INPUT);
|
||||
pinMode(lockPin, OUTPUT);
|
||||
pinMode(programButton, INPUT);
|
||||
digitalWrite(programButton, HIGH); // Enable internal pull up
|
||||
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
sendSketchInfo("Secret Knock", "1.0");
|
||||
present(CHILD_ID, S_LOCK);
|
||||
|
||||
readSecretKnock(); // Load the secret knock (if any) from EEPROM.
|
||||
|
||||
digitalWrite(lockPin, HIGH); // Unlock the door for a bit when we power up. For system check and to allow a way in if the key is forgotten
|
||||
delay(500); // Wait a short time
|
||||
|
||||
lockStatus = loadState(0); // Read last lock status from eeprom
|
||||
setLockState(lockStatus, true); // Now set the last known state and send it to controller
|
||||
|
||||
delay(500); // This delay is here because the solenoid lock returning to place can otherwise trigger and inadvertent knock.
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Listen for any knock at all.
|
||||
knockSensorValue = digitalRead(knockSensor);
|
||||
if (digitalRead(programButton) == LOW){ // is the program button pressed?
|
||||
delay(100); // Cheap debounce.
|
||||
if (digitalRead(programButton) == LOW){
|
||||
if (programModeActive == false){ // If we're not in programming mode, turn it on.
|
||||
programModeActive = true; // Remember we're in programming mode.
|
||||
digitalWrite(ledPin, HIGH); // Turn on the red light too so the user knows we're programming.
|
||||
chirp(500, 1500); // And play a tone in case the user can't see the LED.
|
||||
chirp(500, 1000);
|
||||
} else { // If we are in programing mode, turn it off.
|
||||
programModeActive = false;
|
||||
digitalWrite(ledPin, LOW);
|
||||
chirp(500, 1000); // Turn off the programming LED and play a sad note.
|
||||
chirp(500, 1500);
|
||||
delay(500);
|
||||
}
|
||||
while (digitalRead(programButton) == LOW){
|
||||
delay(10); // Hang around until the button is released.
|
||||
}
|
||||
}
|
||||
delay(250); // Another cheap debounce. Longer because releasing the button can sometimes be sensed as a knock.
|
||||
}
|
||||
|
||||
|
||||
if (knockSensorValue == 0) {
|
||||
if (programModeActive == true){ // Blink the LED when we sense a knock.
|
||||
digitalWrite(ledPin, LOW);
|
||||
} else {
|
||||
digitalWrite(ledPin, HIGH);
|
||||
}
|
||||
knockDelay();
|
||||
if (programModeActive == true){ // Un-blink the LED.
|
||||
digitalWrite(ledPin, HIGH);
|
||||
} else {
|
||||
digitalWrite(ledPin, LOW);
|
||||
}
|
||||
listenToSecretKnock(); // We have our first knock. Go and see what other knocks are in store...
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Records the timing of knocks.
|
||||
void listenToSecretKnock(){
|
||||
int i = 0;
|
||||
// First reset the listening array.
|
||||
for (i=0; i < maximumKnocks; i++){
|
||||
knockReadings[i] = 0;
|
||||
}
|
||||
|
||||
int currentKnockNumber = 0; // Position counter for the array.
|
||||
int startTime = millis(); // Reference for when this knock started.
|
||||
int now = millis();
|
||||
|
||||
do { // Listen for the next knock or wait for it to timeout.
|
||||
knockSensorValue = digitalRead(knockSensor);
|
||||
|
||||
if (knockSensorValue == 0){ // Here's another knock. Save the time between knocks.
|
||||
Serial.println("knock");
|
||||
|
||||
now=millis();
|
||||
knockReadings[currentKnockNumber] = now - startTime;
|
||||
currentKnockNumber ++;
|
||||
startTime = now;
|
||||
|
||||
if (programModeActive==true){ // Blink the LED when we sense a knock.
|
||||
digitalWrite(ledPin, LOW);
|
||||
} else {
|
||||
digitalWrite(ledPin, HIGH);
|
||||
}
|
||||
knockDelay();
|
||||
if (programModeActive == true){ // Un-blink the LED.
|
||||
digitalWrite(ledPin, HIGH);
|
||||
} else {
|
||||
digitalWrite(ledPin, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
now = millis();
|
||||
|
||||
// Stop listening if there are too many knocks or there is too much time between knocks.
|
||||
} while ((now-startTime < knockComplete) && (currentKnockNumber < maximumKnocks));
|
||||
Serial.println("end");
|
||||
|
||||
//we've got our knock recorded, lets see if it's valid
|
||||
if (programModeActive == false){ // Only do this if we're not recording a new knock.
|
||||
if (validateKnock() == true){
|
||||
// Lock/unlock door
|
||||
chirp(500, 1500); // And play a tone in case the user can't see the LED.
|
||||
chirp(500, 1000);
|
||||
setLockState(!lockStatus, true);
|
||||
} else {
|
||||
Serial.println("fail unlock");
|
||||
|
||||
// knock is invalid. Blink the LED as a warning to others.
|
||||
for (i=0; i < 4; i++){
|
||||
digitalWrite(ledPin, HIGH);
|
||||
delay(50);
|
||||
digitalWrite(ledPin, LOW);
|
||||
delay(50);
|
||||
}
|
||||
}
|
||||
} else { // If we're in programming mode we still validate the lock because it makes some numbers we need, we just don't do anything with the return.
|
||||
validateKnock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Unlocks the door.
|
||||
void setLockState(bool state, bool doSend){
|
||||
if (state)
|
||||
Serial.println("open lock");
|
||||
else
|
||||
Serial.println("close lock");
|
||||
if (doSend)
|
||||
send(lockMsg.set(state));
|
||||
|
||||
digitalWrite(ledPin, state);
|
||||
digitalWrite(lockPin, state);
|
||||
saveState(0,state);
|
||||
lockStatus = state;
|
||||
delay(500); // This delay is here because releasing the latch can cause a vibration that will be sensed as a knock.
|
||||
}
|
||||
|
||||
// Checks to see if our knock matches the secret.
|
||||
// Returns true if it's a good knock, false if it's not.
|
||||
boolean validateKnock(){
|
||||
int i = 0;
|
||||
|
||||
int currentKnockCount = 0;
|
||||
int secretKnockCount = 0;
|
||||
int maxKnockInterval = 0; // We use this later to normalize the times.
|
||||
|
||||
for (i=0;i<maximumKnocks;i++){
|
||||
if (knockReadings[i] > 0){
|
||||
currentKnockCount++;
|
||||
}
|
||||
if (secretCode[i] > 0){
|
||||
secretKnockCount++;
|
||||
}
|
||||
|
||||
if (knockReadings[i] > maxKnockInterval){ // Collect normalization data while we're looping.
|
||||
maxKnockInterval = knockReadings[i];
|
||||
}
|
||||
}
|
||||
|
||||
// If we're recording a new knock, save the info and get out of here.
|
||||
if (programModeActive == true){
|
||||
for (i=0; i < maximumKnocks; i++){ // Normalize the time between knocks. (the longest time = 100)
|
||||
secretCode[i] = map(knockReadings[i], 0, maxKnockInterval, 0, 100);
|
||||
}
|
||||
saveSecretKnock(); // save the result to EEPROM
|
||||
programModeActive = false;
|
||||
playbackKnock(maxKnockInterval);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentKnockCount != secretKnockCount){ // Easiest check first. If the number of knocks is wrong, don't unlock.
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Now we compare the relative intervals of our knocks, not the absolute time between them.
|
||||
(ie: if you do the same pattern slow or fast it should still open the door.)
|
||||
This makes it less picky, which while making it less secure can also make it
|
||||
less of a pain to use if you're tempo is a little slow or fast.
|
||||
*/
|
||||
int totaltimeDifferences = 0;
|
||||
int timeDiff = 0;
|
||||
for (i=0; i < maximumKnocks; i++){ // Normalize the times
|
||||
knockReadings[i]= map(knockReadings[i], 0, maxKnockInterval, 0, 100);
|
||||
timeDiff = abs(knockReadings[i] - secretCode[i]);
|
||||
if (timeDiff > rejectValue){ // Individual value too far out of whack. No access for this knock!
|
||||
return false;
|
||||
}
|
||||
totaltimeDifferences += timeDiff;
|
||||
}
|
||||
// It can also fail if the whole thing is too inaccurate.
|
||||
if (totaltimeDifferences / secretKnockCount > averageRejectValue){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// reads the secret knock from EEPROM. (if any.)
|
||||
void readSecretKnock(){
|
||||
byte reading;
|
||||
reading = loadState(1);
|
||||
if (reading == eepromValid){ // only read EEPROM if the signature byte is correct.
|
||||
for (int i=0; i < maximumKnocks ;i++){
|
||||
secretCode[i] = loadState(i+2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//saves a new pattern too eeprom
|
||||
void saveSecretKnock(){
|
||||
saveState(1, 0); // clear out the signature. That way we know if we didn't finish the write successfully.
|
||||
for (int i=0; i < maximumKnocks; i++){
|
||||
saveState(i+2, secretCode[i]);
|
||||
}
|
||||
saveState(1, eepromValid); // all good. Write the signature so we'll know it's all good.
|
||||
}
|
||||
|
||||
// Plays back the pattern of the knock in blinks and beeps
|
||||
void playbackKnock(int maxKnockInterval){
|
||||
digitalWrite(ledPin, LOW);
|
||||
delay(1000);
|
||||
digitalWrite(ledPin, HIGH);
|
||||
chirp(200, 1800);
|
||||
for (int i = 0; i < maximumKnocks ; i++){
|
||||
digitalWrite(ledPin, LOW);
|
||||
// only turn it on if there's a delay
|
||||
if (secretCode[i] > 0){
|
||||
delay(map(secretCode[i], 0, 100, 0, maxKnockInterval)); // Expand the time back out to what it was. Roughly.
|
||||
digitalWrite(ledPin, HIGH);
|
||||
chirp(200, 1800);
|
||||
}
|
||||
}
|
||||
digitalWrite(ledPin, LOW);
|
||||
}
|
||||
|
||||
// Deals with the knock delay thingy.
|
||||
void knockDelay(){
|
||||
int itterations = (knockFadeTime / 20); // Wait for the peak to dissipate before listening to next one.
|
||||
for (int i=0; i < itterations; i++){
|
||||
delay(10);
|
||||
analogRead(knockSensor); // This is done in an attempt to defuse the analog sensor's capacitor that will give false readings on high impedance sensors.
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
// Plays a non-musical tone on the piezo.
|
||||
// playTime = milliseconds to play the tone
|
||||
// delayTime = time in microseconds between ticks. (smaller=higher pitch tone.)
|
||||
void chirp(int playTime, int delayTime){
|
||||
long loopTime = (playTime * 1000L) / delayTime;
|
||||
pinMode(audioOut, OUTPUT);
|
||||
for(int i=0; i < loopTime; i++){
|
||||
digitalWrite(audioOut, HIGH);
|
||||
delayMicroseconds(delayTime);
|
||||
digitalWrite(audioOut, LOW);
|
||||
}
|
||||
pinMode(audioOut, INPUT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
// We only expect one type of message from controller. But we better check anyway.
|
||||
if (message.type==V_LOCK_STATUS) {
|
||||
// Change relay state
|
||||
setLockState(message.getBool(), false);
|
||||
|
||||
// Write some debug info
|
||||
Serial.print("Incoming lock status:");
|
||||
Serial.println(message.getBool());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Patrick "Anticimex" Fallberg <patrick@fallberg.net>
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Example sketch showing how to securely control locks.
|
||||
* This example will remember lock state even after power failure.
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
// Select soft/hardware signing method
|
||||
#define MY_SIGNING_SOFT // Software signing enabled
|
||||
//#define MY_SIGNING_ATSHA204 // Hardware signing using ATSHA204A
|
||||
|
||||
// Enable node whitelisting
|
||||
//#define MY_SIGNING_NODE_WHITELISTING {{.nodeId = GATEWAY_ADDRESS,.serial = {0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01}}}
|
||||
// Enable this if you want destination node to sign all messages sent to this node. Default is not to require signing.
|
||||
//#define MY_SIGNING_REQUEST_SIGNATURES
|
||||
|
||||
|
||||
// SETTINGS FOR MY_SIGNING_SOFT
|
||||
// Set the soft_serial value to an arbitrary value for proper security (9 bytes)
|
||||
#define MY_SIGNING_SOFT_SERIAL 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09
|
||||
// Key to use for HMAC calculation in soft signing (32 bytes)
|
||||
#define MY_SIGNING_SOFT_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
|
||||
#define MY_SIGNING_SOFT_RANDOMSEED_PIN 7
|
||||
|
||||
// SETTINGS FOR MY_SIGNING_ATSHA204
|
||||
#define MY_SIGNING_ATSHA204_PIN 17 // A3 - pin where ATSHA204 is attached
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
|
||||
#define LOCK_1 3 // Arduino Digital I/O pin number for first lock (second on pin+1 etc)
|
||||
#define NOF_LOCKS 1 // Total number of attached locks
|
||||
#define LOCK_LOCK 1 // GPIO value to write to lock attached lock
|
||||
#define LOCK_UNLOCK 0 // GPIO value to write to unlock attached lock
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Add callback for incoming messages (signing is required)
|
||||
setIncomingCallback(incomingMessage);
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Secure Lock", "1.0");
|
||||
|
||||
// Fetch lock status
|
||||
for (int lock=1, pin=LOCK_1; lock<=NOF_LOCKS;lock++, pin++) {
|
||||
// Register all locks to gw (they will be created as child devices)
|
||||
present(lock, S_LOCK, "SecureActuator", false);
|
||||
// Then set lock pins in output mode
|
||||
pinMode(pin, OUTPUT);
|
||||
// Set lock to last known state (using eeprom storage)
|
||||
digitalWrite(pin, loadState(lock)?LOCK_LOCK:LOCK_UNLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
// We only expect one type of message from controller. But we better check anyway.
|
||||
if (message.type==V_LOCK_STATUS && message.sensor<=NOF_LOCKS) {
|
||||
// Change relay state
|
||||
digitalWrite(message.sensor-1+LOCK_1, message.getBool()?LOCK_LOCK:LOCK_UNLOCK);
|
||||
// Store state in eeprom
|
||||
saveState(message.sensor, message.getBool());
|
||||
// Write some debug info
|
||||
Serial.print("Incoming change for lock:");
|
||||
Serial.print(message.sensor);
|
||||
Serial.print(", New status: ");
|
||||
Serial.println(message.getBool());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// Sensebender Micro board
|
||||
// Simple blinking FW to test OTA updates
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable repeater feature
|
||||
#define MY_REPEATER_FEATURE
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define SketchName "Sensebender Blink"
|
||||
#define SketchVersion "20150721"
|
||||
#define NODE_ID AUTO
|
||||
#define CHILD_ID_COUNTER 0
|
||||
|
||||
#define LED_PIN A2
|
||||
#define BLINK_INTERVAL 500
|
||||
#define REPORT_TIME 5000L
|
||||
|
||||
unsigned long lastUpdate = 0;
|
||||
boolean LED_STATUS = false;
|
||||
|
||||
MyMessage msgCounter(CHILD_ID_COUNTER, V_VAR1);
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
digitalWrite(LED_PIN, LED_STATUS);
|
||||
|
||||
sendSketchInfo(SketchName, SketchVersion);
|
||||
|
||||
present(CHILD_ID_COUNTER, S_CUSTOM,"Millis()");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
wait(BLINK_INTERVAL);
|
||||
LED_STATUS ^= true;
|
||||
digitalWrite(LED_PIN, LED_STATUS);
|
||||
|
||||
if (millis()-lastUpdate > REPORT_TIME) {
|
||||
send(msgCounter.set( millis() ));
|
||||
lastUpdate = millis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,422 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Thomas Bowman Mørch
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Default sensor sketch for Sensebender Micro module
|
||||
* Act as a temperature / humidity sensor by default.
|
||||
*
|
||||
* If A0 is held low while powering on, it will enter testmode, which verifies all on-board peripherals
|
||||
*
|
||||
* Battery voltage is as battery percentage (Internal message), and optionally as a sensor value (See defines below)
|
||||
*
|
||||
*
|
||||
* Version 1.3 - Thomas Bowman Mørch
|
||||
* Improved transmission logic, eliminating spurious transmissions (when temperatuere / humidity fluctuates 1 up and down between measurements)
|
||||
*
|
||||
* Added OTA boot mode, need to hold A1 low while applying power. (uses slightly more power as it's waiting for bootloader messages)
|
||||
*
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
//#define MY_DEBUG
|
||||
|
||||
// Define a static node address, remove if you want auto address assignment
|
||||
//#deine MY_NODE_ID 3
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <Wire.h>
|
||||
#include <SI7021.h>
|
||||
#include "drivers/SPIFlash/SPIFlash.cpp"
|
||||
#include <EEPROM.h>
|
||||
#include <sha204_lib_return_codes.h>
|
||||
#include <sha204_library.h>
|
||||
#include <RunningAverage.h>
|
||||
//#include <avr/power.h>
|
||||
|
||||
// Uncomment the line below, to transmit battery voltage as a normal sensor value
|
||||
//#define BATT_SENSOR 199
|
||||
|
||||
#define RELEASE "1.3"
|
||||
|
||||
#define AVERAGES 2
|
||||
|
||||
// Child sensor ID's
|
||||
#define CHILD_ID_TEMP 1
|
||||
#define CHILD_ID_HUM 2
|
||||
|
||||
// How many milli seconds between each measurement
|
||||
#define MEASURE_INTERVAL 60000
|
||||
|
||||
// How many milli seconds should we wait for OTA?
|
||||
#define OTA_WAIT_PERIOD 300
|
||||
|
||||
// FORCE_TRANSMIT_INTERVAL, this number of times of wakeup, the sensor is forced to report all values to the controller
|
||||
#define FORCE_TRANSMIT_INTERVAL 30
|
||||
|
||||
// When MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes.
|
||||
// Between the forced transmissions a tranmission will only occur if the measured value differs from the previous measurement
|
||||
|
||||
// HUMI_TRANSMIT_THRESHOLD tells how much the humidity should have changed since last time it was transmitted. Likewise with
|
||||
// TEMP_TRANSMIT_THRESHOLD for temperature threshold.
|
||||
#define HUMI_TRANSMIT_THRESHOLD 0.5
|
||||
#define TEMP_TRANSMIT_THRESHOLD 0.5
|
||||
|
||||
// Pin definitions
|
||||
#define TEST_PIN A0
|
||||
#define OTA_ENABLE A1
|
||||
#define LED_PIN A2
|
||||
#define ATSHA204_PIN 17 // A3
|
||||
|
||||
const int sha204Pin = ATSHA204_PIN;
|
||||
atsha204Class sha204(sha204Pin);
|
||||
|
||||
SI7021 humiditySensor;
|
||||
SPIFlash flash(8, 0x1F65);
|
||||
|
||||
// Sensor messages
|
||||
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
|
||||
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
|
||||
|
||||
#ifdef BATT_SENSOR
|
||||
MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE);
|
||||
#endif
|
||||
|
||||
// Global settings
|
||||
int measureCount = 0;
|
||||
int sendBattery = 0;
|
||||
boolean isMetric = true;
|
||||
boolean highfreq = true;
|
||||
boolean ota_enabled = false;
|
||||
boolean transmission_occured = false;
|
||||
|
||||
// Storage of old measurements
|
||||
float lastTemperature = -100;
|
||||
int lastHumidity = -100;
|
||||
long lastBattery = -100;
|
||||
|
||||
RunningAverage raHum(AVERAGES);
|
||||
|
||||
/****************************************************
|
||||
*
|
||||
* Setup code
|
||||
*
|
||||
****************************************************/
|
||||
void setup() {
|
||||
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.print(F("Sensebender Micro FW "));
|
||||
Serial.print(RELEASE);
|
||||
Serial.flush();
|
||||
|
||||
// First check if we should boot into test mode
|
||||
|
||||
pinMode(TEST_PIN,INPUT);
|
||||
digitalWrite(TEST_PIN, HIGH); // Enable pullup
|
||||
if (!digitalRead(TEST_PIN)) testMode();
|
||||
|
||||
pinMode(OTA_ENABLE, INPUT);
|
||||
digitalWrite(OTA_ENABLE, HIGH);
|
||||
if (!digitalRead(OTA_ENABLE)) {
|
||||
ota_enabled = true;
|
||||
}
|
||||
|
||||
// Make sure that ATSHA204 is not floating
|
||||
pinMode(ATSHA204_PIN, INPUT);
|
||||
digitalWrite(ATSHA204_PIN, HIGH);
|
||||
|
||||
digitalWrite(TEST_PIN,LOW);
|
||||
digitalWrite(OTA_ENABLE, LOW); // remove pullup, save some power.
|
||||
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
|
||||
humiditySensor.begin();
|
||||
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
|
||||
Serial.flush();
|
||||
Serial.println(F(" - Online!"));
|
||||
sendSketchInfo("Sensebender Micro", RELEASE);
|
||||
|
||||
present(CHILD_ID_TEMP,S_TEMP);
|
||||
present(CHILD_ID_HUM,S_HUM);
|
||||
|
||||
#ifdef BATT_SENSOR
|
||||
present(BATT_SENSOR, S_POWER);
|
||||
#endif
|
||||
|
||||
|
||||
isMetric = getConfig().isMetric;
|
||||
Serial.print(F("isMetric: ")); Serial.println(isMetric);
|
||||
raHum.clear();
|
||||
sendTempHumidityMeasurements(false);
|
||||
sendBattLevel(false);
|
||||
if (ota_enabled) Serial.println("OTA FW update enabled");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***********************************************
|
||||
*
|
||||
* Main loop function
|
||||
*
|
||||
***********************************************/
|
||||
void loop() {
|
||||
|
||||
measureCount ++;
|
||||
sendBattery ++;
|
||||
bool forceTransmit = false;
|
||||
transmission_occured = false;
|
||||
if ((measureCount == 5) && highfreq)
|
||||
{
|
||||
if (!ota_enabled) clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
|
||||
highfreq = false;
|
||||
}
|
||||
|
||||
if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission
|
||||
forceTransmit = true;
|
||||
measureCount = 0;
|
||||
}
|
||||
|
||||
sendTempHumidityMeasurements(forceTransmit);
|
||||
if (sendBattery > 60)
|
||||
{
|
||||
sendBattLevel(forceTransmit); // Not needed to send battery info that often
|
||||
sendBattery = 0;
|
||||
}
|
||||
|
||||
if (ota_enabled & transmission_occured) {
|
||||
wait(OTA_WAIT_PERIOD);
|
||||
}
|
||||
|
||||
sleep(MEASURE_INTERVAL);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************
|
||||
*
|
||||
* Sends temperature and humidity from Si7021 sensor
|
||||
*
|
||||
* Parameters
|
||||
* - force : Forces transmission of a value (even if it's the same as previous measurement)
|
||||
*
|
||||
*********************************************/
|
||||
void sendTempHumidityMeasurements(bool force)
|
||||
{
|
||||
bool tx = force;
|
||||
|
||||
si7021_env data = humiditySensor.getHumidityAndTemperature();
|
||||
|
||||
raHum.addValue(data.humidityPercent);
|
||||
|
||||
float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths)/100);
|
||||
float diffHum = abs(lastHumidity - raHum.getAverage());
|
||||
|
||||
Serial.print(F("TempDiff :"));Serial.println(diffTemp);
|
||||
Serial.print(F("HumDiff :"));Serial.println(diffHum);
|
||||
|
||||
if (isnan(diffHum)) tx = true;
|
||||
if (diffTemp > TEMP_TRANSMIT_THRESHOLD) tx = true;
|
||||
if (diffHum > HUMI_TRANSMIT_THRESHOLD) tx = true;
|
||||
|
||||
if (tx) {
|
||||
measureCount = 0;
|
||||
float temperature = (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0;
|
||||
|
||||
int humidity = data.humidityPercent;
|
||||
Serial.print("T: ");Serial.println(temperature);
|
||||
Serial.print("H: ");Serial.println(humidity);
|
||||
|
||||
send(msgTemp.set(temperature,1));
|
||||
send(msgHum.set(humidity));
|
||||
lastTemperature = temperature;
|
||||
lastHumidity = humidity;
|
||||
transmission_occured = true;
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************
|
||||
*
|
||||
* Sends battery information (battery percentage)
|
||||
*
|
||||
* Parameters
|
||||
* - force : Forces transmission of a value
|
||||
*
|
||||
*******************************************/
|
||||
void sendBattLevel(bool force)
|
||||
{
|
||||
if (force) lastBattery = -1;
|
||||
long vcc = readVcc();
|
||||
if (vcc != lastBattery) {
|
||||
lastBattery = vcc;
|
||||
|
||||
#ifdef BATT_SENSOR
|
||||
send(msgBatt.set(vcc));
|
||||
#endif
|
||||
|
||||
// Calculate percentage
|
||||
|
||||
vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at
|
||||
|
||||
long percent = vcc / 14.0;
|
||||
sendBatteryLevel(percent);
|
||||
transmission_occured = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************
|
||||
*
|
||||
* Internal battery ADC measuring
|
||||
*
|
||||
*******************************************/
|
||||
long readVcc() {
|
||||
// Read 1.1V reference against AVcc
|
||||
// set the reference to Vcc and the measurement to the internal 1.1V reference
|
||||
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
|
||||
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
|
||||
ADMUX = _BV(MUX5) | _BV(MUX0);
|
||||
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
|
||||
ADcdMUX = _BV(MUX3) | _BV(MUX2);
|
||||
#else
|
||||
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
|
||||
#endif
|
||||
|
||||
delay(2); // Wait for Vref to settle
|
||||
ADCSRA |= _BV(ADSC); // Start conversion
|
||||
while (bit_is_set(ADCSRA,ADSC)); // measuring
|
||||
|
||||
uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
|
||||
uint8_t high = ADCH; // unlocks both
|
||||
|
||||
long result = (high<<8) | low;
|
||||
|
||||
result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
|
||||
return result; // Vcc in millivolts
|
||||
|
||||
}
|
||||
|
||||
/****************************************************
|
||||
*
|
||||
* Verify all peripherals, and signal via the LED if any problems.
|
||||
*
|
||||
****************************************************/
|
||||
void testMode()
|
||||
{
|
||||
uint8_t rx_buffer[SHA204_RSP_SIZE_MAX];
|
||||
uint8_t ret_code;
|
||||
byte tests = 0;
|
||||
|
||||
digitalWrite(LED_PIN, HIGH); // Turn on LED.
|
||||
Serial.println(F(" - TestMode"));
|
||||
Serial.println(F("Testing peripherals!"));
|
||||
Serial.flush();
|
||||
Serial.print(F("-> SI7021 : "));
|
||||
Serial.flush();
|
||||
|
||||
if (humiditySensor.begin())
|
||||
{
|
||||
Serial.println(F("ok!"));
|
||||
tests ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(F("failed!"));
|
||||
}
|
||||
Serial.flush();
|
||||
|
||||
Serial.print(F("-> Flash : "));
|
||||
Serial.flush();
|
||||
if (flash.initialize())
|
||||
{
|
||||
Serial.println(F("ok!"));
|
||||
tests ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(F("failed!"));
|
||||
}
|
||||
Serial.flush();
|
||||
|
||||
|
||||
Serial.print(F("-> SHA204 : "));
|
||||
ret_code = sha204.sha204c_wakeup(rx_buffer);
|
||||
Serial.flush();
|
||||
if (ret_code != SHA204_SUCCESS)
|
||||
{
|
||||
Serial.print(F("Failed to wake device. Response: ")); Serial.println(ret_code, HEX);
|
||||
}
|
||||
Serial.flush();
|
||||
if (ret_code == SHA204_SUCCESS)
|
||||
{
|
||||
ret_code = sha204.getSerialNumber(rx_buffer);
|
||||
if (ret_code != SHA204_SUCCESS)
|
||||
{
|
||||
Serial.print(F("Failed to obtain device serial number. Response: ")); Serial.println(ret_code, HEX);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.print(F("Ok (serial : "));
|
||||
for (int i=0; i<9; i++)
|
||||
{
|
||||
if (rx_buffer[i] < 0x10)
|
||||
{
|
||||
Serial.print('0'); // Because Serial.print does not 0-pad HEX
|
||||
}
|
||||
Serial.print(rx_buffer[i], HEX);
|
||||
}
|
||||
Serial.println(")");
|
||||
tests ++;
|
||||
}
|
||||
|
||||
}
|
||||
Serial.flush();
|
||||
|
||||
Serial.println(F("Test finished"));
|
||||
|
||||
if (tests == 3)
|
||||
{
|
||||
Serial.println(F("Selftest ok!"));
|
||||
while (1) // Blink OK pattern!
|
||||
{
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
delay(200);
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
delay(200);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println(F("----> Selftest failed!"));
|
||||
while (1) // Blink FAILED pattern! Rappidly blinking..
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ArduinoGateway prints data received from sensors on the serial link.
|
||||
* The gateway accepts input on seral which will be sent out on radio network.
|
||||
*
|
||||
* The GW code is designed for Arduino Nano 328p / 16MHz
|
||||
*
|
||||
* Wire connections (OPTIONAL):
|
||||
* - Inclusion button should be connected between digital pin 3 and GND
|
||||
* - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
|
||||
*
|
||||
* LEDs (OPTIONAL):
|
||||
* - To use the feature, uncomment MY_LEDS_BLINKING_FEATURE in MyConfig.h
|
||||
* - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
|
||||
* - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
|
||||
* - ERR (red) - fast blink on error during transmission error or recieve crc error
|
||||
*
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
// Enable serial gateway
|
||||
#define MY_GATEWAY_SERIAL
|
||||
|
||||
// Flash leds on rx/tx/err
|
||||
#define MY_LEDS_BLINKING_FEATURE
|
||||
// Set blinking period
|
||||
#define MY_DEFAULT_LED_BLINK_PERIOD 300
|
||||
|
||||
// Enable inclusion mode
|
||||
#define MY_INCLUSION_MODE_FEATURE
|
||||
// Enable Inclusion mode button on gateway
|
||||
#define MY_INCLUSION_BUTTON_FEATURE
|
||||
// Set inclusion mode duration (in seconds)
|
||||
#define MY_INCLUSION_MODE_DURATION 60
|
||||
// Digital pin used for inclusion mode button
|
||||
#define MY_INCLUSION_MODE_BUTTON_PIN 3
|
||||
|
||||
#define MY_DEFAULT_ERR_LED_PIN 7 // Error led pin
|
||||
#define MY_DEFAULT_RX_LED_PIN 8 // Receive led pin
|
||||
#define MY_DEFAULT_TX_LED_PIN 9 // the PCB, on board LED
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
* Contribution by: Derek Macias
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Example showing how to create an atuator for a servo.
|
||||
* Connect red to +5V, Black or brown to GND and the last cable to Digital pin 3.
|
||||
* The servo consumes much power and should probably have its own powersource.'
|
||||
* The arduino might spontanally restart if too much power is used (happend
|
||||
* to me when servo tried to pass the extreme positions = full load).
|
||||
* http://www.mysensors.org/build/servo
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <Servo.h>
|
||||
|
||||
#define SERVO_DIGITAL_OUT_PIN 3
|
||||
#define SERVO_MIN 0 // Fine tune your servos min. 0-180
|
||||
#define SERVO_MAX 180 // Fine tune your servos max. 0-180
|
||||
#define DETACH_DELAY 900 // Tune this to let your movement finish before detaching the servo
|
||||
#define CHILD_ID 10 // Id of the sensor child
|
||||
|
||||
MyMessage msg(CHILD_ID, V_DIMMER);
|
||||
Servo myservo; // create servo object to control a servo
|
||||
// a maximum of eight servo objects can be created Sensor gw(9,10);
|
||||
unsigned long timeOfLastChange = 0;
|
||||
bool attachedServo = false;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Attach method for incoming messages
|
||||
setIncomingCallback(incomingMessage);
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Servo", "1.0");
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
present(CHILD_ID, S_COVER);
|
||||
|
||||
// Request last servo state at startup
|
||||
request(CHILD_ID, V_DIMMER);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (attachedServo && millis() - timeOfLastChange > DETACH_DELAY) {
|
||||
myservo.detach();
|
||||
attachedServo = false;
|
||||
}
|
||||
}
|
||||
|
||||
void incomingMessage(const MyMessage &message) {
|
||||
myservo.attach(SERVO_DIGITAL_OUT_PIN);
|
||||
attachedServo = true;
|
||||
if (message.type==V_DIMMER) { // This could be M_ACK_VARIABLE or M_SET_VARIABLE
|
||||
int val = message.getInt();
|
||||
myservo.write(SERVO_MAX + (SERVO_MIN-SERVO_MAX)/100 * val); // sets the servo position 0-180
|
||||
// Write some debug info
|
||||
Serial.print("Servo changed. new state: ");
|
||||
Serial.println(val);
|
||||
} else if (message.type==V_UP) {
|
||||
Serial.println("Servo UP command");
|
||||
myservo.write(SERVO_MIN);
|
||||
send(msg.set(100));
|
||||
} else if (message.type==V_DOWN) {
|
||||
Serial.println("Servo DOWN command");
|
||||
myservo.write(SERVO_MAX);
|
||||
send(msg.set(0));
|
||||
} else if (message.type==V_STOP) {
|
||||
Serial.println("Servo STOP command");
|
||||
myservo.detach();
|
||||
attachedServo = false;
|
||||
|
||||
}
|
||||
timeOfLastChange = millis();
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,186 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Arduino soil moisture based on gypsum sensor/resistive sensor to avoid electric catalyse in soil
|
||||
* Required to interface the sensor: 2 * 4.7kOhm + 2 * 1N4148
|
||||
*
|
||||
* Gypsum sensor and calibration:
|
||||
* DIY: See http://vanderleevineyard.com/1/category/vinduino/1.html
|
||||
* Built: Davis / Watermark 200SS
|
||||
* http://www.cooking-hacks.com/watermark-soil-moisture-sensor?_bksrc=item2item&_bkloc=product
|
||||
* http://www.irrometer.com/pdf/supportmaterial/sensors/voltage-WM-chart.pdf
|
||||
* cb (centibar) http://www.irrometer.com/basics.html
|
||||
* 0-10 Saturated Soil. Occurs for a day or two after irrigation
|
||||
* 10-20 Soil is adequately wet (except coarse sands which are drying out at this range)
|
||||
* 30-60 Usual range to irrigate or water (except heavy clay soils).
|
||||
* 60-100 Usual range to irrigate heavy clay soils
|
||||
* 100-200 Soil is becoming dangerously dry for maximum production. Proceed with caution.
|
||||
*
|
||||
* Connection:
|
||||
* D6, D7: alternative powering to avoid sensor degradation
|
||||
* A0, A1: alternative resistance mesuring
|
||||
*
|
||||
* Based on:
|
||||
* "Vinduino" portable soil moisture sensor code V3.00
|
||||
* Date December 31, 2012
|
||||
* Reinier van der Lee and Theodore Kaskalis
|
||||
* www.vanderleevineyard.com
|
||||
* Contributor: epierre
|
||||
**/
|
||||
|
||||
// Copyright (C) 2015, Reinier van der Lee
|
||||
// www.vanderleevineyard.com
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <math.h> // Conversion equation from resistance to %
|
||||
#include <MySensor.h>
|
||||
|
||||
// Setting up format for reading 3 soil sensors
|
||||
#define NUM_READS 10 // Number of sensor reads for filtering
|
||||
#define CHILD_ID 0
|
||||
|
||||
MyMessage msg(CHILD_ID, V_LEVEL);
|
||||
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
|
||||
|
||||
long buffer[NUM_READS];
|
||||
int index;
|
||||
|
||||
typedef struct { // Structure to be used in percentage and resistance values matrix to be filtered (have to be in pairs)
|
||||
int moisture;
|
||||
long resistance;
|
||||
} values;
|
||||
|
||||
const long knownResistor = 4700; // Constant value of known resistor in Ohms
|
||||
|
||||
int supplyVoltage; // Measured supply voltage
|
||||
int sensorVoltage; // Measured sensor voltage
|
||||
|
||||
values valueOf[NUM_READS]; // Calculated moisture percentages and resistances to be sorted and filtered
|
||||
|
||||
int i; // Simple index variable
|
||||
|
||||
void setup() {
|
||||
|
||||
sendSketchInfo("Soil Moisture Sensor Reverse Polarity", "1.0");
|
||||
present(CHILD_ID, S_HUM);
|
||||
// initialize the digital pins as an output.
|
||||
// Pin 6,7 is for sensor 1
|
||||
// initialize the digital pin as an output.
|
||||
// Pin 6 is sense resistor voltage supply 1
|
||||
pinMode(6, OUTPUT);
|
||||
|
||||
// initialize the digital pin as an output.
|
||||
// Pin 7 is sense resistor voltage supply 2
|
||||
pinMode(7, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
measure(6,7,1);
|
||||
Serial.print ("\t");
|
||||
Serial.println (average());
|
||||
long read1 = average();
|
||||
|
||||
measure(7,6,0);
|
||||
Serial.print ("\t");
|
||||
Serial.println (average());
|
||||
long read2= average();
|
||||
|
||||
long sensor1 = (read1 + read2)/2;
|
||||
|
||||
Serial.print ("resistance bias =" );
|
||||
Serial.println (read1-read2);
|
||||
Serial.print ("sensor bias compensated value = ");
|
||||
Serial.println (sensor1);
|
||||
Serial.println ();
|
||||
|
||||
//send back the values
|
||||
send(msg.set((long int)ceil(sensor1)));
|
||||
// delay until next measurement (msec)
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
|
||||
void measure (int phase_b, int phase_a, int analog_input)
|
||||
{
|
||||
// read sensor, filter, and calculate resistance value
|
||||
// Noise filter: median filter
|
||||
|
||||
for (i=0; i<NUM_READS; i++) {
|
||||
|
||||
// Read 1 pair of voltage values
|
||||
digitalWrite(phase_a, HIGH); // set the voltage supply on
|
||||
delayMicroseconds(25);
|
||||
supplyVoltage = analogRead(analog_input); // read the supply voltage
|
||||
delayMicroseconds(25);
|
||||
digitalWrite(phase_a, LOW); // set the voltage supply off
|
||||
delay(1);
|
||||
|
||||
digitalWrite(phase_b, HIGH); // set the voltage supply on
|
||||
delayMicroseconds(25);
|
||||
sensorVoltage = analogRead(analog_input); // read the sensor voltage
|
||||
delayMicroseconds(25);
|
||||
digitalWrite(phase_b, LOW); // set the voltage supply off
|
||||
|
||||
// Calculate resistance
|
||||
// the 0.5 add-term is used to round to the nearest integer
|
||||
// Tip: no need to transform 0-1023 voltage value to 0-5 range, due to following fraction
|
||||
long resistance = (knownResistor * (supplyVoltage - sensorVoltage ) / sensorVoltage) ;
|
||||
|
||||
delay(1);
|
||||
addReading(resistance);
|
||||
Serial.print (resistance);
|
||||
Serial.print ("\t");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Averaging algorithm
|
||||
void addReading(long resistance){
|
||||
buffer[index] = resistance;
|
||||
index++;
|
||||
if (index >= NUM_READS) index = 0;
|
||||
}
|
||||
|
||||
long average(){
|
||||
long sum = 0;
|
||||
for (int i = 0; i < NUM_READS; i++){
|
||||
sum += buffer[i];
|
||||
}
|
||||
return (long)(sum / NUM_READS);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Example sketch showing how to request time from controller.
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <Time.h>
|
||||
|
||||
boolean timeReceived = false;
|
||||
unsigned long lastUpdate=0, lastRequest=0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Clock", "1.0");
|
||||
|
||||
// Request time from controller.
|
||||
requestTime(receiveTime);
|
||||
}
|
||||
|
||||
// This is called when a new time value was received
|
||||
void receiveTime(unsigned long time) {
|
||||
// Ok, set incoming time
|
||||
setTime(time);
|
||||
timeReceived = true;
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
unsigned long now = millis();
|
||||
|
||||
// If no time has been received yet, request it every 10 second from controller
|
||||
// When time has been received, request update every hour
|
||||
if ((!timeReceived && (now-lastRequest) > (10UL*1000UL))
|
||||
|| (timeReceived && (now-lastRequest) > (60UL*1000UL*60UL))) {
|
||||
// Request time from controller.
|
||||
Serial.println("requesting time");
|
||||
requestTime(receiveTime);
|
||||
lastRequest = now;
|
||||
}
|
||||
|
||||
// Print time every second
|
||||
if (timeReceived && now-lastUpdate > 1000) {
|
||||
Serial.print(hour());
|
||||
printDigits(minute());
|
||||
printDigits(second());
|
||||
Serial.print(" ");
|
||||
Serial.print(day());
|
||||
Serial.print(" ");
|
||||
Serial.print(month());
|
||||
Serial.print(" ");
|
||||
Serial.print(year());
|
||||
Serial.println();
|
||||
lastUpdate = now;
|
||||
}
|
||||
}
|
||||
|
||||
void printDigits(int digits){
|
||||
// utility function for digital clock display: prints preceding colon and leading 0
|
||||
Serial.print(":");
|
||||
if(digits < 10)
|
||||
Serial.print('0');
|
||||
Serial.print(digits);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// SevenSegNumFontPlus.c
|
||||
// Font type : Special (SubSet)
|
||||
// Font size : 32x50 pixels
|
||||
// Memory usage : 2204 bytes
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
const uint8_t ArialNumFontPlus[2204] PROGMEM={
|
||||
0x20,0x32,0x30,0x0B,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x00,0x00,0x1F,0xF8,0x00,0x00,0x7F,0xFE,0x00,0x00,0xFF,0xFF,0x00,0x01,0xFF,0xFF,0x00,0x03,0xF8,0x1F,0x80,0x03,0xF0,0x0F,0xC0,0x07,0xE0,0x07,0xC0,0x07,0xC0,0x03,0xE0,0x0F,0xC0,0x03,0xE0,0x0F,0x80,0x01,0xF0,0x0F,0x80,0x01,0xF0,0x1F,0x80,0x01,0xF0,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x3F,0x00,0x00,0xFC,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3F,0x00,0x00,0x7C,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x0F,0x80,0x01,0xF0,0x0F,0x80,0x01,0xF0,0x0F,0x80,0x01,0xF0,0x07,0xC0,0x03,0xE0,0x07,0xC0,0x03,0xE0,0x03,0xE0,0x07,0xC0,0x03,0xF0,0x0F,0xC0,0x01,0xF8,0x1F,0x80,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFE,0x00,0x00,0x7F,0xFC,0x00,0x00,0x1F,0xF8,0x00,0x00,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 0 neu
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x03,0xF0,0x00,0x00,0x07,0xF0,0x00,0x00,0x0F,0xF0,0x00,0x00,0x1F,0xF0,0x00,0x00,0x3F,0xF0,0x00,0x00,0x7F,0xF0,0x00,0x01,0xFF,0xF0,0x00,0x03,0xFD,0xF0,0x00,0x0F,0xF1,0xF0,0x00,0x0F,0xE1,0xF0,0x00,0x0F,0x81,0xF0,0x00,0x0F,0x01,0xF0,0x00,0x0C,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //1 neu
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x00,0x00,0x7F,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0xC0,0x03,0xFF,0xFF,0xE0,0x07,0xE0,0x0F,0xF0,0x0F,0xC0,0x03,0xF0,0x0F,0x80,0x01,0xF0,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x3E,0x00,0x00,0xF8,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x03,0xF0,0x00,0x00,0x07,0xF0,0x00,0x00,0x0F,0xE0,0x00,0x00,0x1F,0xC0,0x00,0x00,0x3F,0x80,0x00,0x00,0x7F,0x00,0x00,0x00,0xFE,0x00,0x00,0x01,0xFC,0x00,0x00,0x03,0xF8,0x00,0x00,0x07,0xF0,0x00,0x00,0x0F,0xE0,0x00,0x00,0x1F,0xC0,0x00,0x00,0x3F,0x80,0x00,0x00,0x7F,0x00,0x00,0x00,0xFE,0x00,0x00,0x01,0xFC,0x00,0x00,0x03,0xF8,0x00,0x00,0x07,0xF0,0x00,0x00,0x07,0xE0,0x00,0x00,0x0F,0xC0,0x00,0x00,0x0F,0x80,0x00,0x00,0x1F,0x80,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x7F,0xFF,0xFF,0xFC,0x7F,0xFF,0xFF,0xFC,0x7F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 2 neu
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x00,0x00,0x3F,0xFC,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x03,0xE0,0x1F,0xC0,0x07,0xC0,0x0F,0xC0,0x07,0x80,0x07,0xE0,0x0F,0x80,0x03,0xE0,0x0F,0x00,0x03,0xE0,0x0F,0x00,0x03,0xF0,0x0F,0x00,0x01,0xF0,0x00,0x00,0x03,0xF0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x07,0xE0,0x00,0x00,0x0F,0xC0,0x00,0x00,0x1F,0xC0,0x00,0x00,0x3F,0x80,0x00,0x07,0xFF,0x00,0x00,0x07,0xFF,0x00,0x00,0x07,0xFF,0x00,0x00,0x07,0xFF,0x80,0x00,0x00,0x1F,0xC0,0x00,0x00,0x0F,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x01,0xF8,0x0F,0x80,0x01,0xF8,0x0F,0x80,0x03,0xF0,0x0F,0xC0,0x07,0xF0,0x07,0xE0,0x0F,0xE0,0x03,0xFC,0x3F,0xC0,0x01,0xFF,0xFF,0x80,0x00,0xFF,0xFF,0x00,0x00,0x7F,0xFC,0x00,0x00,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 3 neu
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0xFF,0x00,0x00,0x01,0xFF,0x00,0x00,0x01,0xFF,0x00,0x00,0x03,0xFF,0x00,0x00,0x07,0xDF,0x00,0x00,0x07,0xDF,0x00,0x00,0x0F,0x9F,0x00,0x00,0x0F,0x9F,0x00,0x00,0x1F,0x1F,0x00,0x00,0x3E,0x1F,0x00,0x00,0x7E,0x1F,0x00,0x00,0x7C,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x01,0xF0,0x1F,0x00,0x03,0xE0,0x1F,0x00,0x03,0xE0,0x1F,0x00,0x07,0xC0,0x1F,0x00,0x07,0xC0,0x1F,0x00,0x0F,0x80,0x1F,0x00,0x1F,0x80,0x1F,0x00,0x1F,0x00,0x1F,0x00,0x3E,0x00,0x1F,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00, //4 neu
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF0,0x01,0xFF,0xFF,0xF0,0x01,0xFF,0xFF,0xF0,0x01,0xFF,0xFF,0xF0,0x01,0xFF,0xFF,0xF0,0x03,0xE0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x03,0xC0,0x00,0x00,0x07,0xC0,0x00,0x00,0x07,0xC0,0x00,0x00,0x07,0xC0,0x00,0x00,0x07,0xC0,0x00,0x00,0x07,0x80,0x00,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0xF0,0x00,0x0F,0x8F,0xFE,0x00,0x0F,0xBF,0xFF,0x80,0x0F,0xFF,0xFF,0xC0,0x0F,0xFF,0xFF,0xE0,0x1F,0xFF,0x07,0xF0,0x1F,0xE0,0x03,0xF0,0x1F,0xC0,0x01,0xF8,0x1F,0x00,0x00,0xF8,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x3F,0x00,0x00,0xF8,0x3F,0x00,0x00,0xF8,0x3F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF0,0x1F,0x00,0x01,0xF0,0x1F,0x80,0x03,0xE0,0x0F,0xC0,0x07,0xE0,0x07,0xE0,0x1F,0xC0,0x03,0xFF,0xFF,0x80,0x03,0xFF,0xFF,0x00,0x01,0xFF,0xFE,0x00,0x00,0x7F,0xF8,0x00,0x00,0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 5 neu
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x00,0x00,0x3F,0xFE,0x00,0x00,0xFF,0xFF,0x00,0x01,0xFF,0xFF,0x80,0x03,0xFF,0xFF,0xC0,0x07,0xE0,0x07,0xE0,0x07,0xC0,0x03,0xF0,0x0F,0xC0,0x01,0xF0,0x0F,0x80,0x00,0xF8,0x1F,0x80,0x00,0xF8,0x1F,0x80,0x00,0xF8,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x03,0xF0,0x00,0x3F,0x1F,0xFC,0x00,0x3F,0x7F,0xFE,0x00,0x3F,0xFF,0xFF,0x80,0x3F,0xFF,0xFF,0xC0,0x3F,0xF8,0x0F,0xE0,0x3F,0xE0,0x03,0xF0,0x3F,0xE0,0x03,0xF0,0x3F,0xC0,0x01,0xF8,0x3F,0x80,0x00,0xF8,0x3F,0x80,0x00,0xF8,0x3F,0x00,0x00,0x7C,0x3F,0x00,0x00,0x7C,0x3F,0x00,0x00,0x7C,0x3F,0x00,0x00,0x7C,0x3F,0x00,0x00,0x7C,0x3F,0x00,0x00,0x7C,0x1F,0x00,0x00,0x7C,0x1F,0x80,0x00,0x78,0x1F,0x80,0x00,0xF8,0x1F,0x80,0x00,0xF8,0x0F,0x80,0x00,0xF8,0x0F,0xC0,0x01,0xF0,0x07,0xF0,0x03,0xF0,0x03,0xF8,0x0F,0xE0,0x01,0xFF,0xFF,0xC0,0x00,0xFF,0xFF,0x80,0x00,0x7F,0xFF,0x00,0x00,0x1F,0xFC,0x00,0x00,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 6 neu
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0xFC,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x07,0xC0,0x00,0x00,0x0F,0x80,0x00,0x00,0x1F,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x01,0xF0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x03,0xE0,0x00,0x00,0x07,0xC0,0x00,0x00,0x07,0xC0,0x00,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,0x00,0x0F,0x80,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 7 neu
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x00,0x00,0x7F,0xFE,0x00,0x00,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x80,0x03,0xF8,0x1F,0xC0,0x07,0xE0,0x07,0xE0,0x07,0xC0,0x03,0xE0,0x0F,0xC0,0x03,0xF0,0x0F,0x80,0x01,0xF0,0x0F,0x80,0x01,0xF0,0x0F,0x80,0x01,0xF0,0x0F,0x80,0x01,0xF0,0x0F,0x80,0x01,0xF0,0x0F,0x80,0x01,0xF0,0x07,0xC0,0x03,0xE0,0x07,0xC0,0x03,0xE0,0x03,0xE0,0x07,0xC0,0x01,0xF0,0x07,0x80,0x00,0xFC,0x3F,0x00,0x00,0x7F,0xFF,0x00,0x00,0x3F,0xFC,0x00,0x00,0x7F,0xFE,0x00,0x00,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0xC0,0x07,0xF0,0x0F,0xE0,0x0F,0xC0,0x03,0xF0,0x0F,0x80,0x01,0xF0,0x1F,0x80,0x01,0xF8,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x3E,0x00,0x00,0x7C,0x1F,0x00,0x00,0xF8,0x1F,0x00,0x00,0xF8,0x0F,0x80,0x01,0xF0,0x0F,0x80,0x03,0xF0,0x07,0xC0,0x07,0xE0,0x03,0xF0,0x0F,0xC0,0x01,0xFF,0xFF,0x80,0x00,0xFF,0xFF,0x00,0x00,0x3F,0xFC,0x00,0x00,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 8 neu
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x00,0x00,0x3F,0xFC,0x00,0x00,0xFF,0xFF,0x00,0x01,0xFF,0xFF,0x80,0x03,0xFF,0xFF,0xC0,0x03,0xF8,0x1F,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xE0,0x07,0xF0,0x0F,0xC0,0x03,0xF0,0x0F,0xC0,0x03,0xF8,0x1F,0x80,0x01,0xF8,0x1F,0x80,0x01,0xF8,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x80,0x01,0xFC,0x1F,0x80,0x01,0xFC,0x0F,0xC0,0x03,0xFC,0x0F,0xC0,0x03,0xFC,0x07,0xE0,0x07,0xFC,0x07,0xE0,0x07,0xFC,0x03,0xF8,0x1F,0xFC,0x01,0xFF,0xFF,0xFC,0x00,0xFF,0xFF,0xFC,0x00,0xFF,0xFE,0xFC,0x00,0x7F,0xF8,0xFC,0x00,0x1F,0xE0,0xFC,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0xFC,0x00,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF0,0x1F,0x00,0x03,0xF0,0x1F,0x80,0x07,0xE0,0x0F,0xC0,0x0F,0xE0,0x0F,0xE0,0x3F,0xC0,0x07,0xFF,0xFF,0x80,0x03,0xFF,0xFF,0x00,0x01,0xFF,0xFE,0x00,0x00,0xFF,0xF8,0x00,0x00,0x3F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 9 neu
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x01,0xF0,0x00,0x00,0x03,0xF8,0x00,0x00,0x03,0xF8,0x00,0x00,0x03,0xF8,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x01,0xF0,0x00,0x00,0x03,0xF8,0x00,0x00,0x03,0xF8,0x00,0x00,0x03,0xF8,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // :
|
||||
};
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - Henrik Ekblad
|
||||
*
|
||||
* DESCRIPTION
|
||||
* http://www.mysensors.org/build/scene_controller
|
||||
* Touch Display Scene Controller build using a touch enabled tft display
|
||||
* attached to a ATMega 2560. This example fetches time from controller and sends
|
||||
* in scene commands to the controller.
|
||||
* Short press sends V_SCENE_ON and long press (>0.5sec) sends V_SCENE_OFF.
|
||||
*
|
||||
* Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
*
|
||||
* This example uses:
|
||||
* UTFT library: http://www.henningkarlsen.com/electronics/library.php?id=51
|
||||
* Convert your own images here: http://www.henningkarlsen.com/electronics/t_imageconverter565.php
|
||||
*
|
||||
* The 3v3 output on the ATMega2560 is especially bad. I had to use a step down
|
||||
* on the 5V output to get solid transmissions.
|
||||
*
|
||||
*
|
||||
* Connect radio
|
||||
* ----------------------------------
|
||||
* Radio Arduino Pin
|
||||
* ----------------------------------
|
||||
* GND GND
|
||||
* 5V -> Step down -> 3V3 (see buying guide for help finding step-down)
|
||||
* SCK 14
|
||||
* MOSI 15
|
||||
* MISO 16
|
||||
* CE 17
|
||||
* CSN 18
|
||||
*
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable soft spi as radio has a hard time sharing spi
|
||||
#define MY_SOFTSPI
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <Time.h>
|
||||
#include <MySensor.h>
|
||||
#include <stdarg.h>
|
||||
#include <UTFT.h>
|
||||
#include <UTouch.h>
|
||||
#include <UTFT_Buttons.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "arial_bold.c"
|
||||
#include "ArialNumFontPlus.c"
|
||||
#include "logo.c"
|
||||
|
||||
#define CHILD_ID 1
|
||||
|
||||
int LONG_PRESS = 500; // Number of millisecons to trinnger scene off for button push
|
||||
int RESEND_DEBOUNCE = 2000; // Number of millisecons interval between sending of same
|
||||
// scene number again.
|
||||
// This is used to avoid unwanted re-trigger when using
|
||||
// a sensetive touch diplay.
|
||||
|
||||
// Add your buttons here. Max is 5 if you still want time at the top.
|
||||
char *buttons[] = {
|
||||
(char *)"Good Morning",
|
||||
(char *)"Clean Up!",
|
||||
(char *)"All Lights Off",
|
||||
(char *)"Music On/Off"
|
||||
};
|
||||
|
||||
const int buttonCount = sizeof(buttons)/sizeof(char *);
|
||||
const int padding = 10;
|
||||
const int topBarHeight = 60;
|
||||
|
||||
MyMessage on(CHILD_ID, V_SCENE_ON);
|
||||
MyMessage off(CHILD_ID, V_SCENE_OFF);
|
||||
|
||||
UTFT myGLCD(ITDB32S,38,39,40,41);
|
||||
UTouch myTouch( 6, 5, 4, 3, 2);
|
||||
UTFT_Buttons myButtons(&myGLCD, &myTouch);
|
||||
boolean timeReceived = false;
|
||||
unsigned long lastTimeUpdate=0, lastRequest=0;
|
||||
char timeBuf[20];
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
myGLCD.InitLCD();
|
||||
myGLCD.clrScr();
|
||||
myGLCD.setFont((uint8_t*)ArialNumFontPlus);
|
||||
myGLCD.setColor(100, 255, 100);
|
||||
myGLCD.setBackColor(0, 0, 0);
|
||||
myGLCD.drawBitmap (0, 0, 60, 60, (unsigned int*)logo);
|
||||
|
||||
myTouch.InitTouch();
|
||||
myTouch.setPrecision(PREC_MEDIUM);
|
||||
|
||||
myButtons.setButtonColors(VGA_WHITE, VGA_GRAY, VGA_WHITE, VGA_RED, VGA_BLUE);
|
||||
myButtons.setTextFont((uint8_t*)arial_bold);
|
||||
int height = (myGLCD.getDisplayYSize()-topBarHeight-(padding*(buttonCount+2)))/buttonCount;
|
||||
|
||||
// Add buttons
|
||||
for (int i=0; i<buttonCount;i++) {
|
||||
int y = topBarHeight + padding+(i*(height+padding));
|
||||
myButtons.addButton( padding, y, myGLCD.getDisplayXSize()-padding*2, height, buttons[i]);
|
||||
}
|
||||
myButtons.drawButtons();
|
||||
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("Scene Ctrl", "1.0");
|
||||
present(CHILD_ID, S_SCENE_CONTROLLER);
|
||||
// Request time from controller.
|
||||
requestTime(receiveTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int lastPressedButton = -1;
|
||||
unsigned long lastPressedButtonTime = 0;
|
||||
|
||||
void loop()
|
||||
{
|
||||
unsigned long now = millis();
|
||||
|
||||
if (myTouch.dataAvailable()) {
|
||||
int pressedButton = myButtons.checkButtons();
|
||||
|
||||
if (pressedButton>=0) {
|
||||
bool longPress = millis()-now>(unsigned long)LONG_PRESS;
|
||||
|
||||
if (pressedButton != lastPressedButton || now-lastPressedButtonTime > (unsigned long)RESEND_DEBOUNCE) {
|
||||
if (longPress) {
|
||||
send(off.set(pressedButton));
|
||||
Serial.print("Long pressed: ");
|
||||
} else {
|
||||
send(on.set(pressedButton));
|
||||
Serial.print("Pressed: ");
|
||||
}
|
||||
Serial.println(pressedButton);
|
||||
lastPressedButton = pressedButton;
|
||||
lastPressedButtonTime=now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If no time has been received yet, request it every 10 second from controller
|
||||
// When time has been received, request update every hour
|
||||
if ((!timeReceived && now-lastRequest > (unsigned long)10*1000)
|
||||
|| (timeReceived && now-lastRequest > (unsigned long)60*1000*60)) {
|
||||
// Request time from controller.
|
||||
Serial.println("requesting time");
|
||||
requestTime(receiveTime);
|
||||
lastRequest = now;
|
||||
}
|
||||
|
||||
// Update time every second
|
||||
if (timeReceived && now-lastTimeUpdate > 1000) {
|
||||
printTime();
|
||||
lastTimeUpdate = now;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This is called when a new time value was received
|
||||
void receiveTime(unsigned long time) {
|
||||
// Ok, set incoming time
|
||||
setTime(time);
|
||||
timeReceived = true;
|
||||
}
|
||||
|
||||
void printTime() {
|
||||
sprintf(timeBuf, "%02d:%02d:%02d", hour(), minute(), second());
|
||||
myGLCD.print(timeBuf, 60,7);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
// Ubuntu.c
|
||||
// Font type : Full (95 characters)
|
||||
// Font size : 24x32 pixels
|
||||
// Memory usage : 9124 bytes
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
const uint8_t Ubuntu[9124] PROGMEM={
|
||||
0x18,0x20,0x20,0x5F,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // <space>
|
||||
0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // !
|
||||
0x00,0x00,0x00,0x01,0xC0,0xE0,0x03,0xE1,0xF0,0x03,0xE1,0xF0,0x03,0xE1,0xF0,0x01,0xE0,0xF0,0x00,0xE0,0x70,0x01,0xC0,0xE0,0x03,0xC1,0xE0,0x0F,0x87,0xC0,0x0E,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // "
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x70,0x00,0x38,0x70,0x00,0x70,0xE0,0x00,0x70,0xE0,0x00,0x70,0xE0,0x00,0x70,0xE0,0x0F,0xFF,0xF8,0x0F,0xFF,0xF8,0x0F,0xFF,0xF8,0x00,0xE1,0xC0,0x00,0xE1,0xC0,0x00,0xE1,0xC0,0x01,0xC3,0x80,0x01,0xC3,0x80,0x01,0xC3,0x80,0x0F,0xFF,0xF8,0x0F,0xFF,0xF8,0x0F,0xFF,0xF8,0x03,0x87,0x00,0x03,0x87,0x00,0x03,0x87,0x00,0x03,0x87,0x00,0x07,0x0E,0x00,0x07,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // #
|
||||
0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x7F,0x00,0x01,0xFF,0xC0,0x03,0xFF,0xC0,0x07,0x80,0x80,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x80,0x00,0x03,0xC0,0x00,0x03,0xF8,0x00,0x01,0xFE,0x00,0x00,0x7F,0x80,0x00,0x0F,0xC0,0x00,0x03,0xC0,0x00,0x01,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x02,0x01,0xC0,0x07,0xFF,0xC0,0x07,0xFF,0x80,0x01,0xFE,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x00,0x00, // $
|
||||
0x00,0x00,0x00,0x07,0x80,0x70,0x0F,0xC0,0xE0,0x0C,0xC0,0xE0,0x18,0x61,0xC0,0x18,0x63,0x80,0x18,0x63,0x80,0x18,0x67,0x00,0x18,0x67,0x00,0x18,0x6E,0x00,0x0C,0xDC,0x00,0x0F,0xDC,0x00,0x07,0xB8,0x00,0x00,0x3B,0xC0,0x00,0x77,0xE0,0x00,0x76,0x60,0x00,0xEC,0x30,0x01,0xCC,0x30,0x01,0xCC,0x30,0x03,0x8C,0x30,0x03,0x8C,0x30,0x07,0x0C,0x30,0x0E,0x06,0x60,0x0E,0x07,0xE0,0x1C,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // %
|
||||
0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0xFF,0x00,0x01,0xFF,0x00,0x03,0xC7,0x80,0x03,0x83,0x80,0x03,0x83,0x80,0x03,0x83,0x80,0x03,0x87,0x00,0x01,0xCF,0x00,0x01,0xFE,0x00,0x00,0xFC,0x00,0x01,0xF0,0x70,0x03,0xF8,0x70,0x03,0xBC,0x70,0x07,0x1E,0x60,0x0E,0x0F,0xE0,0x0E,0x07,0xE0,0x0E,0x03,0xC0,0x0E,0x01,0xC0,0x0F,0x03,0xE0,0x07,0x8F,0xE0,0x07,0xFF,0x70,0x03,0xFE,0x70,0x00,0xF8,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // &
|
||||
0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x3C,0x00,0x00,0x1E,0x00,0x00,0x0E,0x00,0x00,0x07,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // '
|
||||
0x00,0x07,0x00,0x00,0x0F,0x80,0x00,0x0F,0x00,0x00,0x1E,0x00,0x00,0x3C,0x00,0x00,0x38,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x38,0x00,0x00,0x3C,0x00,0x00,0x1E,0x00,0x00,0x0F,0x00,0x00,0x07,0x80,0x00,0x03,0x00,0x00,0x01,0x00, // (
|
||||
0x00,0x60,0x00,0x00,0xF0,0x00,0x00,0x78,0x00,0x00,0x3C,0x00,0x00,0x1E,0x00,0x00,0x0E,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x0E,0x00,0x00,0x1E,0x00,0x00,0x3C,0x00,0x00,0x78,0x00,0x00,0xF0,0x00,0x00,0x60,0x00,0x00,0x40,0x00, // )
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x02,0x1C,0x20,0x03,0xC9,0xE0,0x07,0xFF,0xF0,0x01,0xFF,0xC0,0x00,0x1C,0x00,0x00,0x36,0x00,0x00,0x77,0x00,0x00,0xF3,0x80,0x01,0xE3,0xC0,0x00,0xE3,0x80,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // *
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // +
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x1F,0x00,0x00,0x1F,0x00,0x00,0x1F,0x00,0x00,0x0F,0x00,0x00,0x07,0x00,0x00,0x0E,0x00,0x00,0x1C,0x00,0x00,0x78,0x00,0x00,0x70,0x00,0x00,0x00,0x00, // ,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // -
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // .
|
||||
0x00,0x01,0xC0,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0x07,0x00,0x00, // /
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x01,0xFF,0x00,0x03,0xFF,0x80,0x03,0xC7,0x80,0x07,0x83,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x30,0xE0,0x0E,0x78,0xE0,0x0E,0x78,0xE0,0x0E,0x78,0xE0,0x0E,0x30,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x83,0xC0,0x03,0xC7,0x80,0x03,0xFF,0x80,0x01,0xFF,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 0
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x7C,0x00,0x00,0xFC,0x00,0x03,0xFC,0x00,0x07,0x9C,0x00,0x02,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x03,0xFF,0xC0,0x03,0xFF,0xC0,0x03,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 1
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x03,0xFF,0x00,0x07,0xFF,0x80,0x07,0x87,0xC0,0x02,0x03,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x03,0x80,0x00,0x07,0x80,0x00,0x07,0x00,0x00,0x0E,0x00,0x00,0x1C,0x00,0x00,0x38,0x00,0x00,0x70,0x00,0x00,0xE0,0x00,0x01,0xC0,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 2
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x0F,0xFF,0x00,0x0F,0xFF,0x80,0x06,0x07,0x80,0x00,0x03,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x03,0xC0,0x00,0x07,0x80,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x80,0x00,0x07,0xC0,0x00,0x01,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x01,0xE0,0x04,0x03,0xC0,0x0F,0xFF,0x80,0x0F,0xFF,0x00,0x03,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 3
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x0F,0x80,0x00,0x1F,0x80,0x00,0x3F,0x80,0x00,0x3B,0x80,0x00,0x73,0x80,0x00,0xF3,0x80,0x01,0xE3,0x80,0x01,0xC3,0x80,0x03,0x83,0x80,0x03,0x83,0x80,0x07,0x03,0x80,0x0F,0x03,0x80,0x0E,0x03,0x80,0x1E,0x03,0x80,0x1F,0xFF,0xF0,0x1F,0xFF,0xF0,0x1F,0xFF,0xF0,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 4
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0x80,0x03,0xFF,0x80,0x03,0xFF,0x80,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x03,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0xF0,0x00,0x07,0xFE,0x00,0x07,0xFF,0x00,0x00,0x1F,0x80,0x00,0x07,0x80,0x00,0x03,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x03,0xC0,0x0C,0x07,0x80,0x0F,0xFF,0x00,0x0F,0xFE,0x00,0x03,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 5
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,0x1F,0xC0,0x00,0x7F,0xC0,0x00,0xFC,0x00,0x01,0xE0,0x00,0x03,0xC0,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x06,0x7E,0x00,0x0F,0xFF,0x80,0x0F,0xFF,0xC0,0x0F,0x03,0xC0,0x0E,0x01,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x07,0x00,0xE0,0x07,0x01,0xC0,0x07,0xC3,0xC0,0x03,0xFF,0x80,0x01,0xFF,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 6
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x00,0x00,0xE0,0x00,0x01,0xC0,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 7
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x01,0xFF,0x00,0x03,0xFF,0x80,0x03,0xC7,0xC0,0x07,0x03,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x81,0xC0,0x03,0xC3,0x80,0x03,0xF7,0x00,0x01,0xFE,0x00,0x01,0xFF,0x80,0x03,0xCF,0xC0,0x07,0x03,0xC0,0x06,0x01,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0F,0x01,0xE0,0x07,0x83,0xC0,0x07,0xFF,0xC0,0x03,0xFF,0x80,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 8
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x01,0xFF,0x00,0x03,0xFF,0x80,0x07,0x87,0xC0,0x07,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0F,0x00,0xE0,0x07,0x81,0xE0,0x07,0xFF,0xE0,0x03,0xFF,0xE0,0x00,0xFE,0xE0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x03,0xC0,0x00,0x07,0x80,0x00,0x0F,0x00,0x00,0x7E,0x00,0x07,0xFC,0x00,0x07,0xF8,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 9
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // :
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x3C,0x00,0x00,0x1C,0x00,0x00,0x38,0x00,0x00,0x70,0x00,0x01,0xE0,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ;
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x01,0xE0,0x00,0x0F,0xE0,0x00,0x3F,0xC0,0x00,0xFE,0x00,0x03,0xF8,0x00,0x0F,0xC0,0x00,0x0F,0x00,0x00,0x0F,0xC0,0x00,0x07,0xF8,0x00,0x00,0xFE,0x00,0x00,0x3F,0xC0,0x00,0x0F,0xE0,0x00,0x01,0xE0,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // <
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // =
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x0F,0x00,0x00,0x0F,0xE0,0x00,0x07,0xF8,0x00,0x00,0xFE,0x00,0x00,0x3F,0x80,0x00,0x07,0xE0,0x00,0x01,0xE0,0x00,0x07,0xE0,0x00,0x3F,0xC0,0x00,0xFE,0x00,0x07,0xF8,0x00,0x0F,0xE0,0x00,0x0F,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // >
|
||||
0x00,0x00,0x00,0x00,0xFE,0x00,0x03,0xFF,0x80,0x03,0xFF,0xC0,0x01,0x03,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x01,0xC0,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0x0E,0x00,0x00,0x1C,0x00,0x00,0x3C,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ?
|
||||
|
||||
0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0xFF,0x80,0x01,0xFF,0xC0,0x01,0xE1,0xE0,0x03,0x80,0xE0,0x03,0x80,0x70,0x07,0x00,0x70,0x07,0x00,0x70,0x07,0x07,0xF0,0x0E,0x1F,0xF0,0x0E,0x3F,0xF0,0x0E,0x3C,0x70,0x0E,0x78,0x70,0x0E,0x70,0x70,0x0E,0x70,0x70,0x0E,0x70,0x70,0x0E,0x70,0x70,0x0E,0x78,0x70,0x0E,0x38,0x70,0x07,0x3F,0xF0,0x07,0x1F,0xF0,0x07,0x07,0xE0,0x07,0x80,0x00,0x03,0xC0,0x00,0x03,0xC0,0x00,0x01,0xF0,0x00,0x00,0xFF,0xC0,0x00,0x7F,0xC0,0x00,0x1F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, // @
|
||||
0x00,0x00,0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00,0xFF,0x00,0x00,0xF7,0x00,0x00,0xE7,0x00,0x00,0xE7,0x00,0x01,0xE7,0x80,0x01,0xC3,0x80,0x01,0xC3,0x80,0x03,0xC3,0xC0,0x03,0xC1,0xC0,0x03,0x81,0xC0,0x03,0x81,0xC0,0x07,0x81,0xE0,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x0F,0x00,0xF0,0x0E,0x00,0x70,0x0E,0x00,0x70,0x0E,0x00,0x70,0x1E,0x00,0x78,0x1C,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // A
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFC,0x00,0x0F,0xFF,0x00,0x0F,0xFF,0x80,0x0E,0x07,0xC0,0x0E,0x03,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x03,0x80,0x0E,0x07,0x80,0x0F,0xFF,0x00,0x0F,0xFF,0x00,0x0F,0xFF,0x80,0x0E,0x03,0xC0,0x0E,0x01,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x01,0xE0,0x0E,0x07,0xC0,0x0F,0xFF,0xC0,0x0F,0xFF,0x00,0x0F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // B
|
||||
0x00,0x00,0x00,0x00,0x3F,0x80,0x00,0x7F,0xE0,0x01,0xFF,0xE0,0x03,0xE0,0x40,0x03,0xC0,0x00,0x07,0x80,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0F,0x00,0x00,0x07,0x00,0x00,0x07,0x80,0x00,0x03,0xC0,0x00,0x03,0xE0,0x40,0x01,0xFF,0xE0,0x00,0xFF,0xE0,0x00,0x3F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // C
|
||||
0x00,0x00,0x00,0x0F,0xF0,0x00,0x0F,0xFE,0x00,0x0F,0xFF,0x00,0x0E,0x0F,0x80,0x0E,0x03,0x80,0x0E,0x03,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x01,0xE0,0x0E,0x01,0xC0,0x0E,0x03,0xC0,0x0E,0x03,0x80,0x0E,0x0F,0x80,0x0F,0xFF,0x00,0x0F,0xFE,0x00,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // D
|
||||
0x00,0x00,0x00,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0xFF,0x80,0x07,0xFF,0x80,0x07,0xFF,0x80,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // E
|
||||
0x00,0x00,0x00,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // F
|
||||
0x00,0x00,0x00,0x00,0x3F,0x80,0x00,0xFF,0xC0,0x01,0xFF,0xE0,0x03,0xE0,0xC0,0x03,0xC0,0x40,0x07,0x80,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0F,0x00,0xE0,0x07,0x00,0xE0,0x07,0x80,0xE0,0x03,0xC0,0xE0,0x03,0xE0,0xE0,0x01,0xFF,0xE0,0x00,0xFF,0xE0,0x00,0x3F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // G
|
||||
0x00,0x00,0x00,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // H
|
||||
0x00,0x00,0x00,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // I
|
||||
0x00,0x00,0x00,0x01,0xFF,0xC0,0x01,0xFF,0xC0,0x01,0xFF,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x04,0x03,0xC0,0x07,0x07,0x80,0x0F,0xFF,0x00,0x07,0xFE,0x00,0x01,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // J
|
||||
0x00,0x00,0x00,0x0E,0x01,0xE0,0x0E,0x03,0xC0,0x0E,0x03,0x80,0x0E,0x07,0x80,0x0E,0x0F,0x00,0x0E,0x0E,0x00,0x0E,0x1C,0x00,0x0E,0x3C,0x00,0x0E,0x78,0x00,0x0E,0xF0,0x00,0x0F,0xE0,0x00,0x0F,0xE0,0x00,0x0F,0xF0,0x00,0x0E,0xF8,0x00,0x0E,0x7C,0x00,0x0E,0x3E,0x00,0x0E,0x1E,0x00,0x0E,0x0F,0x00,0x0E,0x07,0x80,0x0E,0x03,0xC0,0x0E,0x03,0xC0,0x0E,0x01,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // K
|
||||
0x00,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // L
|
||||
0x00,0x00,0x00,0x03,0x00,0x60,0x03,0x80,0xF0,0x07,0x80,0xF0,0x07,0x80,0xF0,0x06,0xC1,0xB0,0x06,0xC1,0xB0,0x06,0xE3,0xB0,0x06,0x63,0x30,0x06,0x63,0x30,0x06,0x77,0x30,0x06,0x36,0x30,0x06,0x36,0x30,0x06,0x3E,0x30,0x06,0x1C,0x38,0x0E,0x1C,0x38,0x0E,0x00,0x38,0x0E,0x00,0x38,0x0E,0x00,0x38,0x0E,0x00,0x38,0x0E,0x00,0x38,0x0E,0x00,0x38,0x0E,0x00,0x38,0x0E,0x00,0x38,0x0E,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // M
|
||||
0x00,0x00,0x00,0x07,0x80,0x70,0x07,0xC0,0x70,0x07,0xC0,0x70,0x07,0xE0,0x70,0x07,0xE0,0x70,0x07,0xF0,0x70,0x07,0x70,0x70,0x07,0x70,0x70,0x07,0x38,0x70,0x07,0x38,0x70,0x07,0x1C,0x70,0x07,0x1C,0x70,0x07,0x0E,0x70,0x07,0x0E,0x70,0x07,0x06,0x70,0x07,0x07,0x70,0x07,0x07,0x70,0x07,0x03,0xF0,0x07,0x03,0xF0,0x07,0x01,0xF0,0x07,0x01,0xF0,0x07,0x00,0xF0,0x07,0x00,0xF0,0x07,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // N
|
||||
0x00,0x00,0x00,0x00,0x7C,0x00,0x01,0xFF,0x00,0x03,0xFF,0x80,0x07,0x83,0xC0,0x0F,0x01,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x1C,0x00,0xF0,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0xF0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0F,0x01,0xE0,0x07,0x83,0xC0,0x03,0xFF,0x80,0x01,0xFF,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // O
|
||||
|
||||
0x00,0x00,0x00,0x07,0xFC,0x00,0x07,0xFF,0x00,0x07,0xFF,0x80,0x07,0x03,0xC0,0x07,0x01,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x01,0xE0,0x07,0x03,0xC0,0x07,0xFF,0x80,0x07,0xFF,0x00,0x07,0xFC,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // P
|
||||
0x00,0x00,0x00,0x00,0x7C,0x00,0x01,0xFF,0x00,0x03,0xFF,0x80,0x07,0x83,0xC0,0x0F,0x01,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x1C,0x00,0xF0,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0xF0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0F,0x01,0xE0,0x07,0x83,0xC0,0x03,0xFF,0x80,0x01,0xFF,0x00,0x00,0xFE,0x00,0x00,0x38,0x00,0x00,0x3C,0x00,0x00,0x1F,0x00,0x00,0x0F,0xE0,0x00,0x07,0xE0,0x00,0x00,0xC0,0x00,0x00,0x00, // Q
|
||||
0x00,0x00,0x00,0x0F,0xF8,0x00,0x0F,0xFE,0x00,0x0F,0xFF,0x00,0x0E,0x07,0x80,0x0E,0x03,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x03,0x80,0x0E,0x07,0x80,0x0F,0xFF,0x00,0x0F,0xFE,0x00,0x0F,0xFC,0x00,0x0E,0x1E,0x00,0x0E,0x0E,0x00,0x0E,0x07,0x00,0x0E,0x07,0x00,0x0E,0x03,0x80,0x0E,0x03,0x80,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // R
|
||||
0x00,0x00,0x00,0x00,0x7F,0x00,0x01,0xFF,0xC0,0x03,0xFF,0xC0,0x03,0xC0,0x80,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x80,0x00,0x03,0xE0,0x00,0x01,0xF8,0x00,0x00,0xFE,0x00,0x00,0x3F,0x80,0x00,0x0F,0xC0,0x00,0x03,0xC0,0x00,0x01,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x04,0x01,0xE0,0x0F,0x03,0xC0,0x0F,0xFF,0xC0,0x07,0xFF,0x80,0x01,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // S
|
||||
0x00,0x00,0x00,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // T
|
||||
0x00,0x00,0x00,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0F,0x01,0xE0,0x07,0x01,0xC0,0x07,0x83,0xC0,0x03,0xFF,0x80,0x01,0xFF,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // U
|
||||
0x00,0x00,0x00,0x1C,0x00,0x70,0x1C,0x00,0x70,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x03,0x83,0x80,0x03,0x83,0x80,0x03,0x83,0x80,0x03,0x87,0x80,0x01,0xC7,0x00,0x01,0xC7,0x00,0x01,0xC7,0x00,0x00,0xEE,0x00,0x00,0xEE,0x00,0x00,0xEE,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // V
|
||||
0x00,0x00,0x00,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x38,0xE0,0x0E,0x38,0xE0,0x0E,0x38,0xE0,0x0E,0x6C,0xE0,0x0E,0x6C,0xE0,0x0E,0x6C,0xE0,0x0E,0xC6,0xE0,0x0E,0xC6,0xE0,0x0E,0xC6,0xE0,0x0F,0x83,0xE0,0x0F,0x83,0xE0,0x0F,0x83,0xE0,0x0F,0x01,0xE0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // W
|
||||
0x00,0x00,0x00,0x1E,0x00,0xF0,0x0E,0x00,0xE0,0x0F,0x01,0xE0,0x07,0x01,0xC0,0x03,0x83,0x80,0x03,0x83,0x80,0x01,0xC7,0x00,0x01,0xEF,0x00,0x00,0xEE,0x00,0x00,0xFE,0x00,0x00,0x7C,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x7C,0x00,0x00,0xFE,0x00,0x00,0xEE,0x00,0x01,0xC7,0x00,0x03,0xC7,0x80,0x03,0x83,0x80,0x07,0x83,0xC0,0x07,0x01,0xC0,0x0F,0x01,0xE0,0x0E,0x00,0xE0,0x1E,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // X
|
||||
0x00,0x00,0x00,0x1C,0x00,0x70,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0F,0x01,0xE0,0x07,0x01,0xC0,0x07,0x83,0xC0,0x03,0x83,0x80,0x03,0xC3,0x80,0x01,0xC7,0x00,0x01,0xEF,0x00,0x00,0xEE,0x00,0x00,0xFE,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // Y
|
||||
0x00,0x00,0x00,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x07,0xFF,0xE0,0x00,0x01,0xC0,0x00,0x03,0xC0,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0x0F,0x00,0x00,0x0E,0x00,0x00,0x1E,0x00,0x00,0x3C,0x00,0x00,0x38,0x00,0x00,0x78,0x00,0x00,0x70,0x00,0x00,0xE0,0x00,0x01,0xE0,0x00,0x01,0xC0,0x00,0x03,0xC0,0x00,0x03,0x80,0x00,0x07,0x80,0x00,0x07,0x00,0x00,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // Z
|
||||
0x01,0xFF,0x00,0x01,0xFF,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xFF,0x00,0x01,0xFF,0x00, // [
|
||||
0x03,0x80,0x00,0x03,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x00,0xE0,0x00,0x00,0xE0, // <backslash>
|
||||
0x00,0xFF,0x80,0x00,0xFF,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0xFF,0x80,0x00,0xFF,0x80, // ]
|
||||
0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0xEE,0x00,0x00,0xEE,0x00,0x01,0xC7,0x00,0x01,0xC7,0x00,0x03,0xC7,0x80,0x03,0x83,0x80,0x07,0x83,0xC0,0x07,0x01,0xC0,0x0F,0x01,0xE0,0x02,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ^
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xF8,0x3F,0xFF,0xF8,0x3F,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // _
|
||||
|
||||
0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0xFE,0x00,0x01,0xC7,0x00,0x01,0x83,0x00,0x01,0x83,0x00,0x01,0x83,0x00,0x01,0xC7,0x00,0x00,0xFE,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // `
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x01,0xFF,0x80,0x01,0xFF,0xC0,0x01,0x83,0xE0,0x00,0x01,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x7F,0xE0,0x01,0xFF,0xE0,0x03,0xFF,0xE0,0x07,0xC0,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x80,0xE0,0x03,0xFF,0xE0,0x01,0xFF,0xE0,0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // a
|
||||
0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x7E,0x00,0x07,0xFF,0x00,0x07,0xFF,0x80,0x07,0x83,0xC0,0x07,0x01,0xC0,0x07,0x01,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x01,0xE0,0x07,0x01,0xC0,0x07,0x07,0xC0,0x07,0xFF,0x80,0x07,0xFF,0x00,0x03,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // b
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xC0,0x00,0xFF,0xE0,0x03,0xFF,0xE0,0x03,0xE0,0x40,0x07,0x80,0x00,0x07,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x0E,0x00,0x00,0x07,0x00,0x00,0x07,0x80,0x00,0x03,0xE0,0x60,0x03,0xFF,0xE0,0x00,0xFF,0xE0,0x00,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // c
|
||||
0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x7E,0xE0,0x00,0xFF,0xE0,0x01,0xFF,0xE0,0x03,0xC1,0xE0,0x03,0x80,0xE0,0x07,0x80,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x80,0xE0,0x03,0x80,0xE0,0x03,0xE0,0xE0,0x01,0xFF,0xE0,0x00,0xFF,0xE0,0x00,0x3F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // d
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x01,0xFF,0x00,0x03,0xFF,0x80,0x07,0xC3,0xC0,0x07,0x01,0xC0,0x07,0x00,0xE0,0x0E,0x00,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0E,0x00,0x00,0x0E,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0xC0,0xC0,0x03,0xFF,0xC0,0x01,0xFF,0xC0,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // e
|
||||
0x00,0x0F,0xC0,0x00,0x3F,0xF0,0x00,0x7F,0xF0,0x00,0x78,0x30,0x00,0xF0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x0F,0xFF,0xC0,0x0F,0xFF,0xC0,0x0F,0xFF,0xC0,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // f
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x01,0xFF,0xC0,0x03,0xFF,0xC0,0x07,0x81,0xC0,0x07,0x01,0xC0,0x0F,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x0E,0x01,0xC0,0x07,0x01,0xC0,0x07,0x83,0xC0,0x03,0xFF,0xC0,0x01,0xFF,0xC0,0x00,0xFD,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x00,0x03,0xC0,0x06,0x07,0x80,0x07,0xFF,0x80,0x07,0xFF,0x00,0x03,0xFC,0x00,0x00,0x00,0x00, // g
|
||||
0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0xFC,0x00,0x07,0xFF,0x00,0x07,0xFF,0x80,0x07,0x07,0x80,0x07,0x03,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // h
|
||||
0x00,0x00,0x00,0x00,0x60,0x00,0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xF0,0x00,0x0F,0xF0,0x00,0x0F,0xF0,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x70,0x00,0x00,0x78,0x20,0x00,0x3F,0xE0,0x00,0x3F,0xE0,0x00,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // i
|
||||
0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x0F,0x00,0x00,0x0F,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0x80,0x03,0xFF,0x80,0x03,0xFF,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x06,0x0F,0x00,0x0F,0xFF,0x00,0x0F,0xFE,0x00,0x03,0xF8,0x00, // j
|
||||
0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x01,0xE0,0x07,0x03,0xC0,0x07,0x07,0x80,0x07,0x0F,0x00,0x07,0x1E,0x00,0x07,0x3C,0x00,0x07,0x78,0x00,0x07,0xF0,0x00,0x07,0xE0,0x00,0x07,0xF0,0x00,0x07,0x78,0x00,0x07,0x1C,0x00,0x07,0x0F,0x00,0x07,0x07,0x00,0x07,0x03,0x80,0x07,0x03,0xC0,0x07,0x01,0xE0,0x07,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // k
|
||||
0x07,0xF8,0x00,0x07,0xF8,0x00,0x07,0xF8,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x38,0x00,0x00,0x3C,0x10,0x00,0x1F,0xF0,0x00,0x1F,0xF0,0x00,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // l
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE3,0xC0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0E,0x3C,0xF0,0x0E,0x1C,0x70,0x0E,0x1C,0x70,0x0E,0x1C,0x70,0x0E,0x1C,0x70,0x0E,0x1C,0x70,0x0E,0x1C,0x70,0x0E,0x1C,0x70,0x0E,0x00,0x70,0x0E,0x00,0x70,0x0E,0x00,0x70,0x0E,0x00,0x70,0x0E,0x00,0x70,0x0E,0x00,0x70,0x0E,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // m
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x03,0xFF,0x80,0x03,0xFF,0xC0,0x03,0x83,0xC0,0x03,0x81,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // n
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x01,0xFF,0x00,0x03,0xFF,0x80,0x07,0x83,0xC0,0x07,0x01,0xC0,0x0F,0x01,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x07,0x01,0xE0,0x07,0x01,0xC0,0x07,0x83,0xC0,0x03,0xFF,0x80,0x01,0xFF,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // o
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x07,0xFF,0x00,0x07,0xFF,0x80,0x07,0x07,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x01,0xE0,0x07,0x01,0xC0,0x07,0x83,0xC0,0x07,0xFF,0x80,0x07,0xFF,0x00,0x07,0x7C,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00, // p
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x80,0x00,0xFF,0xE0,0x01,0xFF,0xE0,0x03,0xE0,0xE0,0x03,0x80,0xE0,0x03,0x80,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x80,0xE0,0x03,0x80,0xE0,0x03,0xC1,0xE0,0x01,0xFF,0xE0,0x00,0xFF,0xE0,0x00,0x3E,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0, // q
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xC0,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x07,0x80,0x80,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // r
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x01,0xFF,0x80,0x03,0xFF,0x80,0x07,0x81,0x80,0x07,0x00,0x00,0x07,0x00,0x00,0x07,0xC0,0x00,0x03,0xF0,0x00,0x01,0xFE,0x00,0x00,0x7F,0x00,0x00,0x1F,0x80,0x00,0x03,0xC0,0x00,0x01,0xC0,0x00,0x01,0xC0,0x06,0x03,0xC0,0x07,0xFF,0x80,0x07,0xFF,0x80,0x01,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // s
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x0F,0xFF,0xE0,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xF0,0x20,0x00,0x7F,0xE0,0x00,0x7F,0xE0,0x00,0x1F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // t
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x81,0xC0,0x03,0xC1,0xC0,0x03,0xFF,0xC0,0x01,0xFF,0xC0,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // u
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x70,0x1E,0x00,0xF0,0x0E,0x00,0xE0,0x0E,0x00,0xE0,0x0F,0x01,0xE0,0x07,0x01,0xC0,0x07,0x01,0xC0,0x07,0x83,0xC0,0x03,0x83,0x80,0x03,0x83,0x80,0x03,0xC7,0x00,0x01,0xC7,0x00,0x01,0xEF,0x00,0x00,0xEE,0x00,0x00,0xFE,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // v
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x00,0x70,0x1C,0x10,0x70,0x0C,0x38,0xE0,0x0E,0x38,0xE0,0x0E,0x38,0xE0,0x0E,0x28,0xE0,0x0E,0x6C,0xE0,0x0E,0x6C,0xE0,0x06,0x44,0xC0,0x06,0xC6,0xC0,0x06,0xC7,0xC0,0x07,0x87,0xC0,0x07,0x83,0xC0,0x07,0x83,0x80,0x03,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // w
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x01,0xE0,0x0F,0x03,0xC0,0x07,0x03,0x80,0x03,0x87,0x80,0x03,0xCF,0x00,0x01,0xEE,0x00,0x00,0xFC,0x00,0x00,0x7C,0x00,0x00,0x78,0x00,0x00,0x7C,0x00,0x00,0xFE,0x00,0x01,0xEE,0x00,0x01,0xC7,0x00,0x03,0xC3,0x80,0x07,0x83,0xC0,0x0F,0x01,0xC0,0x0E,0x01,0xE0,0x1E,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // x
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x70,0x0F,0x00,0xF0,0x07,0x00,0xE0,0x07,0x00,0xE0,0x07,0x80,0xE0,0x03,0x81,0xE0,0x03,0x81,0xC0,0x03,0xC1,0xC0,0x01,0xC3,0xC0,0x01,0xC3,0x80,0x01,0xE3,0x80,0x00,0xE7,0x80,0x00,0xF7,0x80,0x00,0x77,0x00,0x00,0x7F,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x1E,0x00,0x00,0x3C,0x00,0x00,0x3C,0x00,0x00,0x78,0x00,0x0F,0xF0,0x00,0x0F,0xF0,0x00,0x0F,0xC0,0x00, // y
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x00,0x03,0x80,0x00,0x07,0x80,0x00,0x0F,0x00,0x00,0x1E,0x00,0x00,0x1C,0x00,0x00,0x38,0x00,0x00,0x78,0x00,0x00,0xF0,0x00,0x00,0xE0,0x00,0x01,0xE0,0x00,0x03,0xC0,0x00,0x03,0x80,0x00,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x07,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // z
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x01,0xC0,0x00,0x0F,0x80,0x00,0x0F,0x80,0x00,0x01,0xC0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0xE0,0x00,0x00,0x70,0x00,0x00,0x7F,0x80,0x00,0x1F,0x80, // {
|
||||
0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00,0x00,0x1C,0x00, // |
|
||||
0x00,0xFC,0x00,0x00,0xFF,0x00,0x00,0x07,0x00,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x01,0xC0,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x01,0xC0,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x03,0x80,0x00,0x07,0x00,0x00,0xFF,0x00,0x00,0xFC,0x00, // }
|
||||
0x00,0x00,0x00,0x01,0xE0,0x20,0x03,0xF0,0x30,0x07,0xFC,0x70,0x0E,0x3F,0xE0,0x0C,0x0F,0xC0,0x04,0x07,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ~
|
||||
};
|
||||
@@ -0,0 +1,111 @@
|
||||
// arial_bold.c
|
||||
// Font type : Full (95 characters)
|
||||
// Font size : 16x16 pixels
|
||||
// Memory usage : 3044 bytes
|
||||
// Submitted by : MBWK
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
const uint8_t arial_bold[3044] PROGMEM={
|
||||
0x10,0x10,0x20,0x5F,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // <space>
|
||||
0x00,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00, // !
|
||||
0x00,0x00,0x00,0x00,0x06,0x60,0x06,0x60,0x06,0x60,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // "
|
||||
0x00,0x00,0x00,0x00,0x03,0x60,0x03,0x60,0x06,0xC0,0x3F,0xF0,0x3F,0xF0,0x06,0xC0,0x0D,0x80,0x3F,0xF0,0x3F,0xF0,0x0D,0x80,0x1B,0x00,0x1B,0x00,0x00,0x00,0x00,0x00, // #
|
||||
0x00,0x00,0x01,0x00,0x03,0x80,0x07,0xC0,0x0D,0x60,0x0D,0x00,0x0F,0x00,0x07,0x80,0x03,0xC0,0x01,0xE0,0x0D,0x60,0x0D,0x60,0x07,0xC0,0x03,0x80,0x01,0x00,0x00,0x00, // $
|
||||
0x00,0x00,0x00,0x00,0x3C,0x18,0x66,0x30,0x66,0x30,0x66,0x60,0x66,0xC0,0x3C,0xC0,0x01,0x9E,0x01,0xB3,0x03,0x33,0x03,0x33,0x06,0x33,0x0C,0x1E,0x00,0x00,0x00,0x00, // %
|
||||
0x00,0x00,0x00,0x00,0x07,0xC0,0x0F,0xE0,0x0C,0x60,0x0C,0x60,0x07,0xC0,0x07,0x80,0x0D,0x90,0x19,0xD8,0x18,0xF0,0x18,0x78,0x0F,0xFC,0x07,0x88,0x00,0x00,0x00,0x00, // &
|
||||
0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // '
|
||||
0x00,0x00,0x01,0x80,0x03,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x03,0x00,0x03,0x00,0x01,0x80,0x00,0x00,0x00,0x00, // (
|
||||
0x00,0x00,0x06,0x00,0x03,0x00,0x03,0x00,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x03,0x00,0x03,0x00,0x06,0x00,0x00,0x00,0x00,0x00, // )
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x03,0x80,0x33,0x98,0x3F,0xF8,0x07,0xC0,0x07,0xC0,0x0E,0xE0,0x1C,0x70,0x04,0x40,0x00,0x00,0x00,0x00,0x00,0x00, // *
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x07,0xF8,0x07,0xF8,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, // +
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x01,0x00,0x01,0x00,0x02,0x00,0x00,0x00, // ,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xE0,0x03,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // -
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // .
|
||||
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00, // /
|
||||
|
||||
0x00,0x00,0x00,0x00,0x03,0xC0,0x07,0xE0,0x0E,0x70,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0E,0x70,0x07,0xE0,0x03,0xC0,0x00,0x00,0x00,0x00, // 0
|
||||
0x00,0x00,0x00,0x00,0x01,0x80,0x03,0x80,0x07,0x80,0x0D,0x80,0x09,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00, // 1
|
||||
0x00,0x00,0x00,0x00,0x03,0xC0,0x07,0xE0,0x0E,0x30,0x0C,0x30,0x00,0x30,0x00,0x60,0x00,0xE0,0x01,0xC0,0x03,0x80,0x06,0x00,0x0F,0xF0,0x0F,0xF0,0x00,0x00,0x00,0x00, // 2
|
||||
0x00,0x00,0x00,0x00,0x03,0xE0,0x07,0xF0,0x0E,0x30,0x00,0x30,0x01,0xE0,0x01,0xE0,0x00,0x70,0x00,0x30,0x0C,0x30,0x0E,0x70,0x07,0xE0,0x03,0xC0,0x00,0x00,0x00,0x00, // 3
|
||||
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0xE0,0x00,0xE0,0x01,0xE0,0x03,0x60,0x03,0x60,0x06,0x60,0x0C,0x60,0x0F,0xF0,0x0F,0xF0,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00, // 4
|
||||
0x00,0x00,0x00,0x00,0x07,0xE0,0x07,0xE0,0x06,0x00,0x0C,0x00,0x0F,0xC0,0x0F,0xE0,0x0C,0x70,0x00,0x30,0x0C,0x30,0x0E,0x70,0x07,0xE0,0x03,0xC0,0x00,0x00,0x00,0x00, // 5
|
||||
0x00,0x00,0x00,0x00,0x03,0xE0,0x07,0xF0,0x06,0x30,0x0C,0x00,0x0D,0xC0,0x0F,0xE0,0x0E,0x70,0x0C,0x30,0x0C,0x30,0x06,0x30,0x07,0xE0,0x03,0xC0,0x00,0x00,0x00,0x00, // 6
|
||||
0x00,0x00,0x00,0x00,0x0F,0xF0,0x0F,0xF0,0x00,0x60,0x00,0xC0,0x00,0xC0,0x01,0x80,0x01,0x80,0x01,0x80,0x03,0x80,0x03,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00, // 7
|
||||
0x00,0x00,0x00,0x00,0x03,0xC0,0x07,0xE0,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x07,0xE0,0x07,0xE0,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x07,0xE0,0x03,0xC0,0x00,0x00,0x00,0x00, // 8
|
||||
0x00,0x00,0x00,0x00,0x03,0xC0,0x07,0xE0,0x0C,0x60,0x0C,0x30,0x0C,0x30,0x0E,0x70,0x07,0xF0,0x03,0xB0,0x00,0x30,0x0C,0x60,0x0F,0xE0,0x07,0xC0,0x00,0x00,0x00,0x00, // 9
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // :
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x00,0x80,0x00,0x80,0x01,0x00,0x00,0x00, // ;
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0xE0,0x03,0xC0,0x0F,0x00,0x1C,0x00,0x0F,0x00,0x03,0xC0,0x00,0xE0,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00, // <
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF0,0x1F,0xF0,0x00,0x00,0x00,0x00,0x1F,0xF0,0x1F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // =
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x0E,0x00,0x07,0x80,0x01,0xE0,0x00,0x70,0x01,0xE0,0x07,0x80,0x0E,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // >
|
||||
0x00,0x00,0x00,0x00,0x03,0xC0,0x07,0xE0,0x0E,0x30,0x0C,0x30,0x00,0x70,0x00,0xE0,0x01,0xC0,0x01,0x80,0x01,0x80,0x00,0x00,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00, // ?
|
||||
|
||||
0x00,0x00,0x07,0xC0,0x0C,0x30,0x13,0x78,0x17,0xE8,0x2C,0xC8,0x2C,0xC8,0x2C,0xC8,0x2F,0xD0,0x26,0xE0,0x10,0x08,0x08,0x10,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00, // @
|
||||
0x00,0x00,0x00,0x00,0x03,0x80,0x03,0x80,0x06,0xC0,0x06,0xC0,0x06,0xC0,0x0C,0x60,0x0C,0x60,0x0F,0xE0,0x1F,0xF0,0x18,0x30,0x18,0x30,0x30,0x18,0x00,0x00,0x00,0x00, // A
|
||||
0x00,0x00,0x00,0x00,0x1F,0xE0,0x1F,0xF0,0x18,0x30,0x18,0x30,0x18,0x30,0x1F,0xE0,0x1F,0xF0,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0xF0,0x1F,0xE0,0x00,0x00,0x00,0x00, // B
|
||||
0x00,0x00,0x00,0x00,0x03,0xE0,0x0F,0xF0,0x0C,0x38,0x1C,0x10,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x1C,0x10,0x0C,0x38,0x0F,0xF0,0x03,0xE0,0x00,0x00,0x00,0x00, // C
|
||||
0x00,0x00,0x00,0x00,0x1F,0xC0,0x1F,0xF0,0x18,0x30,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x30,0x1F,0xF0,0x1F,0xC0,0x00,0x00,0x00,0x00, // D
|
||||
0x00,0x00,0x00,0x00,0x0F,0xF8,0x0F,0xF8,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0F,0xF8,0x0F,0xF8,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0F,0xF8,0x0F,0xF8,0x00,0x00,0x00,0x00, // E
|
||||
0x00,0x00,0x00,0x00,0x0F,0xF0,0x0F,0xF0,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0F,0xE0,0x0F,0xE0,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00, // F
|
||||
0x00,0x00,0x00,0x00,0x07,0xE0,0x1F,0xF0,0x18,0x38,0x38,0x10,0x30,0x00,0x30,0x00,0x30,0xF8,0x30,0xF8,0x38,0x18,0x18,0x38,0x1F,0xF8,0x07,0xE0,0x00,0x00,0x00,0x00, // G
|
||||
0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1F,0xF8,0x1F,0xF8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00, // H
|
||||
0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00, // I
|
||||
0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x0C,0x30,0x0E,0x70,0x07,0xE0,0x03,0xC0,0x00,0x00,0x00,0x00, // J
|
||||
0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x18,0x60,0x18,0xC0,0x19,0x80,0x1B,0xC0,0x1E,0xC0,0x1C,0x60,0x18,0x70,0x18,0x30,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00, // K
|
||||
0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0F,0xF0,0x0F,0xF0,0x00,0x00,0x00,0x00, // L
|
||||
0x00,0x00,0x00,0x00,0x38,0x38,0x38,0x38,0x3C,0x78,0x3C,0x78,0x34,0x58,0x36,0xD8,0x36,0xD8,0x36,0xD8,0x33,0x98,0x33,0x98,0x33,0x98,0x31,0x18,0x00,0x00,0x00,0x00, // M
|
||||
0x00,0x00,0x00,0x00,0x18,0x18,0x1C,0x18,0x1E,0x18,0x1E,0x18,0x1B,0x18,0x19,0x98,0x19,0x98,0x18,0xD8,0x18,0x78,0x18,0x78,0x18,0x38,0x18,0x18,0x00,0x00,0x00,0x00, // N
|
||||
0x00,0x00,0x00,0x00,0x07,0xC0,0x1F,0xF0,0x18,0x30,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x18,0x18,0x30,0x1F,0xF0,0x07,0xC0,0x00,0x00,0x00,0x00, // O
|
||||
|
||||
0x00,0x00,0x00,0x00,0x0F,0xE0,0x0F,0xF0,0x0C,0x38,0x0C,0x18,0x0C,0x38,0x0F,0xF0,0x0F,0xE0,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00, // P
|
||||
0x00,0x00,0x00,0x00,0x07,0xC0,0x1F,0xF0,0x18,0x30,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x18,0x30,0x18,0x31,0xB8,0x18,0xF0,0x1F,0xF0,0x07,0xB0,0x00,0x18,0x00,0x00, // Q
|
||||
0x00,0x00,0x00,0x00,0x1F,0xE0,0x1F,0xF0,0x18,0x38,0x18,0x18,0x18,0x38,0x1F,0xF0,0x1F,0xC0,0x18,0xE0,0x18,0x70,0x18,0x30,0x18,0x38,0x18,0x1C,0x00,0x00,0x00,0x00, // R
|
||||
0x00,0x00,0x00,0x00,0x03,0xE0,0x07,0xF0,0x0E,0x38,0x0C,0x18,0x0F,0x00,0x07,0xE0,0x01,0xF0,0x00,0x38,0x0C,0x18,0x0E,0x38,0x07,0xF0,0x03,0xE0,0x00,0x00,0x00,0x00, // S
|
||||
0x00,0x00,0x00,0x00,0x1F,0xF8,0x1F,0xF8,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00, // T
|
||||
0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1C,0x38,0x0F,0xF0,0x07,0xE0,0x00,0x00,0x00,0x00, // U
|
||||
0x00,0x00,0x00,0x00,0x30,0x18,0x18,0x30,0x18,0x30,0x18,0x30,0x0C,0x60,0x0C,0x60,0x0E,0xE0,0x06,0xC0,0x06,0xC0,0x03,0x80,0x03,0x80,0x03,0x80,0x00,0x00,0x00,0x00, // V
|
||||
0x00,0x00,0x00,0x00,0x31,0xC6,0x31,0xC6,0x31,0xC6,0x1B,0x6C,0x1B,0x6C,0x1B,0x6C,0x1B,0x6C,0x1B,0x6C,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x00,0x00,0x00,0x00, // W
|
||||
0x00,0x00,0x00,0x00,0x18,0x30,0x1C,0x70,0x0C,0x60,0x06,0xC0,0x07,0xC0,0x03,0x80,0x03,0x80,0x07,0xC0,0x06,0xC0,0x0C,0x60,0x1C,0x70,0x18,0x30,0x00,0x00,0x00,0x00, // X
|
||||
0x00,0x00,0x00,0x00,0x18,0x18,0x1C,0x38,0x0C,0x30,0x06,0x60,0x06,0x60,0x03,0xC0,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00, // Y
|
||||
0x00,0x00,0x00,0x00,0x07,0xF8,0x07,0xF8,0x00,0x30,0x00,0x60,0x00,0xE0,0x00,0xC0,0x01,0x80,0x03,0x80,0x03,0x00,0x06,0x00,0x0F,0xF8,0x0F,0xF8,0x00,0x00,0x00,0x00, // Z
|
||||
0x00,0x00,0x03,0xC0,0x03,0xC0,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0xC0,0x03,0xC0,0x00,0x00, // [
|
||||
0x00,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00, // <backslash>
|
||||
0x00,0x00,0x03,0xC0,0x03,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x03,0xC0,0x03,0xC0,0x00,0x00, // ]
|
||||
0x00,0x00,0x01,0x80,0x03,0xC0,0x03,0xC0,0x06,0x60,0x06,0x60,0x06,0x60,0x0C,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ^
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00, // _
|
||||
|
||||
0x00,0x00,0x00,0x00,0x01,0x80,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // `
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x0F,0xE0,0x0C,0x60,0x01,0xE0,0x07,0xE0,0x0E,0x60,0x0C,0x60,0x0F,0xE0,0x07,0xB0,0x00,0x00,0x00,0x00,0x00,0x00, // a
|
||||
0x00,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0D,0xC0,0x0F,0xE0,0x0E,0x70,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0E,0x70,0x0F,0xE0,0x0D,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, // b
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x07,0xE0,0x0E,0x60,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0E,0x60,0x07,0xE0,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, // c
|
||||
0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x30,0x03,0xB0,0x07,0xF0,0x0E,0x70,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0E,0x70,0x07,0xF0,0x03,0xB0,0x00,0x00,0x00,0x00,0x00,0x00, // d
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x07,0xC0,0x0C,0x60,0x0F,0xE0,0x0F,0xE0,0x0C,0x00,0x0E,0x60,0x07,0xC0,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00, // e
|
||||
0x00,0x00,0x03,0xC0,0x07,0xC0,0x06,0x00,0x0F,0x80,0x0F,0x80,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // f
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x60,0x0F,0xE0,0x1C,0xE0,0x18,0x60,0x18,0x60,0x18,0x60,0x1C,0xE0,0x0F,0xE0,0x07,0x60,0x18,0x60,0x1F,0xE0,0x0F,0xC0,0x00,0x00, // g
|
||||
0x00,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0D,0xE0,0x0F,0xF0,0x0E,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x00,0x00,0x00,0x00,0x00,0x00, // h
|
||||
0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x00,0x00,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00, // i
|
||||
0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x00,0x00,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x07,0x80,0x07,0x00, // j
|
||||
0x00,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x60,0x0C,0xC0,0x0D,0x80,0x0F,0x80,0x0F,0xC0,0x0E,0xC0,0x0C,0xC0,0x0C,0x60,0x0C,0x60,0x00,0x00,0x00,0x00,0x00,0x00, // k
|
||||
0x00,0x00,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00, // l
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x38,0x3F,0xFC,0x39,0xCC,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x00,0x00,0x00,0x00,0x00,0x00, // m
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0xE0,0x0F,0xF0,0x0E,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x00,0x00,0x00,0x00,0x00,0x00, // n
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x07,0xE0,0x0E,0x70,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0E,0x70,0x07,0xE0,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, // o
|
||||
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0xC0,0x0F,0xE0,0x0E,0x70,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0E,0x70,0x0F,0xE0,0x0D,0xC0,0x0C,0x00,0x0C,0x00,0x0C,0x00, // p
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xB0,0x07,0xF0,0x0E,0x70,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0E,0x70,0x07,0xF0,0x03,0xB0,0x00,0x30,0x00,0x30,0x00,0x30, // q
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x70,0x03,0xF0,0x03,0x80,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // r
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x0F,0xE0,0x0C,0x60,0x0F,0x00,0x07,0xC0,0x00,0xE0,0x0C,0x60,0x0F,0xE0,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, // s
|
||||
0x00,0x00,0x01,0x00,0x03,0x00,0x03,0x00,0x07,0xC0,0x07,0xC0,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0xC0,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, // t
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x70,0x0F,0xF0,0x07,0xB0,0x00,0x00,0x00,0x00,0x00,0x00, // u
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x30,0x06,0x30,0x06,0x30,0x03,0x60,0x03,0x60,0x03,0x60,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, // v
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0xC6,0x31,0xC6,0x19,0xCC,0x1B,0x6C,0x1B,0x6C,0x1B,0x6C,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x00,0x00,0x00,0x00,0x00,0x00, // w
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x30,0x07,0x70,0x03,0x60,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x03,0x60,0x07,0x70,0x06,0x30,0x00,0x00,0x00,0x00,0x00,0x00, // x
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18,0x0C,0x18,0x06,0x30,0x06,0x30,0x03,0x60,0x03,0x60,0x03,0xE0,0x01,0xC0,0x01,0xC0,0x01,0x80,0x07,0x80,0x07,0x00, // y
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xF8,0x03,0xF8,0x00,0x30,0x00,0x70,0x00,0xE0,0x01,0xC0,0x01,0x80,0x03,0xF8,0x03,0xF8,0x00,0x00,0x00,0x00,0x00,0x00, // z
|
||||
0x01,0xC0,0x03,0xC0,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x0E,0x00,0x0E,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0xC0,0x01,0xC0,0x00,0x00, // {
|
||||
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80, // |
|
||||
0x03,0x80,0x03,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x70,0x00,0x70,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x03,0xC0,0x03,0x80,0x00,0x00, // }
|
||||
0x00,0x00,0x00,0x00,0x07,0x88,0x0F,0xF8,0x08,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ~
|
||||
};
|
||||
@@ -0,0 +1,235 @@
|
||||
// Generated by : ImageConverter 565 Online
|
||||
// Generated from : top.png
|
||||
// Time generated : Tue, 30 Sep 14 23:16:51 +0200 (Server timezone: CET)
|
||||
// Image Size : 60x60 pixels
|
||||
// Memory usage : 7200 bytes
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
const unsigned short logo[3600] PROGMEM={
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0010 (16) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0020 (32) pixels
|
||||
0x08E4, 0x28A3, 0x89A7, 0x71C7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0030 (48) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0040 (64) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0050 (80) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xAD55, 0x18C3, 0x0082, 0x4944, 0x5A08, 0x8147, 0xBB0D, 0x5A69, // 0x0060 (96) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0070 (112) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0080 (128) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x52A0, 0x3180, 0x0000, 0x52AA, 0x2945, // 0x0090 (144) pixels
|
||||
0x2965, 0x0000, 0x0000, 0x0000, 0x18E3, 0x0021, 0x4144, 0x69C6, 0x6924, 0xAA49, 0xB3AD, 0x00E2, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00A0 (160) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00B0 (176) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00C0 (192) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2104, 0x0861, 0x2924, 0x0000, 0x0000, 0x00C2, // 0x00D0 (208) pixels
|
||||
0x1862, 0x4924, 0x4924, 0x9965, 0xCB4A, 0xE48D, 0x9329, 0x0004, 0x6A69, 0x51A5, 0x2125, 0x0000, 0x5000, 0x0000, 0x0000, 0x0000, // 0x00E0 (224) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00F0 (240) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0100 (256) pixels
|
||||
0x0000, 0x1002, 0x1924, 0x41A4, 0x3124, 0x0000, 0x0000, 0x4A69, 0x2924, 0x0000, 0x0000, 0x4125, 0x38E4, 0x5983, 0x9A46, 0xE40A, // 0x0110 (272) pixels
|
||||
0xFCCD, 0xF4CE, 0x50E5, 0x6226, 0xBBAC, 0xAAEB, 0x4904, 0x0000, 0x4104, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0120 (288) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0130 (304) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2124, 0x10C3, 0x0000, 0x0000, 0x2800, 0x41A5, 0x9309, // 0x0140 (320) pixels
|
||||
0x8288, 0x00E5, 0x4A49, 0x73AE, 0x31A6, 0x1800, 0x59C7, 0x71E7, 0x2100, 0x8266, 0xE40B, 0xFCAC, 0xFC8C, 0xDC8F, 0x5187, 0xA387, // 0x0150 (336) pixels
|
||||
0xABA9, 0x9249, 0x58C0, 0x0000, 0x0000, 0x8410, 0x2104, 0x10A2, 0x2965, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0160 (352) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0170 (368) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0944, 0x2062, 0x5165, 0x5903, 0x00A4, 0x0165, 0x8A67, 0xAB28, 0x7267, 0x29E8, 0x7B0C, // 0x0180 (384) pixels
|
||||
0x6185, 0x8207, 0xC3AC, 0x6A04, 0x0140, 0xC36A, 0xFDEC, 0xF5AC, 0xFD30, 0xCC51, 0x70C5, 0xC469, 0xEC8D, 0x89E9, 0x0000, 0x5269, // 0x0190 (400) pixels
|
||||
0x20C3, 0x0861, 0x0841, 0x18A2, 0x39E7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x01A0 (416) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x01B0 (432) pixels
|
||||
0x5000, 0x0000, 0x71A5, 0x9A88, 0xAAA8, 0xC2C9, 0xA248, 0x9A26, 0xCA87, 0xCAC8, 0x58C0, 0x69C5, 0xC30B, 0xD3AC, 0xDC4A, 0x51A2, // 0x01C0 (448) pixels
|
||||
0x5A65, 0xEC6B, 0xFDCB, 0xFE0E, 0xFD0F, 0xEBF1, 0xB3EB, 0xED6E, 0xEC10, 0x61C7, 0x0123, 0x0021, 0x0082, 0x10C3, 0x3186, 0x0000, // 0x01D0 (464) pixels
|
||||
0x0000, 0x6180, 0x5000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x01E0 (480) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF800, 0x0000, 0xFFF0, 0x5943, // 0x01F0 (496) pixels
|
||||
0xA226, 0xD369, 0xEB4A, 0xE289, 0xE26A, 0xEB0E, 0x9AAA, 0x5042, 0xDBAC, 0xEC8C, 0xDC29, 0x7A45, 0xCC4A, 0xFB4C, 0xFD8D, 0xFDF0, // 0x0200 (512) pixels
|
||||
0xF510, 0xFD8F, 0xF5CF, 0xFE31, 0xCC31, 0x0000, 0x3801, 0x4143, 0x59A6, 0x4165, 0x0082, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0210 (528) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0220 (544) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0041, 0x9986, 0xC2E8, 0xDB88, 0xF44A, // 0x0230 (560) pixels
|
||||
0xDBCB, 0xEBCD, 0xD44D, 0x41C5, 0xB308, 0xEC0B, 0xF46C, 0xE40D, 0xD38A, 0xEC2D, 0xFEAE, 0xFEF2, 0xFDD2, 0xFE51, 0xFD52, 0xFCB1, // 0x0240 (576) pixels
|
||||
0xEC50, 0xCBEE, 0xB42A, 0xA2C6, 0x8985, 0x79A6, 0x89A6, 0xB1E6, 0xA1C6, 0x5924, 0x4986, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0250 (592) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0260 (608) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0040, 0x6125, 0xE3A9, 0xF4EB, 0xF5AC, 0xDD49, 0xE5CB, 0xFE6E, 0xC44E, // 0x0270 (624) pixels
|
||||
0x9B8A, 0xE4CD, 0xFD70, 0xFDB1, 0xCCCE, 0xF62E, 0xFE8D, 0xFE50, 0xFE56, 0xFD97, 0xF4B6, 0xF3F0, 0xFD2F, 0xFE50, 0xF5D1, 0xDC10, // 0x0280 (640) pixels
|
||||
0xB289, 0xC269, 0xCA68, 0xEB6C, 0xDC2F, 0xA2C9, 0x2062, 0x1945, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0290 (656) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x02A0 (672) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x00E3, 0x3904, 0xB1C6, 0xE34C, 0xEC2C, 0xE4AB, 0xCD2B, 0xF64C, 0xFE70, 0xFE4F, 0xEE4E, 0xFED2, 0xFED2, // 0x02B0 (688) pixels
|
||||
0xFEB2, 0xFE33, 0xFDD3, 0xFE74, 0xF535, 0xCB11, 0xEB32, 0xFCF2, 0xFDF1, 0xF574, 0xFE13, 0xFE52, 0xBC4B, 0x8226, 0x6945, 0x6A28, // 0x02C0 (704) pixels
|
||||
0x3228, 0x2124, 0x1904, 0x51C7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x02D0 (720) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x10A2, // 0x02E0 (736) pixels
|
||||
0x0861, 0x91C5, 0xDA4A, 0xEAAB, 0xF3D1, 0xED12, 0xD591, 0xC50D, 0xA3E9, 0xB50C, 0xEE92, 0xB4EE, 0x7329, 0x82E8, 0xC572, 0xEDF3, // 0x02F0 (752) pixels
|
||||
0xB3ED, 0x3800, 0xA3CF, 0xFEF6, 0xFED0, 0xFEB4, 0xFEF3, 0xF6CF, 0xEEAE, 0xBD2A, 0x0120, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0300 (768) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0310 (784) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1001, 0x39C7, 0x8227, 0xE2AA, 0xDB0C, // 0x0320 (800) pixels
|
||||
0xE4B3, 0xCD11, 0x83EA, 0x5286, 0x52AA, 0x7BEF, 0x2940, 0x3A2A, 0x5AEB, 0x73CF, 0x52AA, 0x3945, 0x1184, 0x6B2B, 0xACF1, 0xB54F, // 0x0330 (816) pixels
|
||||
0xF733, 0xFF51, 0xFF32, 0xFF55, 0xFF33, 0xF696, 0xCC93, 0x624A, 0x0120, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0340 (832) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0350 (848) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6248, 0x9249, 0xCB2A, 0xABEC, 0x8C2B, 0x5AE6, 0x10C3, 0x5269, // 0x0360 (864) pixels
|
||||
0xA4F3, 0xD637, 0x9C90, 0xAD33, 0xAD12, 0xE6FA, 0xC5B5, 0x6AC9, 0x83CE, 0xBD53, 0xCDD5, 0x9450, 0x6B47, 0xCD91, 0xFEB4, 0xEED4, // 0x0370 (880) pixels
|
||||
0x9490, 0x736E, 0xCCD5, 0xCC94, 0x7B2D, 0x0000, 0xFC10, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0380 (896) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0390 (912) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x6A8A, 0x8B0A, 0x9C2B, 0x7BCA, 0x3163, 0x526B, 0x1904, 0x736C, 0xE698, 0xD658, 0xD658, 0xD616, // 0x03A0 (928) pixels
|
||||
0xF719, 0xFF5B, 0xF71A, 0xEED8, 0xD5F5, 0xEEFA, 0xE6B8, 0xA4F3, 0x29A8, 0x0000, 0xAC31, 0xEE36, 0x9C2E, 0x0000, 0x4145, 0xAB70, // 0x03B0 (944) pixels
|
||||
0xC4B4, 0x93F0, 0x0000, 0x0000, 0x4008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x03C0 (960) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x03D0 (976) pixels
|
||||
0x8B6B, 0x7B6A, 0x1124, 0x0000, 0x0000, 0x41E6, 0x0002, 0xB512, 0xFF7B, 0xFF9C, 0xFF9C, 0xFFDD, 0xFF9C, 0xFFBD, 0xFFFF, 0xFF9C, // 0x03E0 (992) pixels
|
||||
0xFF5B, 0xFFBD, 0xFF9C, 0xF71A, 0x9CB1, 0x0000, 0x0000, 0xACB2, 0xE6B6, 0x4A68, 0x0000, 0x0144, 0x738E, 0x6B4D, 0x0000, 0x0000, // 0x03F0 (1008) pixels
|
||||
0x500A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0400 (1024) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2145, 0x3144, 0x0002, 0x0000, 0x0000, // 0x0410 (1040) pixels
|
||||
0x0000, 0x39C7, 0x0083, 0xC594, 0xEED9, 0xEEB8, 0xEEFA, 0xC5F7, 0xEEFA, 0xFFDD, 0xDEFB, 0xA4F2, 0xEE97, 0xF6D8, 0xEEF9, 0xFF7B, // 0x0420 (1056) pixels
|
||||
0xDE56, 0x41C6, 0x0000, 0x0000, 0x9491, 0x7BCE, 0x0000, 0x6209, 0x0000, 0x0000, 0x6A49, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0430 (1072) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0440 (1088) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2965, 0x0000, 0xAD12, // 0x0450 (1104) pixels
|
||||
0xCE17, 0x534E, 0x02B0, 0x7472, 0xF73A, 0xFF7B, 0xF71A, 0xA4F2, 0x02AE, 0x4B6F, 0x9C91, 0xFF5B, 0xF6D9, 0x838C, 0x0000, 0x0000, // 0x0460 (1120) pixels
|
||||
0x0000, 0x0001, 0x2124, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0470 (1136) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0480 (1152) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x8400, 0x5000, 0x8410, 0x0000, 0xB4D3, 0x2965, 0x3985, 0xA4D1, 0xFFDF, 0xCEDC, 0x4413, 0xDEFA, // 0x0490 (1168) pixels
|
||||
0xFF9C, 0xEED9, 0xFF5A, 0xFF5A, 0x8D36, 0xBE59, 0xFFDE, 0xFF7B, 0xFF19, 0x8BEE, 0x0000, 0x0000, 0x0000, 0x632C, 0x0005, 0x0000, // 0x04A0 (1184) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x04B0 (1200) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x04C0 (1216) pixels
|
||||
0x0000, 0x0000, 0x8410, 0x0000, 0x7BCF, 0x2966, 0x5247, 0xBD95, 0xFFDE, 0xFF9C, 0xF73A, 0xFF7B, 0xF719, 0xCE17, 0xF75C, 0xFFDE, // 0x04D0 (1232) pixels
|
||||
0xFF7C, 0xFF5A, 0xFFDE, 0xFF3A, 0xFF5A, 0xACF1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x04E0 (1248) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x04F0 (1264) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8410, 0x0000, // 0x0500 (1280) pixels
|
||||
0x8C51, 0x2966, 0x62A9, 0x9CB2, 0xE6B9, 0xEEB8, 0xFF5B, 0xFF9C, 0xEEB8, 0xD637, 0xFF9C, 0xFFBD, 0xFF7B, 0xFF5B, 0xFF5B, 0xFF19, // 0x0510 (1296) pixels
|
||||
0xFF5A, 0xC574, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0520 (1312) pixels
|
||||
0x0000, 0x0000, 0x5000, 0x52AA, 0x8000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0530 (1328) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8410, 0x0000, 0xACF3, 0x3186, 0x5AA9, 0x940E, // 0x0540 (1344) pixels
|
||||
0x9C90, 0xD616, 0xEEF9, 0xFF7B, 0xDE78, 0xB533, 0xE697, 0xFF39, 0xFF5A, 0xFF5B, 0xFF3A, 0xFF5B, 0xFF5A, 0xC593, 0x0000, 0x0000, // 0x0550 (1360) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0560 (1376) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0570 (1392) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2125, 0x5248, 0xA490, 0xC5B5, 0xEED9, 0xF73A, 0xF71A, // 0x0580 (1408) pixels
|
||||
0xACF2, 0xBD74, 0xB533, 0xF71A, 0xFF9C, 0xFF3B, 0xFF7C, 0xFF9C, 0xFF9C, 0xB512, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0590 (1424) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x05A0 (1440) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x05B0 (1456) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2125, 0x41E7, 0xA4B1, 0xBD95, 0xE698, 0xF71A, 0xFF7B, 0xEEB8, 0xFF3A, 0xF6F9, 0xFFBD, // 0x05C0 (1472) pixels
|
||||
0xEEB9, 0xAC2F, 0xE71B, 0xFFBD, 0xFF9C, 0xB532, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x05D0 (1488) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x4208, 0x2965, 0x5248, 0xB512, 0xE676, 0xA46F, 0x0000, 0xFFF0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x05E0 (1504) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x05F0 (1520) pixels
|
||||
0x0000, 0x4208, 0x0000, 0xA490, 0xFF7C, 0xAD54, 0x91E6, 0xFF3B, 0xFFBC, 0xFF5A, 0xFF7B, 0xFFDD, 0xDC90, 0xB450, 0xF75B, 0xFF3A, // 0x0600 (1536) pixels
|
||||
0xFF9B, 0xA4D1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0610 (1552) pixels
|
||||
0x4A28, 0xC573, 0xFF7B, 0xFF5A, 0x7B4B, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x52AA, 0x0000, 0x0000, // 0x0620 (1568) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4208, 0x0000, 0x52AA, 0x1904, 0x62C9, // 0x0630 (1584) pixels
|
||||
0xFF5B, 0xE6BA, 0x5800, 0xDC0E, 0xFF1B, 0xFF7B, 0xFFBD, 0xF617, 0xB940, 0xD617, 0xFF5A, 0xFF19, 0xFF7B, 0x7B6C, 0x0000, 0x0000, // 0x0640 (1600) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5000, 0x0000, 0x08C4, 0x6B0A, 0x942F, 0xF6F9, 0xFF7A, 0xC574, // 0x0650 (1616) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0660 (1632) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8410, 0x0000, 0x738E, 0x4A49, 0x08A3, 0xCDB4, 0xFF7B, 0x9CB1, 0x9000, // 0x0670 (1648) pixels
|
||||
0xC267, 0xA3AD, 0xB34C, 0xA8E0, 0xBD14, 0xF71A, 0xFF39, 0xFF9B, 0xE698, 0x0000, 0x0000, 0x52AA, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0680 (1664) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x4200, 0x0000, 0x1904, 0x6AEA, 0x83AC, 0xC573, 0x8BEE, 0x0000, 0x52AA, 0x0000, 0x0000, 0x0000, // 0x0690 (1680) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0004, 0x4229, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x06A0 (1696) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x4208, 0x0000, 0x5AAA, 0x2146, 0x83CD, 0xFF19, 0xFF19, 0xBD53, 0x9BEE, 0x9BAD, 0xACD3, 0xC658, // 0x06B0 (1712) pixels
|
||||
0xF73B, 0xFF5A, 0xFF5A, 0xF73A, 0x630C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x06C0 (1728) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00A7, // 0x06D0 (1744) pixels
|
||||
0x4A28, 0x4A48, 0x428B, 0x0000, 0x4208, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x06E0 (1760) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x4228, 0x3186, 0xCDF6, 0xFF7B, 0xFF7B, 0xF71A, 0xF73A, 0xFF9C, 0xFF7C, 0xFF3A, 0xFF3A, 0xFF9C, 0x9471, // 0x06F0 (1776) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2104, // 0x0700 (1792) pixels
|
||||
0x2104, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4208, 0x0000, 0x0000, 0xACD1, 0xE677, 0x836C, 0x0000, // 0x0710 (1808) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8410, 0x0000, 0x8C51, // 0x0720 (1824) pixels
|
||||
0x2945, 0x39C6, 0x9C90, 0xE6B9, 0xFF9C, 0xFF5A, 0xFF19, 0xFF3A, 0xFF7B, 0xFFDD, 0xB5B6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0730 (1840) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x39C7, 0x18C3, 0x3186, 0x0000, 0x0000, 0x0000, // 0x0740 (1856) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFF0, 0x10E4, 0xB512, 0xFF9B, 0xE6B8, 0x0002, 0x0000, 0x8410, 0x0000, 0x0000, // 0x0750 (1872) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0000, 0x52AA, 0x10E3, 0x0000, 0x83AD, // 0x0760 (1888) pixels
|
||||
0xE698, 0xFF19, 0xFF39, 0xEED8, 0xD658, 0x9492, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0770 (1904) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x18E3, 0x18E3, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0780 (1920) pixels
|
||||
0x0000, 0x0000, 0xAD55, 0x2145, 0x9C4F, 0xBD32, 0x9450, 0x31A7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0790 (1936) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x52AA, 0x0000, 0x0000, 0x8C31, 0xB576, 0x41E7, 0x5AA9, 0x5A68, 0x8C0F, 0x8C0F, 0x5ACA, // 0x07A0 (1952) pixels
|
||||
0x4A6A, 0xB532, 0x8BCD, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x07B0 (1968) pixels
|
||||
0x0000, 0x0000, 0x18C3, 0x2945, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2965, // 0x07C0 (1984) pixels
|
||||
0x18C3, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x07D0 (2000) pixels
|
||||
0x0000, 0x52AA, 0x0000, 0x1003, 0xCE1A, 0xEF1D, 0x62EC, 0x7B8C, 0xA4B1, 0x9C70, 0xB512, 0xB532, 0xD616, 0xF6D8, 0x6B0B, 0x0000, // 0x07E0 (2016) pixels
|
||||
0x3165, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x18E3, 0x18E3, 0x0000, // 0x07F0 (2032) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xA451, 0x2945, 0x18E3, // 0x0800 (2048) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x9E73, 0x0000, // 0x0810 (2064) pixels
|
||||
0x9493, 0xF77E, 0xCE39, 0x4A48, 0xCDF6, 0xC5B5, 0xEED9, 0xE6B8, 0xFF3A, 0x942F, 0x73AE, 0x8430, 0x39C7, 0x0000, 0x0000, 0x0000, // 0x0820 (2080) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2124, 0x18E3, 0x8410, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0830 (2096) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8410, 0x18E3, 0x18E3, 0x4A69, 0x0000, 0x0000, // 0x0840 (2112) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8410, 0x0000, 0x4268, 0x5A8C, 0x0003, 0xB557, 0xFFDF, 0xA555, // 0x0850 (2128) pixels
|
||||
0xA4B1, 0xDE57, 0xEEB8, 0xFFBC, 0xB554, 0xA534, 0xB595, 0xB576, 0x7BD0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0860 (2144) pixels
|
||||
0x0000, 0x0000, 0x4208, 0x18C3, 0x18E3, 0x31A6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0870 (2160) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x52AA, 0x0000, 0x0000, 0x2124, 0x18C3, 0x2104, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0880 (2176) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x4208, 0x0000, 0x4A68, 0x526B, 0x7B50, 0x62AD, 0xDEBC, 0xFFFF, 0x8430, 0xB554, 0xFF7B, 0xE6B9, // 0x0890 (2192) pixels
|
||||
0x636E, 0xF7BE, 0x8C71, 0xDE9B, 0xCE1A, 0x1063, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x39E7, 0x18E3, 0x18E3, 0x2104, // 0x08A0 (2208) pixels
|
||||
0x8410, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x08B0 (2224) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3186, 0x18C3, 0x2104, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x08C0 (2240) pixels
|
||||
0x4208, 0x0000, 0x4A49, 0x4A0A, 0xACF7, 0x7B70, 0xA514, 0xFFFF, 0xF79E, 0x9491, 0xE6B8, 0x83EF, 0xDEDB, 0xE71C, 0x8410, 0xFFFF, // 0x08D0 (2256) pixels
|
||||
0xF77E, 0xA4D5, 0x0000, 0x0000, 0x0000, 0x0000, 0x3186, 0x2104, 0x18E3, 0x18E3, 0x39C7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x08E0 (2272) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x08F0 (2288) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x18C3, 0x2104, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x31C6, 0x734E, // 0x0900 (2304) pixels
|
||||
0xB537, 0xACB6, 0x5AAB, 0xE71C, 0xFFFF, 0xCE59, 0x0000, 0x9CD3, 0xFFFF, 0xA535, 0xBDF7, 0xFFFF, 0xF79E, 0xE6DD, 0xC5D8, 0x4228, // 0x0910 (2320) pixels
|
||||
0x0000, 0x3186, 0x18E3, 0x2104, 0x4208, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0920 (2336) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4A49, // 0x0930 (2352) pixels
|
||||
0x10A2, 0x18C3, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3166, 0x9453, 0xBD58, 0xB518, 0x83B1, 0xAD75, // 0x0940 (2368) pixels
|
||||
0xD6BA, 0x2125, 0x3186, 0x736E, 0xB596, 0x7BF0, 0xE73C, 0xFFFF, 0xF77E, 0xF79E, 0xF79E, 0xC5F8, 0x10A1, 0x1082, 0x8410, 0x0000, // 0x0950 (2384) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0960 (2400) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x52AA, 0x18E3, 0x10A2, 0x18C3, // 0x0970 (2416) pixels
|
||||
0x18C3, 0x0861, 0x0861, 0x0000, 0x0000, 0x2985, 0x41E8, 0xA4D5, 0xACF7, 0xC5D9, 0xE6DC, 0x6B4D, 0x62ED, 0xA4D4, 0x9452, 0xC5B9, // 0x0980 (2432) pixels
|
||||
0x522A, 0x8430, 0xFFFF, 0xFFBF, 0xF77E, 0xF7BE, 0xF77E, 0xE6DD, 0x9CD4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0990 (2448) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x09A0 (2464) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2104, 0x18E3, 0x18E3, 0x18C3, 0x18C3, 0x2945, // 0x09B0 (2480) pixels
|
||||
0x39C7, 0x3186, 0x62CC, 0x9C54, 0x9C35, 0xD63A, 0xF75E, 0xA534, 0x83D0, 0xC5D8, 0x9CD3, 0xE6DD, 0x7B70, 0xB5B6, 0xFFFF, 0xEF5E, // 0x09C0 (2496) pixels
|
||||
0xF77E, 0xFFBF, 0xF77E, 0xE6FD, 0xBD98, 0x39A7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x09D0 (2512) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x09E0 (2528) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4A49, 0x5AAC, 0x8392, // 0x09F0 (2544) pixels
|
||||
0xB537, 0xCE1A, 0xE6FC, 0xF7BE, 0xDEDB, 0xD69A, 0x8C71, 0xFFFF, 0xEF7D, 0xEF7D, 0xFFFF, 0xEF5E, 0xF77E, 0xFFDF, 0xF79E, 0xF77E, // 0x0A00 (2560) pixels
|
||||
0xD65B, 0x7B70, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0A10 (2576) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0A20 (2592) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4208, 0x5A4B, 0xA495, 0xD67B, 0xC599, 0xDEBC, 0xFFFF, // 0x0A30 (2608) pixels
|
||||
0xFFBF, 0xE71C, 0x8C71, 0xE73C, 0xB5B6, 0xEF7D, 0xFFFF, 0xEF5E, 0xF77E, 0xFFFF, 0xFFDF, 0xF79E, 0xEF5E, 0xC5B9, 0x4A49, 0x0000, // 0x0A40 (2624) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0A50 (2640) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0A60 (2656) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x39E7, 0x4A2A, 0xACF6, 0xE6FC, 0xD63A, 0xE71D, 0xFFFF, 0xF79E, 0xEF3D, 0x9CD3, 0xD69A, // 0x0A70 (2672) pixels
|
||||
0xBDF7, 0xFFDE, 0xFFDF, 0xF77E, 0xF79E, 0xFFDF, 0xFFFF, 0xFFBF, 0xF7BF, 0xEF1D, 0xAD15, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0A80 (2688) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0A90 (2704) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0AA0 (2720) pixels
|
||||
0x0000, 0x2965, 0x62CC, 0xACD6, 0xEF3D, 0xE6DC, 0xE71D, 0xFFFF, 0xF7BF, 0xF75E, 0x9CF3, 0xDEDB, 0xFFDF, 0xE73C, 0xFFDF, 0xF7BE, // 0x0AB0 (2736) pixels
|
||||
0xF7BF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xEF5E, 0xD65A, 0x41E8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0AC0 (2752) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0AD0 (2768) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1922, 0x734F, 0xB4F7, // 0x0AE0 (2784) pixels
|
||||
0xEF5E, 0xE6FC, 0xEF3D, 0xEF5D, 0xF79E, 0xF79E, 0xB5B6, 0xBDF7, 0xC638, 0xC638, 0xFFFF, 0xFFDF, 0xF79E, 0xFFFF, 0xFFFF, 0xFFFF, // 0x0AF0 (2800) pixels
|
||||
0xFFFF, 0xFFDF, 0xEF1D, 0x9452, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0B00 (2816) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0B10 (2832) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2144, 0x736F, 0xBD78, 0xEF5E, 0xDEBC, 0xEF3D, 0xE6FC, // 0x0B20 (2848) pixels
|
||||
0xF7BF, 0xF79E, 0xD69A, 0x9492, 0xFFFF, 0xFFDF, 0xFFFF, 0xFFDF, 0xF79E, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xF79F, 0xC5D9, // 0x0B30 (2864) pixels
|
||||
0x2144, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0B40 (2880) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0B50 (2896) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x31A6, 0x7B8F, 0xB537, 0xE6DC, 0xE71D, 0xF79E, 0xE6FD, 0xFFDF, 0xFFFF, 0xEF7D, 0x9492, // 0x0B60 (2912) pixels
|
||||
0xE71C, 0x738E, 0xEF7D, 0xFFDF, 0xFFBF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFDF, 0xD67B, 0x62ED, 0x0000, 0x8410, 0x0000, // 0x0B70 (2928) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0B80 (2944) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0B90 (2960) pixels
|
||||
0x0000, 0x39C7, 0x83F0, 0xACF7, 0xD65B, 0xF79E, 0xFFDF, 0xE6FC, 0xFFDF, 0xFFFF, 0xFFDF, 0x8C71, 0xE71C, 0xE71C, 0xFFFF, 0xFFDF, // 0x0BA0 (2976) pixels
|
||||
0xFFBF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xDE7B, 0x8BD2, 0x0000, 0x630C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0BB0 (2992) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0BC0 (3008) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x39C7, 0x8C31, 0xACD6, // 0x0BD0 (3024) pixels
|
||||
0xD65B, 0xF79E, 0xFFDF, 0xE6FD, 0xFFDF, 0xEF5E, 0xEF1D, 0x83F0, 0xE73C, 0xFFFF, 0xEF5D, 0xFFFF, 0xFFDF, 0xFFFF, 0xFFFF, 0xFFFF, // 0x0BE0 (3040) pixels
|
||||
0xFFFF, 0xFFFF, 0xDE9C, 0xD65B, 0x8430, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0BF0 (3056) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0C00 (3072) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x52AA, 0x0000, 0x31A6, 0x8C31, 0x9C74, 0xDE9B, 0xFFDF, 0xFFDF, 0xEF1D, // 0x0C10 (3088) pixels
|
||||
0xF79E, 0xEF5E, 0xE6FD, 0x9493, 0xCE79, 0xD6BA, 0xBDD7, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xF77E, 0xBD78, 0x9472, // 0x0C20 (3104) pixels
|
||||
0x4A4C, 0x524B, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0C30 (3120) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0C40 (3136) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x4208, 0x0000, 0x3166, 0x73AE, 0x9C74, 0xE6DC, 0xFFDF, 0xF79E, 0xF79E, 0xF79E, 0xF79E, 0xE6DC, 0xC618, // 0x0C50 (3152) pixels
|
||||
0x9492, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xEF3D, 0xDE9C, 0xACD6, 0x6ACD, 0x3ACF, 0x9D9A, 0x7C94, 0x0000, 0x0000, // 0x0C60 (3168) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0C70 (3184) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0C80 (3200) pixels
|
||||
0x0000, 0x2945, 0x4A8B, 0xA4F5, 0xF77E, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFBF, 0xFFDF, 0x8C51, 0xBDD8, 0xC5DA, 0xBDB9, // 0x0C90 (3216) pixels
|
||||
0xCE3A, 0xC5F9, 0x9C74, 0x622D, 0x3806, 0x2106, 0x3BF4, 0x7DBB, 0xAEBE, 0x8578, 0x0000, 0x0000, 0x4208, 0x0000, 0x0000, 0x0000, // 0x0CA0 (3232) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0CB0 (3248) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x52AA, 0x0000, 0x420A, 0x11CB, 0x632F, // 0x0CC0 (3264) pixels
|
||||
0x9CB5, 0xB597, 0xCE79, 0xD6BA, 0xD6BB, 0xAD77, 0xB5B7, 0xAD96, 0x6B30, 0x0809, 0x300C, 0x280C, 0x3009, 0x0003, 0x0000, 0x00A3, // 0x0CD0 (3280) pixels
|
||||
0x332F, 0x7D99, 0x8E1C, 0x8E1B, 0x9E7D, 0x95FB, 0x2986, 0x0000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0CE0 (3296) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0CF0 (3312) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x001F, 0x0000, 0x82B5, 0x398D, 0x18CC, 0x0170, 0x00B0, 0x000C, 0x100A, // 0x0D00 (3328) pixels
|
||||
0x180B, 0x000A, 0x0009, 0x0009, 0x380B, 0x518D, 0x48CC, 0x484B, 0x49AD, 0x3BF5, 0x5CF8, 0x6539, 0x7DDC, 0xBEDD, 0xCF1D, 0x759B, // 0x0D10 (3344) pixels
|
||||
0x9E7C, 0xA67D, 0x3AAC, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0D20 (3360) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0D30 (3376) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x000A, 0x0000, 0x398C, 0x314B, 0x3A32, 0x53B7, 0x53B6, 0x42D4, 0x4314, 0x5375, 0x63B5, 0x6395, // 0x0D40 (3392) pixels
|
||||
0x4252, 0x496E, 0x4AF2, 0x5436, 0x5CD9, 0x5D5B, 0x8DFC, 0x9E7D, 0xAE9D, 0xBEDD, 0xCEFD, 0x5D5A, 0xA67C, 0xA69D, 0x5390, 0x0000, // 0x0D50 (3408) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0D60 (3424) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0D70 (3440) pixels
|
||||
0x4208, 0x0000, 0x318A, 0x292A, 0x30ED, 0x52F4, 0x53B7, 0x4BF7, 0x5438, 0x5458, 0x5C17, 0x5376, 0x4B36, 0x6CD9, 0x5D5A, 0x75DB, // 0x0D80 (3456) pixels
|
||||
0x85FC, 0x963C, 0xA67C, 0xA67C, 0x9E5C, 0xA67C, 0x8DFB, 0x5D5A, 0xA67C, 0xBEFE, 0x74B5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0D90 (3472) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0DA0 (3488) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02AA, 0x0000, 0x31C9, 0x292A, // 0x0DB0 (3504) pixels
|
||||
0x394D, 0x4212, 0x4315, 0x43B6, 0x5CB9, 0x4B96, 0x5BB6, 0x7458, 0x6C58, 0x755A, 0x5D5A, 0x85DB, 0xAE9D, 0x9E5C, 0xBEDD, 0xAE9D, // 0x0DC0 (3520) pixels
|
||||
0x963C, 0x9E5C, 0x75BB, 0x657B, 0xBEBD, 0xB6DE, 0x74F7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0DD0 (3536) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0DE0 (3552) pixels
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2108, 0x396E, 0x41D0, 0x42D4, 0x3356, // 0x0DF0 (3568) pixels
|
||||
0x3BF7, 0x43B7, 0x53D7, 0x5C99, 0x5417, 0x651A, 0x5D5A, 0x7DBB, 0x85FB, 0x8E1C, 0x9E5C, 0x8E1C, 0x85FB, 0x963C, 0x961C, 0x7DDB, // 0x0E00 (3584) pixels
|
||||
0xD73E, 0xAEBD, 0x8517, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0E10 (3600) pixels
|
||||
};
|
||||
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* REVISION HISTORY
|
||||
* Version 1.0 - epierre
|
||||
* Contribution: bulldoglowell, gizmocuz
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Arduino UVM-30A
|
||||
* Index table taken from: http://www.elecrow.com/sensors-c-111/environment-c-111_112/uv-sensor-moduleuvm30a-p-716.html
|
||||
* Because this table is pretty lineair, we can calculate a UVI with one decimal
|
||||
*
|
||||
* Connect sensor:
|
||||
*
|
||||
* + >>> 5V
|
||||
* - >>> GND
|
||||
* out >>> A0
|
||||
*
|
||||
* License: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
|
||||
*/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
|
||||
#define UV_SENSOR_ANALOG_PIN 0
|
||||
|
||||
#define CHILD_ID_UV 0
|
||||
|
||||
unsigned long SLEEP_TIME = 30*1000; // Sleep time between reads (in milliseconds)
|
||||
|
||||
MyMessage uvMsg(CHILD_ID_UV, V_UV);
|
||||
|
||||
unsigned long lastSend =0;
|
||||
float uvIndex;
|
||||
float lastUV = -1;
|
||||
uint16_t uvIndexValue [12] = { 50, 227, 318, 408, 503, 606, 696, 795, 881, 976, 1079, 1170};
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("UV Sensor", "1.2");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
present(CHILD_ID_UV, S_UV);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
unsigned long currentTime = millis();
|
||||
|
||||
uint16_t uv = analogRead(UV_SENSOR_ANALOG_PIN);// Get UV value
|
||||
if (uv>1170)
|
||||
uv=1170;
|
||||
|
||||
//Serial.print("UV Analog reading: ");
|
||||
//Serial.println(uv);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
if (uv <= uvIndexValue[i])
|
||||
{
|
||||
uvIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//calculate 1 decimal if possible
|
||||
if (i>0) {
|
||||
float vRange=uvIndexValue[i]-uvIndexValue[i-1];
|
||||
float vCalc=uv-uvIndexValue[i-1];
|
||||
uvIndex+=(1.0/vRange)*vCalc-1.0;
|
||||
}
|
||||
|
||||
//Serial.print("UVI: ");
|
||||
//Serial.println(uvIndex,2);
|
||||
|
||||
//Send value to gateway if changed, or at least every 5 minutes
|
||||
if ((uvIndex != lastUV)||(currentTime-lastSend >= 5UL*60UL*1000UL)) {
|
||||
lastSend=currentTime;
|
||||
send(uvMsg.set(uvIndex,2));
|
||||
lastUV = uvIndex;
|
||||
}
|
||||
|
||||
sleep(SLEEP_TIME);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* The MySensors Arduino library handles the wireless radio link and protocol
|
||||
* between your home built sensors/actuators and HA controller of choice.
|
||||
* The sensors forms a self healing radio network with optional repeaters. Each
|
||||
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
|
||||
* network topology allowing messages to be routed to nodes.
|
||||
*
|
||||
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
|
||||
* Copyright (C) 2013-2015 Sensnology AB
|
||||
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
|
||||
*
|
||||
* Documentation: http://www.mysensors.org
|
||||
* Support Forum: http://forum.mysensors.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
*******************************
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Vibration Sensor
|
||||
*
|
||||
* connect the sensor as follows :
|
||||
*
|
||||
* VCC >>> 5V
|
||||
* S >>> D3
|
||||
* GND >>> GND
|
||||
*
|
||||
* Based on: http://www.dfrobot.com/wiki/index.php/DFRobot_Digital_Vibration_Sensor_V2_SKU:DFR0027
|
||||
* Contributor: epierre
|
||||
**/
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
#define MY_DEBUG
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
//#define MY_RADIO_RFM69
|
||||
|
||||
#include <MySensor.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#define CHILD_ID_VIBRATION 0
|
||||
#define VIBRATION_SENSOR_DIGITAL_PIN 3
|
||||
#define SensorLED 13
|
||||
|
||||
unsigned long SLEEP_TIME = 10*1000; // Sleep time between reads (in seconds)
|
||||
|
||||
//VARIABLES
|
||||
int val = 0; // variable to store the value coming from the sensor
|
||||
float valVIBRATION =0.0;
|
||||
float lastVIBRATION =0.0;
|
||||
unsigned char state = 0;
|
||||
|
||||
MyMessage vibrationMsg(CHILD_ID_VIBRATION, V_LEVEL);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Send the sketch version information to the gateway and Controller
|
||||
sendSketchInfo("VIBRATION Sensor", "1.0");
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
present(CHILD_ID_VIBRATION, S_VIBRATION);
|
||||
|
||||
|
||||
pinMode(VIBRATION_SENSOR_DIGITAL_PIN, INPUT);
|
||||
attachInterrupt(1, blink, FALLING);// Trigger the blink function when the falling edge is detected
|
||||
pinMode(SensorLED, OUTPUT);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if(state>=40){ // basically below 40 so ignire basic level
|
||||
send(vibrationMsg.set(int(state)));
|
||||
state = 0;
|
||||
digitalWrite(SensorLED,HIGH);
|
||||
} else {
|
||||
state = 0;
|
||||
digitalWrite(SensorLED,LOW);
|
||||
}
|
||||
|
||||
|
||||
// Power down the radio. Note that the radio will get powered back up
|
||||
// on the next write() call.
|
||||
delay(1000); //delay to allow serial to fully print before sleep
|
||||
|
||||
sleep(SLEEP_TIME); //sleep for: sleepTime
|
||||
}
|
||||
|
||||
void blink()//Interrupts function
|
||||
{
|
||||
state++;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user