refactor(devices): store hardware identity as hw_family / hw_revision
The firmware moved its NVS identity keys from hw_type / hw_version to
hw_family / hw_revision (NvsMigration.cpp), and the NVS generator, cloudflash
and the device models already used the new names. Firestore device docs and
the manufacturing code still wrote and read hw_type / hw_version, so the
device API's hw_family / hw_revision were always "" (0 of 14 docs had them)
and the console used two names for one value.
Device docs now use the firmware's names (schema v1.1.0, decision D2 in the
bellsystems-schema repo). The apps don't read these fields, so no app change.
- Manufacturing batch-create writes hw_family / hw_revision; the inventory
API exposes hw_family / hw_revision (filters: ?hw_family= / ?hw_families=).
Reads fall back to hw_type / hw_version so docs not yet migrated still work.
- devices/firestore_v1.py renames hw_type / hw_version on read and write and
rejects a hw_family that isn't a code (e.g. "Bell Plus"): when the console
generates NVS from it, the firmware builds its OTA URL from that value.
- Inventory, provisioning, onboarding and overview pages use the new names.
Unchanged on purpose: the firmware catalog and flash assets
(/api/firmware/{hw_type}/..., hw_type_override) — a separate store and the
URL devices call; same values, only the variable name differs. The public
cloudflash response keeps its hw_type field (public contract).
Data migration (rename + fix 3 display-label values) runs from the
bellsystems-schema repo AFTER this is deployed: the currently deployed
console still reads hw_type.
Verified: 118 backend tests pass; frontend builds; ESLint errors in
ProvisioningWizard.jsx (7) are pre-existing and unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -250,8 +250,8 @@ const TABLE_COLUMNS = [
|
||||
render: (d) => friendlyName(d) || <span style={{ color: 'var(--color-text-muted)' }}>—</span>,
|
||||
},
|
||||
{
|
||||
key: 'hw_type', label: 'Board Type', sortable: true,
|
||||
render: (d) => d.hw_type || <span style={{ color: 'var(--color-text-muted)' }}>—</span>,
|
||||
key: 'hw_family', label: 'Board Type', sortable: true,
|
||||
render: (d) => d.hw_family || <span style={{ color: 'var(--color-text-muted)' }}>—</span>,
|
||||
},
|
||||
{
|
||||
key: 'mfg_status', label: 'Status',
|
||||
@@ -301,14 +301,14 @@ function DevicePicker({ onSelect }) {
|
||||
}
|
||||
if (boardTypes.length > 0) {
|
||||
const boardTypeSet = new Set(boardTypes)
|
||||
list = list.filter((d) => boardTypeSet.has(d.hw_type))
|
||||
list = list.filter((d) => boardTypeSet.has(d.hw_family))
|
||||
}
|
||||
const q = search.trim().toLowerCase()
|
||||
if (q) {
|
||||
list = list.filter((d) => {
|
||||
if ((d.serial_number || '').toLowerCase().includes(q)) return true
|
||||
if ((friendlyName(d) || '').toLowerCase().includes(q)) return true
|
||||
if ((d.hw_type || '').toLowerCase().includes(q)) return true
|
||||
if ((d.hw_family || '').toLowerCase().includes(q)) return true
|
||||
if ((d.customer_name || '').toLowerCase().includes(q)) return true
|
||||
if ((d.users || []).some((u) => (u.display_name || '').toLowerCase().includes(q) || (u.email || '').toLowerCase().includes(q))) return true
|
||||
return false
|
||||
@@ -640,7 +640,7 @@ const PlanStep = forwardRef(function PlanStep({ device, onDeviceUpdated }, ref)
|
||||
const startIso = startDateStr ? `${startDateStr}T00:00:00Z` : new Date().toISOString()
|
||||
// PUT /devices/{id} returns the DeviceInDB shape, which doesn't line up
|
||||
// field-for-field with the DeviceInventoryItem shape the rest of the wizard
|
||||
// uses (e.g. hw_type vs hw_family) — merge in just the two fields Configure
|
||||
// uses — merge in just the two fields Configure
|
||||
// actually needs rather than replacing the whole device object.
|
||||
const updated = await api.put(`/devices/${device.id}`, {
|
||||
device_subscription: {
|
||||
@@ -1975,7 +1975,7 @@ function DeviceWorkspace({ device, onDeviceUpdated, onDone, onChangeDevice }) {
|
||||
return (
|
||||
<Card
|
||||
title={device.serial_number}
|
||||
subtitle={`${friendlyName(device) || device.hw_type || '—'} · ${device.mfg_status}`}
|
||||
subtitle={`${friendlyName(device) || device.hw_family || '—'} · ${device.mfg_status}`}
|
||||
action={<Button variant="ghost" size="sm" onClick={onChangeDevice}>Change Device</Button>}
|
||||
>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--space-6)' }}>
|
||||
|
||||
@@ -235,7 +235,7 @@ export default function OverviewTab({
|
||||
api.get('/crm/products').catch(() => null),
|
||||
]).then(([mfgItem, productsRes]) => {
|
||||
if (mfgItem?.revision) setHwRevision(mfgItem.revision)
|
||||
const hwType = mfgItem?.hw_type || ''
|
||||
const hwType = mfgItem?.hw_family || ''
|
||||
if (!hwType) return
|
||||
const products = productsRes?.products || []
|
||||
const norm = s => (s || '').toLowerCase().replace(/[^a-z0-9]/g, '')
|
||||
|
||||
@@ -154,7 +154,7 @@ export default function DeviceInventory() {
|
||||
const params = new URLSearchParams()
|
||||
if (search) params.set('search', search)
|
||||
if (statusFilter) params.set('status', statusFilter)
|
||||
if (typeFilter) params.set('hw_type', typeFilter)
|
||||
if (typeFilter) params.set('hw_family', typeFilter)
|
||||
params.set('limit', '500')
|
||||
const data = await api.get(`/manufacturing/devices${params.toString() ? `?${params}` : ''}`)
|
||||
const devs = data.devices || []
|
||||
@@ -198,8 +198,8 @@ export default function DeviceInventory() {
|
||||
if (!sortKey) return devices
|
||||
return [...devices].sort((a, b) => {
|
||||
let av, bv
|
||||
if (sortKey === 'type') { av = BOARD_TYPE_LABELS[a.hw_type] || a.hw_type || ''; bv = BOARD_TYPE_LABELS[b.hw_type] || b.hw_type || '' }
|
||||
else if (sortKey === 'version') { av = a.hw_version || ''; bv = b.hw_version || '' }
|
||||
if (sortKey === 'type') { av = BOARD_TYPE_LABELS[a.hw_family] || a.hw_family || ''; bv = BOARD_TYPE_LABELS[b.hw_family] || b.hw_family || '' }
|
||||
else if (sortKey === 'version') { av = a.hw_revision || ''; bv = b.hw_revision || '' }
|
||||
else if (sortKey === 'created') { av = a.created_at || ''; bv = b.created_at || '' }
|
||||
else if (sortKey === 'customer') {
|
||||
const ca = customerMap[a.customer_id]; const cb = customerMap[b.customer_id]
|
||||
@@ -268,7 +268,7 @@ export default function DeviceInventory() {
|
||||
sortable: true,
|
||||
render: (d) => (
|
||||
<span style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-secondary)' }}>
|
||||
{BOARD_TYPE_LABELS[d.hw_type] || d.hw_type}
|
||||
{BOARD_TYPE_LABELS[d.hw_family] || d.hw_family}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
@@ -278,7 +278,7 @@ export default function DeviceInventory() {
|
||||
sortable: true,
|
||||
render: (d) => (
|
||||
<span style={{ fontSize: 'var(--font-size-sm)', fontFamily: 'var(--font-family-mono)', color: 'var(--color-text-muted)' }}>
|
||||
{formatHwVersion(d.hw_version)}
|
||||
{formatHwVersion(d.hw_revision)}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -645,7 +645,7 @@ export default function DeviceInventoryDetail() {
|
||||
)
|
||||
}
|
||||
|
||||
const boardLabel = BOARD_TYPE_LABELS[device.hw_type] || device.hw_type
|
||||
const boardLabel = BOARD_TYPE_LABELS[device.hw_family] || device.hw_family
|
||||
const existingUserIds = deviceUsers.map((u) => u.user_id).filter(Boolean)
|
||||
|
||||
const editStepMeta = editModalData ? LIFECYCLE[editModalData.stepIndex] : null
|
||||
@@ -662,7 +662,7 @@ export default function DeviceInventoryDetail() {
|
||||
</StatusBadge>
|
||||
</span>
|
||||
}
|
||||
subtitle={`${device.name || device.device_name || '—'} · ${boardLabel} · ${formatHwVersion(device.hw_version)}`}
|
||||
subtitle={`${device.name || device.device_name || '—'} · ${boardLabel} · ${formatHwVersion(device.hw_revision)}`}
|
||||
>
|
||||
{canEdit && (
|
||||
<Button variant="secondary" size="md" onClick={() => navigate(`/manufacturing/provision?sn=${sn}`)}>
|
||||
@@ -687,7 +687,7 @@ export default function DeviceInventoryDetail() {
|
||||
<Field label="Serial Number" value={device.serial_number} mono />
|
||||
<Field label="Batch ID" value={device.batch_id || device.mfg_batch_id} mono />
|
||||
<Field label="Hardware Family" value={boardLabel} />
|
||||
<Field label="HW Version" value={formatHwVersion(device.hw_version)} mono />
|
||||
<Field label="HW Version" value={formatHwVersion(device.hw_revision)} mono />
|
||||
<Field label="Created At" value={formatDate(device.created_at)} />
|
||||
<Field label="Device Name" value={device.name || device.device_name} />
|
||||
<div style={{ gridColumn: '1 / -1' }}>
|
||||
|
||||
@@ -344,7 +344,7 @@ function BespokePickerModal({ open, onConfirm, onClose }) {
|
||||
Hardware Family for NVS
|
||||
</label>
|
||||
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', marginBottom: 'var(--space-2)' }}>
|
||||
Written to NVS as <span style={{ fontFamily: 'var(--font-family-mono)' }}>hw_type</span>.
|
||||
Written to NVS as <span style={{ fontFamily: 'var(--font-family-mono)' }}>hw_family</span>.
|
||||
</p>
|
||||
<input
|
||||
type="text"
|
||||
@@ -508,7 +508,7 @@ function StepSelectDevice({ mode, preloadSn, onSelected, onCreatedSn }) {
|
||||
|
||||
// ── Selected confirmation panel ──
|
||||
if (picked) {
|
||||
const boardInfo = BOARD_TYPE_MAP[picked.hw_type]
|
||||
const boardInfo = BOARD_TYPE_MAP[picked.hw_family]
|
||||
const pal = BOARD_FAMILY_COLORS[boardInfo?.family || 'vesper']
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--space-4)' }}>
|
||||
@@ -516,8 +516,8 @@ function StepSelectDevice({ mode, preloadSn, onSelected, onCreatedSn }) {
|
||||
<p style={{ fontSize: 'var(--font-size-xs)', fontWeight: 'var(--font-weight-semibold)', color: pal.selectedText, textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', marginBottom: 'var(--space-3)' }}>Device Selected</p>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'var(--space-3)' }}>
|
||||
<InfoCell label="Serial Number" value={picked.serial_number} mono />
|
||||
<InfoCell label="Board Type" value={BOARD_TYPE_LABELS[picked.hw_type] || picked.hw_type} />
|
||||
<InfoCell label="HW Revision" value={formatHwVersion(picked.hw_version)} />
|
||||
<InfoCell label="Board Type" value={BOARD_TYPE_LABELS[picked.hw_family] || picked.hw_family} />
|
||||
<InfoCell label="HW Revision" value={formatHwVersion(picked.hw_revision)} />
|
||||
<InfoCell label="Status" value={<StatusBadge variant={STATUS_VARIANT[picked.mfg_status] || 'neutral'}>{picked.mfg_status}</StatusBadge>} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -660,8 +660,8 @@ function StepSelectDevice({ mode, preloadSn, onSelected, onCreatedSn }) {
|
||||
onMouseLeave={(e) => { e.currentTarget.style.backgroundColor = '' }}
|
||||
>
|
||||
<td style={{ padding: 'var(--space-3)', fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{d.serial_number}</td>
|
||||
<td style={{ padding: 'var(--space-3)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-secondary)' }}>{BOARD_TYPE_LABELS[d.hw_type] || d.hw_type}</td>
|
||||
<td style={{ padding: 'var(--space-3)', fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-muted)' }}>{formatHwVersion(d.hw_version)}</td>
|
||||
<td style={{ padding: 'var(--space-3)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-secondary)' }}>{BOARD_TYPE_LABELS[d.hw_family] || d.hw_family}</td>
|
||||
<td style={{ padding: 'var(--space-3)', fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-sm)', color: 'var(--color-text-muted)' }}>{formatHwVersion(d.hw_revision)}</td>
|
||||
<td style={{ padding: 'var(--space-3)' }}>
|
||||
<StatusBadge variant={STATUS_VARIANT[d.mfg_status] || 'neutral'}>{d.mfg_status}</StatusBadge>
|
||||
</td>
|
||||
@@ -888,7 +888,7 @@ function StepFlash({ device, bespokeOverride, onFlashed, serialConn }) {
|
||||
|
||||
const webSerialAvailable = typeof navigator !== 'undefined' && 'serial' in navigator
|
||||
const busy = connecting || flashing
|
||||
const boardInfo = BOARD_TYPE_MAP[device.hw_type]
|
||||
const boardInfo = BOARD_TYPE_MAP[device.hw_family]
|
||||
|
||||
const familyPal = BOARD_FAMILY_COLORS[boardInfo?.family || 'vesper']
|
||||
const readyToFlash = portConnected && !flashing && !done && log.length === 0
|
||||
@@ -934,7 +934,7 @@ function StepFlash({ device, bespokeOverride, onFlashed, serialConn }) {
|
||||
{bespokeOverride ? (
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'var(--space-3)' }}>
|
||||
<InfoCell label="Serial Number" value={device.serial_number} mono />
|
||||
<InfoCell label="NVS hw_type" value={bespokeOverride.hwFamily} />
|
||||
<InfoCell label="NVS hw_family" value={bespokeOverride.hwFamily} />
|
||||
<InfoCell label="NVS hw_revision" value="1.0" />
|
||||
<div>
|
||||
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', fontWeight: 'var(--font-weight-semibold)', marginBottom: 'var(--space-1)' }}>Firmware</p>
|
||||
@@ -956,7 +956,7 @@ function StepFlash({ device, bespokeOverride, onFlashed, serialConn }) {
|
||||
Board Type:
|
||||
<span style={{ display: 'inline-block', width: 'var(--space-3)' }} />
|
||||
<span style={{ fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-md)', fontWeight: 'var(--font-weight-semibold)', color: 'var(--color-primary)' }}>
|
||||
{boardInfo?.uiName || boardInfo?.name || device.hw_type}
|
||||
{boardInfo?.uiName || boardInfo?.name || device.hw_family}
|
||||
</span>
|
||||
{boardInfo?.codename && (
|
||||
<span style={{ fontFamily: 'var(--font-family-mono)', color: 'var(--color-text-muted)', fontSize: 'var(--font-size-xs)', marginLeft: 'var(--space-2)' }}>| {boardInfo.codename}</span>
|
||||
@@ -967,7 +967,7 @@ function StepFlash({ device, bespokeOverride, onFlashed, serialConn }) {
|
||||
Revision:
|
||||
<span style={{ display: 'inline-block', width: 'var(--space-3)' }} />
|
||||
<span style={{ fontFamily: 'var(--font-family-mono)', fontSize: 'var(--font-size-md)', fontWeight: 'var(--font-weight-semibold)', color: 'var(--color-primary)' }}>
|
||||
{formatHwVersion(device.hw_version)}
|
||||
{formatHwVersion(device.hw_revision)}
|
||||
</span>
|
||||
</p>
|
||||
</>
|
||||
@@ -1453,11 +1453,11 @@ function StepDone({ device, onProvisionNext, serialConn }) {
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
|
||||
<div style={{ padding: 'var(--space-4)', borderRight: '1px solid var(--color-border)' }}>
|
||||
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', marginBottom: 'var(--space-1)' }}>Board Type</p>
|
||||
<p style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{BOARD_TYPE_LABELS[device?.hw_type] || device?.hw_type}</p>
|
||||
<p style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{BOARD_TYPE_LABELS[device?.hw_family] || device?.hw_family}</p>
|
||||
</div>
|
||||
<div style={{ padding: 'var(--space-4)', display: 'flex', flexDirection: 'column', alignItems: 'flex-end' }}>
|
||||
<p style={{ fontSize: 'var(--font-size-xs)', color: 'var(--color-text-muted)', textTransform: 'uppercase', letterSpacing: 'var(--tracking-wide)', marginBottom: 'var(--space-1)' }}>HW Version</p>
|
||||
<p style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{formatHwVersion(device?.hw_version)}</p>
|
||||
<p style={{ fontSize: 'var(--font-size-sm)', color: 'var(--color-text-primary)' }}>{formatHwVersion(device?.hw_revision)}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user