knowledge_base:programming:protobuf

Google Protocol Buffers for Python3

  1. Download protobuf binary and follow readme.txt - https://github.com/protocolbuffers/protobuf/releases/tag/v3.6.1 (protoc-3.6.1-linux-x86_64.zip)
  2. Install setuptools (sudo apt-get install python3-setuptools)
  3. Download and install protobuf compiler - https://github.com/protocolbuffers/protobuf/releases/tag/v3.6.1 (protobuf-python-3.6.1.zip), (sudo python3 setup.py install) setup.py is located in the python folder
  1. Get btsnoop_hci.log by turning on Android developer option
  2. Use wireshark to extract RFCOMM payload
  3. Rip protobuf from payload binary by ripping transport header (See AMA protocol spec for transport header details). I wrote a little python3 program called rippproto.py to do that
  4. Parsing protobuf message. I wrote a little python3 program called listctl.py to do that
  1. xclip requires x-server. VcXsrv (open source) or Xming (donation based) are two possible choices. VcXsrv is what I use.
  2. subprocess package can run xclip (or any shell command) in Python3 and redirect input/output
thomwang@SJC-5CG7193RWZ:~/AMA_ProtoFiles$ ./onestep.py -x 100006085a4a020803
Version: 1
Stream Id: 0 - control stream
Payload Bytes: 6
command: GETFIRMWAREINFORMATION
response {
  error_code: UNSUPPORTED
}

thomwang@SJC-5CG7193RWZ:~/AMA_ProtoFiles$ ./onestep.py -x 10003c08144a381a360a113037373036315a38313431313036334145120c426f736520514333352049491a03000102220e413259303451504643414e4c5051
Version: 1
Stream Id: 0 - control stream
Payload Bytes: 60
command: GET_DEVICE_INFORMATION
response {
  device_information {
    serial_number: "077061Z81411063AE"
    name: "Bose QC35 II"
    supported_transports: BLUETOOTH_LOW_ENERGY
    supported_transports: BLUETOOTH_RFCOMM
    supported_transports: BLUETOOTH_IAP
    device_type: "A2Y04QPFCANLPQ"
  }
}

thomwang@SJC-5CG7193RWZ:~/AMA_ProtoFiles$ ./onestep.py -x 10000608154a025200
Version: 1
Stream Id: 0 - control stream
Payload Bytes: 6
command: GET_DEVICE_CONFIGURATION
response {
  device_configuration {
  }
}

thomwang@SJC-5CG7193RWZ:~/AMA_ProtoFiles$ ./onestep.py -x 10000608324a020803
Version: 1
Stream Id: 0 - control stream
Payload Bytes: 6
command: SYNCHRONIZE_SETTINGS
response {
  error_code: UNSUPPORTED
}
  • Last modified: 2022/12/02 15:58
  • by George Wayne