1"use strict";(self.webpackChunkbuttplug_io_docusaurus=self.webpackChunkbuttplug_io_docusaurus||[]).push([["11715"],{8139(e,n,s){s.r(n),s.d(n,{metadata:()=>r,default:()=>h,frontMatter:()=>o,contentTitle:()=>t,toc:()=>a,assets:()=>c});var r=JSON.parse('{"id":"spec/sensors","title":"Generic Sensor Messages","description":"Messages for requesting and receiving information about generic","source":"@site/versioned_docs/version-spec-v3/spec/sensors.md","sourceDirName":"spec","slug":"/spec/sensors","permalink":"/docs/spec-v3/spec/sensors","draft":false,"unlisted":false,"tags":[],"version":"spec-v3","frontMatter":{},"sidebar":"specSidebar","previous":{"title":"Generic Device Messages","permalink":"/docs/spec-v3/spec/generic"},"next":{"title":"Raw Device Messages","permalink":"/docs/spec-v3/spec/raw"}}'),i=s(74848),d=s(28453);let o={},t="Generic Sensor Messages",c={},a=[{value:"SensorReadCmd",id:"sensorreadcmd",level:2},{value:"SensorReading",id:"sensorreading",level:2},{value:"SensorSubscribeCmd",id:"sensorsubscribecmd",level:2},{value:"SensorUnsubscribeCmd",id:"sensorunsubscribecmd",level:2}];function l(e){let n={code:"code",em:"em",h1:"h1",h2:"h2",header:"header",hr:"hr",li:"li",mermaid:"mermaid",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,d.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"generic-sensor-messages",children:"Generic Sensor Messages"})}),"\n",(0,i.jsx)(n.p,{children:"Messages for requesting and receiving information about generic\nsensors on devices, including batteries, radio levels, accelerometers,\nbuttons, etc."}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h2,{id:"sensorreadcmd",children:"SensorReadCmd"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Description:"})," Client request to have a device return the current value for a sensor"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Introduced In Spec Version:"})," 3"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Last Updated In Spec Version:"})," 3"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Fields:"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"Id"})," (unsigned int): Message Id"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"DeviceIndex"})," (unsigned int): Index of device to read data from."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"SensorIndex"})," (unsigned int): Index of sensor on device to read data from (index relates to\nposition of sensor in SensorReadCmd message attributes)."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"SensorType"})," (string): Type of sensor, used as confirmation of context, must match value in\nSensorReadCmd message attributes."]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Expected Response:"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"SensorReading message with matching Id on successful request."}),"\n",(0,i.jsx)(n.li,{children:"Error message on value or message error."}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Flow Diagram:"})}),"\n",(0,i.jsx)(n.mermaid,{value:"sequenceDiagram\n Client->>+Server: SensorReadCmd Id=1\n Server->>-Client: SensorReading Id=1"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Serialization Example:"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'[\n {\n "SensorReadCmd": {\n "Id": 1,\n "DeviceIndex": 0,\n "SensorIndex": 0,\n "SensorType": "Pressure"\n }\n }\n]\n'})}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h2,{id:"sensorreading",children:"SensorReading"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Description:"})," Server response when data is read (in response to SensorReadCmd) or received (after\nSensorSubscribe) from a device sensor."]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Introduced In Spec Version:"})," 3"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Last Updated In Spec Version:"})," 3"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Fields:"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"Id"})," (unsigned int): Message Id"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"DeviceIndex"})," (unsigned int): Index of device to read data from."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"SensorIndex"})," (unsigned int): Index of sensor on device that data was read from (index relates to\nposition of sensor in SensorReadCmd message attributes)."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"SensorType"})," (string): Type of sensor."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"Data"})," (array of signed int): Array of signed integers representing data. Signed integers are used\ndue to varying return values (for instance, RSSI is negative, battery is [0, 100], buttons are [0,\n1], etc...). Information on formatting/units of measurement/etc may be included in feature\ndescriptors."]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Serialization Example:"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'[\n {\n "SensorReading": {\n "Id": 1,\n "DeviceIndex": 0,\n "SensorIndex": 0,\n "SensorType": "Pressure",\n "Data": [591]\n }\n }\n]\n'})}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h2,{id:"sensorsubscribecmd",children:"SensorSubscribeCmd"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Description:"})," Client request to have the server subscribe and send all data that comes in from a\ndevice sensor that is not explicitly read. Usually useful for Bluetooth notify endpoints, or other\nstreaming data endpoints."]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.em,{children:"Note:"})," Only the Subscribe command will show up in the MessageAttributes portion of DeviceAdded or DeviceList. It is assumed that if Subscribe can happen, Unsubscribe can also happen, so the information is not duplicated. Having the Subscribe command in the MessageAttributes implies that Unsubscribe will also work."]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Introduced In Spec Version:"})," 3"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Last Updated In Spec Version:"})," 3"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Fields:"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"Id"})," (unsigned int): Message Id"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"DeviceIndex"})," (unsigned int): Index of device to read data from."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"SensorIndex"})," (unsigned int): Index of sensor on device to read data from (index relates to\nposition of sensor in SensorReadCmd message attributes)."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"SensorType"})," (string): Type of sensor, used as confirmation of context, must match value in\nSensorReadCmd message attributes."]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Expected Response:"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Ok if subscription is successful, followed by SensorReading messages on all new readings."}),"\n",(0,i.jsx)(n.li,{children:"Error message on value or message error."}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Flow Diagram:"})}),"\n",(0,i.jsx)(n.mermaid,{value:"sequenceDiagram\n Client->>+Server: SensorSubscribeCmd Id=1\n Server->>-Client: Ok Id=1\n Server->>+Client: SensorReading Id=0\n Server->>+Client: SensorReading Id=0"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Serialization Example:"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'[\n {\n "SensorSubscribeCmd": {\n "Id": 1,\n "DeviceIndex": 0,\n "SensorIndex": 0,\n "SensorType": "Pressure"\n }\n }\n]\n'})}),"\n",(0,i.jsx)(n.hr,{}),"\n",(0,i.jsx)(n.h2,{id:"sensorunsubscribecmd",children:"SensorUnsubscribeCmd"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Description:"})," Client request to have the server unsubscribe from a device sensor to which it had\npreviously subscribed."]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.em,{children:"Note:"})," Only the Subscribe command will show up in the MessageAttributes portion of DeviceAdded or DeviceList. It is assumed that if Subscribe can happen, Unsubscribe can also happen, so the information is not duplicated. Having the Subscribe command in the MessageAttributes implies that Unsubscribe will also work."]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Introduced In Spec Version:"})," 3"]}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:"Last Updated In Spec Version:"})," 3"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Fields:"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"Id"})," (unsigned int): Message Id"]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"DeviceIndex"})," (unsigned int): Index of device to read data from."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"SensorIndex"})," (unsigned int): Index of sensor on device to read data from (index relates to\nposition of sensor in SensorReadCmd message attributes)."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.em,{children:"SensorType"})," (string): Type of sensor, used as confirmation of context, must match value in\nSensorReadCmd message attributes."]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Expected Response:"})}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Ok if unsubscription is successful."}),"\n",(0,i.jsx)(n.li,{children:"Error message on value or message error."}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Flow Diagram:"})}),"\n",(0,i.jsx)(n.mermaid,{value:"sequenceDiagram\n Client->>+Server: SensorUnsubscribeCmd Id=1\n Server->>-Client: Ok Id=1"}),"\n",(0,i.jsx)(n.p,{children:(0,i.jsx)(n.strong,{children:"Serialization Example:"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'[\n {\n "SensorUnsubscribeCmd": {\n "Id": 1,\n "DeviceIndex": 0,\n "SensorIndex": 0,\n "SensorType": "Pressure"\n }\n }\n]\n'})})]})}function h(e={}){let{wrapper:n}={...(0,d.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(l,{...e})}):l(e)}},28453(e,n,s){s.d(n,{R:()=>o,x:()=>t});var r=s(96540);let i={},d=r.createContext(i);function o(e){let n=r.useContext(d);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function t(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:o(e.components),r.createElement(d.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.