Revert "New payload type for gamestart"

This reverts commit 1743d8d58a.
This commit is contained in:
Midgard 2021-02-01 18:42:38 +01:00
parent 1743d8d58a
commit 1f14c8aecd
Signed by: midgard
GPG key ID: 511C112F1331BBB4
3 changed files with 4 additions and 38 deletions

View file

@ -51,7 +51,7 @@ Types for controller:
- 2 game start
[ X B B B B B B B ]
-------- - - -
time left ↓ ↓ #puzzle modules - 1
time left ↓ ↓ #puzzle modules
#strikes #max strikes
- 3 state (every x ms e.g. in the middle of each second)

View file

@ -42,8 +42,6 @@ uint8_t payload_type(uint8_t module_type, uint8_t module_id, uint8_t msg_type) {
return OBUS_PAYLDTYPE_EMPTY;
case OBUS_MSGTYPE_C_GAMESTART:
return OBUS_PAYLDTYPE_GAMESTART;
case OBUS_MSGTYPE_C_STATE:
case OBUS_MSGTYPE_C_SOLVED:
case OBUS_MSGTYPE_C_TIMEOUT:
@ -115,17 +113,6 @@ bool receive(struct message *msg) {
case OBUS_PAYLDTYPE_EMPTY:
break;
case OBUS_PAYLDTYPE_GAMESTART:
if (receive_frame.can_dlc < 8) {
Serial.println(F("W Received illegal gamestatus msg: payload <8"));
return false;
}
msg->gamestart.time_left = unpack_4b_into_u32(&(receive_frame.data[1]));
msg->gamestart.strikes = receive_frame.data[5];
msg->gamestart.max_strikes = receive_frame.data[6];
msg->gamestart.puzzle_modules_connected = 1 + (uint16_t) receive_frame.data[7];
break;
case OBUS_PAYLDTYPE_GAMESTATUS:
if (receive_frame.can_dlc < 8) {
Serial.println(F("W Received illegal gamestatus msg: payload <8"));
@ -196,13 +183,6 @@ void send(struct message *msg) {
case OBUS_PAYLDTYPE_EMPTY:
break;
case OBUS_PAYLDTYPE_GAMESTART:
pack_u32_into_4b(&(send_frame.data[1]), msg->gamestatus.time_left);
send_frame.data[5] = msg->gamestatus.strikes;
send_frame.data[6] = msg->gamestatus.max_strikes;
length = 7;
break;
case OBUS_PAYLDTYPE_GAMESTATUS:
pack_u32_into_4b(&(send_frame.data[1]), msg->gamestatus.time_left);
send_frame.data[5] = msg->gamestatus.strikes;

View file

@ -36,7 +36,6 @@
#define OBUS_PAYLDTYPE_COUNT 2
#define OBUS_PAYLDTYPE_INFO 3
#define OBUS_PAYLDTYPE_MODULEADDR 4
#define OBUS_PAYLDTYPE_GAMESTART 5
#define OBUS_PAYLD_INFO_MAXLEN (OBUS_MSG_LENGTH - 1)
@ -48,12 +47,6 @@ struct module {
};
struct payld_empty {};
struct payld_gamestart {
uint32_t time_left;
uint8_t strikes;
uint8_t max_strikes;
uint16_t puzzle_modules_connected; // uint16 because the range is 1 through 256 inclusive
};
struct payld_gamestatus {
uint32_t time_left;
uint8_t strikes;
@ -72,7 +65,6 @@ struct message {
uint8_t msg_type;
union {
struct payld_empty empty;
struct payld_gamestart gamestart;
struct payld_gamestatus gamestatus;
uint8_t count;
struct payld_infomessage infomessage;
@ -173,17 +165,11 @@ inline void send_c_hello(struct module from) {
* Send a controller "game start" OBUS message
*/
inline void send_c_gamestart(
struct module from, uint32_t time_left, uint8_t strikes, uint8_t max_strikes, uint16_t puzzle_modules_connected) {
struct module from, uint32_t time_left, uint8_t strikes, uint8_t max_strikes, uint8_t puzzle_modules_solved) {
assert(from.type == OBUS_TYPE_CONTROLLER);
assert(puzzle_modules_connected - 1 <= UINT8_MAX);
struct message msg = _msg(from, false, OBUS_MSGTYPE_C_GAMESTART);
msg.gamestart.time_left = time_left;
msg.gamestart.strikes = strikes;
msg.gamestart.max_strikes = max_strikes;
msg.gamestart.puzzle_modules_connected = (uint8_t) (puzzle_modules_connected - 1);
send(&msg);
_send_payld_gamestatus(
from, false, OBUS_MSGTYPE_C_GAMESTART, time_left, strikes, max_strikes, puzzle_modules_solved);
}
/**