Specifications¶
The message format is NDEF. This is used to transmit data to a phone using NFC. An NDEF message has 3 fields: Type, Length and Value.
|
Sensor data are stored in a URL record. As it is the only one in the message and of a known type, a phone opens the URL automatically in its default web browser. NDEF record header
NDEF record payload start
NDEF record payload continued
|
The circular buffer starts on a block boundary and occupies an integer number of 16-byte blocks. 1K of EEPROM is enough for 32 blocks. Only two blocks are edited in RAM at a time:
Blocks are subdivided into two 8-byte demis. Each demi holds 2 base64 encoded pairs. Each pair consists of 2 base64 encoded sensor readings. By default these will be captured simultaneously by a temperature sensor and a humidity sensor. New sensor readings are written to Cursor Demi. Each time this occurs, the subsequent Endstop (CODEC_SPEC_13) is updated. When Cursor Demi is full, both it and the endstop are moved forward when the next sensor reading is added:
The previous oldest demi is overwritten. Note there can be a gap between the most recent sample and the start of the endstop demis. This is zero padded. The padding will not be decoded because the number of valid samples in the buffer is included in the endstop. |
The endstop occupies 2 demis (16 bytes) after the cursor demi. It is terminated with a unique character. This marks the end of the circular buffer; the divide between new and old data. The decoder finds this in order to unwrap the circular buffer into a list of samples, ordered newest to oldest. The endstop contains data about the current state of the circular buffer, for example the number of valid samples it contains. These data are appended to the circular buffer to meet Reduce EEPROM wear (CODEC_SPEC_2). |
This is a 3 byte structure that expands to 4 bytes after base64 encoding. The unencoded structure is:
|
This is a 9 byte structure that expands to 12 bytes after base64 encoding. The unencoded structure is:
|
This is a 6 byte structure that expands to 8 bytes after base64 encoding. It corresponds to The unencoded structure is:
|
Flags to indicate causes of the most recent microcontroller reset.
|
TNF and flags for the NDEF record.
|
The encoder must use <2K of RAM and <16K of non-volatile FRAM, as can be found on an MSP430FR2033 microcontroller. |
The encoder will run for >2 years on a hardware powered by a CR1620 battery. |
The encoder must run without input from the user. This includes after the Power-on-Reset when a battery is replaced. |
Before the circular buffer is decoded, URL parameters such as VFmt b64 (CODEC_SPEC_18) are needed. |
The decoder outputs a list of samples from the URL. Output depends on FormatCode (CODEC_FEAT_42). By default samples will contain temperature and humidity readings, converted to degrees C and percent respectively. Each will have a timestamp precise to one minute. This corresponds to the time that the sample was added to the circular buffer. |