Skip to content

Commit

Permalink
Update the protocol submodule; regenerate protocol files; minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeuz committed Jul 19, 2023
1 parent d6e0c1a commit 12ec94a
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 513 deletions.
3 changes: 0 additions & 3 deletions proto_defs/gen_proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ source "$PROTO_DEFS_DIR/.venv/bin/activate"
# Install dependencies
pip3 install protobuf

# Compile common definitions
gen_proto "${SHARED_DIR}/common/ledger.proto"

# Compile control request definitions
gen_proto "${SHARED_DIR}/control/extensions.proto"
gen_proto "${SHARED_DIR}/control/common.proto"
Expand Down
6 changes: 3 additions & 3 deletions proto_defs/internal/ledger.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ syntax = "proto3";

package particle.firmware;

import "common/ledger.proto";
import "cloud/ledger.proto";
import "nanopb.proto";

/**
* Ledger info.
*/
message LedgerInfo {
string name = 1 [(nanopb).max_length = 32]; ///< Ledger name.
particle.ledger.LedgerScope scope = 2; ///< Ledger scope.
particle.ledger.SyncDirection sync_direction = 3; ///< Sync direction.
cloud.ledger.Scope scope = 2; ///< Ledger scope.
cloud.ledger.SyncDirection sync_direction = 3; ///< Sync direction.
/**
* Time the ledger was last updated, in milliseconds since the Unix epoch.
*
Expand Down
2 changes: 1 addition & 1 deletion proto_defs/shared
8 changes: 8 additions & 0 deletions proto_defs/src/cloud/cloud.pb.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
#error Regenerate this file with the current version of nanopb generator.
#endif

PB_BIND(particle_cloud_Request, particle_cloud_Request, AUTO)


PB_BIND(particle_cloud_Response, particle_cloud_Response, AUTO)


PB_BIND(particle_cloud_ServerMovedPermanentlyRequest, particle_cloud_ServerMovedPermanentlyRequest, AUTO)


PB_BIND(particle_cloud_ServerMovedPermanentlyResponse, particle_cloud_ServerMovedPermanentlyResponse, AUTO)





120 changes: 120 additions & 0 deletions proto_defs/src/cloud/cloud.pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,71 @@
#ifndef PB_PARTICLE_CLOUD_CLOUD_CLOUD_PB_H_INCLUDED
#define PB_PARTICLE_CLOUD_CLOUD_CLOUD_PB_H_INCLUDED
#include <pb.h>
#include "ledger.pb.h"

#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif

/* Enum definitions */
typedef enum _particle_cloud_Request_Type {
particle_cloud_Request_Type_INVALID = 0,
particle_cloud_Request_Type_LEDGER_GET_INFO = 1,
particle_cloud_Request_Type_LEDGER_SET_DATA = 2,
particle_cloud_Request_Type_LEDGER_GET_DATA = 3,
particle_cloud_Request_Type_LEDGER_SUBSCRIBE = 4,
particle_cloud_Request_Type_LEDGER_NOTIFY_UPDATE = 5
} particle_cloud_Request_Type;

typedef enum _particle_cloud_Response_Result {
particle_cloud_Response_Result_OK = 0,
particle_cloud_Response_Result_LEDGER_NOT_FOUND = 1,
particle_cloud_Response_Result_INVALID_SYNC_DIRECTION = 2
} particle_cloud_Response_Result;

/* Struct definitions */
/* *
A response for a ServerMovedPermanentlyRequest. */
typedef struct _particle_cloud_ServerMovedPermanentlyResponse {
char dummy_field;
} particle_cloud_ServerMovedPermanentlyResponse;

/* *
Request message. */
typedef struct _particle_cloud_Request {
particle_cloud_Request_Type type; /* /< Request type. */
pb_size_t which_data;
union {
particle_cloud_ledger_GetInfoRequest ledger_get_info;
particle_cloud_ledger_SetDataRequest ledger_set_data;
particle_cloud_ledger_GetDataRequest ledger_get_data;
particle_cloud_ledger_SubscribeRequest ledger_subscribe;
particle_cloud_ledger_NotifyUpdateRequest ledger_notify_update;
} data;
} particle_cloud_Request;

/* *
Response message. */
typedef struct _particle_cloud_Response {
/* *
Result code.
Possible result codes are defined by the `Result` enum. If the response is sent by the device,
the result code may be negative in which case it indicates a Device OS system error:
https://github.com/particle-iot/device-os/blob/develop/services/inc/system_error.h */
int32_t result;
pb_callback_t message; /* /< Diagnostic message. */
pb_size_t which_data;
union {
particle_cloud_ledger_GetInfoResponse ledger_get_info;
particle_cloud_ledger_SetDataResponse ledger_set_data;
particle_cloud_ledger_GetDataResponse ledger_get_data;
particle_cloud_ledger_SubscribeResponse ledger_subscribe;
particle_cloud_ledger_NotifyUpdateResponse ledger_notify_update;
} data;
} particle_cloud_Response;

/* *
A request sent to the device to notify it that it must disconnect from the current server and
use another server for further connections to the Cloud. */
Expand All @@ -38,23 +91,81 @@ typedef struct _particle_cloud_ServerMovedPermanentlyRequest {
} particle_cloud_ServerMovedPermanentlyRequest;


/* Helper constants for enums */
#define _particle_cloud_Request_Type_MIN particle_cloud_Request_Type_INVALID
#define _particle_cloud_Request_Type_MAX particle_cloud_Request_Type_LEDGER_NOTIFY_UPDATE
#define _particle_cloud_Request_Type_ARRAYSIZE ((particle_cloud_Request_Type)(particle_cloud_Request_Type_LEDGER_NOTIFY_UPDATE+1))

#define _particle_cloud_Response_Result_MIN particle_cloud_Response_Result_OK
#define _particle_cloud_Response_Result_MAX particle_cloud_Response_Result_INVALID_SYNC_DIRECTION
#define _particle_cloud_Response_Result_ARRAYSIZE ((particle_cloud_Response_Result)(particle_cloud_Response_Result_INVALID_SYNC_DIRECTION+1))


#ifdef __cplusplus
extern "C" {
#endif

/* Initializer values for message structs */
#define particle_cloud_Request_init_default {_particle_cloud_Request_Type_MIN, 0, {particle_cloud_ledger_GetInfoRequest_init_default}}
#define particle_cloud_Response_init_default {0, {{NULL}, NULL}, 0, {particle_cloud_ledger_GetInfoResponse_init_default}}
#define particle_cloud_ServerMovedPermanentlyRequest_init_default {{{NULL}, NULL}, 0, {{NULL}, NULL}, {{NULL}, NULL}}
#define particle_cloud_ServerMovedPermanentlyResponse_init_default {0}
#define particle_cloud_Request_init_zero {_particle_cloud_Request_Type_MIN, 0, {particle_cloud_ledger_GetInfoRequest_init_zero}}
#define particle_cloud_Response_init_zero {0, {{NULL}, NULL}, 0, {particle_cloud_ledger_GetInfoResponse_init_zero}}
#define particle_cloud_ServerMovedPermanentlyRequest_init_zero {{{NULL}, NULL}, 0, {{NULL}, NULL}, {{NULL}, NULL}}
#define particle_cloud_ServerMovedPermanentlyResponse_init_zero {0}

/* Field tags (for use in manual encoding/decoding) */
#define particle_cloud_Request_type_tag 1
#define particle_cloud_Request_ledger_get_info_tag 2
#define particle_cloud_Request_ledger_set_data_tag 3
#define particle_cloud_Request_ledger_get_data_tag 4
#define particle_cloud_Request_ledger_subscribe_tag 5
#define particle_cloud_Request_ledger_notify_update_tag 6
#define particle_cloud_Response_result_tag 1
#define particle_cloud_Response_message_tag 2
#define particle_cloud_Response_ledger_get_info_tag 3
#define particle_cloud_Response_ledger_set_data_tag 4
#define particle_cloud_Response_ledger_get_data_tag 5
#define particle_cloud_Response_ledger_subscribe_tag 6
#define particle_cloud_Response_ledger_notify_update_tag 7
#define particle_cloud_ServerMovedPermanentlyRequest_server_addr_tag 1
#define particle_cloud_ServerMovedPermanentlyRequest_server_port_tag 2
#define particle_cloud_ServerMovedPermanentlyRequest_server_pub_key_tag 3
#define particle_cloud_ServerMovedPermanentlyRequest_sign_tag 4

/* Struct field encoding specification for nanopb */
#define particle_cloud_Request_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UENUM, type, 1) \
X(a, STATIC, ONEOF, MESSAGE, (data,ledger_get_info,data.ledger_get_info), 2) \
X(a, STATIC, ONEOF, MESSAGE, (data,ledger_set_data,data.ledger_set_data), 3) \
X(a, STATIC, ONEOF, MESSAGE, (data,ledger_get_data,data.ledger_get_data), 4) \
X(a, STATIC, ONEOF, MESSAGE, (data,ledger_subscribe,data.ledger_subscribe), 5) \
X(a, STATIC, ONEOF, MESSAGE, (data,ledger_notify_update,data.ledger_notify_update), 6)
#define particle_cloud_Request_CALLBACK NULL
#define particle_cloud_Request_DEFAULT NULL
#define particle_cloud_Request_data_ledger_get_info_MSGTYPE particle_cloud_ledger_GetInfoRequest
#define particle_cloud_Request_data_ledger_set_data_MSGTYPE particle_cloud_ledger_SetDataRequest
#define particle_cloud_Request_data_ledger_get_data_MSGTYPE particle_cloud_ledger_GetDataRequest
#define particle_cloud_Request_data_ledger_subscribe_MSGTYPE particle_cloud_ledger_SubscribeRequest
#define particle_cloud_Request_data_ledger_notify_update_MSGTYPE particle_cloud_ledger_NotifyUpdateRequest

#define particle_cloud_Response_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, SINT32, result, 1) \
X(a, CALLBACK, OPTIONAL, STRING, message, 2) \
X(a, STATIC, ONEOF, MESSAGE, (data,ledger_get_info,data.ledger_get_info), 3) \
X(a, STATIC, ONEOF, MESSAGE, (data,ledger_set_data,data.ledger_set_data), 4) \
X(a, STATIC, ONEOF, MESSAGE, (data,ledger_get_data,data.ledger_get_data), 5) \
X(a, STATIC, ONEOF, MESSAGE, (data,ledger_subscribe,data.ledger_subscribe), 6) \
X(a, STATIC, ONEOF, MESSAGE, (data,ledger_notify_update,data.ledger_notify_update), 7)
#define particle_cloud_Response_CALLBACK pb_default_field_callback
#define particle_cloud_Response_DEFAULT NULL
#define particle_cloud_Response_data_ledger_get_info_MSGTYPE particle_cloud_ledger_GetInfoResponse
#define particle_cloud_Response_data_ledger_set_data_MSGTYPE particle_cloud_ledger_SetDataResponse
#define particle_cloud_Response_data_ledger_get_data_MSGTYPE particle_cloud_ledger_GetDataResponse
#define particle_cloud_Response_data_ledger_subscribe_MSGTYPE particle_cloud_ledger_SubscribeResponse
#define particle_cloud_Response_data_ledger_notify_update_MSGTYPE particle_cloud_ledger_NotifyUpdateResponse

#define particle_cloud_ServerMovedPermanentlyRequest_FIELDLIST(X, a) \
X(a, CALLBACK, SINGULAR, STRING, server_addr, 1) \
X(a, STATIC, SINGULAR, UINT32, server_port, 2) \
Expand All @@ -68,15 +179,24 @@ X(a, CALLBACK, SINGULAR, BYTES, sign, 4)
#define particle_cloud_ServerMovedPermanentlyResponse_CALLBACK NULL
#define particle_cloud_ServerMovedPermanentlyResponse_DEFAULT NULL

extern const pb_msgdesc_t particle_cloud_Request_msg;
extern const pb_msgdesc_t particle_cloud_Response_msg;
extern const pb_msgdesc_t particle_cloud_ServerMovedPermanentlyRequest_msg;
extern const pb_msgdesc_t particle_cloud_ServerMovedPermanentlyResponse_msg;

/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define particle_cloud_Request_fields &particle_cloud_Request_msg
#define particle_cloud_Response_fields &particle_cloud_Response_msg
#define particle_cloud_ServerMovedPermanentlyRequest_fields &particle_cloud_ServerMovedPermanentlyRequest_msg
#define particle_cloud_ServerMovedPermanentlyResponse_fields &particle_cloud_ServerMovedPermanentlyResponse_msg

/* Maximum encoded size of messages (where known) */
/* particle_cloud_Response_size depends on runtime parameters */
/* particle_cloud_ServerMovedPermanentlyRequest_size depends on runtime parameters */
#if defined(particle_cloud_ledger_GetInfoRequest_size) && defined(particle_cloud_ledger_SetDataRequest_size) && defined(particle_cloud_ledger_SubscribeRequest_size)
#define particle_cloud_Request_size (2 + sizeof(union particle_cloud_Request_data_size_union))
union particle_cloud_Request_data_size_union {char f2[(6 + particle_cloud_ledger_GetInfoRequest_size)]; char f3[(6 + particle_cloud_ledger_SetDataRequest_size)]; char f5[(6 + particle_cloud_ledger_SubscribeRequest_size)]; char f0[45];};
#endif
#define particle_cloud_ServerMovedPermanentlyResponse_size 0

#ifdef __cplusplus
Expand Down
43 changes: 12 additions & 31 deletions proto_defs/src/cloud/ledger.pb.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,40 @@
#error Regenerate this file with the current version of nanopb generator.
#endif

PB_BIND(particle_cloud_LedgerRequest, particle_cloud_LedgerRequest, AUTO)
PB_BIND(particle_cloud_ledger_GetInfoRequest, particle_cloud_ledger_GetInfoRequest, AUTO)


PB_BIND(particle_cloud_LedgerRequest_ListLedgers, particle_cloud_LedgerRequest_ListLedgers, AUTO)
PB_BIND(particle_cloud_ledger_GetInfoResponse, particle_cloud_ledger_GetInfoResponse, AUTO)


PB_BIND(particle_cloud_LedgerRequest_GetPage, particle_cloud_LedgerRequest_GetPage, AUTO)
PB_BIND(particle_cloud_ledger_GetInfoResponse_Ledger, particle_cloud_ledger_GetInfoResponse_Ledger, AUTO)


PB_BIND(particle_cloud_LedgerRequest_SyncPage, particle_cloud_LedgerRequest_SyncPage, AUTO)
PB_BIND(particle_cloud_ledger_SetDataRequest, particle_cloud_ledger_SetDataRequest, AUTO)


PB_BIND(particle_cloud_LedgerRequest_Subscribe, particle_cloud_LedgerRequest_Subscribe, AUTO)
PB_BIND(particle_cloud_ledger_SetDataResponse, particle_cloud_ledger_SetDataResponse, AUTO)


PB_BIND(particle_cloud_LedgerRequest_Subscribe_LedgerPages, particle_cloud_LedgerRequest_Subscribe_LedgerPages, AUTO)
PB_BIND(particle_cloud_ledger_GetDataRequest, particle_cloud_ledger_GetDataRequest, AUTO)


PB_BIND(particle_cloud_LedgerRequest_Unsubscribe, particle_cloud_LedgerRequest_Unsubscribe, AUTO)
PB_BIND(particle_cloud_ledger_GetDataResponse, particle_cloud_ledger_GetDataResponse, AUTO)


PB_BIND(particle_cloud_LedgerRequest_Unsubscribe_LedgerPages, particle_cloud_LedgerRequest_Unsubscribe_LedgerPages, AUTO)
PB_BIND(particle_cloud_ledger_SubscribeRequest, particle_cloud_ledger_SubscribeRequest, AUTO)


PB_BIND(particle_cloud_LedgerRequest_NotifyPageChanged, particle_cloud_LedgerRequest_NotifyPageChanged, AUTO)
PB_BIND(particle_cloud_ledger_SubscribeResponse, particle_cloud_ledger_SubscribeResponse, AUTO)


PB_BIND(particle_cloud_LedgerRequest_NotifyPageChanged_LedgerPages, particle_cloud_LedgerRequest_NotifyPageChanged_LedgerPages, AUTO)
PB_BIND(particle_cloud_ledger_SubscribeResponse_Ledger, particle_cloud_ledger_SubscribeResponse_Ledger, AUTO)


PB_BIND(particle_cloud_LedgerResponse, particle_cloud_LedgerResponse, AUTO)
PB_BIND(particle_cloud_ledger_NotifyUpdateRequest, particle_cloud_ledger_NotifyUpdateRequest, AUTO)


PB_BIND(particle_cloud_LedgerResponse_ListLedgers, particle_cloud_LedgerResponse_ListLedgers, AUTO)


PB_BIND(particle_cloud_LedgerResponse_ListLedgers_Ledger, particle_cloud_LedgerResponse_ListLedgers_Ledger, AUTO)


PB_BIND(particle_cloud_LedgerResponse_GetPage, particle_cloud_LedgerResponse_GetPage, AUTO)


PB_BIND(particle_cloud_LedgerResponse_SyncPage, particle_cloud_LedgerResponse_SyncPage, AUTO)


PB_BIND(particle_cloud_LedgerResponse_Subscribe, particle_cloud_LedgerResponse_Subscribe, AUTO)


PB_BIND(particle_cloud_LedgerResponse_Unsubscribe, particle_cloud_LedgerResponse_Unsubscribe, AUTO)


PB_BIND(particle_cloud_LedgerResponse_NotifyPageChanged, particle_cloud_LedgerResponse_NotifyPageChanged, AUTO)

PB_BIND(particle_cloud_ledger_NotifyUpdateResponse, particle_cloud_ledger_NotifyUpdateResponse, AUTO)



Expand Down
Loading

0 comments on commit 12ec94a

Please sign in to comment.