/* It returns 0 if the packet was acknowledge, -1 otherwise.  */
static int gdb_send_packet(const uint8_t *data, size_t len)
/* It returns 0 if the packet was acknowledge, -1 otherwise.  */
static int gdb_send_packet(const uint8_t *data, size_t len)
{
	uint8_t buf[2];
	uint8_t checksum = 0;
	z_gdb_putchar('$');
	while (len-- > 0) {
		checksum += *data;
		z_gdb_putchar(*data++);
	}
	z_gdb_putchar('#');
	if (gdb_bin2hex(&checksum, 1, buf, sizeof(buf)) == 0) {
		return -1;
	}
	z_gdb_putchar(buf[0]);
	z_gdb_putchar(buf[1]);
	if (z_gdb_getchar() == '+') {
		return 0;
	}
	return -1;
}