Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions backend/cmd/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ max_retries = 0 # Maximum retries before cycling (0 = infinite retr
connection_timeout_ms = 1000 # Connection timeout in milliseconds
keep_alive_ms = 1000 # Keep-alive interval in milliseconds

# BLCU (Boot Loader Control Unit) Configuration
[blcu]
ip = "127.0.0.1" # TFTP server IP address
download_order_id = 0 # Packet ID for download orders (0 = use default)
upload_order_id = 0 # Packet ID for upload orders (0 = use default)

# TFTP Configuration
[tftp]
block_size = 131072 # TFTP block size in bytes (128kB)
Expand Down
6 changes: 1 addition & 5 deletions backend/cmd/dev-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ timeout_ms = 5000 # Timeout for TFTP operations in milliseconds
backoff_factor = 2 # Backoff factor for retries
enable_progress = true # Enable progress updates during transfers

# BLCU Configuration
[blcu]
ip = "10.10.10.5" # BLCU IP address
download_order_id = 0 # Order ID for download operations (0 = use default)
upload_order_id = 0 # Order ID for upload operations (0 = use default)


# Logging Configuration
[logging]
Expand Down
3 changes: 1 addition & 2 deletions backend/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const (
TcpServer = "TCP_SERVER"
UDP = "UDP"
SNTP = "SNTP"
BlcuAck = "blcu_ack"
AddStateOrder = "add_state_order"
RemoveStateOrder = "remove_state_order"
)
Expand Down Expand Up @@ -62,7 +61,7 @@ func main() {
}

// <--- vehicle orders --->
vehicleOrders, err := vehicle_models.NewVehicleOrders(podData.Boards, adj.Info.Addresses[BLCU])
vehicleOrders, err := vehicle_models.NewVehicleOrders(podData.Boards)
if err != nil {
trace.Fatal().Err(err).Msg("creating vehicleOrders")
}
Expand Down
40 changes: 0 additions & 40 deletions backend/cmd/setup_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ import (
"github.com/HyperloopUPV-H8/h9-backend/internal/pod_data"
"github.com/HyperloopUPV-H8/h9-backend/internal/utils"
"github.com/HyperloopUPV-H8/h9-backend/pkg/abstraction"
"github.com/HyperloopUPV-H8/h9-backend/pkg/boards"
"github.com/HyperloopUPV-H8/h9-backend/pkg/transport"
"github.com/HyperloopUPV-H8/h9-backend/pkg/transport/network/tcp"
"github.com/HyperloopUPV-H8/h9-backend/pkg/transport/network/udp"
blcu_packet "github.com/HyperloopUPV-H8/h9-backend/pkg/transport/packet/blcu"
"github.com/HyperloopUPV-H8/h9-backend/pkg/transport/packet/data"
"github.com/HyperloopUPV-H8/h9-backend/pkg/transport/packet/order"
"github.com/HyperloopUPV-H8/h9-backend/pkg/transport/packet/protection"
Expand Down Expand Up @@ -45,11 +43,6 @@ func configureTransport(
transp.SetTargetIp(adj.Info.Addresses[board.Name], abstraction.TransportTarget(board.Name))
}

// If BLCU is configured set BLCU packet ID mappings
if common.Contains(config.Vehicle.Boards, "BLCU") {
configureBLCUTransport(adj, transp, config)
}

// Start handling TCP CLIENT connections
configureTCPClientTransport(adj, podData, transp, config)

Expand All @@ -61,36 +54,6 @@ func configureTransport(

}

// configureBLCUTransport sets the packet IDs and target IP for the BLCU board.
// It prefers values from config, falls back to ADJ and finally to a loopback default.
func configureBLCUTransport(adj adj_module.ADJ,
transp *transport.Transport,
config config.Config) {
// Use configurable packet IDs or defaults
downloadOrderID := config.Blcu.DownloadOrderId
uploadOrderID := config.Blcu.UploadOrderId
if downloadOrderID == 0 {
downloadOrderID = boards.DefaultBlcuDownloadOrderId
}
if uploadOrderID == 0 {
uploadOrderID = boards.DefaultBlcuUploadOrderId
}

transp.SetIdTarget(abstraction.PacketId(downloadOrderID), abstraction.TransportTarget("BLCU"))
transp.SetIdTarget(abstraction.PacketId(uploadOrderID), abstraction.TransportTarget("BLCU"))

// Use BLCU address from config, ADJ, or default
blcuIP := config.Blcu.IP
if blcuIP == "" {
if adjBlcuIP, exists := adj.Info.Addresses[BLCU]; exists {
blcuIP = adjBlcuIP
} else {
blcuIP = "127.0.0.1"
}
}
transp.SetTargetIp(blcuIP, abstraction.TransportTarget("BLCU"))
}

func configureTCPClientTransport(
adj adj_module.ADJ,
podData pod_data.PodData,
Expand Down Expand Up @@ -247,9 +210,6 @@ func getTransportDecEnc(info adj_module.Info, podData pod_data.PodData) (*presen
encoder.SetPacketEncoder(id, dataEncoder)
}

// Register BLCU ack decoder
decoder.SetPacketDecoder(abstraction.PacketId(info.MessageIds[BlcuAck]), blcu_packet.NewDecoder())

// TODO Solve this foking mess, I have tried...
stateOrdersDecoder := order.NewDecoder(binary.LittleEndian)
stateOrdersDecoder.SetActionId(abstraction.PacketId(info.MessageIds[AddStateOrder]), stateOrdersDecoder.DecodeAdd)
Expand Down
42 changes: 0 additions & 42 deletions backend/cmd/setup_vehicle.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import (
"github.com/HyperloopUPV-H8/h9-backend/internal/pod_data"
"github.com/HyperloopUPV-H8/h9-backend/internal/update_factory"
"github.com/HyperloopUPV-H8/h9-backend/pkg/abstraction"
"github.com/HyperloopUPV-H8/h9-backend/pkg/boards"
"github.com/HyperloopUPV-H8/h9-backend/pkg/broker"
blcu_topics "github.com/HyperloopUPV-H8/h9-backend/pkg/broker/topics/blcu"
connection_topic "github.com/HyperloopUPV-H8/h9-backend/pkg/broker/topics/connection"
data_topic "github.com/HyperloopUPV-H8/h9-backend/pkg/broker/topics/data"
logger_topic "github.com/HyperloopUPV-H8/h9-backend/pkg/broker/topics/logger"
Expand Down Expand Up @@ -75,7 +73,6 @@ func configureBroker(subloggers abstraction.SubloggersMap, loggerHandler *logger
})

broker.SetPool(pool)
blcu_topics.RegisterTopics(broker, pool)

return broker, cleanup
}
Expand All @@ -101,45 +98,6 @@ func configureVehicle(
vehicle.SetIdToBoardName(idToBoard)
vehicle.SetTransport(transp)

// Register BLCU board for handling bootloader operations
if blcuIP, exists := adj.Info.Addresses[BLCU]; exists {
blcuId, idExists := adj.Info.BoardIds["BLCU"]
if !idExists {
return fmt.Errorf("BLCU IP found in ADJ but board ID missing")
} else {
// Get configurable order IDs or use defaults
downloadOrderId := config.Blcu.DownloadOrderId
uploadOrderId := config.Blcu.UploadOrderId
if downloadOrderId == 0 {
downloadOrderId = boards.DefaultBlcuDownloadOrderId
}
if uploadOrderId == 0 {
uploadOrderId = boards.DefaultBlcuUploadOrderId
}

tftpConfig := boards.TFTPConfig{
BlockSize: config.TFTP.BlockSize,
Retries: config.TFTP.Retries,
TimeoutMs: config.TFTP.TimeoutMs,
BackoffFactor: config.TFTP.BackoffFactor,
EnableProgress: config.TFTP.EnableProgress,
}
blcuBoard := boards.NewWithConfig(blcuIP, tftpConfig, abstraction.BoardId(blcuId), downloadOrderId, uploadOrderId)
vehicle.AddBoard(blcuBoard)
vehicle.SetBlcuId(abstraction.BoardId(blcuId))

trace.
Info().
Str("ip", blcuIP).
Int("id", int(blcuId)).
Uint16("download_order_id", downloadOrderId).
Uint16("upload_order_id", uploadOrderId).
Msg("BLCU board registered")
}
} else {
trace.Warn().Msg("BLCU not found in ADJ configuration - bootloader operations unavailable")
}

return nil

}
Expand Down
7 changes: 0 additions & 7 deletions backend/internal/config/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ type TFTP struct {
EnableProgress bool `toml:"enable_progress"`
}

type Blcu struct {
IP string `toml:"ip"`
DownloadOrderId uint16 `toml:"download_order_id"`
UploadOrderId uint16 `toml:"upload_order_id"`
}

type TCP struct {
BackoffMinMs int `toml:"backoff_min_ms"`
BackoffMaxMs int `toml:"backoff_max_ms"`
Expand All @@ -54,6 +48,5 @@ type Config struct {
Transport Transport
TFTP TFTP
TCP TCP
Blcu Blcu
Logging Logging
}
2 changes: 1 addition & 1 deletion backend/internal/vehicle/models/order_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type StateOrderDescription struct {
Enabled bool `json:"enabled"`
}

func NewVehicleOrders(boards []pod_data.Board, blcuName string) (VehicleOrders, error) {
func NewVehicleOrders(boards []pod_data.Board) (VehicleOrders, error) {
vehicleOrders := VehicleOrders{
Boards: make([]BoardOrders, 0),
}
Expand Down
Loading
Loading