Skip to content

Commit 1fe709e

Browse files
committed
format code
1 parent be67306 commit 1fe709e

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

infinite_sense_core/src/ptp.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
namespace infinite_sense {
88

99
namespace {
10-
constexpr char FUNC_NAME[] = "f";
11-
constexpr char FUNC_TYPE_A[] = "a";
12-
constexpr char FUNC_TYPE_B[] = "b";
10+
constexpr char func_name[] = "f";
11+
constexpr char func_type_a[] = "a";
12+
constexpr char func_type_b[] = "b";
1313
} // namespace
1414

1515
void Ptp::SetUsbPtr(const std::shared_ptr<serial::Serial>& serial_ptr) {
@@ -25,11 +25,11 @@ void Ptp::SetNetPtr(const std::shared_ptr<UDPSocket>& net_ptr, const std::string
2525

2626
void Ptp::ReceivePtpData(const nlohmann::json& data) {
2727
try {
28-
const std::string func = data.at(FUNC_NAME);
28+
const std::string func = data.at(func_name);
2929

30-
if (func == FUNC_TYPE_A) {
30+
if (func == func_type_a) {
3131
HandleTimeSyncRequest(data);
32-
} else if (func == FUNC_TYPE_B) {
32+
} else if (func == func_type_b) {
3333
HandleTimeSyncResponse(data);
3434
}
3535
} catch (const nlohmann::json::exception& e) {
@@ -39,8 +39,8 @@ void Ptp::ReceivePtpData(const nlohmann::json& data) {
3939

4040
void Ptp::HandleTimeSyncRequest(const nlohmann::json& data) {
4141
try {
42-
time_t1_ = data.at(FUNC_TYPE_A);
43-
time_t2_ = data.at(FUNC_TYPE_B);
42+
time_t1_ = data.at(func_type_a);
43+
time_t2_ = data.at(func_type_b);
4444
updated_t1_t2_ = true;
4545
} catch (const nlohmann::json::exception& e) {
4646
LOG(ERROR) << "Invalid 'a' message format: " << e.what();
@@ -49,17 +49,17 @@ void Ptp::HandleTimeSyncRequest(const nlohmann::json& data) {
4949

5050
void Ptp::HandleTimeSyncResponse(const nlohmann::json& data) {
5151
try {
52-
const uint64_t t3 = data.at(FUNC_TYPE_A);
52+
const uint64_t t3 = data.at(func_type_a);
5353
const uint64_t t4 = GetCurrentTimeUs();
5454

5555
if (updated_t1_t2_) {
5656
const int64_t delay = static_cast<int64_t>(t4 - t3 + time_t2_ - time_t1_) / 2;
5757
const int64_t offset = static_cast<int64_t>(time_t2_ - time_t1_ - t4 + t3) / 2;
5858

5959
nlohmann::json response = {
60-
{FUNC_NAME, FUNC_TYPE_B},
61-
{FUNC_TYPE_A, delay},
62-
{FUNC_TYPE_B, offset},
60+
{func_name, func_type_b},
61+
{func_type_a, delay},
62+
{func_type_b, offset},
6363
};
6464

6565
SendJson(response);
@@ -74,8 +74,8 @@ void Ptp::SendPtpData() const {
7474
const uint64_t mark = GetCurrentTimeUs();
7575

7676
nlohmann::json data = {
77-
{FUNC_NAME, FUNC_TYPE_A},
78-
{FUNC_TYPE_A, mark},
77+
{func_name, func_type_a},
78+
{func_type_a, mark},
7979
};
8080

8181
SendJson(data);

0 commit comments

Comments
 (0)