Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 |
--- 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
--- 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