CubeSensorChar
Hierarchy
↳ CubeSensorChar
Implements
Index
Constructors
Properties
Methods
- addEventListener
- getMagnetSatus
- getPosture
- getShakeLevel
- isFlat
- prepare
- readValue
- setFrameRate
- writeValue
- writeValueCore
Constructors
constructor
+ new CubeSensorChar(service
: BluetoothRemoteGATTService): CubeSensorChar
Inherited from CubeChar.constructor
Defined in cube/char/char.ts:19
Parameters:
Name | Type |
---|---|
service | BluetoothRemoteGATTService |
Returns: CubeSensorChar
Properties
Protected
characteristic
• characteristic: BluetoothRemoteGATTCharacteristic
Inherited from CubeChar.characteristic
Defined in cube/char/char.ts:10
Protected
errStrInProgress
• errStrInProgress: string = "GATT operation already in progress."
Inherited from CubeChar.errStrInProgress
Defined in cube/char/char.ts:12
Readonly
uuid
• uuid: string = "10b20106-5b3b-4571-9508-cf3efcd7bbae"
Defined in cube/char/sensorChar.ts:24
Static
magnetId
▪ magnetId: object = { noMagnet: 'noMagnet', pattern1: 'pattern1', pattern2: 'pattern2', pattern3: 'pattern3', pattern4: 'pattern4', pattern5: 'pattern5', pattern6: 'pattern6', } as const
Defined in cube/char/sensorChar.ts:58
Magnet IDs.
Type declaration:
noMagnet: "noMagnet" = "noMagnet"
pattern1: "pattern1" = "pattern1"
pattern2: "pattern2" = "pattern2"
pattern3: "pattern3" = "pattern3"
pattern4: "pattern4" = "pattern4"
pattern5: "pattern5" = "pattern5"
pattern6: "pattern6" = "pattern6"
Static
postureId
▪ postureId: object = { top: 'top', bottom: 'bottom', back: 'back', front: 'front', right: 'right', left: 'left', } as const
Defined in cube/char/sensorChar.ts:29
Posture IDs.
Type declaration:
back: "back" = "back"
bottom: "bottom" = "bottom"
front: "front" = "front"
left: "left" = "left"
right: "right" = "right"
top: "top" = "top"
Static
shakeLevelId
▪ shakeLevelId: object = { noDetection: 0x00, level1: 0x01, level2: 0x02, level3: 0x03, level4: 0x04, level5: 0x05, level6: 0x06, level7: 0x07, level8: 0x08, level9: 0x09, level10: 0x0a, } as const
Defined in cube/char/sensorChar.ts:41
Shake level IDs.
Type declaration:
level1: 1 = 1
level10: 10 = 10
level2: 2 = 2
level3: 3 = 3
level4: 4 = 4
level5: 5 = 5
level6: 6 = 6
level7: 7 = 7
level8: 8 = 8
level9: 9 = 9
noDetection: 0 = 0
Methods
addEventListener
▸ addEventListener(type
: string, listener
: CubeSensorCharListner): void
Defined in cube/char/sensorChar.ts:264
Register callback.
Parameters:
Name | Type | Description |
---|---|---|
type | string | Specify the type from 'flat', 'collision', 'doubletap', 'magnet' or 'posture'. |
listener | CubeSensorCharListner | - |
Returns: void
getMagnetSatus
▸ getMagnetSatus(): string
Defined in cube/char/sensorChar.ts:149
Get current magnet status.
Returns: string
string id of magnet status.
getPosture
▸ getPosture(): string
Defined in cube/char/sensorChar.ts:131
Get current posture.
Returns: string
string id of posture.
getShakeLevel
▸ getShakeLevel(): number
Defined in cube/char/sensorChar.ts:140
Get current shake level.
Returns: number
id of shake level.
isFlat
▸ isFlat(): boolean
Defined in cube/char/sensorChar.ts:122
Get current flat status.
Returns: boolean
is flat or not.
prepare
▸ prepare(): Promise‹string | Error›
Implementation of CubeCharIF
Defined in cube/char/sensorChar.ts:87
Prepare for using sensor characteristic function.
Returns: Promise‹string | Error›
Promise. resolve
handler says that methods are available in this class.
readValue
▸ readValue(): Promise‹DataView›
Implementation of CubeCharIF
Inherited from CubeChar.readValue
Defined in cube/char/char.ts:110
Read value from remote GATT Characteristics.
Returns: Promise‹DataView›
Promise. resolve
handler include data.
setFrameRate
▸ setFrameRate(fps
: number): void
Implementation of CubeCharIF
Inherited from CubeChar.setFrameRate
Defined in cube/char/char.ts:134
Set framerate.
Parameters:
Name | Type |
---|---|
fps | number |
Returns: void
writeValue
▸ writeValue(buf
: ArrayBuffer): Promise‹string | Error›
Implementation of CubeCharIF
Inherited from CubeChar.writeValue
Defined in cube/char/char.ts:55
Write value to remote GATT Characteristics.
Parameters:
Name | Type | Description |
---|---|---|
buf | ArrayBuffer | data buffer including command for Cube. |
Returns: Promise‹string | Error›
Promise. resolve
handler says that write command executed correctly.
writeValueCore
▸ writeValueCore(buf
: ArrayBuffer, countRetry
: number): Promise‹string | Error›
Inherited from CubeChar.writeValueCore
Defined in cube/char/char.ts:78
Write value to remote GATT Characteristics. Core function.
Parameters:
Name | Type | Description |
---|---|---|
buf | ArrayBuffer | data buffer including command for Cube. |
countRetry | number | Counter for retry. |
Returns: Promise‹string | Error›
Promise. resolve
handler says that write command executed correctly.