NVType C Reference

A file for organising configuration data stored in Non-Volatile memory.

These data are read by several parts of the encoder, where it is declared as an external global variable.

The variable definition depends on how the encoder is being run:

  • When running under CFFI (see PyEncoder) nv is defined in nvtype.c

  • When running as part of a larger project (e.g. the cupl Tag firmware) nv must be defined elsewhere.

The intention is for nv to occupy the 512 byte MSP430 information FRAM.

Date

6 Aug 2018

Author

Malcolm Mackay

Copyright

Plotsensor Ltd.

Defines

SERIAL_LENBYTES

Length of the tag serial string in bytes.

SECKEY_LENBYTES

Length of the secret key used for HMAC-MD5 in bytes.

BASEURL_LENBYTES

Maximum length of the base URL string in bytes.

SMPLINT_LENBYTES

Length of the sample interval (minutes) integer in bytes.

VFMTINT_LENBYTES

VFmt character array length in bytes.

FORMAT_ASCII_MAXLEN

Maximum length of the format ASCII string.

MINVOLTAGEMV_ASCII_MAXLEN

Maximum length of the minimum voltage (mV) ASCII string.

SMPLINTERVAL_ASCII_MAXLEN

Maximum length of the sample interval string.

Typedefs

typedef struct nvstruct nv_t

Structure to hold configuration data held in non-volatile memory.

struct nvstruct
#include <nvtype.h>

Structure to hold configuration data held in non-volatile memory.

Public Members

char serial[SERIAL_LENBYTES]

Alphanumeric serial of the tag running the cupl encoder.

char seckey[SECKEY_LENBYTES]

Secret key string used for HMAC-MD5.

char smplintervalmins[SMPLINT_LENBYTES]

Time interval betweeen samples in minutes.

char baseurl[BASEURL_LENBYTES]

URL of the cupl Web Application frontend.

char format

Codec format byte.

unsigned int minvoltagemv

Minimum startup voltage in mV.

unsigned int usehmac

When non-zero enable HMAC otherwise use MD5 only.

unsigned int httpsdisable

When non-zero use HTTP in the URL otherwise use HTTPS.

unsigned int sleepintervaldays

Number of days to wait without scans before putting the cupl Tag into deep sleep mode.

unsigned int allwritten

When non-zero all required NV parameters have been set.

unsigned int resetsperloop

Incremented each time the tag microcontroller resets. Zeroed when the circular buffer loops around (see ds_looparound).

unsigned int resetsalltime

Incremented each time the tag microcontroller resets.

Functions

void fram_write_enable()

Enable writes to FRAM. Should be defined in the processor-specific cuplTag project.

void fram_write_disable()

Disable writes to FRAM. Should be defined in the processor-specific cuplTag project.

Variables

nv_t nv   = {.serial="AAAACCCC", .seckey="AAAACCCC"}

Externally defined parameters stored in non-volatile memory.