Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Put" Actuator Data to turn on/off LED #3

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c67078b
Add "Put" Actuator Data to turn on/off LED
seojeongmoon Oct 28, 2019
92314ad
Update saul_coap.c
seojeongmoon Oct 28, 2019
213bf65
Merge pull request #1 from seojeongmoon/seojeongmoon-patch-2
seojeongmoon Oct 28, 2019
7c9fc11
Indent saul_coap.c
rosetree Oct 28, 2019
822549c
Merge branch 'master' into sj-patch-1
rosetree Oct 28, 2019
6c3c622
Merge pull request #2 from rosetree/sj-patch-1
seojeongmoon Oct 28, 2019
595197a
Update README.md
seojeongmoon Nov 18, 2019
ff1ea4d
Update saul_coap.c
seojeongmoon Nov 25, 2019
1f93d2f
Update saul_coap.c
seojeongmoon Nov 25, 2019
8fa1d2a
Update saul_coap.c
seojeongmoon Nov 29, 2019
c443565
Update saul_coap.c
seojeongmoon Nov 29, 2019
37eb3c4
Update Makefile
seojeongmoon Nov 29, 2019
f88ce1e
Update saul_coap.c
seojeongmoon Dec 1, 2019
ab49362
Update saul_coap.c
seojeongmoon Dec 1, 2019
d605861
added resource for winch
seojeongmoon Dec 1, 2019
bad8f35
Update README.md
seojeongmoon Dec 2, 2019
7245414
Update README on testing with dtls
seojeongmoon Dec 2, 2019
7092915
added cbor.h, TO DO comments
seojeongmoon Dec 2, 2019
80f8d5c
separate winch from saul_coap, error corrections
seojeongmoon Dec 2, 2019
0ea1f32
Create winch.c
seojeongmoon Dec 2, 2019
842fd36
Rename winch.c to winch.txt
seojeongmoon Dec 2, 2019
8e05a98
error removed
seojeongmoon Dec 2, 2019
93d1c1a
specify directory
seojeongmoon Dec 9, 2019
6a6e086
Update winch.txt
seojeongmoon Dec 9, 2019
1b1f02d
Merge remote-tracking branch 'rosetree/master' into seojeongmoon-patch-1
seojeongmoon Dec 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions saul_coap.c
Original file line number Diff line number Diff line change
@@ -44,7 +44,11 @@ static const coap_resource_t _resources[] = {
{ "/press", COAP_GET, _sense_press_handler, NULL },
{ "/saul/cnt", COAP_GET, _saul_cnt_handler, NULL },
{ "/saul/dev", COAP_POST, _saul_dev_handler, NULL },
{"/saul/atr", COAP_PUT, _saul_atr_handler, NULL}
{"/saul/atr", COAP_PUT, _saul_atr_handler, NULL},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does atr stand for? Attribute? Another coding style related request: could you use a space after { and before }, like in the surrounding lines.

{ "/sensor", COAP_GET, _saul_sensortype_handler, NULL },
{ "/servo", COAP_GET, _sense_servo_handler, NULL },
{ "/temp", COAP_GET, _sense_temp_handler, NULL },
{ "/voltage", COAP_GET, _sense_voltage_handler, NULL },
};

static gcoap_listener_t _listener = {
@@ -246,7 +250,7 @@ static ssize_t _saul_atr_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, void
else {
return gcoap_response(pdu, buf, len, COAP_CODE_BAD_REQUEST);
}

return _atr_type_responder(pdu, buf, len, type);
}

@@ -259,30 +263,30 @@ static ssize_t _atr_type_responder(coap_pkt_t* pdu, uint8_t *buf, size_t len, ui
gcoap_resp_init(pdu, buf, len, COAP_CODE_CONTENT);
coap_opt_add_format(pdu, COAP_FORMAT_TEXT);
resp_len = coap_opt_finish(pdu, COAP_OPT_FINISH_PAYLOAD);

if (dev == NULL) {
char *err = "device not found";
if (pdu->payload_len >= strlen(err)) {
memcpy(pdu->payload, err, strlen(err));
resp_len += gcoap_response(pdu, buf, len, COAP_CODE_404);
return resp_len;
}
else {
phydat_dump(&res, type);//phydat.h
dim = saul_reg_write(dev, &res); // &res -as saul_reg_read store location or *res data to write?
// return gcoap_response(pdu, buf, len, COAP_CODE_404);
}
char *err = "device not found";
if (pdu->payload_len >= strlen(err)) {
memcpy(pdu->payload, err, strlen(err));
resp_len += gcoap_response(pdu, buf, len, COAP_CODE_404);
return resp_len;
}
else {
phydat_dump(&res, type);//phydat.h
dim = saul_reg_write(dev, &res); // &res -as saul_reg_read store location or *res data to write?
// return gcoap_response(pdu, buf, len, COAP_CODE_404);
}
}
if (dim <= 0) {
char *err = "no values found";
if (pdu->payload_len >= strlen(err)) {
memcpy(pdu->payload, err, strlen(err));
resp_len += gcoap_response(pdu, buf, len, COAP_CODE_404);
return resp_len;
}
else {
return gcoap_response(pdu, buf, len, COAP_CODE_404);
}
if (dim <= 0) {
char *err = "no values found";
if (pdu->payload_len >= strlen(err)) {
memcpy(pdu->payload, err, strlen(err));
resp_len += gcoap_response(pdu, buf, len, COAP_CODE_404);
return resp_len;
}
else {
return gcoap_response(pdu, buf, len, COAP_CODE_404);
}
}
/* write the response buffer with the request device value */
resp_len += fmt_u16_dec((char *)pdu->payload, res.val[0]);