Skip to content

Commit

Permalink
working integration with parameter server
Browse files Browse the repository at this point in the history
  • Loading branch information
RCMast3r committed May 18, 2024
1 parent 096a4dc commit bc78530
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/InterfaceParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace EthParams
const uint16_t default_protobuf_recv_port = 20000;

const IPAddress default_netmask(255, 255, 255, 0);
const IPAddress default_gateway(192, 168, 0, 1);
const IPAddress default_gateway(192, 168, 1, 1);

const uint16_t default_buffer_size = 1024;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/interfaces/include/ProtobufMsgInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ bool handle_ethernet_socket_send_pb(qn::EthernetUDP* socket, const pb_struct& ms
pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
if (!pb_encode(&stream, msg_desc, &msg)) {
// You can handle error more explicitly by looking at stream.errmsg
Serial.println("error couldnt encode");
return false;
}
auto message_length = stream.bytes_written;
socket->write(buffer, message_length);
socket->endPacket();

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ lib_deps =
SPI
Nanopb
https://github.com/ssilverman/QNEthernet#v0.27.0
https://github.com/hytech-racing/HT_params/releases/download/2024-05-16T15_35_16/ht_eth_pb_lib.tar.gz
https://github.com/hytech-racing/HT_params/releases/download/2024-05-18T02_37_57/ht_eth_pb_lib.tar.gz
https://github.com/hytech-racing/shared_firmware_interfaces.git
https://github.com/hytech-racing/shared_firmware_systems.git
https://github.com/RCMast3r/spi_libs
Expand Down
12 changes: 8 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ void setup()
init_all_CAN_devices();

qn::Ethernet.begin(EthParams::default_MCU_ip, EthParams::default_netmask, EthParams::default_gateway);
qn::Ethernet.setDHCPEnabled(false);
protobuf_send_socket.begin(EthParams::default_protobuf_send_port);
protobuf_recv_socket.begin(EthParams::default_protobuf_recv_port);

Expand Down Expand Up @@ -531,14 +532,17 @@ void handle_ethernet_interface_comms()
// TODO un fuck this and make it more sane

handle_ethernet_socket_receive(&protobuf_recv_socket, &recv_pb_stream_union_msg, ethernet_interfaces);

// this is just kinda here i know.

if (param_interface.params_need_sending())
{
// Serial.println("handling ethernet");/
// Serial.println("handling ethernet");
auto config = param_interface.get_config();
if (!handle_ethernet_socket_send_pb(&protobuf_send_socket, config, config_fields))
HT_ETH_Union union_response = HT_ETH_Union_init_zero;
union_response.which_type_union = HT_ETH_Union_config__tag;
union_response.type_union.config_ = config;
if (!handle_ethernet_socket_send_pb(&protobuf_send_socket, union_response, HT_ETH_Union_fields))
{
Serial.println("yo shit happened");
// TODO this means that something bad has happend
}
param_interface.reset_params_need_sending();
Expand Down

0 comments on commit bc78530

Please sign in to comment.