Skip to content

Commit

Permalink
enable forwarding of alertmessages from app, to enable broadcasting t…
Browse files Browse the repository at this point in the history
…o CAN bus
  • Loading branch information
brentpicasso committed Jul 24, 2021
1 parent 3c296b3 commit 43beddc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
= 2.18.4 =
* Enable pit-to-car alert message CAN bus broadcast for app-based telemetry

= 2.18.2 =
* Predictive Timer: Fix time jumping at the end of a lap
* OBDII: match PID responses to the configured CAN mapping ID, to account for standard as well as extended mapping responses
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/alertmsg_can_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void alertmsg_can_send_message(const struct alertmessage *alertmsg)
}
msg.addressValue = address;
if (!CAN_tx_msg(ALERTMSG_CAN_BUS, &msg, DEFAULT_CAN_TIMEOUT)) {
pr_warning_str_msg(_LOG_PFX "Failed sending CAN alertmsg segment 1 ", message_text);
pr_warning_str_msg(_LOG_PFX "Failed sending CAN alertmsg segment 1: ", message_text);
}

/* Send the second 1/2 of the alert message */
Expand All @@ -66,6 +66,6 @@ void alertmsg_can_send_message(const struct alertmessage *alertmsg)
}
msg.addressValue = address + 1;
if (!CAN_tx_msg(ALERTMSG_CAN_BUS, &msg, DEFAULT_CAN_TIMEOUT)) {
pr_warning_str_msg(_LOG_PFX "Failed sending CAN alertmsg segment 2", message_text);
pr_warning_str_msg(_LOG_PFX "Failed sending CAN alertmsg segment 2: ", message_text);
}
}
11 changes: 8 additions & 3 deletions src/logger/loggerApi.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,20 @@ int api_alertmessage(struct Serial *serial, const jsmntok_t *json)
struct api_event event;
event.source=serial;
event.type = ApiEventType_Alertmessage;
bool forward_message = true;
jsmn_exists_set_val_string(json, "message", event.data.alertmsg.message, MAX_ALERTMESSAGE_LENGTH, true);
jsmn_exists_set_val_int(json, "id", &event.data.alertmsg.id);
jsmn_exists_set_val_int(json, "priority", &event.data.alertmsg.priority);

/* Broadcast to other connections */
api_event_process_callbacks(&event);
jsmn_exists_set_val_bool(json, "fwd", &forward_message);

/* Broadcast CAN message for alertmessage */
alertmsg_can_send_message(&event.data.alertmsg);

if (forward_message) {
/* Broadcast to other connections */
api_event_process_callbacks(&event);
}

return API_SUCCESS_NO_RETURN;
}

Expand Down

0 comments on commit 43beddc

Please sign in to comment.