Skip to content

Commit 8501476

Browse files
API version 1.1
1 parent 16cb558 commit 8501476

File tree

3 files changed

+191
-122
lines changed

3 files changed

+191
-122
lines changed

Api.proto

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ syntax = "proto2";
33
package io.bluewavestudio.openautopro.api;
44

55
enum Constants {
6+
option allow_alias = true;
67
API_MAJOR_VERSION = 1;
7-
API_MINOR_VERSION = 0;
8+
API_MINOR_VERSION = 1;
89
}
910

1011
enum MessageType {
1112
MESSAGE_INVALID_ID = 0;
1213
MESSAGE_HELLO_REQUEST = 1; // Direction: Client -> OpenAuto Pro
1314
MESSAGE_HELLO_RESPONSE = 2; // Direction: Client <- OpenAuto Pro
1415
MESSAGE_SET_STATUS_SUBSCRIPTIONS = 3; // Direction: Client -> OpenAuto Pro
15-
MESSAGE_CHANGE_REAR_GEAR_STATUS = 4; // Direction: Client -> OpenAuto Pro
16+
MESSAGE_SET_REVERSE_GEAR_STATUS = 4; // Direction: Client -> OpenAuto Pro
1617
MESSAGE_PROJECTION_STATUS = 5; // Direction: Client <- OpenAuto Pro
1718
MESSAGE_MEDIA_STATUS = 6; // Direction: Client <- OpenAuto Pro
1819
MESSAGE_MEDIA_METADATA = 7; // Direction: Client <- OpenAuto Pro
@@ -121,7 +122,7 @@ message SetStatusSubscriptions {
121122
/*
122123
* Direction: Client -> OpenAuto Pro
123124
*/
124-
message ChangeRearGearStatus {
125+
message SetReverseGearStatus {
125126
required bool engaged = 1; // Status of the rear gear engagement
126127
}
127128

@@ -156,6 +157,7 @@ message MediaStatus {
156157
MEDIA_SOURCE_AUTOBOX = 2;
157158
MEDIA_SOURCE_A2DP = 3;
158159
MEDIA_SOURCE_STORAGE = 4;
160+
MEDIA_SOURCE_FM_RADIO = 5;
159161
}
160162

161163
required string position_label = 1; // Label of current track position (e. g. 03:19)

api_examples/python/ReverseGear.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#
2+
# Copyright (C) BlueWave Studio - All Rights Reserved
3+
#
4+
5+
import threading
6+
import common.Api_pb2 as oap_api
7+
from common.Client import Client, ClientEventHandler
8+
9+
10+
class EventHandler(ClientEventHandler):
11+
12+
def __init__(self):
13+
self._reverse_gear_engaged = False
14+
self._timer = None
15+
16+
def on_hello_response(self, client, message):
17+
print(
18+
"received hello response, result: {}, oap version: {}.{}, api version: {}.{}"
19+
.format(message.result, message.oap_version.major,
20+
message.oap_version.minor, message.api_version.major,
21+
message.api_version.minor))
22+
23+
self.toggle_reverse_gear_status(client)
24+
25+
def toggle_reverse_gear_status(self, client):
26+
self._reverse_gear_engaged = not self._reverse_gear_engaged
27+
28+
set_reverse_gear_status = oap_api.SetReverseGearStatus()
29+
set_reverse_gear_status.engaged = self._reverse_gear_engaged
30+
client.send(oap_api.MESSAGE_SET_REVERSE_GEAR_STATUS, 0,
31+
set_reverse_gear_status.SerializeToString())
32+
33+
self._timer = threading.Timer(15, self.toggle_reverse_gear_status,
34+
[client])
35+
self._timer.start()
36+
37+
def get_timer(self):
38+
return self._timer
39+
40+
41+
def main():
42+
client = Client("reverse gear status example")
43+
event_handler = EventHandler()
44+
client.set_event_handler(event_handler)
45+
client.connect('127.0.0.1', 44405)
46+
47+
active = True
48+
while active:
49+
try:
50+
active = client.wait_for_message()
51+
except KeyboardInterrupt:
52+
break
53+
54+
if event_handler.get_timer() is not None:
55+
event_handler.get_timer().cancel()
56+
57+
client.disconnect()
58+
59+
60+
if __name__ == "__main__":
61+
main()

0 commit comments

Comments
 (0)