refactor: 重构项目 (#3)

This commit is contained in:
iAMD
2022-09-23 10:28:33 +08:00
committed by GitHub
parent 81a6f4528b
commit 9ec2449694
160 changed files with 16034 additions and 26183 deletions

View File

@ -1,135 +0,0 @@
syntax = "proto3";
package dev.yanshouwang.bluetooth_low_energy;
message Message {
MessageCategory category = 1;
oneof value {
BluetoothState state = 2;
StartDiscoveryArguments startDiscoveryArguments = 3;
Discovery discovery = 4;
ConnectArguments connectArguments = 5;
GattDisconnectArguments disconnectArguments = 6;
GattConnectionLost connectionLost = 7;
GattCharacteristicReadArguments characteristicReadArguments = 8;
GattCharacteristicWriteArguments characteristicWriteArguments = 9;
GattCharacteristicNotifyArguments characteristicNotifyArguments = 10;
GattCharacteristicValue characteristicValue = 11;
GattDescriptorReadArguments descriptorReadArguments = 12;
GattDescriptorWriteArguments descriptorWriteArguments = 13;
}
}
message StartDiscoveryArguments {
repeated string services = 1;
}
message Discovery {
string uuid = 1;
sint32 rssi = 2;
bytes advertisements = 3;
bool connectable = 4;
}
message ConnectArguments {
string uuid = 1;
}
message GATT {
string key = 1;
int32 maximumWriteLength = 2;
repeated GattService services = 3;
}
message GattService {
string key = 1;
string uuid = 2;
repeated GattCharacteristic characteristics = 3;
}
message GattCharacteristic {
string key = 1;
string uuid = 2;
bool canRead = 3;
bool canWrite = 4;
bool canWriteWithoutResponse = 5;
bool canNotify = 6;
repeated GattDescriptor descriptors = 7;
}
message GattDescriptor {
string key = 1;
string uuid = 2;
}
message GattDisconnectArguments{
string key = 1;
}
message GattConnectionLost {
string key = 1;
string error = 2;
}
message GattCharacteristicReadArguments {
string gatt_key = 1;
string service_key = 2;
string key = 3;
}
message GattCharacteristicWriteArguments {
string gatt_key = 1;
string service_key = 2;
string key = 3;
bytes value = 4;
bool withoutResponse = 5;
}
message GattCharacteristicNotifyArguments{
string gatt_key = 1;
string service_key = 2;
string key = 3;
bool state = 4;
}
message GattCharacteristicValue {
string gatt_key = 1;
string service_key = 2;
string key = 3;
bytes value = 4;
}
message GattDescriptorReadArguments {
string gatt_key = 1;
string service_key = 2;
string characteristic_key = 3;
string key = 4;
}
message GattDescriptorWriteArguments {
string gatt_key = 1;
string service_key = 2;
string characteristic_key = 3;
string key = 4;
bytes value = 5;
}
enum MessageCategory {
BLUETOOTH_STATE = 0;
CENTRAL_START_DISCOVERY = 1;
CENTRAL_STOP_DISCOVERY = 2;
CENTRAL_DISCOVERED = 3;
CENTRAL_CONNECT = 4;
GATT_DISCONNECT = 5;
GATT_CONNECTION_LOST = 6;
GATT_CHARACTERISTIC_READ = 7;
GATT_CHARACTERISTIC_WRITE = 8;
GATT_CHARACTERISTIC_NOTIFY = 9;
GATT_DESCRIPTOR_READ = 10;
GATT_DESCRIPTOR_WRITE = 11;
}
enum BluetoothState {
UNSUPPORTED = 0;
POWERED_OFF = 1;
POWERED_ON = 2;
}

61
proto/messages.proto Normal file
View File

@ -0,0 +1,61 @@
syntax = "proto3";
package proto;
option java_package = "dev.yanshouwang.bluetooth_low_energy.proto";
option java_multiple_files = true;
message Advertisement {
UUID uuid = 1;
int32 rssi = 2;
optional bool connectable = 3;
bytes data = 4;
optional string local_name = 5;
bytes manufacturer_specific_data = 6;
repeated ServiceData service_datas = 7;
repeated UUID service_uuids = 8;
repeated UUID solicited_service_uuids = 9;
optional int32 tx_power_level = 10;
}
message Peripheral {
int64 id = 1;
int32 maximum_write_length = 2;
}
message GattService {
int64 id = 1;
UUID uuid = 2;
}
message GattCharacteristic {
int64 id = 1;
UUID uuid = 2;
bool can_read = 3;
bool can_write = 4;
bool can_write_without_response = 5;
bool can_notify = 6;
}
message GattDescriptor {
int64 id = 1;
UUID uuid = 2;
}
enum BluetoothState {
BLUETOOTH_STATE_UNSUPPORTED = 0;
BLUETOOTH_STATE_POWERED_OFF = 1;
BLUETOOTH_STATE_POWERED_ON = 2;
}
message UUID {
string value = 1;
}
message ServiceData {
UUID uuid = 1;
bytes data = 2;
}
message BluetoothLowEnergyException {
string message = 1;
}