14#if DETWS_ENABLE_SIGFOX
18char hex_nibble(uint8_t v)
20 return (
char)(v < 10 ?
'0' + v :
'A' + (v - 10));
24bool contains(
const char *hay, uint16_t len,
const char *needle)
29 if (nlen == 0 || len < nlen)
31 for (uint16_t i = 0; i + nlen <= len; i++)
34 while (j < nlen && hay[i + j] == needle[j])
43uint16_t sigfox_build_uplink(
const uint8_t *payload, uint8_t len,
char *out, uint16_t cap)
48 uint16_t need = (uint16_t)(6 + 2 * len + 2 + 1);
51 const char *pfx =
"AT$SF=";
53 for (
const char *s = pfx; *s; s++)
55 for (uint8_t i = 0; i < len; i++)
57 out[p++] = hex_nibble((uint8_t)(payload[i] >> 4));
58 out[p++] = hex_nibble((uint8_t)(payload[i] & 0x0F));
66sigfox_result sigfox_parse_response(
const char *buf, uint16_t len)
69 return sigfox_result::SIGFOX_PENDING;
70 if (contains(buf, len,
"ERROR"))
71 return sigfox_result::SIGFOX_ERROR;
72 if (contains(buf, len,
"OK"))
73 return sigfox_result::SIGFOX_OK;
74 return sigfox_result::SIGFOX_PENDING;
#define DETWS_SIGFOX_MAX_PAYLOAD
Maximum Sigfox uplink payload (the network caps a message at 12 bytes).
Sigfox modem AT-command codec (DETWS_ENABLE_SIGFOX) - Wisol / Murata over UART.