@robdobsn/raftjs 1.5.0 → 1.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/react-native/RaftAttributeHandler.js +6 -1
  2. package/dist/react-native/RaftAttributeHandler.js.map +1 -1
  3. package/dist/react-native/RaftChannelBLE.native.js +1 -1
  4. package/dist/react-native/RaftChannelBLE.native.js.map +1 -1
  5. package/dist/react-native/RaftConnector.js +1 -1
  6. package/dist/react-native/RaftConnector.js.map +1 -1
  7. package/dist/react-native/RaftDeviceInfo.d.ts +3 -0
  8. package/dist/react-native/RaftDeviceManager.d.ts +12 -7
  9. package/dist/react-native/RaftDeviceManager.js +185 -41
  10. package/dist/react-native/RaftDeviceManager.js.map +1 -1
  11. package/dist/react-native/RaftDeviceMgrIF.d.ts +7 -3
  12. package/dist/react-native/RaftDeviceStates.d.ts +5 -1
  13. package/dist/react-native/RaftDeviceStates.js +2 -2
  14. package/dist/react-native/RaftDeviceStates.js.map +1 -1
  15. package/dist/react-native/RaftMsgHandler.d.ts +1 -1
  16. package/dist/react-native/RaftStruct.js +2 -1
  17. package/dist/react-native/RaftStruct.js.map +1 -1
  18. package/dist/react-native/RaftTypes.d.ts +9 -12
  19. package/dist/react-native/RaftTypes.js +5 -47
  20. package/dist/react-native/RaftTypes.js.map +1 -1
  21. package/dist/web/RaftAttributeHandler.js +6 -1
  22. package/dist/web/RaftAttributeHandler.js.map +1 -1
  23. package/dist/web/RaftConnector.js +1 -1
  24. package/dist/web/RaftConnector.js.map +1 -1
  25. package/dist/web/RaftDeviceInfo.d.ts +3 -0
  26. package/dist/web/RaftDeviceManager.d.ts +12 -7
  27. package/dist/web/RaftDeviceManager.js +185 -41
  28. package/dist/web/RaftDeviceManager.js.map +1 -1
  29. package/dist/web/RaftDeviceMgrIF.d.ts +7 -3
  30. package/dist/web/RaftDeviceStates.d.ts +5 -1
  31. package/dist/web/RaftDeviceStates.js +2 -2
  32. package/dist/web/RaftDeviceStates.js.map +1 -1
  33. package/dist/web/RaftMsgHandler.d.ts +1 -1
  34. package/dist/web/RaftStruct.js +2 -1
  35. package/dist/web/RaftStruct.js.map +1 -1
  36. package/dist/web/RaftTypes.d.ts +9 -12
  37. package/dist/web/RaftTypes.js +5 -47
  38. package/dist/web/RaftTypes.js.map +1 -1
  39. package/examples/dashboard/package.json +6 -3
  40. package/examples/dashboard/src/ConnManager.ts +5 -1
  41. package/examples/dashboard/src/DeviceActionsForm.tsx +49 -49
  42. package/examples/dashboard/src/DeviceLineChart.tsx +44 -20
  43. package/examples/dashboard/src/DevicePanel.tsx +33 -2
  44. package/examples/dashboard/src/DevicesPanel.tsx +5 -4
  45. package/examples/dashboard/src/LatencyTest.ts +130 -0
  46. package/examples/dashboard/src/LatencyTestPanel.tsx +92 -0
  47. package/examples/dashboard/src/Main.tsx +192 -76
  48. package/examples/dashboard/src/SettingsManager.ts +67 -0
  49. package/examples/dashboard/src/SettingsScreen.tsx +174 -0
  50. package/examples/dashboard/src/SystemTypeCog/CogStateInfo.ts +13 -8
  51. package/examples/dashboard/src/SystemTypeCog/SystemTypeCog.ts +9 -5
  52. package/examples/dashboard/src/SystemTypeGeneric/StateInfoGeneric.ts +12 -6
  53. package/examples/dashboard/src/SystemTypeGeneric/SystemTypeGeneric.ts +9 -5
  54. package/examples/dashboard/src/SystemTypeMarty/RICStateInfo.ts +23 -4
  55. package/examples/dashboard/src/SystemTypeMarty/RICSystemUtils.ts +1 -1
  56. package/examples/dashboard/src/SystemTypeMarty/SystemTypeMarty.ts +1 -1
  57. package/examples/dashboard/src/index.html +2 -2
  58. package/examples/dashboard/src/styles.css +14 -0
  59. package/package.json +5 -4
  60. package/src/RaftAttributeHandler.ts +7 -1
  61. package/src/RaftChannelBLE.native.ts +1 -1
  62. package/src/RaftConnector.ts +1 -1
  63. package/src/RaftDeviceInfo.ts +3 -0
  64. package/src/RaftDeviceManager.ts +220 -50
  65. package/src/RaftDeviceMgrIF.ts +9 -3
  66. package/src/RaftDeviceStates.ts +6 -2
  67. package/src/RaftStruct.ts +2 -1
  68. package/src/RaftTypes.ts +22 -30
