summaryrefslogtreecommitdiff
path: root/src/nfa/include/nfa_snep_api.h
blob: c7238245fe3337c0188bf6d32297c3fc37290fe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/******************************************************************************
 *
 *  Copyright (C) 2010-2014 Broadcom Corporation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

/******************************************************************************
 *
 *  This is the public interface file for NFA SNEP, Broadcom's NFC
 *  application layer for mobile phones.
 *
 ******************************************************************************/
#ifndef NFA_SNEP_API_H
#define NFA_SNEP_API_H

#include "nfa_api.h"

/*****************************************************************************
**  Constants and data types
*****************************************************************************/

/* return an NDEF message           */
#define NFA_SNEP_REQ_CODE_GET 0x01
/* accept an NDEF message           */
#define NFA_SNEP_REQ_CODE_PUT 0x02
/* do not send remaining fragments  */

#define tNFA_SNEP_REQ_CODE uint8_t

#define tNFA_SNEP_RESP_CODE uint8_t

/* NFA SNEP callback events */
/* Server/client Registeration Status   */
#define NFA_SNEP_REG_EVT 0x00
/* LLCP link has been activated, client only   */
#define NFA_SNEP_ACTIVATED_EVT 0x01
/* LLCP link has been deactivated, client only */
#define NFA_SNEP_DEACTIVATED_EVT 0x02
/* Data link has been created           */
#define NFA_SNEP_CONNECTED_EVT 0x03
/* GET request from client              */
#define NFA_SNEP_GET_REQ_EVT 0x04
/* PUT request from client              */
#define NFA_SNEP_PUT_REQ_EVT 0x05
/* GET response from server             */
#define NFA_SNEP_GET_RESP_EVT 0x06
/* PUT response from server             */
#define NFA_SNEP_PUT_RESP_EVT 0x07
/* Failed to connect or disconnected    */
#define NFA_SNEP_DISC_EVT 0x08

#define NFA_SNEP_ALLOC_BUFF_EVT                                         \
  0x09                              /* Request to allocate a buffer for \
                                       NDEF*/
#define NFA_SNEP_FREE_BUFF_EVT 0x0A /* Request to deallocate buffer for NDEF*/
/* GET response sent to client          */
#define NFA_SNEP_GET_RESP_CMPL_EVT 0x0B

typedef uint8_t tNFA_SNEP_EVT;

/* Data for NFA_SNEP_REG_EVT */
typedef struct {
  tNFA_STATUS status;
  tNFA_HANDLE reg_handle; /* handle for registered server/client */
  char service_name[LLCP_MAX_SN_LEN + 1]; /* only for server */
} tNFA_SNEP_REG;

/* Data for NFA_SNEP_ACTIVATED_EVT */
typedef struct {
  tNFA_HANDLE client_handle; /* handle for registered client    */
} tNFA_SNEP_ACTIVATED;

/* Data for NFA_SNEP_DEACTIVATED_EVT */
typedef tNFA_SNEP_ACTIVATED tNFA_SNEP_DEACTIVATED;

/* Data for NFA_SNEP_CONNECTED_EVT */
/*
** for server, new handle will be assigned for conn_handle
** for client, handle used in NFA_SnepConnect () is returned in conn_handle
*/
typedef struct {
  tNFA_HANDLE reg_handle;  /* server/client handle            */
  tNFA_HANDLE conn_handle; /* handle for data link connection */
} tNFA_SNEP_CONNECT;

/* Data for NFA_SNEP_GET_REQ_EVT */
typedef struct {
  tNFA_HANDLE conn_handle;    /* handle for data link connection */
  uint32_t acceptable_length; /* acceptable length from client   */
  uint32_t ndef_length;       /* NDEF message length             */
  uint8_t* p_ndef;            /* NDEF message                    */
} tNFA_SNEP_GET_REQ;

/* Data for NFA_SNEP_PUT_REQ_EVT */
typedef struct {
  tNFA_HANDLE conn_handle; /* handle for data link connection */
  uint32_t ndef_length;    /* NDEF message length             */
  uint8_t* p_ndef;         /* NDEF message                    */
} tNFA_SNEP_PUT_REQ;

