-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdpa_json.h
77 lines (66 loc) · 2.46 KB
/
dpa_json.h
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
/**
* @file DPA support library (JSON support)
* @version 1.6.0
*
* Copyright 2015-2021 IQRF Tech s.r.o.
* Copyright 2019-2021 MICRORISC s.r.o.
*
* 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.
*/
#ifndef _DPA_JSON_H
#define _DPA_JSON_H
#if defined(__cplusplus)
extern "C" {
#endif
#include <dpa_library.h>
#define JSON_MSG_ID_BUFF_SIZE 10
#define JSON_REQUEST_BUFF_SIZE 32
#define JSON_OBJECT_BUFF_SIZE 384
typedef enum{
JSON_PARSE_OK = 0,
JSON_PARSE_ERROR
} PARSE_RESULT;
/**
* Initialize support of JSON format in DPA library
*/
void jsonInit(void);
/**
* Parse DPA request packet from MQTT JSON message
* @param DpaPacket pointer to DPA request packet, filled with data from received MQTT JSON message
* @param DataBuffer pointer to buffer, with received MQTT JSON message
* @param DataBufferSize size of MQTT JSON message
* @return operation result (JSON_PARSE_OK or JSON_PARSE_ERROR)
*/
PARSE_RESULT jsonParse(T_DPA_PACKET *DpaPacket, uint8_t *DataBuffer, uint16_t DataBufferSize);
/**
* Create JSON message from received DPA packet
* @param DataBuffer - pointer to buffer with generated JSON message
* @param DpaResponse - pointer to T_DPA_PACKET with DPA notification or response data
* @param DpaOperationResult - result of dpaSendRequest(... ) function
* @return size of created JSON message (0 = message was not created, due to its size is over the size of DataBuffer)
*/
uint16_t jsonCreate(uint8_t *DataBuffer, T_DPA_PACKET *DpaResponse, DPA_OPERATION_RESULT DpaOperationResult);
/**
* Get the timeout parameter from JSON message ( used in dpaSendRequest(... ) function )
* @return timeout parameter from JSON message (0 = timeout parameter not defined)
*/
uint16_t jsonGetTimeout(void);
/**
* Get the number of additional data bytes of DPA request in JSON message ( used in dpaSendRequest(... ) function )
* @return number of additional data bytes in DPA request message
*/
uint8_t jsonGetDataSize(void);
#if defined(__cplusplus)
}
#endif
#endif