diff --git a/connections/status.cc b/connections/status.cc index 976f455e..46216ab3 100644 --- a/connections/status.cc +++ b/connections/status.cc @@ -53,6 +53,12 @@ std::string Status::ToString() const { return "kWifiLanError"; case Status::kPayloadUnknown: return "kPayloadUnknown"; + case Status::kReset: + return "kReset"; + case Status::kTimeout: + return "kTimeout"; + case Status::kUnknown: + // fall through default: return "Unknown"; } diff --git a/connections/status.h b/connections/status.h index cc40005c..0c2c1fa0 100644 --- a/connections/status.h +++ b/connections/status.h @@ -22,7 +22,7 @@ namespace connections { // Protocol operation result: kSuccess, if operation was successful; // descriptive error code otherwise. -// LINT.IfChange +// LINT.IfChange(status_enum) struct Status { // Status is a struct, so it is possible to pass some context about failure, // by adding extra fields to it when necessary, and not change any of the @@ -44,6 +44,9 @@ struct Status { kBleError, kWifiLanError, kPayloadUnknown, + kReset, + kTimeout, + kUnknown, kNextValue, }; Value value{kError}; @@ -53,9 +56,9 @@ struct Status { std::string ToString() const; }; // LINT.ThenChange( -// //depot/google3/location/nearby/cpp/sharing/implementation/nearby_connections_manager.cc:24 -// //depot/google3/location/nearby/cpp/sharing/implementation/nearby_connections_types.h:46 -// //depot/google3/location/nearby/cpp/sharing/implementation/nearby_connections_types_test.cc +// ../sharing/nearby_connections_manager.cc:status_enum, +// ../sharing/nearby_connections_types.h:status_enum, +// ../sharing/nearby_connections_types_test.cc:status_enum // ) inline bool operator==(const Status& a, const Status& b) { diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCCoreAdapter.mm b/connections/swift/NearbyCoreAdapter/Sources/GNCCoreAdapter.mm index e4395758..ef72eded 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/GNCCoreAdapter.mm +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCCoreAdapter.mm @@ -87,6 +87,12 @@ GNCStatus GNCStatusFromCppStatus(Status status) { return GNCStatusWifiLanError; case Status::kPayloadUnknown: return GNCStatusPayloadUnknown; + case Status::kReset: + return GNCStatusReset; + case Status::kTimeout: + return GNCStatusTimeout; + case Status::kUnknown: + return GNCStatusUnknown; case Status::kNextValue: return GNCStatusUnknown; } diff --git a/connections/swift/NearbyCoreAdapter/Sources/GNCError.mm b/connections/swift/NearbyCoreAdapter/Sources/GNCError.mm index 36c6d43e..db10fee7 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/GNCError.mm +++ b/connections/swift/NearbyCoreAdapter/Sources/GNCError.mm @@ -65,6 +65,12 @@ NSError *NSErrorFromCppStatus(Status status) { return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorWifiLanError userInfo:nil]; case Status::kPayloadUnknown: return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorPayloadUnknown userInfo:nil]; + case Status::kReset: + return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorReset userInfo:nil]; + case Status::kTimeout: + return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorTimeout userInfo:nil]; + case Status::kUnknown: + return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorUnknown userInfo:nil]; case Status::kNextValue: return [NSError errorWithDomain:GNCErrorDomain code:GNCErrorUnknown userInfo:nil]; } diff --git a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionDelegate.h b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionDelegate.h index 85c6aed6..84d22a27 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionDelegate.h +++ b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCConnectionDelegate.h @@ -35,6 +35,8 @@ typedef NS_CLOSED_ENUM(NSInteger, GNCStatus) { GNCStatusWifiLanError, GNCStatusPayloadUnknown, GNCStatusUnknown, + GNCStatusReset, + GNCStatusTimeout, }; /** diff --git a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCError.h b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCError.h index 4242b676..76952324 100644 --- a/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCError.h +++ b/connections/swift/NearbyCoreAdapter/Sources/Public/NearbyCoreAdapter/GNCError.h @@ -38,4 +38,6 @@ typedef NS_ERROR_ENUM(GNCErrorDomain, GNCErrorCode){ GNCErrorBleError, GNCErrorWifiLanError, GNCErrorPayloadUnknown, + GNCErrorReset, + GNCErrorTimeout, } NS_SWIFT_NAME(NearbyError); diff --git a/proto/sharing_enums.proto b/proto/sharing_enums.proto index abb3478d..b27fb956 100644 --- a/proto/sharing_enums.proto +++ b/proto/sharing_enums.proto @@ -312,6 +312,61 @@ enum AttachmentTransmissionStatus { FAILED_NULL_CONNECTION_DISCONNECTED = 19; } +// Generic result status of NearbyConnections API calls. +enum ConnectionLayerStatus { + // No status is available + CONNECTION_LAYER_STATUS_UNKNOWN = 0; + // The operation was successful. + CONNECTION_LAYER_STATUS_SUCCESS = 1; + // The operation failed, without any more information. + CONNECTION_LAYER_STATUS_ERROR = 2; + // The app called an API method out of order (i.e. another method is expected + // to be called first). + CONNECTION_LAYER_STATUS_OUT_OF_ORDER_API_CALL = 3; + // The app already has active operations (advertising, discovering, or + // connected to other devices) with another Strategy. Stop these operations on + // the current Strategy before trying to advertise or discover with a new + // Strategy. + CONNECTION_LAYER_STATUS_ALREADY_HAVE_ACTIVE_STRATEGY = 4; + // The app is already advertising; call StopAdvertising() before trying to + // advertise again. + CONNECTION_LAYER_STATUS_ALREADY_ADVERTISING = 5; + // The app is already discovering; call StopDiscovery() before trying to + // discover again. + CONNECTION_LAYER_STATUS_ALREADY_DISCOVERING = 6; + // NC is already listening for incoming connections from remote endpoints. + CONNECTION_LAYER_STATUS_ALREADY_LISTENING = 7; + // An attempt to read from/write to a connected remote endpoint failed. If + // this occurs repeatedly, consider invoking DisconnectFromEndpoint(). + CONNECTION_LAYER_STATUS_END_POINT_IO_ERROR = 8; + // An attempt to interact with a remote endpoint failed because it's unknown + // to us -- it's either an endpoint that was never discovered, or an endpoint + // that never connected to us (both of which are indicative of bad input from + // the client app). + CONNECTION_LAYER_STATUS_END_POINT_UNKNOWN = 9; + // The remote endpoint rejected the connection request. + CONNECTION_LAYER_STATUS_CONNECTION_REJECTED = 10; + // The app is already connected to the specified endpoint. Multiple + // connections to a remote endpoint cannot be maintained simultaneously. + CONNECTION_LAYER_STATUS_ALREADY_CONNECTED_TO_END_POINT = 11; + // The remote endpoint is not connected; messages cannot be sent to it. + CONNECTION_LAYER_STATUS_NOT_CONNECTED_TO_END_POINT = 12; + // There was an error trying to use the device's Bluetooth capabilities. + CONNECTION_LAYER_STATUS_BLUETOOTH_ERROR = 13; + // There was an error trying to use the device's Bluetooth Low Energy + // capabilities. + CONNECTION_LAYER_STATUS_BLE_ERROR = 14; + // There was an error trying to use the device's Wi-Fi capabilities. + CONNECTION_LAYER_STATUS_WIFI_LAN_ERROR = 15; + // An attempt to interact with an in-flight Payload failed because it's + // unknown to us. + CONNECTION_LAYER_STATUS_PAYLOAD_UNKNOWN = 16; + // The connection was reset + CONNECTION_LAYER_STATUS_RESET = 17; + // The connection timed out + CONNECTION_LAYER_STATUS_TIMEOUT = 18; +} + // The status of processing attachments after receiver received payloads // successfully. enum ProcessReceivedAttachmentsStatus {