Emanuel Kuflik
/
smat_controller
Diff: mqtt.h
- Revision:
- 4:64c6fc70ddb7
- Parent:
- 2:f10d6fecb345
- Child:
- 5:e0d8e5e922f1
diff -r 663c6fc11321 -r 64c6fc70ddb7 mqtt.h --- a/mqtt.h Fri Dec 06 18:29:12 2019 +0000 +++ b/mqtt.h Fri Dec 06 20:34:52 2019 +0000 @@ -24,6 +24,13 @@ drive_state_t state; // for debugging }position_msg_t; +typedef struct road_msg{ + int id; +}road_msg_t; + +typedef struct other_road{ + bool done; +}other_road_t; typedef struct control_msg{ int speed; @@ -42,6 +49,7 @@ // functions for creatin of mqtt and wifi bring up WiFiInterface* setup_wifi(); int send_position_msg(position_msg_t* msg); + int send_road_msg(position_msg_t* msg); void manage_network(); void bringup_network(); @@ -56,6 +64,9 @@ // queue for sending position msessages Queue<position_msg_t, 16> position_queue; + // queue for sending road msessages + Queue<road_msg_t, 1> road_queue; + // queue for control message passsing between mqtt and car threads Queue<control_msg_t, 1> control_queue[MAX_CARS_ON_ROAD]; @@ -90,6 +101,12 @@ position_queue.put(msg); } + // adding to road queue to be sent on mqtt network + inline void add_to_road_queue(road_msg_t* msg) + { + road_queue.put(msg); + } + // adding to a queue to be sent on mqtt network inline void add_to_control_queue(int car_id,control_msg_t* msg) { @@ -105,6 +122,18 @@ return message; } + inline bool get_road_msg(int curr_id) + { + int temp = curr_id; + while(temp == curr_id){ + osEvent evt = road_queue.get(); + assert(evt.status == osEventMessage); + road_msg_t *message = (road_msg_t*)evt.value.p; + temp = message->id; + } + return true; + } + };