-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from ElectronicCats/wifiserver
Add Wifi Web Server example
- Loading branch information
Showing
61 changed files
with
6,650 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
unsigned char STATUSOK[] = {0x90, 0x00}, Cmd[256], CmdSize; | ||
|
||
uint8_t uidcf[20] = { | ||
0x20, 0x02, 0x05, 0x01, /* CORE_SET_CONFIG_CMD */ | ||
0x00, 0x02, 0x00, 0x01 /* TOTAL_DURATION */ | ||
}; | ||
|
||
uint8_t uidlen = 0; | ||
|
||
uint8_t data[] = {0x90, 0x00}; | ||
uint8_t requestCmd[] = {0x00, 0xB0, 0x00, 0x00, 0x0F}; | ||
bool emulateNFCFlag = false; | ||
int attempts = 0; | ||
|
||
const int EMULATE_NFCID_DELAY_MS = 1000; | ||
unsigned long emulateNFCIDTimer = 0; |
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,34 @@ | ||
void printData(uint8_t* buff, uint8_t lenbuffer, uint8_t cmd) { | ||
char tmp[1]; | ||
if (cmd == 1) | ||
Serial.print("\nCommand: "); | ||
else if (cmd == 2) | ||
Serial.print("\nReader command: "); | ||
else if (cmd == 3) | ||
Serial.print("\nBomberCat answer: "); | ||
else | ||
Serial.print("\nCard answer: "); | ||
|
||
for (uint8_t u = 0; u < lenbuffer; u++) { | ||
sprintf(tmp, "0x%.2X", buff[u]); | ||
Serial.print(tmp); | ||
Serial.print(" "); | ||
} | ||
} | ||
|
||
void emulateNFCID() { | ||
if (nfc.CardModeReceive(Cmd, &CmdSize) == 0) { // Receive command from reader | ||
printData(Cmd, CmdSize, 1); | ||
printData(data, sizeof(data), 3); | ||
Serial.println("\nAttempts = " + String(attempts)); | ||
attempts++; | ||
|
||
nfc.CardModeSend(data, sizeof(data)); // Emulate the dummy data and the NFCID | ||
|
||
// If Cmd is equal to requestCmd, then the reader is asking for the NFCID | ||
if (memcmp(Cmd, requestCmd, sizeof(requestCmd)) == 0) { | ||
Serial.println("Reader is asking for the NFCID"); | ||
Serial.println("NFCID: " + getHexRepresentation(uidcf, sizeof(uidcf))); | ||
} | ||
} | ||
} |
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,186 @@ | ||
#include "Debug.h" | ||
|
||
void Debug::setEnabled(bool enabled) { | ||
this->enabled = enabled; | ||
} | ||
|
||
bool Debug::isEnabled() { | ||
return this->enabled; | ||
} | ||
|
||
void Debug::waitForSerialConnection() { | ||
if (!this->enabled) { | ||
return; | ||
} | ||
while (!Serial) { // Wait for the serial connection to be established | ||
delay(1); | ||
} | ||
} | ||
|
||
void Debug::write(uint8_t message) { | ||
if (this->enabled) { | ||
Serial.write(message); | ||
} | ||
} | ||
|
||
void Debug::write(const uint8_t *buffer, size_t size) { | ||
if (this->enabled) { | ||
Serial.write(buffer, size); | ||
} | ||
} | ||
|
||
void Debug::print(String message) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
} | ||
} | ||
|
||
void Debug::println(String message) { | ||
if (this->enabled) { | ||
Serial.println(message); | ||
} | ||
} | ||
|
||
void Debug::print(int message) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
} | ||
} | ||
|
||
void Debug::println(int message) { | ||
if (this->enabled) { | ||
Serial.println(message); | ||
} | ||
} | ||
|
||
void Debug::print(long message) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
} | ||
} | ||
|
||
void Debug::println(long message) { | ||
if (this->enabled) { | ||
Serial.println(message); | ||
} | ||
} | ||
|
||
void Debug::print(double message) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
} | ||
} | ||
|
||
void Debug::println(double message) { | ||
if (this->enabled) { | ||
Serial.println(message); | ||
} | ||
} | ||
|
||
void Debug::print(float message) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
} | ||
} | ||
|
||
void Debug::println(float message) { | ||
if (this->enabled) { | ||
Serial.println(message); | ||
} | ||
} | ||
|
||
void Debug::print(char message) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
} | ||
} | ||
|
||
void Debug::println(char message) { | ||
if (this->enabled) { | ||
Serial.println(message); | ||
} | ||
} | ||
|
||
void Debug::print(bool message) { | ||
if (this->enabled) { | ||
Serial.print(message ? "true" : "false"); | ||
} | ||
} | ||
|
||
void Debug::println(bool message) { | ||
if (this->enabled) { | ||
Serial.println(message ? "true" : "false"); | ||
} | ||
} | ||
|
||
void Debug::print(const char message[]) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
} | ||
} | ||
|
||
void Debug::println(const char message[]) { | ||
if (this->enabled) { | ||
Serial.println(message); | ||
} | ||
} | ||
|
||
void Debug::print(arduino::IPAddress message) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
} | ||
} | ||
|
||
void Debug::println(arduino::IPAddress message) { | ||
if (this->enabled) { | ||
Serial.println(message); | ||
} | ||
} | ||
|
||
void Debug::print(String message, String message2) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
Serial.print(message2); | ||
} | ||
} | ||
|
||
void Debug::println(String message, String message2) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
Serial.println(message2); | ||
} | ||
} | ||
|
||
void Debug::print(String message, String message2, String message3) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
Serial.print(message2); | ||
Serial.print(message3); | ||
} | ||
} | ||
|
||
void Debug::println(String message, String message2, String message3) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
Serial.print(message2); | ||
Serial.println(message3); | ||
} | ||
} | ||
|
||
void Debug::print(String message, String message2, String message3, String message4) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
Serial.print(message2); | ||
Serial.print(message3); | ||
Serial.print(message4); | ||
} | ||
} | ||
|
||
void Debug::println(String message, String message2, String message3, String message4) { | ||
if (this->enabled) { | ||
Serial.print(message); | ||
Serial.print(message2); | ||
Serial.print(message3); | ||
Serial.println(message4); | ||
} | ||
} |
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,37 @@ | ||
#include "Arduino.h" | ||
|
||
class Debug { | ||
private: | ||
bool enabled; | ||
|
||
public: | ||
void setEnabled(bool enabled); | ||
bool isEnabled(); | ||
void waitForSerialConnection(); | ||
void write(uint8_t message); | ||
void write(const uint8_t *buffer, size_t size); | ||
void print(String message); | ||
void println(String message); | ||
void print(int message); | ||
void println(int message); | ||
void print(long message); | ||
void println(long message); | ||
void print(double message); | ||
void println(double message); | ||
void print(float message); | ||
void println(float message); | ||
void print(char message); | ||
void println(char message); | ||
void print(bool message); | ||
void println(bool message); | ||
void print(const char message[]); | ||
void println(const char message[]); | ||
void print(arduino::IPAddress message); | ||
void println(arduino::IPAddress message); | ||
void print(String message, String message2); | ||
void println(String message, String message2); | ||
void print(String message, String message2, String message3); | ||
void println(String message, String message2, String message3); | ||
void print(String message, String message2, String message3, String message4); | ||
void println(String message, String message2, String message3, String message4); | ||
}; |
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 "Electroniccats_PN7150.h" | ||
#define PN7150_IRQ (11) | ||
#define PN7150_VEN (13) | ||
#define PN7150_ADDR (0x28) | ||
#define DETECT_TAGS_DELAY_MS (200) | ||
#define READ_ATTEMPTS (2) | ||
|
||
Electroniccats_PN7150 nfc(PN7150_IRQ, PN7150_VEN, PN7150_ADDR); // creates a global NFC device interface object, attached to pins 7 (IRQ) and 8 (VEN) and using the default I2C address 0x28 | ||
RfIntf_t RfInterface; // Intarface to save data for multiple tags | ||
|
||
uint8_t mode = 1; // modes: 1 = Reader/ Writer, 2 = Emulation | ||
|
||
String pollMode, nfcID, sensRes, selRes, bitRate, afi, dsfid; | ||
bool runDetectTags = false; | ||
bool clearNFCValuesFlag = false; | ||
uint8_t nfcExecutionCounter = 0; | ||
bool nfcDiscoverySuccess = false; |
Oops, something went wrong.