1
package fantasia;
2
3
option java_package = "edu.cmu.ece549.fantasia";
4
option java_outer_classname = "AppPackets";
5
message Packet {
6
  enum PacketType {
7
		APP_START 		= 0; //no wand
8
		JOIN 					= 1; //no body
9
		PART 					= 2; //no body
10
		ACCEL_CONFIG 	= 3;
11
		BUTTON_CONFIG = 4; 
12
		IR_CONFIG 		= 5;
13
		RGB_CONFIG 		= 6;
14
		APP_CONFIG 		= 7;
15
		ACCEL_DATA 		= 8;
16
		BUTTON_PRESS 	= 9;
17
		APP_END				= 10; // no wand or body
18
	}
19
20
	message Wand {
21
		required uint64 addr = 1;
22
		optional string name = 2 [default = "Unknown"];
23
	}
24
25
  message AppStartBody {
26
		required uint32 uuid 				= 1;
27
		required uint32 max_players = 2;
28
		required uint32 button_id		= 3;
29
  }
30
31
  message AccelConfigBody {
32
		required AccelMode mode = 1 [default = NONE];
33
		required uint32 data = 2 [default = 0];
34
		enum AccelMode {
35
		  NONE = 0;
36
		  TIMER = 1;
37
		  POLL = 2;
38
		  THRESHOLD = 3;
39
		}
40
  }
41
42
  message ButtonConfigBody {
43
	 	required uint32 button_mask 	= 1 [default = 0];
44
		required ButtonMode mode 			= 2 [default = NONE];
45
		enum ButtonMode {
46
		  NONE = 0;
47
		  MOMENTARY_ON = 1;
48
		  MOMENTARY_OFF = 2;
49
		  SINGLE = 3;
50
		  MULTI = 4;
51
		  BLINK = 5;
52
		}
53
  }
54
55
  message IRConfigBody {
56
		required uint32 enable 	= 1 [default = 0];
57
  }
58
59
	message RGBConfigBody {
60
		required RGBColor enable 	= 1 [default = BLACK]; 
61
		enum RGBColor {
62
		  BLACK = 0;
63
		  RED = 1;
64
		  GREEN  = 2;
65
		  BLUE = 3;
66
		  CYAN = 4;
67
		  MAGENTA = 5;
68
		  YELLOW = 6;
69
		  WHITE  = 7;
70
		  ORANGE = 8;
71
		}
72
		required RGBMode mode 		= 2 [default = NONE];
73
		enum RGBMode {
74
		  NONE = 0;
75
		  STATIC = 1;
76
		  CYCLE = 2;
77
		  BUTTON = 3;
78
		  CYCLE_BUTTON = 4;
79
		}
80
  }
81
82
  message AppConfigBody {
83
		required AccelConfigBody 	accel_config 	= 1;
84
		required ButtonConfigBody button_config = 2;
85
		required IRConfigBody			ir_config 		= 3;
86
		required RGBConfigBody		rgb_config		= 4;
87
  }
88
 
89
	message AccelDataBody {
90
		required sint32 x 					= 2;
91
		required sint32 y 					= 3;
92
		required sint32 z 					= 4;
93
  }	
94
	
95
	message ButtonPressBody {
96
		required uint32 button_id		= 2;
97
  }
98
99
	//field definintions
100
	//At most one optional body message should be set
101
	//If set, it will correspond to the packet type
102
	//Wand will be set it accordance with packet type
103
  required PacketType 				type 								= 1;
104
	optional Wand 							wand 								= 2;
105
	optional AppStartBody 			app_start_body	 		= 3;
106
	optional AccelConfigBody 		accel_config_body 	= 4;
107
	optional ButtonConfigBody 	button_config_body	= 5;
108
	optional IRConfigBody 			ir_config_body 			= 6;
109
	optional RGBConfigBody 			rgb_config_body 		= 7;
110
	optional AppConfigBody 			app_config_body 		= 8;
111
	optional AccelDataBody 			accel_data_body 		= 9;
112
	optional ButtonPressBody 		button_press_body 	= 10;
113
}