-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRequestCommand.java
More file actions
141 lines (129 loc) · 4.42 KB
/
RequestCommand.java
File metadata and controls
141 lines (129 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*******************************************************************************
* Copyright (C) 2012 Sven Nobis
*
* This file is part of AndroidRCCar (http://androidrccar.sven.to)
*
* AndroidRCCar is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this source code; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************/
package to.sven.androidrccar.host.accessorycommunication.model;
import to.sven.androidrccar.common.communication.model.AdjustSpeedMessage;
import to.sven.androidrccar.common.communication.model.TurnCarMessage;
/**
* This enumeration contains all commands that can be send to the µController (Car).
*
* It contains a command type id and the length of the payload in bytes.
*
* @author sven
*
*/
public enum RequestCommand {
/**
* No Operation Command
*
* Expected response: {@link ResponseMessage#REQUEST_OK}
*
* This command may not changed in newer protocol versions!
*/
NOOP ((byte)0x01, (short)0),
/**
* Tells the µController to send the protocol version.
*
* Expected response: {@link ResponseMessage#PROTOCOL_VERSION}
*
* This command may not changed in newer protocol versions!
*/
GET_PROTOCOL_VERSION ((byte)0x02, (short)0),
/**
* Tells the µController to send the features of the car.
*
* Expected response: {@link ResponseMessage#FEATURES}
*
* Note: Call this command only if protocol versions match!
*/
GET_FEATURES ((byte)0x03, (short)0),
/**
* Tells the µController to "turn the wheels" of the car.
*
* Payload:
* rotation as {@link Short}: {@link Short#MAX_VALUE} for maximum rotation to the right,
* {@link Short#MIN_VALUE} for maximum rotation to the left,
* 0 for no rotation.
* Expected response: {@link ResponseMessage#REQUEST_OK}
*
* Note: Call this command only if protocol versions match!
*
* @see TurnCarMessage#rotation
*/
TURN_CAR ((byte)0x04, (short)2),
/**
* Tells the µController to adjust the speed of the car.
*
* Payload:
* speed as {@link Short}: {@link Short#MAX_VALUE} for maximum forward speed,
* {@link Short#MIN_VALUE} for maximum backward speed (if supported),
* 0 is stop.
* Expected response: {@link ResponseMessage#REQUEST_OK}
*
* Note: Call this command only if protocol versions match!
*
* @see AdjustSpeedMessage#speed
* @see CarFeatures#driveBackward
*/
ADJUST_SPEED ((byte)0x05, (short)2),
/**
* Tells the µController to rotate the camera.
*
* Payload:
* pan as {@link Short}: (if supported, else 0)
* {@link Short#MAX_VALUE} for maximum pan to the right
* {@link Short#MIN_VALUE} for maximum pan to the left
* 0 no rotation/looking forward
* tilt as {@link Short}: same as pan for tilt up (+) and down (-).
* Expected response: {@link ResponseMessage#REQUEST_OK}
*
* Note: Call this command only if protocol versions match
* and camera pan and tilt is supported.
*
* @see CarFeatures#supportPanCamera()
* @see CarFeatures#supportTiltCamera()
*/
ROTATE_CAM ((byte)0x06, (short)(2+2)),
/**
* Tells the µController to send the battery state.
*
* Expected response: {@link ResponseMessage#BATTERY_STATE}
*
* Note: Call this command only if protocol versions match
* and battery state is supported.
*/
GET_BATTERY_STATE ((byte)0x07, (short)0);
/**
* Unique identifier for the message type.
*/
public final byte messageId;
/**
* Length of the additional data in bytes.
*/
public final short payloadLength;
/**
* Default constructor
* @param commandTypeId Unique identifier for the command type.
* @param payloadLength Length of the additional data in bytes.
*/
RequestCommand(byte commandTypeId, short payloadLength) {
this.messageId = commandTypeId;
this.payloadLength = payloadLength;
}
}