}
/* socat /dev/ttyUSB0,raw,echo=0,b115200 /dev/ttyACM1,raw,echo=0,b115200 */
-void xbeeapp_rx(struct xbee_dev *dev, int channel, int type,
+int8_t xbeeapp_rx(struct xbee_dev *dev, int channel, int type,
void *frame, unsigned len, void *opaque)
{
struct xbee_ctx *ctx = opaque;
- int do_hexdump = xbee_hexdump;
+ int8_t ret = 0;
if (xbee_debug)
printf_P(PSTR("type=0x%x, channel=%d, ctx=%p\r\n"),
/* this answer contains an atcmd answer at offset 10 */
if (dump_atcmd(ctx, frame + 10, len - 10) < 0)
- do_hexdump = 1;
+ ret = -1;
+
break;
}
case XBEE_TYPE_ATRESP: {
if (dump_atcmd(ctx, frame, len) < 0)
- do_hexdump = 1;
+ ret = -1;
+
break;
}
case XBEE_TYPE_XMIT_STATUS: {
if (parse_xmit_status(ctx, frame, len) < 0)
- do_hexdump = 1;
+ ret = -1;
+
break;
}
case XBEE_TYPE_RECV: {
if (xbee_recv_data(frame, len) < 0)
- do_hexdump = 1;
+ ret = -1;
+
break;
}
case XBEE_TYPE_NODE_ID:
default:
printf_P(PSTR("Invalid frame\r\n"));
- do_hexdump = 1;
+ ret = -1;
break;
}
- if (do_hexdump)
+ if (ret < 0)
+ hexdump("undecoded rx frame", frame, len);
+ else if (xbee_hexdump)
hexdump("undecoded rx frame", frame, len);
/* restart command line if it was a blocking query */
void bootloader(void);
-void xbeeapp_rx(struct xbee_dev *dev, int channel, int type,
- void *frame, unsigned len, void *opaque);
+int8_t xbeeapp_rx(struct xbee_dev *dev, int channel, int type,
+ void *frame, unsigned len, void *opaque);
int xbeeapp_send_atcmd(const char *atcmd_str,
void *param, unsigned param_len, int foreground,
int (*func)(void *frame, unsigned len, void *arg),