Modifying the text_record NFC example

Hi,

I'm trying to modify the text_record example for NFC data transfer to transmit a numeric payload (working on an nrf52832). The original example transmits "Hello World!" with its language code, and I got that flashed just fine. I'm modifying the code to transmit an ID (uint8), a timestamp (YYYYMMDD) and a value (uint8).

The main problem is adding an extra two variables to the structs. I've made project-local copies of the header files "msg.h" and "record.h", and my own header file which is based on the header "text_rec.h". I've attached all my code to this ticket.

The error I'm currently getting is 

c:\nordic\attempt1\src\attempt1.h:59:7: error: expected identifier before numeric constant
59 | 0, \

And I'm not sure how to fix this, since the 0's in this structure were in the original code, but I did add two more for the new variables...

All the attached code is in the same directory, with one dependency on a header I haven't edited. 

Hope this all makes sense! Thank you for your help.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef NFC_NDEF_ATTEMPT1_H_
#define NFC_NDEF_ATTEMPT1_H_
#include <zephyr/types.h>
#include "record.h"
#ifdef __cplusplus
extern "C" {
#endif
struct nfc_ndef_text_rec_payload {
/** Pointer to the ID. */
uint8_t const *id;
/** Length of the ID. */
uint8_t id_length;
/** Pointer to the timestamp. */
uint8_t const *time;
/** Length of the timestamp. */
uint32_t time_length;
/** Pointer to the data. */
uint8_t const *data;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// main.c
#include <zephyr.h>
// #include <sys/reboot.h'>
#include <dk_buttons_and_leds.h>
#include <nfc_t2t_lib.h>
#include "msg.h"
#include "attempt1.h"
#define NFC_FIELD_LED DK_LED1
#define NDEF_BUF_SIZE 128
#define MAX_REC_COUNT 1
//strain reading
static const uint32_t strainreading = 289319;
static const uint8_t timestamp[] = {'2', '0', '2', '2', '0', '4', '2', '7'};
static const uint32_t identifier = 1;
//buffer to hold NFC NDEF
static uint8_t ndef_buf[NDEF_BUF_SIZE];
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef NFC_NDEF_RECORD_H_
#define NFC_NDEF_RECORD_H_
#include <zephyr/types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef int (*payload_constructor_t)(void *payload_descriptor,
uint8_t *buffer,
uint32_t *len);
struct nfc_ndef_record_desc {
uint8_t id_length;
uint8_t const *id;
uint8_t time_length;
uint8_t const *time;
uint8_t type_length;
uint8_t const *type;
payload_constructor_t payload_constructor;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef NFC_NDEF_MSG_H_
#define NFC_NDEF_MSG_H_
#include <zephyr/types.h>
#include "record.h"
#ifdef __cplusplus
extern "C" {
#endif
struct nfc_ndef_msg_desc {
/** Pointer to an array of pointers to NDEF record descriptors. */
struct nfc_ndef_record_desc const **record;
/** Number of elements in the allocated record array, which defines
* the maximum number of records within the NDEF message.
*/
uint32_t max_record_count;
/** Number of records in the NDEF message. */
uint32_t record_count;
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX