-
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
11 changed files
with
119 additions
and
88 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
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
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,41 @@ | ||
#include "NFCReader.h" | ||
|
||
NFCReader::NFCReader() | ||
{ | ||
} | ||
|
||
void NFCReader::init(String nfc_id, uint8_t ss_pin, PubSubClient *client) | ||
{ | ||
this->ss_pin = ss_pin; | ||
this->nfc_id = nfc_id; | ||
this->client = client; | ||
reader.PCD_Init(ss_pin, RST_PIN); | ||
} | ||
|
||
void NFCReader::loop() | ||
{ | ||
if (!reader.PICC_IsNewCardPresent()) | ||
{ | ||
return; | ||
} | ||
if (!reader.PICC_ReadCardSerial()) | ||
{ | ||
return; | ||
} | ||
String uid = ""; | ||
for (byte i = 0; i < reader.uid.size; i++) | ||
{ | ||
uid += String(reader.uid.uidByte[i] < 0x10 ? "0" : ""); | ||
uid += String(reader.uid.uidByte[i], HEX); | ||
} | ||
Serial.print("NFC ID: "); | ||
Serial.print(nfc_id); | ||
Serial.print( "UID: "); | ||
Serial.println(uid); | ||
reader.PICC_HaltA(); | ||
reader.PCD_StopCrypto1(); | ||
|
||
// Publish Topic | ||
String topic = "nfc/" + nfc_id + "/update"; | ||
client->publish(topic.c_str(), uid.c_str()); | ||
} |
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,24 @@ | ||
#ifndef NFCREADER_H | ||
#define NFCREADER_H | ||
#include <MFRC522.h> | ||
#include <PubSubClient.h> | ||
|
||
#define RST_PIN 9 | ||
#define SS_1_PIN 10 | ||
#define SS_2_PIN 8 | ||
|
||
class NFCReader | ||
{ | ||
private: | ||
int ss_pin; | ||
String nfc_id; | ||
MFRC522 reader; | ||
PubSubClient *client; | ||
|
||
public: | ||
NFCReader(); | ||
void init(String nfc_id, uint8_t ss_pin, PubSubClient *client); | ||
void loop(); | ||
}; | ||
|
||
#endif |
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
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 |
---|---|---|
@@ -1,17 +1,6 @@ | ||
#include "Settings.h" | ||
|
||
const char *ssid = "SPWH_L12_60d5d1"; | ||
const char *password = "1df7e4eabee84"; | ||
const char *ssid = "SSID"; | ||
const char *password = "PASSWORD"; | ||
|
||
const char *HOST = "sakurajosui"; | ||
|
||
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"}}; | ||
char HOST[25]; |
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