-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
141 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"files.associations": { | ||
"thread": "cpp", | ||
"*.ipp": "cpp", | ||
"texture": "cpp", | ||
"*.tcc": "cpp", | ||
"boundingbox": "cpp", | ||
"boundingsphere": "cpp", | ||
"timer": "cpp", | ||
"numeric": "cpp", | ||
"config": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const char *mqtt_broker = "p390e24a.ala.us-east-1.emqxsl.com"; // broker address | ||
const char *topic = "stop/#"; // define topic | ||
const char *mqtt_username = "test"; // username for authentication | ||
const char *mqtt_password = "password"; // password for authentication | ||
const int mqtt_port = 8883; // port of MQTT over TLS | ||
const char *root_ca = | ||
"-----BEGIN CERTIFICATE-----\n" | ||
"MIIEqjCCA5KgAwIBAgIQAnmsRYvBskWr+YBTzSybsTANBgkqhkiG9w0BAQsFADBh\n" | ||
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" | ||
"d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" | ||
"QTAeFw0xNzExMjcxMjQ2MTBaFw0yNzExMjcxMjQ2MTBaMG4xCzAJBgNVBAY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3d3dy5kaWdpY2VydC5jb20vQ1BT\n" | ||
"MAgGBmeBDAECATANBgkqhkiG9w0BAQsFAAOCAQEAK3Gp6/aGq7aBZsxf/oQ+TD/B\n" | ||
"SwW3AU4ETK+GQf2kFzYZkby5SFrHdPomunx2HBzViUchGoofGgg7gHW0W3MlQAXW\n" | ||
"M0r5LUvStcr82QDWYNPaUy4taCQmyaJ+VB+6wxHstSigOlSNF2a6vg4rgexixeiV\n" | ||
"4YSB03Yqp2t3TeZHM9ESfkus74nQyW7pRGezj+TC44xCagCQQOzzNmzEAP2SnCrJ\n" | ||
"sNE2DpRVMnL8J6xBRdjmOsC3N6cQuKuRXbzByVBjCqAA8t1L0I+9wXJerLPyErjy\n" | ||
"rMKWaBFLmfK/AHNF4ZihwPGOc7w6UHczBZXH5RFzJNnww+WnKuTPI0HfnVH8lg==\n" | ||
"-----END CERTIFICATE-----\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Stations: | ||
yamashita_station | ||
umishita_station | ||
StopRail: | ||
yamashita_s1 | ||
yamashita_s2 | ||
umishita_s1 | ||
PointRail: | ||
yamashita_p1 | ||
PassDetector: | ||
yamashita_d1 | ||
umishita_d1 | ||
*/ | ||
|
||
#define STOP_ON_ANGLE 45 | ||
#define STOP_OFF_ANGLE 5 | ||
|
||
// 接続されているStopRailとServoの設定 | ||
|
||
// target: stop, point, pin: [0-9]*, id: str | ||
|
||
#define POINT_STRAIGHT_ANGLE 165 | ||
#define POINT_REVERSE_ANGLE 180 | ||
|
||
#define SERVO_SETTING_LENGTH 4 | ||
#define SWITCH_SETTING_LENGTH 2 | ||
|
||
servo_item ServoSetting[] = { | ||
{"stop", 26, "yamashita_s1"}, // 26 | ||
{"stop", 27, "yamashita_s2"}, // 27 | ||
{"point", 14, "yamashita_p1"}, // 14 | ||
{"stop", 12, "umishita_s1"} // 12 | ||
}; | ||
|
||
switch_item SwitchSetting[] = { | ||
{16, "yamashita_b1", "OPEN"}, | ||
{17, "yamashita_b1", "CLOSE"}}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "switch.hpp" | ||
|
||
BlockSwitch::BlockSwitch() {} | ||
|
||
void BlockSwitch::init(String id, String state, int pin, PubSubClient client) | ||
{ | ||
this->id = id; | ||
this->pin = pin; | ||
this->state = state; | ||
pinMode(pin, INPUT_PULLUP); | ||
} | ||
|
||
void BlockSwitch::loop() | ||
{ | ||
if (digitalRead(pin) == LOW) | ||
{ | ||
if (millis() - last_switch_time < 3000) | ||
{ | ||
return; | ||
} | ||
char topic[100] = ""; | ||
sprintf(topic, "block/%s/update", id.c_str()); | ||
client.publish(topic, state.c_str()); | ||
last_switch_time = millis(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <Arduino.h> | ||
#include <PubSubClient.h> | ||
|
||
class BlockSwitch | ||
{ | ||
private: | ||
String id; | ||
String state; | ||
int pin; | ||
unsigned long last_switch_time = 0; | ||
PubSubClient client; | ||
|
||
public: | ||
BlockSwitch(); | ||
void loop(); | ||
void init(String id, String state, int pin, PubSubClient client); | ||
}; |