Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Add status logging #215

Merged
merged 3 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/softdevice_api/testcase_driver_open_close.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ TEST_CASE(CREATE_TEST_NAME_AND_TAGS(driver_open_close,
testutil::Central, serialPort.port, env.baudRate, env.mtu, env.retransmissionInterval,
env.responseTimeout);

c->setStatusCallback([&](const sd_rpc_app_status_t code, const std::string &message) {
if (code == PKT_DECODE_ERROR || code == PKT_SEND_MAX_RETRIES_REACHED ||
code == PKT_UNEXPECTED)
{
NRF_LOG(c->role() << " error in status callback " << static_cast<uint32_t>(code)
<< ": " << message);
}
});

REQUIRE(sd_rpc_log_handler_severity_filter_set(c->unwrap(), env.driverLogLevel) ==
NRF_SUCCESS);

Expand All @@ -108,6 +117,15 @@ TEST_CASE(CREATE_TEST_NAME_AND_TAGS(driver_open_close,
REQUIRE(sd_rpc_log_handler_severity_filter_set(c->unwrap(), env.driverLogLevel) ==
NRF_SUCCESS);

c->setStatusCallback([&](const sd_rpc_app_status_t code, const std::string &message) {
if (code == PKT_DECODE_ERROR || code == PKT_SEND_MAX_RETRIES_REACHED ||
code == PKT_UNEXPECTED)
{
NRF_LOG(c->role() << " error in status callback " << static_cast<uint32_t>(code)
<< ": " << message);
}
});

c->setGapEventCallback([&](const uint16_t eventId,
const ble_gap_evt_t *gapEvent) -> bool {
switch (eventId)
Expand Down Expand Up @@ -156,6 +174,16 @@ TEST_CASE(CREATE_TEST_NAME_AND_TAGS(driver_open_close,
REQUIRE(sd_rpc_log_handler_severity_filter_set(c->unwrap(), env.driverLogLevel) ==
NRF_SUCCESS);

c->setStatusCallback(
[&](const sd_rpc_app_status_t code, const std::string &message) {
if (code == PKT_DECODE_ERROR || code == PKT_SEND_MAX_RETRIES_REACHED ||
code == PKT_UNEXPECTED)
{
NRF_LOG(c->role() << " error in status callback " << static_cast<uint32_t>(code)
<< ": " << message);
}
});

for (uint32_t i = 0; i < numberOfIterations; i++)
{
NRF_LOG("Starting iteration #" << std::dec << static_cast<uint32_t>(i + 1) << " of "
Expand Down
4 changes: 4 additions & 0 deletions test/softdevice_api/testcase_issue_gh_112.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ TEST_CASE(CREATE_TEST_NAME_AND_TAGS(issue_gh_112,
code == PKT_UNEXPECTED)
{
centralError = true;
NRF_LOG(c->role() << " error in status callback " << static_cast<uint32_t>(code) << ": "
<< message);
}
});

Expand All @@ -545,6 +547,8 @@ TEST_CASE(CREATE_TEST_NAME_AND_TAGS(issue_gh_112,
code == PKT_UNEXPECTED)
{
peripheralError = true;
NRF_LOG(p->role() << " error in status callback " << static_cast<uint32_t>(code) << ": "
<< message);
}
});

Expand Down
21 changes: 21 additions & 0 deletions test/softdevice_api/testcase_issue_stuck_in_scan_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ TEST_CASE(CREATE_TEST_NAME_AND_TAGS(issue_stuck_in_scan_mode,
testutil::Peripheral, peripheral.port, env.baudRate, env.mtu, env.retransmissionInterval,
env.responseTimeout);

p->setStatusCallback([&](const sd_rpc_app_status_t code, const std::string &message) {
if (code == PKT_DECODE_ERROR || code == PKT_SEND_MAX_RETRIES_REACHED ||
code == PKT_UNEXPECTED)
{
error = true;
NRF_LOG(p->role() << " error in status callback " << static_cast<uint32_t>(code) << ": "
<< message);
}
});

REQUIRE(sd_rpc_log_handler_severity_filter_set(p->unwrap(), env.driverLogLevel) == NRF_SUCCESS);
REQUIRE(p->open() == NRF_SUCCESS);
REQUIRE(p->configure() == NRF_SUCCESS);
Expand All @@ -113,6 +123,16 @@ TEST_CASE(CREATE_TEST_NAME_AND_TAGS(issue_stuck_in_scan_mode,
testutil::Central, central.port, env.baudRate, env.mtu, env.retransmissionInterval,
env.responseTimeout);

c->setStatusCallback([&](const sd_rpc_app_status_t code, const std::string &message) {
if (code == PKT_DECODE_ERROR || code == PKT_SEND_MAX_RETRIES_REACHED ||
code == PKT_UNEXPECTED)
{
error = true;
NRF_LOG(c->role() << " error in status callback " << static_cast<uint32_t>(code)
<< ": " << message);
}
});

NRF_LOG(c->role() << " Starting scan iteration #" << std::dec << static_cast<uint32_t>(i)
<< " of " << static_cast<uint32_t>(scanIterations));

Expand Down Expand Up @@ -160,6 +180,7 @@ TEST_CASE(CREATE_TEST_NAME_AND_TAGS(issue_stuck_in_scan_mode,
}
});

REQUIRE(sd_rpc_log_handler_severity_filter_set(c->unwrap(), env.driverLogLevel) == NRF_SUCCESS);
REQUIRE(c->open() == NRF_SUCCESS);
REQUIRE(c->configure() == NRF_SUCCESS);
REQUIRE(c->startScan() == NRF_SUCCESS);
Expand Down
4 changes: 4 additions & 0 deletions test/softdevice_api/testcase_security.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ TEST_CASE(CREATE_TEST_NAME_AND_TAGS(security, [PCA10028][PCA10031][PCA10040][PCA
code == PKT_UNEXPECTED)
{
error = true;
NRF_LOG(c->role() << " error in status callback " << static_cast<uint32_t>(code)
<< ": " << message);
}
});

Expand All @@ -299,6 +301,8 @@ TEST_CASE(CREATE_TEST_NAME_AND_TAGS(security, [PCA10028][PCA10031][PCA10040][PCA
code == PKT_UNEXPECTED)
{
error = true;
NRF_LOG(p->role() << " error in status callback " << static_cast<uint32_t>(code)
<< ": " << message);
}
});

Expand Down