@@ -16,10 +16,16 @@ export default interface RaftDeviceMgrIF {
16
16
  getDevicesState(): DevicesState;
17
17
  getDeviceState(deviceKey: string): DeviceState;
18
18
 
19
+ // Settings
20
+ setMaxDataPointsToStore(maxDataPointsToStore: number): void;
21
+
19
22
  // Callbacks
20
- onNewDevice(callback: (deviceKey: string, state: DeviceState) => void): void;
21
- onNewDeviceAttribute(callback: (deviceKey: string, attrState: DeviceAttributeState) => void): void;
22
- onNewAttributeData(callback: (deviceKey: string, attrState: DeviceAttributeState) => void): void;
23
+ addNewDeviceCallback(callback: (deviceKey: string, state: DeviceState) => void): void;
24
+ removeNewDeviceCallback(callback: (deviceKey: string, state: DeviceState) => void): void;
25
+ addNewAttributeCallback(callback: (deviceKey: string, attrState: DeviceAttributeState) => void): void;
26
+ removeNewAttributeCallback(callback: (deviceKey: string, attrState: DeviceAttributeState) => void): void;
27
+ addAttributeDataCallback(callback: (deviceKey: string, attrState: DeviceAttributeState) => void): void;
28
+ removeAttributeDataCallback(callback: (deviceKey: string, attrState: DeviceAttributeState) => void): void;
23
29
 
24
30
  // Send action to device
25
31
  sendAction(deviceKey: string, action: DeviceTypeAction, data: number[]): void;
@@ -51,6 +51,7 @@ export interface DeviceAttributeState {
51
51
  name: string;
52
52
  newAttribute: boolean;
53
53
  newData: boolean;
54
+ numNewValues: number;
54
55
  values: number[];
55
56
  units: string;
56
57
  range: number[];
@@ -76,6 +77,9 @@ export interface DeviceState {
76
77
  deviceIsNew: boolean;
77
78
  stateChanged: boolean;
78
79
  isOnline: boolean;
80
+ deviceAddress: string;
81
+ deviceType: string;
82
+ busName: string;
79
83
  }
80
84
 
81
85
  export class DevicesState {
@@ -83,6 +87,6 @@ export class DevicesState {
83
87
  }
84
88
 
85
89
  // Add the getDeviceKey method to generate a composite key
86
- export function getDeviceKey(busName: string, devAddr: string): string {
87
- return `${busName}_${devAddr}`;
90
+ export function getDeviceKey(busName: string, devAddr: string, devType: string): string {
91
+ return `${busName}_${devAddr}_${devType}`;
88
92
  }
package/src/RaftStruct.ts CHANGED
@@ -134,9 +134,10 @@ export function structPack(format: string, values: number[]): Uint8Array {
134
134
  let offset = 0;
135
135
  let littleEndian = false;
136
136
 
137
+ let valIdx = 0;
137
138
  for (let i = 0; i < format.length; i++) {
138
139
  const char = format[i];
139
- const value = values[i];
140
+ const value = values[valIdx];
140
141
  switch (char) {
141
142
  case "<":
142
143
  littleEndian = true;
package/src/RaftTypes.ts CHANGED
@@ -32,7 +32,7 @@ export type RaftEventFn = (
32
32
  eventType: string,
33
33
  eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent,
34
34
  eventName: string,
35
- data?: object | string | null,
35
+ data?: object | string | null
36
36
  ) => void;
37
37
 
38
38
  export interface RaftSubscription {
@@ -59,30 +59,22 @@ export class RaftSystemInfo {
59
59
  Friendly? = "";
60
60
  }
61
61
 
62
- export class RaftCalibInfo {
63
- rslt = '';
64
- calDone = 0;
65
- validMs? = 0;
62
+ export type RaftCalibInfo = {
63
+ rslt: string;
64
+ calDone: number;
65
+ validMs? : number;
66
66
  }
67
67
 
68
+ // NOTE: Do not put any methods in any of the response classes as they
69
+ // are simply wrappers around JSON and will not necessarily be constructed
70
+ // as objects
68
71
  export class RaftOKFail {
69
- RAFT_OK = 'ok';
70
- set(rsltFlag: boolean) {
71
- if (rsltFlag) {
72
- this.rslt = this.RAFT_OK;
73
- } else {
74
- this.rslt = 'fail';
75
- }
76
- }
77
- rslt = 'commsFail';
78
- isOk() {
79
- return this.rslt === this.RAFT_OK;
80
- }
72
+ rslt = 'failComms';
81
73
  }
82
74
 
83
- export class RaftReportMsg {
75
+ export type RaftReportMsg = {
84
76
  msgType?: string;
85
- rslt = '';
77
+ rslt: string;
86
78
  timeReceived?: number;
87
79
  hexRd?: string;
88
80
  elemName?: string;
@@ -92,19 +84,19 @@ export class RaftReportMsg {
92
84
  msgBody?: string;
93
85
  }
94
86
 
95
- export class RaftHWFWStat {
96
- s = '';
97
- m = '';
98
- v = '';
99
- n = '';
100
- p = 0;
101
- i = 0;
87
+ export type RaftHWFWStat = {
88
+ s: string;
89
+ m: string;
90
+ v: string;
91
+ n: string;
92
+ p: number;
93
+ i: number;
102
94
  }
103
95
 
104
- export class RaftHWFWUpdRslt {
105
- req = '';
106
- rslt = 'commsFail';
107
- st: RaftHWFWStat = new RaftHWFWStat();
96
+ export type RaftHWFWUpdRslt = {
97
+ req: string;
98
+ rslt: string;
99
+ st: RaftHWFWStat;
108
100
  }
109
101
 
110
102
  export type RaftFWInfo = {