forked from sabas1080/PN7150
-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 parent
48525c7
commit ec99d67
Showing
5 changed files
with
173 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "NdefRecord.h" | ||
|
||
NdefRecord::NdefRecord() { | ||
type = UNSUPPORTED_NDEF_RECORD; | ||
payload = NULL; | ||
payloadSize = 0; | ||
} | ||
|
||
void NdefRecord::create(NdefRecord_t record) { | ||
this->type = record.recordType; | ||
this->payload = record.recordPayload; | ||
this->payloadSize = record.recordPayloadSize; | ||
} | ||
|
||
NdefRecordType_e NdefRecord::getType() { | ||
return this->type; | ||
} | ||
|
||
unsigned char NdefRecord::getPayload() { | ||
return this->payload[getPayloadSize()]; | ||
} | ||
|
||
unsigned short NdefRecord::getPayloadSize() { | ||
return this->payloadSize; | ||
} | ||
|
||
String NdefRecord::getText() { | ||
unsigned char save = payload[payloadSize]; | ||
payload[payloadSize] = '\0'; | ||
String text = ""; | ||
|
||
if (getType() == WELL_KNOWN_SIMPLE_TEXT) { | ||
text = reinterpret_cast<const char *>(&payload[payload[0] + 1]); | ||
} | ||
|
||
payload[payloadSize] = save; | ||
|
||
return text; | ||
} |
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,23 @@ | ||
#ifndef NdefRecord_H | ||
#define NdefRecord_H | ||
|
||
#include <Arduino.h> | ||
|
||
#include "ndef_helper.h" | ||
|
||
class NdefRecord { | ||
private: | ||
NdefRecordType_e type; | ||
unsigned char *payload; | ||
unsigned short payloadSize; | ||
|
||
public: | ||
NdefRecord(); | ||
void create(NdefRecord_t record); | ||
NdefRecordType_e getType(); | ||
unsigned char getPayload(); | ||
unsigned short getPayloadSize(); | ||
String getText(); | ||
}; | ||
|
||
#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