Skip to content

Commit

Permalink
Merge pull request #3 from yoziru/parse-carserver-response
Browse files Browse the repository at this point in the history
parse carserver response
  • Loading branch information
yoziru authored Jul 22, 2024
2 parents 8fb557a + 8f2e3fc commit 9f7d8b9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.22)

include(FetchContent)
project(TeslaBLE
VERSION 2.0.2
VERSION 2.0.3
DESCRIPTION "CPP Tesla BLE Library"
LANGUAGES CXX C
)
Expand Down
16 changes: 8 additions & 8 deletions include/car_server.pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef struct _CarServer_EraseUserDataAction {
typedef struct _CarServer_ResultReason {
pb_size_t which_reason;
union {
pb_callback_t plain_text;
char plain_text[100];
} reason;
} CarServer_ResultReason;

Expand Down Expand Up @@ -546,7 +546,7 @@ extern "C" {
#define CarServer_EraseUserDataAction_init_default {{{NULL}, NULL}}
#define CarServer_Response_init_default {false, CarServer_ActionStatus_init_default, 0, {Signatures_SessionInfo_init_default}}
#define CarServer_ActionStatus_init_default {_CarServer_OperationStatus_E_MIN, false, CarServer_ResultReason_init_default}
#define CarServer_ResultReason_init_default {0, {{{NULL}, NULL}}}
#define CarServer_ResultReason_init_default {0, {""}}
#define CarServer_EncryptedData_init_default {0, {{NULL}, NULL}, {{NULL}, NULL}}
#define CarServer_ChargingSetLimitAction_init_default {0}
#define CarServer_ChargingStartStopAction_init_default {0, {CarServer_Void_init_default}}
Expand Down Expand Up @@ -602,7 +602,7 @@ extern "C" {
#define CarServer_EraseUserDataAction_init_zero {{{NULL}, NULL}}
#define CarServer_Response_init_zero {false, CarServer_ActionStatus_init_zero, 0, {Signatures_SessionInfo_init_zero}}
#define CarServer_ActionStatus_init_zero {_CarServer_OperationStatus_E_MIN, false, CarServer_ResultReason_init_zero}
#define CarServer_ResultReason_init_zero {0, {{{NULL}, NULL}}}
#define CarServer_ResultReason_init_zero {0, {""}}
#define CarServer_EncryptedData_init_zero {0, {{NULL}, NULL}, {{NULL}, NULL}}
#define CarServer_ChargingSetLimitAction_init_zero {0}
#define CarServer_ChargingStartStopAction_init_zero {0, {CarServer_Void_init_zero}}
Expand Down Expand Up @@ -948,8 +948,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, result_reason, 2)
#define CarServer_ActionStatus_result_reason_MSGTYPE CarServer_ResultReason

#define CarServer_ResultReason_FIELDLIST(X, a) \
X(a, CALLBACK, ONEOF, STRING, (reason,plain_text,reason.plain_text), 1)
#define CarServer_ResultReason_CALLBACK pb_default_field_callback
X(a, STATIC, ONEOF, STRING, (reason,plain_text,reason.plain_text), 1)
#define CarServer_ResultReason_CALLBACK NULL
#define CarServer_ResultReason_DEFAULT NULL

#define CarServer_EncryptedData_FIELDLIST(X, a) \
Expand Down Expand Up @@ -1442,8 +1442,6 @@ extern const pb_msgdesc_t CarServer_VehicleControlResetPinToDriveAction_msg;
/* CarServer_VehicleAction_size depends on runtime parameters */
/* CarServer_EraseUserDataAction_size depends on runtime parameters */
/* CarServer_Response_size depends on runtime parameters */
/* CarServer_ActionStatus_size depends on runtime parameters */
/* CarServer_ResultReason_size depends on runtime parameters */
/* CarServer_EncryptedData_size depends on runtime parameters */
/* CarServer_DrivingClearSpeedLimitPinAction_size depends on runtime parameters */
/* CarServer_DrivingSpeedLimitAction_size depends on runtime parameters */
Expand All @@ -1458,7 +1456,8 @@ extern const pb_msgdesc_t CarServer_VehicleControlResetPinToDriveAction_msg;
/* CarServer_AutoSeatClimateAction_size depends on runtime parameters */
/* CarServer_SetVehicleNameAction_size depends on runtime parameters */
/* CarServer_VehicleControlSetPinToDriveAction_size depends on runtime parameters */
#define CARSERVER_CAR_SERVER_PB_H_MAX_SIZE CarServer_ScheduledDepartureAction_size
#define CARSERVER_CAR_SERVER_PB_H_MAX_SIZE CarServer_ActionStatus_size
#define CarServer_ActionStatus_size 105
#define CarServer_AutoSeatClimateAction_CarSeat_size 4
#define CarServer_ChargePortDoorClose_size 0
#define CarServer_ChargePortDoorOpen_size 0
Expand All @@ -1481,6 +1480,7 @@ extern const pb_msgdesc_t CarServer_VehicleControlResetPinToDriveAction_msg;
#define CarServer_MediaPreviousTrack_size 0
#define CarServer_MediaUpdateVolume_size 6
#define CarServer_Ping_size 11
#define CarServer_ResultReason_size 101
#define CarServer_ScheduledChargingAction_size 13
#define CarServer_ScheduledDepartureAction_size 32
#define CarServer_SetCabinOverheatProtectionAction_size 4
Expand Down
4 changes: 2 additions & 2 deletions include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ namespace TeslaBLE
Signatures_SessionInfo *output);
static int parsePayloadUnsignedMessage(UniversalMessage_RoutableMessage_protobuf_message_as_bytes_t *input_buffer,
VCSEC_UnsignedMessage *output);
static int parsePayloadCarServerAction(UniversalMessage_RoutableMessage_protobuf_message_as_bytes_t *input_buffer,
CarServer_Action *output);
static int parsePayloadCarServerResponse(UniversalMessage_RoutableMessage_protobuf_message_as_bytes_t *input_buffer,
CarServer_Response *output);

int buildEphemeralKeyMessage(UniversalMessage_Domain domain,
pb_byte_t *output_buffer,
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TeslaBLE",
"version": "2.0.2",
"version": "2.0.3",
"description": "This CPP library facilitates direct communication with Tesla vehicles via the BLE API. It offers fundamental features such as unlocking/locking, opening the trunk, and more. The library's capabilities are contingent on the range of actions implemented by Tesla, which is the only limitation at present.",
"keywords": "tesla, ble",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion proto/car_server.options
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CarServer.Ping.local_timestamp type:FT_IGNORE
CarServer.Ping.last_remote_timestamp type:FT_IGNORE

# CarServer.EraseUserDataAction.reason type:FT_IGNORE
# CarServer.ResultReason.reason.plain_text type:FT_IGNORE
CarServer.ResultReason.plain_text max_size:100 type:FT_STATIC

# CarServer.EncryptedData.ciphertext type:FT_IGNORE
# CarServer.EncryptedData.tag type:FT_IGNORE
Expand Down
6 changes: 3 additions & 3 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,12 +690,12 @@ namespace TeslaBLE
return 0;
}

int Client::parsePayloadCarServerAction(UniversalMessage_RoutableMessage_protobuf_message_as_bytes_t *input_buffer,
CarServer_Action *output)
int Client::parsePayloadCarServerResponse(UniversalMessage_RoutableMessage_protobuf_message_as_bytes_t *input_buffer,
CarServer_Response *output)
{
pb_istream_t stream = pb_istream_from_buffer(input_buffer->bytes, input_buffer->size);
bool status =
pb_decode(&stream, CarServer_Action_fields, output);
pb_decode(&stream, CarServer_Response_fields, output);
if (!status)
{
printf("Decoding failed: %s\n", PB_GET_ERROR(&stream));
Expand Down

0 comments on commit 9f7d8b9

Please sign in to comment.