updating the proto and adding a button on the device page to test the scan i2c command

This commit is contained in:
csawatzky 2025-06-19 11:32:21 -06:00
parent 10b9cb951d
commit 2c3ba2c1f5
5 changed files with 30 additions and 6 deletions

View file

@ -22,6 +22,7 @@ export interface IDeviceAPIContext {
otherTeam?: string
) => Promise<AxiosResponse<pond.GetDevicePageDataResponse>>;
getMulti: (ids: number[] | string[], otherTeam?: string) => Promise<AxiosResponse<pond.GetMultiDeviceResponse>>;
detectI2C: (id: number, otherTeam?: string) => Promise<AxiosResponse<pond.DetectI2CResponse>>;
getGeoJson: (id: number | string, demo?: boolean, otherTeam?: string) => Promise<any>;
getMultiGeoJson: (ids: number[] | string[], otherTeam?: string) => Promise<any>;
list: (
@ -946,6 +947,19 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
})
};
const detectI2C = (id: number, otherTeam?: string) => {
let url = "/devices/" + id + "/detectI2C";
const view = otherTeam ? otherTeam : as
if(view) url = url + "?as=" + view
return new Promise<AxiosResponse<pond.DetectI2CResponse>>((resolve, reject) => {
put<pond.DetectI2CResponse>(pondURL(url)).then(resp => {
return resolve(resp)
}).catch(err => {
return reject(err)
})
})
}
return (
<DeviceAPIContext.Provider
value={{
@ -991,7 +1005,8 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
getDataUsage,
buyData,
updateComponentPreferences,
listDeviceComponentPreferences
listDeviceComponentPreferences,
detectI2C
}}>
{children}
</DeviceAPIContext.Provider>