2 #include "StreamInjector.h" 9 uint8_t _rx_buffer[32];
10 uint8_t _rx_count = 0;
16 bool _compare(uint8_t * expected,
size_t len) {
17 if (len != _rx_count)
return false;
18 for (uint8_t i=0; i<len; i++) {
19 if (_rx_buffer[i] != expected[i])
return false;
24 void _mock_response(
unsigned char ch) {
26 static uint8_t pending_payload = 1;
28 if (pending_payload > 0) --pending_payload;
29 if (0 == pending_payload) mock.inject(
'>');
31 _rx_buffer[_rx_count++] = ch;
37 bool test_set_channel(
void) {
39 uint8_t expected[4] = {0x00,
'C', 3, 0xFF};
40 return _compare(expected, 4);
45 void test(
const char * name,
bool (*callback)(
void)) {
49 bool response = (callback)();
50 Serial.println(response ?
"OK" :
"FAIL");
58 Serial.println(
"Allwize library test suite");
59 Serial.println(
"--------------------------");
62 mock.callback(_mock_response);
65 test(
"setChannel", test_set_channel);
void setChannel(uint8_t channel)
Sets the communications channel.