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

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
hhenry01 committed Mar 7, 2024
1 parent 5b7e5b3 commit f06a2e8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
78 changes: 39 additions & 39 deletions projects/local_transceiver/src/local_transceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ bool LocalTransceiver::send()

static constexpr int MAX_NUM_RETRIES = 20; // allow retries because the connection is imperfect
for (int i = 0; i < MAX_NUM_RETRIES; i++) {
std::cout << "A" << std::endl;
if (!send(at_write_cmd)) {
continue;
}

std::cout << "B" << std::endl;
if (!rcvRsps({
at_write_cmd,
AT::Line(AT::DELIMITER),
Expand All @@ -153,12 +155,14 @@ bool LocalTransceiver::send()
continue;
}

std::cout << "C" << std::endl;
std::string msg_str = data + checksum(data);
AT::Line msg(msg_str);
if (!send(msg)) {
continue;
}

std::cout << "D" << std::endl;
if (!rcvRsps({
AT::Line(AT::DELIMITER),
AT::Line(AT::write_bin::rsp::SUCCESS),
Expand All @@ -170,38 +174,41 @@ bool LocalTransceiver::send()
continue;
}

// // Check SBD Session status to see if data was sent successfully
// // NEEDS AN ACTIVE SERVER ON $WEBHOOK_SERVER_ENDPOINT OR VIRTUAL IRIDIUM WILL CRASH
// static const AT::Line sbdix_cmd = AT::Line(AT::SBD_SESSION);
// if (!send(sbdix_cmd)) {
// continue;
// }

// if (!rcvRsps({
// AT::Line("\r"),
// sbdix_cmd,
// AT::Line(AT::DELIMITER),
// })) {
// continue;
// }

// auto opt_rsp = readRsp();
// if (!opt_rsp) {
// continue;
// }

// // This string will look something like:
// // "+SBDIX:<MO status>,<MOMSN>,<MT status>,<MTMSN>,<MT length>,<MTqueued>\r\n\r\nOK\r"
// // on success
// // Don't bother to check for OK\r as MO status will tell us if it succeeded or not
// std::string opt_rsp_val = opt_rsp.value();
// std::vector<std::string> sbd_status_vec;
// boost::algorithm::split(sbd_status_vec, opt_rsp_val, boost::is_any_of(AT::DELIMITER));

// AT::SBDStatusRsp rsp(sbd_status_vec[0]);
// if (rsp.MOSuccess()) {
// return true;
// }
std::cout << "E" << std::endl;
// Check SBD Session status to see if data was sent successfully
// NEEDS AN ACTIVE SERVER ON $WEBHOOK_SERVER_ENDPOINT OR VIRTUAL IRIDIUM WILL CRASH
static const AT::Line sbdix_cmd = AT::Line(AT::SBD_SESSION);
if (!send(sbdix_cmd)) {
continue;
}

std::cout << "F" << std::endl;
if (!rcvRsps({
AT::Line("\r"),
sbdix_cmd,
AT::Line(AT::DELIMITER),
})) {
continue;
}

std::cout << "G" << std::endl;
auto opt_rsp = readRsp();
if (!opt_rsp) {
continue;
}

// This string will look something like:
// "+SBDIX:<MO status>,<MOMSN>,<MT status>,<MTMSN>,<MT length>,<MTqueued>\r\n\r\nOK\r"
// on success
// Don't bother to check for OK\r as MO status will tell us if it succeeded or not
std::string opt_rsp_val = opt_rsp.value();
std::vector<std::string> sbd_status_vec;
boost::algorithm::split(sbd_status_vec, opt_rsp_val, boost::is_any_of(AT::DELIMITER));

AT::SBDStatusRsp rsp(sbd_status_vec[0]);
if (rsp.MOSuccess()) {
return true;
}
}
std::cerr << "Failed to transmit data to satellite!" << std::endl;
std::cerr << sensors.DebugString() << std::endl;
Expand All @@ -217,13 +224,6 @@ std::optional<std::string> LocalTransceiver::debugSend(const std::string & cmd)
return std::nullopt;
}

if (!rcvRsps({
at_cmd,
AT::Line(AT::DELIMITER),
})) {
return std::nullopt;
}

return readRsp();
}

Expand Down
5 changes: 4 additions & 1 deletion projects/local_transceiver/test/test_local_transceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ bp::child TestLocalTransceiver::http_echo_server_proc_ = {};
*/
TEST_F(TestLocalTransceiver, debugSendTest)
{
EXPECT_EQ(lcl_trns_->debugSend(AT::CHECK_CONN), AT::Line(AT::STATUS_OK).str_);
auto opt_result = lcl_trns_->debugSend(AT::CHECK_CONN);
EXPECT_TRUE(opt_result);
std::string result = opt_result.value();
EXPECT_TRUE(boost::algorithm::contains(result, AT::Line(AT::STATUS_OK).str_));
}

/**
Expand Down

0 comments on commit f06a2e8

Please sign in to comment.