The (alpha of the) official Exosite library, CoAP version.
NOTE: This mirror repository may be out of date, check the main repo for changes. If there are any remind me to update this mirror.
This is an unstable alpha of the Official Exosite library, there are known issues with the port to this platform. You probably shouldn't use this library yet if you just want to get things done.
This version uses CoAP for the application protocol.
Revision 29:004c318e63fa, committed 2015-01-07
- Comitter:
- Patrick Barrett
- Date:
- Wed Jan 07 14:20:56 2015 -0600
- Parent:
- 28:07869ba0b6de
- Commit message:
- added retry on network error
Changed in this revision
src/exosite.c | Show annotated file Show diff for this revision Revisions of this file |
src/exosite.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 07869ba0b6de -r 004c318e63fa src/exosite.c --- a/src/exosite.c Wed Jan 07 14:23:55 2015 -0600 +++ b/src/exosite.c Wed Jan 07 14:20:56 2015 -0600 @@ -203,6 +203,7 @@ op->tkl = 0; op->token = 0; op->timeout = 0; + op->retries = 0; } void exo_op_done(exo_op *op) @@ -504,8 +505,34 @@ switch (op[i].type) { case EXO_READ: case EXO_WRITE: - // TODO: may want to do some sort of retry system - op[i].state = EXO_REQUEST_ERROR; + case EXO_ACTIVATE: + if (op[i].retries < COAP_MAX_RETRANSMIT){ + switch (op[i].type) { + case EXO_READ: + exo_build_msg_read(&pdu, op[i].alias); + break; + case EXO_WRITE: + exo_build_msg_write(&pdu, op[i].alias, op[i].value); + break; + case EXO_ACTIVATE: + exo_build_msg_activate(&pdu, vendor, model, serial); + break; + default: + break; + } + + // reuse old mid and token + coap_set_mid(&pdu, op[i].mid); + coap_set_token(&pdu, op[i].token, op[i].tkl); + + if (exopal_udp_send(pdu.buf, pdu.len) == 0) { + op[i].retries++; + op[i].timeout = exopal_get_time() + (op[i].retries * COAP_PROBING_RATE * 1000000) + + (((uint64_t)rand() % 1500000)); + } + } else { + op[i].state = EXO_REQUEST_ERROR; + } break; case EXO_SUBSCRIBE: // force a new observe request
diff -r 07869ba0b6de -r 004c318e63fa src/exosite.h --- a/src/exosite.h Wed Jan 07 14:23:55 2015 -0600 +++ b/src/exosite.h Wed Jan 07 14:20:56 2015 -0600 @@ -112,6 +112,7 @@ uint8_t tkl; uint64_t token; uint64_t timeout; + uint8_t retries; } exo_op; // PUBLIC FUNCTIONS