parse_packet refactoring
This commit is contained in:
parent
93d8c837d2
commit
58639579ed
|
|
@ -33,3 +33,5 @@ BreakBeforeBraces: Allman
|
||||||
IndentAccessModifiers: true
|
IndentAccessModifiers: true
|
||||||
|
|
||||||
IndentPPDirectives: AfterHash
|
IndentPPDirectives: AfterHash
|
||||||
|
|
||||||
|
IndentCaseLabels: true
|
||||||
|
|
|
||||||
|
|
@ -1243,25 +1243,31 @@ uint16_t BNO08x::parse_packet(bno08x_rx_packet_t* packet)
|
||||||
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGW(TAG, "SHTP Header RX'd: 0x%X 0x%X 0x%X 0x%X", packet->header[0], packet->header[1], packet->header[2], packet->header[3]);
|
ESP_LOGW(TAG, "SHTP Header RX'd: 0x%X 0x%X 0x%X 0x%X", packet->header[0], packet->header[1], packet->header[2], packet->header[3]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
switch (packet->body[0])
|
||||||
if (packet->body[0] == SHTP_REPORT_PRODUCT_ID_RESPONSE) // check to see that product ID matches what it should
|
|
||||||
{
|
{
|
||||||
|
case SHTP_REPORT_PRODUCT_ID_RESPONSE:
|
||||||
return parse_product_id_report(packet);
|
return parse_product_id_report(packet);
|
||||||
}
|
break;
|
||||||
|
|
||||||
/*if(packet->body[0] == SHTP_REPORT_GET_FEATURE_RESPONSE)
|
case SHTP_REPORT_GET_FEATURE_RESPONSE:
|
||||||
{
|
|
||||||
|
|
||||||
}*/
|
break;
|
||||||
|
|
||||||
if (packet->body[0] == SHTP_REPORT_FRS_READ_RESPONSE)
|
case SHTP_REPORT_FRS_READ_RESPONSE:
|
||||||
{
|
|
||||||
return parse_frs_read_response_report(packet);
|
return parse_frs_read_response_report(packet);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if this packet is a sensor reporting its data to us
|
switch (packet->header[2])
|
||||||
if (packet->header[2] == CHANNEL_REPORTS && packet->body[0] == SHTP_REPORT_BASE_TIMESTAMP)
|
{
|
||||||
|
case CHANNEL_REPORTS:
|
||||||
|
if (packet->body[0] == SHTP_REPORT_BASE_TIMESTAMP)
|
||||||
{
|
{
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
|
|
@ -1269,31 +1275,38 @@ uint16_t BNO08x::parse_packet(bno08x_rx_packet_t* packet)
|
||||||
#endif
|
#endif
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
return parse_input_report(packet); // This will update the rawAccelX, etc variables depending on which feature
|
// this will update the rawAccelX, etc variables depending on which feature report is found
|
||||||
// report is found
|
return parse_input_report(packet);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
if (packet->header[2] == CHANNEL_CONTROL)
|
case CHANNEL_CONTROL:
|
||||||
{
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGI(TAG, "RX'd packet, channel control");
|
ESP_LOGI(TAG, "RX'd packet, channel control");
|
||||||
#endif
|
#endif
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
return parse_command_report(packet); // This will update responses to commands, calibrationStatus, etc.
|
// this will update responses to commands, calibrationStatus, etc.
|
||||||
}
|
return parse_command_report(packet);
|
||||||
|
|
||||||
if (packet->header[2] == CHANNEL_GYRO)
|
break;
|
||||||
{
|
|
||||||
|
case CHANNEL_GYRO:
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGI(TAG, "Rx packet, channel gyro");
|
ESP_LOGI(TAG, "Rx packet, channel gyro");
|
||||||
#endif
|
#endif
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
return parse_input_report(packet); // This will update the rawAccelX, etc variables depending on which feature
|
// this will update the rawAccelX, etc variables depending on which feature report is found
|
||||||
// report is found
|
return parse_input_report(packet);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue