Skip to content

Commit 54a8119

Browse files
committed
fix: support BMC 2.0.x - 2.1.0 USB response format (fixes #21)
- Add "UsbA" to recognized USB-A route values in parseUSBStatus() - Add test cases for BMC 2.0.x response format with "Node X" strings and "UsbA" route values
1 parent 3577601 commit 54a8119

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.3.6] - 2026-01-18
11+
12+
### Fixed
13+
- **BMC 2.0.x - 2.1.0 Compatibility**: Fixed `turingpi_usb` data source to handle "UsbA" route value returned by BMC firmware 2.0.x through 2.1.0 (fixes #21)
14+
- Added "UsbA" to recognized USB-A route values
15+
- Added test coverage for BMC 2.0.x response format
16+
1017
## [1.3.5] - 2026-01-18
1118

1219
### Added

provider/resource_usb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func parseUSBStatus(status *usbStatusResponse) (mode string, node int, route str
314314
switch r {
315315
case "BMC", "bmc", "Bmc":
316316
route = "bmc"
317-
case "USB-A", "usb-a", "USB-2.0", "Usb-a":
317+
case "USB-A", "usb-a", "USB-2.0", "Usb-a", "UsbA":
318318
route = "usb-a"
319319
default:
320320
route = r

provider/resource_usb_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,58 @@ func TestParseUSBStatus(t *testing.T) {
205205
expectedNode: 1,
206206
expectedRoute: "usb-a",
207207
},
208+
// BMC 2.0.x format tests (result array with object values)
209+
{
210+
name: "bmc_2_0_x_format_device_node2",
211+
responseData: []map[string]interface{}{
212+
{
213+
"result": []interface{}{
214+
map[string]interface{}{
215+
"mode": "Device",
216+
"node": "Node 2",
217+
"route": "UsbA",
218+
},
219+
},
220+
},
221+
},
222+
expectedMode: "device",
223+
expectedNode: 2,
224+
expectedRoute: "usb-a",
225+
},
226+
{
227+
name: "bmc_2_0_x_format_host_node1",
228+
responseData: []map[string]interface{}{
229+
{
230+
"result": []interface{}{
231+
map[string]interface{}{
232+
"mode": "Host",
233+
"node": "Node 1",
234+
"route": "UsbA",
235+
},
236+
},
237+
},
238+
},
239+
expectedMode: "host",
240+
expectedNode: 1,
241+
expectedRoute: "usb-a",
242+
},
243+
{
244+
name: "bmc_2_0_x_format_bmc_route",
245+
responseData: []map[string]interface{}{
246+
{
247+
"result": []interface{}{
248+
map[string]interface{}{
249+
"mode": "Device",
250+
"node": "Node 3",
251+
"route": "BMC",
252+
},
253+
},
254+
},
255+
},
256+
expectedMode: "device",
257+
expectedNode: 3,
258+
expectedRoute: "bmc",
259+
},
208260
}
209261

210262
for _, tt := range tests {

0 commit comments

Comments
 (0)