/* Data for NFA_SNEP_GET_RESP_EVT */
typedef struct {
  tNFA_HANDLE conn_handle;       /* handle for data link connection */
  tNFA_SNEP_RESP_CODE resp_code; /* response code from server       */
  uint32_t ndef_length;          /* NDEF message length             */
  uint8_t* p_ndef;               /* NDEF message                    */
} tNFA_SNEP_GET_RESP;

/* Data for NFA_SNEP_PUT_RESP_EVT */
typedef struct {
  tNFA_HANDLE conn_handle;       /* handle for data link connection */
  tNFA_SNEP_RESP_CODE resp_code; /* response code from server       */
} tNFA_SNEP_PUT_RESP;

/* Data for NFA_SNEP_DISC_EVT */
typedef struct {
  tNFA_HANDLE conn_handle; /* handle for data link connection */
                           /* client_handle if connection failed */
} tNFA_SNEP_DISC;

/* Data for NFA_SNEP_ALLOC_BUFF_EVT */
typedef struct {
  tNFA_HANDLE conn_handle; /* handle for data link connection                */
  tNFA_SNEP_REQ_CODE
      req_code; /* NFA_SNEP_REQ_CODE_GET or NFA_SNEP_REQ_CODE_PUT */
  tNFA_SNEP_RESP_CODE resp_code; /* Response code if cannot allocate buffer */
  uint32_t ndef_length; /* NDEF message length                            */
  uint8_t* p_buff;      /* buffer for NDEF message                        */
} tNFA_SNEP_ALLOC;

/* Data for NFA_SNEP_FREE_BUFF_EVT */
typedef struct {
  tNFA_HANDLE conn_handle; /* handle for data link connection */
  uint8_t* p_buff;         /* buffer to free                  */
} tNFA_SNEP_FREE;

/* Data for NFA_SNEP_GET_RESP_CMPL_EVT */
typedef struct {
  tNFA_HANDLE conn_handle; /* handle for data link connection */
  uint8_t* p_buff;         /* buffer for NDEF message         */
} tNFA_SNEP_GET_RESP_CMPL;

/* Union of all SNEP callback structures */
typedef union {
  tNFA_SNEP_REG reg;                     /* NFA_SNEP_REG_EVT             */
  tNFA_SNEP_ACTIVATED activated;         /* NFA_SNEP_ACTIVATED_EVT       */
  tNFA_SNEP_DEACTIVATED deactivated;     /* NFA_SNEP_DEACTIVATED_EVT     */
  tNFA_SNEP_CONNECT connect;             /* NFA_SNEP_CONNECTED_EVT       */
  tNFA_SNEP_GET_REQ get_req;             /* NFA_SNEP_GET_REQ_EVT         */
  tNFA_SNEP_PUT_REQ put_req;             /* NFA_SNEP_PUT_REQ_EVT         */
  tNFA_SNEP_GET_RESP get_resp;           /* NFA_SNEP_GET_RESP_EVT        */
  tNFA_SNEP_PUT_RESP put_resp;           /* NFA_SNEP_PUT_RESP_EVT        */
  tNFA_SNEP_DISC disc;                   /* NFA_SNEP_DISC_EVT            */
  tNFA_SNEP_ALLOC alloc;                 /* NFA_SNEP_ALLOC_BUFF_EVT      */
  tNFA_SNEP_FREE free;                   /* NFA_SNEP_FREE_BUFF_EVT       */
  tNFA_SNEP_GET_RESP_CMPL get_resp_cmpl; /* NFA_SNEP_GET_RESP_CMPL_EVT   */
} tNFA_SNEP_EVT_DATA;

/* NFA SNEP callback */
typedef void(tNFA_SNEP_CBACK)(tNFA_SNEP_EVT event, tNFA_SNEP_EVT_DATA* p_data);

#endif /* NFA_P2P_API_H */