Skip to content

Commit

Permalink
API version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bluewave-studio committed Mar 21, 2022
1 parent 16cb558 commit 8501476
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 122 deletions.
8 changes: 5 additions & 3 deletions Api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ syntax = "proto2";
package io.bluewavestudio.openautopro.api;

enum Constants {
option allow_alias = true;
API_MAJOR_VERSION = 1;
API_MINOR_VERSION = 0;
API_MINOR_VERSION = 1;
}

enum MessageType {
MESSAGE_INVALID_ID = 0;
MESSAGE_HELLO_REQUEST = 1; // Direction: Client -> OpenAuto Pro
MESSAGE_HELLO_RESPONSE = 2; // Direction: Client <- OpenAuto Pro
MESSAGE_SET_STATUS_SUBSCRIPTIONS = 3; // Direction: Client -> OpenAuto Pro
MESSAGE_CHANGE_REAR_GEAR_STATUS = 4; // Direction: Client -> OpenAuto Pro
MESSAGE_SET_REVERSE_GEAR_STATUS = 4; // Direction: Client -> OpenAuto Pro
MESSAGE_PROJECTION_STATUS = 5; // Direction: Client <- OpenAuto Pro
MESSAGE_MEDIA_STATUS = 6; // Direction: Client <- OpenAuto Pro
MESSAGE_MEDIA_METADATA = 7; // Direction: Client <- OpenAuto Pro
Expand Down Expand Up @@ -121,7 +122,7 @@ message SetStatusSubscriptions {
/*
* Direction: Client -> OpenAuto Pro
*/
message ChangeRearGearStatus {
message SetReverseGearStatus {
required bool engaged = 1; // Status of the rear gear engagement
}

Expand Down Expand Up @@ -156,6 +157,7 @@ message MediaStatus {
MEDIA_SOURCE_AUTOBOX = 2;
MEDIA_SOURCE_A2DP = 3;
MEDIA_SOURCE_STORAGE = 4;
MEDIA_SOURCE_FM_RADIO = 5;
}

required string position_label = 1; // Label of current track position (e. g. 03:19)
Expand Down
61 changes: 61 additions & 0 deletions api_examples/python/ReverseGear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# Copyright (C) BlueWave Studio - All Rights Reserved
#

import threading
import common.Api_pb2 as oap_api
from common.Client import Client, ClientEventHandler


class EventHandler(ClientEventHandler):

def __init__(self):
self._reverse_gear_engaged = False
self._timer = None

def on_hello_response(self, client, message):
print(
"received hello response, result: {}, oap version: {}.{}, api version: {}.{}"
.format(message.result, message.oap_version.major,
message.oap_version.minor, message.api_version.major,
message.api_version.minor))

self.toggle_reverse_gear_status(client)

def toggle_reverse_gear_status(self, client):
self._reverse_gear_engaged = not self._reverse_gear_engaged

set_reverse_gear_status = oap_api.SetReverseGearStatus()
set_reverse_gear_status.engaged = self._reverse_gear_engaged
client.send(oap_api.MESSAGE_SET_REVERSE_GEAR_STATUS, 0,
set_reverse_gear_status.SerializeToString())

self._timer = threading.Timer(15, self.toggle_reverse_gear_status,
[client])
self._timer.start()

def get_timer(self):
return self._timer


def main():
client = Client("reverse gear status example")
event_handler = EventHandler()
client.set_event_handler(event_handler)
client.connect('127.0.0.1', 44405)

active = True
while active:
try:
active = client.wait_for_message()
except KeyboardInterrupt:
break

if event_handler.get_timer() is not None:
event_handler.get_timer().cancel()

client.disconnect()


if __name__ == "__main__":
main()
Loading

0 comments on commit 8501476

Please sign in to comment.