-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathresource.cpp
89 lines (72 loc) · 2.73 KB
/
resource.cpp
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
/********************************************************************************
** 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/>. **
*******************************************************************************/
#include "resource.h"
CoapResource::CoapResource() {
}
CoapResource::CoapResource(CoapSensor * sensor) {
del_ = sensor;
is_set_ = true;
}
coap_status_t CoapResource::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) {
if (del_) {
if (method == COAP_GET)
method = GET;
else if (method == COAP_POST)
method = POST;
return del_->callback(method, input_data, input_data_len, output_data, output_data_len, queries);
}
}
void CoapResource::check() {
del_->check();
}
void CoapResource::set_notify_time(uint16_t notify_time) {
// notify_time_ = notify_time;
del_->set_notify_time(notify_time);
}
bool CoapResource::is_set() {
return is_set_;
}
String CoapResource::name() {
return del_->get_name();
}
uint8_t CoapResource::name_length() {
return del_->get_name().length();
}
void CoapResource::nameToStr(char* buf, size_t len) {
return del_->get_name().toCharArray(buf, len);
}
uint8_t CoapResource::method_allowed(uint8_t method) {
if (method == 3)
method = 4;
else if (method == 4)
method = 8;
return del_->get_method() & method;
}
uint16_t CoapResource::notify_time_w() {
return del_->get_notify_time();
}
bool CoapResource::fast_resource() {
return del_->get_fast();
}
uint8_t CoapResource::content_type() {
return del_->get_content_type();
}
bool CoapResource::is_changed() {
return del_->is_changed();
}
void CoapResource::mark_notified() {
return del_->mark_notified();
}