/* wait for an array data from uart device with a timeout  */
static int uart_wait_for(const struct device *dev, uint8_t *data, int len, int timeout)
/* wait for an array data from uart device with a timeout  */
static int uart_wait_for(const struct device *dev, uint8_t *data, int len, int timeout)
{
	int matched_size = 0;
	int64_t timeout_time = k_uptime_get() + timeout;
	while (1) {
		uint8_t c;
		if (k_uptime_get() > timeout_time) {
			return -ETIME;
		}
		if (uart_poll_in(dev, &c) == 0) {
			if (c == data[matched_size]) {
				matched_size++;
				if (matched_size == len) {
					break;
				}
			} else if (c == data[0]) {
				matched_size = 1;
			} else {
				matched_size = 0;
			}
		}
	}
	return 0;
}