added button to send down the onewire scan request
This commit is contained in:
parent
33eb4e6eca
commit
c5a3487db0
8 changed files with 89 additions and 11 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -42,7 +42,7 @@
|
||||||
"mui-tel-input": "^7.0.0",
|
"mui-tel-input": "^7.0.0",
|
||||||
"notistack": "^3.0.1",
|
"notistack": "^3.0.1",
|
||||||
"openweathermap-ts": "^1.2.10",
|
"openweathermap-ts": "^1.2.10",
|
||||||
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#i2c_detect",
|
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#onewire_detect",
|
||||||
"query-string": "^9.2.1",
|
"query-string": "^9.2.1",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-beautiful-dnd": "^13.1.1",
|
"react-beautiful-dnd": "^13.1.1",
|
||||||
|
|
@ -10953,7 +10953,7 @@
|
||||||
},
|
},
|
||||||
"node_modules/protobuf-ts": {
|
"node_modules/protobuf-ts": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#0d0084ce207218ea5c8c94addfbf009814c35a1f",
|
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#aab2a77a75ca78e22d69d4a44e1c900bbac41bcf",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"protobufjs": "^6.8.8"
|
"protobufjs": "^6.8.8"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
"mui-tel-input": "^7.0.0",
|
"mui-tel-input": "^7.0.0",
|
||||||
"notistack": "^3.0.1",
|
"notistack": "^3.0.1",
|
||||||
"openweathermap-ts": "^1.2.10",
|
"openweathermap-ts": "^1.2.10",
|
||||||
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#i2c_detect",
|
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#onewire_detect",
|
||||||
"query-string": "^9.2.1",
|
"query-string": "^9.2.1",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-beautiful-dnd": "^13.1.1",
|
"react-beautiful-dnd": "^13.1.1",
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,28 @@ export default function DeviceWizard(props: Props) {
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
|
{selectedPort &&
|
||||||
|
// selectedPort.addressType === quack.AddressType.ADDRESS_TYPE_CONFIGURABLE_PIN_ARRAY &&
|
||||||
|
// device.featureSupported("detectOneWire") &&
|
||||||
|
selectedPort.autoDetectable && (
|
||||||
|
<Tooltip title="Used to tell the Device to scan this port for any plugged in sensors">
|
||||||
|
<MenuItem
|
||||||
|
key={"scanOneWire"}
|
||||||
|
disabled={scanInProgress || buttonClicked}
|
||||||
|
onClick={() => {
|
||||||
|
setButtonClicked(true)
|
||||||
|
console.log(selectedPort)
|
||||||
|
deviceAPI.detectOneWire(device.id(), selectedPort.address)
|
||||||
|
.then(resp => {
|
||||||
|
openSnack("Device will scan port on next check-in")
|
||||||
|
}).catch(err => {
|
||||||
|
openSnack("Command failed to send to device")
|
||||||
|
})
|
||||||
|
}}>
|
||||||
|
Scan Port
|
||||||
|
</MenuItem>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
{portComponents.length > 0 && (
|
{portComponents.length > 0 && (
|
||||||
<List>
|
<List>
|
||||||
<ListSubheader>Current Components</ListSubheader>
|
<ListSubheader>Current Components</ListSubheader>
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ export default function DeviceScannedComponents(props: Props){
|
||||||
const compAPI = useComponentAPI();
|
const compAPI = useComponentAPI();
|
||||||
const deviceAPI = useDeviceAPI()
|
const deviceAPI = useDeviceAPI()
|
||||||
const [scannedI2C, setScannedI2C] = useState<pond.DetectI2C>() //the unmodified scan of addresses
|
const [scannedI2C, setScannedI2C] = useState<pond.DetectI2C>() //the unmodified scan of addresses
|
||||||
const [validCompAddresses, setValidComponentAddresses] = useState<quack.AddressData[]>([]) //the filtered array of address data
|
const [scannedOneWire, setScannedOneWire] = useState<pond.DetectOneWire[]>([])
|
||||||
|
const [validI2CCompAddresses, setValidI2CComponentAddresses] = useState<quack.AddressData[]>([]) //the filtered array of address data
|
||||||
const [components, setComponents] = useState<Component[]>([])
|
const [components, setComponents] = useState<Component[]>([])
|
||||||
const [steps, setSteps] = useState<CompStep[]>([]);
|
const [steps, setSteps] = useState<CompStep[]>([]);
|
||||||
const { error, success } = useSnackbar();
|
const { error, success } = useSnackbar();
|
||||||
|
|
@ -40,8 +41,8 @@ export default function DeviceScannedComponents(props: Props){
|
||||||
const [openDialog, setOpenDialog] = useState(false);
|
const [openDialog, setOpenDialog] = useState(false);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
//console.log(scannedComponents)
|
|
||||||
if (scannedComponents.i2c) setScannedI2C(scannedComponents.i2c)
|
if (scannedComponents.i2c) setScannedI2C(scannedComponents.i2c)
|
||||||
|
if (scannedComponents.oneWire) setScannedOneWire(scannedComponents.oneWire)
|
||||||
//makes the array empty for testing
|
//makes the array empty for testing
|
||||||
// if (scannedComponents.i2c) {
|
// if (scannedComponents.i2c) {
|
||||||
// let clone = cloneDeep(scannedComponents.i2c)
|
// let clone = cloneDeep(scannedComponents.i2c)
|
||||||
|
|
@ -76,7 +77,7 @@ export default function DeviceScannedComponents(props: Props){
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
setValidComponentAddresses(valid)
|
setValidI2CComponentAddresses(valid)
|
||||||
},[scannedI2C])
|
},[scannedI2C])
|
||||||
|
|
||||||
const stepper = () => {
|
const stepper = () => {
|
||||||
|
|
@ -225,7 +226,7 @@ export default function DeviceScannedComponents(props: Props){
|
||||||
</Typography>
|
</Typography>
|
||||||
<Button variant="contained" color="primary" onClick={()=>{removeScan(scannedI2C.key)}}>Clear Scan</Button>
|
<Button variant="contained" color="primary" onClick={()=>{removeScan(scannedI2C.key)}}>Clear Scan</Button>
|
||||||
</Box>
|
</Box>
|
||||||
{validCompAddresses.length > 0 ? validCompAddresses.map((addr, index) => {
|
{validI2CCompAddresses.length > 0 ? validI2CCompAddresses.map((addr, index) => {
|
||||||
return (
|
return (
|
||||||
<ScannedI2C key={index} sensorNum={index+1} addressData={addr} deviceProduct={device.settings.product} componentSelectionCallback={componentSelection} availablePositions={availablePositions.get(quack.AddressType.ADDRESS_TYPE_I2C) ?? new Map<quack.ComponentType, number[]>()}/>
|
<ScannedI2C key={index} sensorNum={index+1} addressData={addr} deviceProduct={device.settings.product} componentSelectionCallback={componentSelection} availablePositions={availablePositions.get(quack.AddressType.ADDRESS_TYPE_I2C) ?? new Map<quack.ComponentType, number[]>()}/>
|
||||||
)
|
)
|
||||||
|
|
@ -242,6 +243,23 @@ export default function DeviceScannedComponents(props: Props){
|
||||||
}
|
}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
}
|
}
|
||||||
|
{scannedOneWire.length > 0 &&
|
||||||
|
<Box marginTop={10}>
|
||||||
|
<Box justifyContent="space-between" display="flex">
|
||||||
|
<Typography sx={{fontWeight: 650}}>
|
||||||
|
Pin Port Sensors
|
||||||
|
</Typography>
|
||||||
|
<Button variant="contained" color="primary" onClick={()=>{}}>Clear Scan</Button>
|
||||||
|
</Box>
|
||||||
|
{scannedOneWire.map(scan => {
|
||||||
|
return(
|
||||||
|
<Box>
|
||||||
|
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
}
|
||||||
<Box display="flex" flexDirection="row-reverse" marginTop={2}>
|
<Box display="flex" flexDirection="row-reverse" marginTop={2}>
|
||||||
<Button disabled={components.length === 0} variant="contained" color="primary" onClick={()=>{setOpenDialog(true)}}>Add Components</Button>
|
<Button disabled={components.length === 0} variant="contained" color="primary" onClick={()=>{setOpenDialog(true)}}>Add Components</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
7
src/device/autoDetect/ScannedOneWirePort.tsx
Normal file
7
src/device/autoDetect/ScannedOneWirePort.tsx
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import React from "react"
|
||||||
|
|
||||||
|
export default function ScannedOneWirePort(){
|
||||||
|
return (
|
||||||
|
<React.Fragment></React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -48,6 +48,21 @@ const featureVersions: Map<string, FeatureVersionByPlatform> = new Map([
|
||||||
v2CellBlue: "2.1.7",
|
v2CellBlue: "2.1.7",
|
||||||
v2EthBlue: "2.1.7"
|
v2EthBlue: "2.1.7"
|
||||||
}
|
}
|
||||||
|
],[
|
||||||
|
"detectOneWire",
|
||||||
|
{
|
||||||
|
photon: "N/A",
|
||||||
|
electron: "N/A",
|
||||||
|
v2Wifi: "N/A",
|
||||||
|
v2Cell: "N/A",
|
||||||
|
v2WifiS3: "N/A",
|
||||||
|
v2CellS3: "N/A",
|
||||||
|
v2CellBlack: "2.1.8",
|
||||||
|
v2CellGreen: "N/A",
|
||||||
|
v2WifiBlue: "2.1.8",
|
||||||
|
v2CellBlue: "2.1.8",
|
||||||
|
v2EthBlue: "2.1.8"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
export class Device {
|
export class Device {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Button, Card, Divider, List, ListItem, Typography } from "@mui/material";
|
import { Box, Button, Card, Divider, List, ListItem, Typography } from "@mui/material";
|
||||||
import Grid from '@mui/material/Grid2';
|
import Grid from '@mui/material/Grid2';
|
||||||
import { Component, Device, Interaction, User } from "models";
|
import { Component, Device, Interaction, User } from "models";
|
||||||
import { getContextKeys, getContextTypes } from "pbHelpers/Context";
|
import { getContextKeys, getContextTypes } from "pbHelpers/Context";
|
||||||
|
|
@ -169,7 +169,8 @@ export default function DevicePage() {
|
||||||
const loadPortScan = () => {
|
const loadPortScan = () => {
|
||||||
deviceAPI.listFoundComponents(parseInt(deviceID))
|
deviceAPI.listFoundComponents(parseInt(deviceID))
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
if (resp.data.foundComponents?.i2c){
|
console.log(resp.data)
|
||||||
|
if (resp.data.foundComponents){
|
||||||
setScannedAddresses(resp.data.foundComponents ?? undefined)
|
setScannedAddresses(resp.data.foundComponents ?? undefined)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -430,8 +431,8 @@ export default function DevicePage() {
|
||||||
refreshCallback={loadDevice}
|
refreshCallback={loadDevice}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
{scannedAddresses &&
|
{(scannedAddresses?.i2c || scannedAddresses?.oneWire) &&
|
||||||
<Grid size={{ xs: 6, sm: 6, lg: 4, xl: 4 }}>
|
<Grid size={{ xs: 6, sm: 6, lg: 8, xl: 8 }}>
|
||||||
<DeviceScannedComponents
|
<DeviceScannedComponents
|
||||||
scannedComponents={scannedAddresses}
|
scannedComponents={scannedAddresses}
|
||||||
device={device}
|
device={device}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ export interface IDeviceAPIContext {
|
||||||
) => Promise<AxiosResponse<pond.GetDevicePageDataResponse>>;
|
) => Promise<AxiosResponse<pond.GetDevicePageDataResponse>>;
|
||||||
getMulti: (ids: number[] | string[], otherTeam?: string) => Promise<AxiosResponse<pond.GetMultiDeviceResponse>>;
|
getMulti: (ids: number[] | string[], otherTeam?: string) => Promise<AxiosResponse<pond.GetMultiDeviceResponse>>;
|
||||||
detectI2C: (id: number, otherTeam?: string) => Promise<AxiosResponse<pond.DetectI2CResponse>>;
|
detectI2C: (id: number, otherTeam?: string) => Promise<AxiosResponse<pond.DetectI2CResponse>>;
|
||||||
|
detectOneWire: (id: number, port: number, otherTeam?: string) => Promise<AxiosResponse<pond.DetectOneWireResponse>>
|
||||||
listFoundComponents: (id: number, otherTeam?: string) => Promise<AxiosResponse<pond.ListFoundComponentsResponse>>
|
listFoundComponents: (id: number, otherTeam?: string) => Promise<AxiosResponse<pond.ListFoundComponentsResponse>>
|
||||||
getGeoJson: (id: number | string, demo?: boolean, otherTeam?: string) => Promise<any>;
|
getGeoJson: (id: number | string, demo?: boolean, otherTeam?: string) => Promise<any>;
|
||||||
getMultiGeoJson: (ids: number[] | string[], otherTeam?: string) => Promise<any>;
|
getMultiGeoJson: (ids: number[] | string[], otherTeam?: string) => Promise<any>;
|
||||||
|
|
@ -962,6 +963,19 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const detectOneWire = (id: number, port: number, otherTeam?: string) => {
|
||||||
|
let url = "/devices/" + id + "/detectOneWire?port=" + port;
|
||||||
|
const view = otherTeam ? otherTeam : as
|
||||||
|
if(view) url = url + "?as=" + view
|
||||||
|
return new Promise<AxiosResponse<pond.DetectOneWireResponse>>((resolve, reject) => {
|
||||||
|
put<pond.DetectOneWireResponse>(pondURL(url)).then(resp => {
|
||||||
|
return resolve(resp)
|
||||||
|
}).catch(err => {
|
||||||
|
return reject(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const listFoundComponents = (id: number, otherTeam?: string) => {
|
const listFoundComponents = (id: number, otherTeam?: string) => {
|
||||||
let url = "/devices/" + id + "/listScannedComponents";
|
let url = "/devices/" + id + "/listScannedComponents";
|
||||||
const view = otherTeam ? otherTeam : as
|
const view = otherTeam ? otherTeam : as
|
||||||
|
|
@ -1035,6 +1049,7 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
||||||
updateComponentPreferences,
|
updateComponentPreferences,
|
||||||
listDeviceComponentPreferences,
|
listDeviceComponentPreferences,
|
||||||
detectI2C,
|
detectI2C,
|
||||||
|
detectOneWire,
|
||||||
listFoundComponents,
|
listFoundComponents,
|
||||||
removeFoundComponents
|
removeFoundComponents
|
||||||
}}>
|
}}>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue