forked from dgiannakop/Arduino-CoAP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource.h
77 lines (70 loc) · 2.54 KB
/
resource.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
/********************************************************************************
** The Arduino-CoAP is free software: you can redistribute it and/or modify **
** it under the terms of the GNU Lesser General Public License as **
** published by the Free Software Foundation, either version 3 of the **
** License, or (at your option) any later version. **
** **
** The Arduino-CoAP is distributed in the hope that it will be useful, **
** but WITHOUT ANY WARRANTY; without even the implied warranty of **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
** GNU Lesser General Public License for more details. **
** **
** You should have received a copy of the GNU Lesser General Public **
** License along with the Arduino-CoAP. **
** If not, see <http://www.gnu.org/licenses/>. **
*******************************************************************************/
#ifndef RESOURCE_H
#define RESOURCE_H
#include <Arduino.h>
#include "packet.h"
#include "CoapSensor.h"
class CoapResource {
public:
CoapResource();
/**
* Resource Constructor. User to pass as parameters all required fields:
*
*/
CoapResource(CoapSensor * sensor);
/**
* Called when a resouce is to be evaluated again.
*/
coap_status_t execute(uint8_t method, uint8_t* input_data, size_t input_data_len, uint8_t* output_data, size_t* output_data_len, queries_t queries);
/**
* Sets a new notification interval for the current resource.
*/
void set_notify_time(uint16_t notify_time);
/**
* True if sensor value has changed.
*/
bool is_changed();
void mark_notified();
/**
*
*/
bool is_set();
/**
* String representation of the resource's name.
*/
String name();
/**
* Length of the resource's name.
*/
uint8_t name_length();
void nameToStr(char* buf, size_t len);
/**
* Check if the resource allows the method.
*/
uint8_t method_allowed(uint8_t method);
uint16_t notify_time_w();
uint8_t resource_len();
bool fast_resource();
uint8_t content_type();
bool interrupt_flag_w();
void check();
private:
bool is_set_;
CoapSensor *del_;
bool interrupt_flag_;
};
#endif