15 #define TEST_STRING "Ave mundi!"
16 #define EXTENDED_STRING "Lorem ipsum dolor sit amet, consectetur adipiscing elit."\
18 "ligula, lacinia malesuada pellentesque molestie, venenatis "\
19 "non neque. Cras eget ligula eget nunc pharetra tincidunt. "\
36 static volatile bool m_has_connected;
37 static volatile bool m_has_disconnected;
38 static volatile bool m_has_sent;
39 static volatile bool m_has_received;
40 static volatile bool m_timeout;
43 void * p_data,
size_t data_len)
49 m_has_connected =
true;
53 m_has_disconnected =
true;
61 m_has_received =
true;
87 static bool ri_adv_init_null_test (
void)
94 static bool ri_adv_init_twice_test (
void)
102 static bool ri_adv_init_norad_test (
void)
114 printfp (
"\"init\":");
115 status |= ri_adv_init_norad_test();
122 status |= ri_adv_init_null_test();
123 status |= ri_adv_init_twice_test();
132 printfp (
"\"fail\",\r\n");
136 printfp (
"\"pass\",\r\n");
153 static bool ri_adv_interval_short_test (
void)
160 static bool ri_adv_interval_long_test (
void)
170 uint32_t interval = 0;
177 m_channel.
send (msg);
214 snprintf ( (
char *) & (msg.
data), sizeof (msg.
data), TEST_STRING);
216 printfp (
"\"interval\":");
220 m_channel.
on_evt = &ble_isr;
221 status |= ri_adv_interval_short_test();
222 status |= ri_adv_interval_long_test();
223 status |= ri_adv_tx_test (&msg);
227 printfp (
"\"fail\",\r\n");
231 printfp (
"\"pass\",\r\n");
247 snprintf ( (
char *) & (msg.
data), sizeof (msg.
data), EXTENDED_STRING);
249 printfp (
"\"extended\":");
253 m_channel.
on_evt = &ble_isr;
254 status |= ri_adv_tx_test (&msg);
258 printfp (
"\"fail\",\r\n");
262 printfp (
"\"pass\",\r\n");
280 static bool ri_adv_pwr_test_noinit (
void)
287 static bool ri_adv_pwr_test_null (
void)
298 printfp (
"\"power\":");
300 int8_t original = pwr;
301 status |= ri_adv_pwr_test_noinit();
304 status |= ri_adv_pwr_test_null();
307 status |= (original == pwr);
315 status |= (original != pwr);
319 printfp (
"\"fail\",\r\n");
323 printfp (
"\"pass\",\r\n");
360 uint64_t test_start = 0;
361 uint64_t test_end = 0;
362 printfp (
"\"scan\":");
366 m_channel.
on_evt = ble_isr;
386 const uint32_t test_time_ms = (test_end - test_start);
396 if ( (test_min_ms > test_time_ms)
397 || (test_max_ms < test_time_ms)
407 printfp (
"\"fail\"\r\n");
411 printfp (
"\"pass\"\r\n");
472 printfp (
"\"ble_adv_");
474 printfp (
"\":{\r\n");
475 status |= ri_adv_init_test (printfp, modulation);
476 status |= ri_adv_interval_test (printfp, modulation);
477 status |= ri_adv_extended_test (printfp, modulation);
478 status |= ri_adv_power_test (printfp, modulation);
479 status |= ri_adv_rx_interval_test (printfp, modulation);
#define RI_TEST_ADV_TOO_FAST
Interval shorter than allowed for non-connectable advertising.
bool ri_communication_ble_advertising_run_integration_test(const rd_test_print_fp printfp, const ri_radio_modulation_t modulation)
Run advertising test.
#define RI_TEST_ADV_SCAN_INTERVAL
Scan interval for test.
#define RI_TEST_ADV_SCAN_CH_NUM
Number of channels to scan.
#define RI_TEST_ADV_FAST
Fastest allowed interval for connectable advertising.
#define RI_TEST_ADV_TOO_SLOW
Interval longer than allowed for non-connectable advertising.
#define RI_ADV_RND_DELAY
Maximum random delay in adv interval.
#define RI_TEST_ADV_SCAN_WINDOW
Scan window for test.
#define RD_ERROR_INVALID_PARAM
Invalid Parameter.
#define RD_ERROR_NULL
Null Pointer.
uint32_t rd_status_t
bitfield for representing errors
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
void print_modulation(const rd_test_print_fp printfp, const ri_radio_modulation_t modulation)
Print used modulation to printfp.
rd_status_t ri_radio_init(const ri_radio_modulation_t modulation)
Enable radio stack for an user. This function also starts radio activity callbacks internally.
rd_status_t ri_radio_uninit()
Release radio stack.
ri_radio_modulation_t
type of radio modulation to be used.
void(* rd_test_print_fp)(const char *const msg)
function pointer to print test information
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
Functions for testing drivers.
ri_comm_evt_t
Communication event type.
@ RI_COMM_TIMEOUT
Operation timed out.
@ RI_COMM_CONNECTED
Connection established, OK to send, may receive data.
@ RI_COMM_RECEIVED
New data received, available to read with read function.
@ RI_COMM_SENT
One queued message was sent with all repetitions.
@ RI_COMM_DISCONNECTED
Connection lost, cannot send, may not receive data.
rd_status_t ri_adv_scan_start(const uint32_t window_interval_ms, const uint32_t window_size_ms)
setup scan window interval and window size.
rd_status_t ri_adv_tx_power_get(int8_t *dbm)
Get radio TX power.
rd_status_t ri_adv_init(ri_comm_channel_t *const channel)
Initialize Advertising module and scanning module.
rd_status_t ri_adv_tx_interval_get(uint32_t *ms)
Getter for broadcast advertisement interval.
rd_status_t ri_adv_uninit(ri_comm_channel_t *const channel)
rd_status_t ri_adv_tx_interval_set(const uint32_t ms)
rd_status_t ri_adv_tx_power_set(int8_t *dbm)
Set radio TX power.
rd_status_t ri_adv_scan_stop(void)
Stop ongoing scanning.
rd_status_t ri_rtc_init(void)
Initializes RTC at 0 ms.
rd_status_t ri_rtc_uninit(void)
Stop RTC if applicable.
uint64_t ri_rtc_millis(void)
Get milliseconds since init.
rd_status_t ri_yield(void)
Function which will release execution.
control API for communication via outside world
ri_comm_evt_handler_fp_t on_evt
Callback to application-level event handler, must be set in application.
ri_comm_xfer_fp_t send
Asynchronous send function.
Application message structure used for communication.
uint8_t data[RI_COMM_MESSAGE_MAX_LENGTH]
Data payload.
uint8_t repeat_count
Number of times to repeat the message,.
uint8_t data_length
Length of data.