@cutos/core 0.0.11 → 0.0.13

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.
package/dist/cutos.cjs.js CHANGED
@@ -359,6 +359,7 @@ const CORE = Object.freeze({ // core level api
359
359
  CONFIG: 'core-config',
360
360
  BOX_INFO: 'core-box-info',
361
361
  SIGN_INFO: 'core-sign-info',
362
+ DEVICE_INFO: 'core-device-info',
362
363
  SIGN_GROUP_INFO: 'core-sign-group-info',
363
364
  SHELL: 'core-shell',
364
365
  DATABASE: 'core-database',
@@ -383,8 +384,7 @@ const DEVICE = Object.freeze({ // core level api
383
384
  NFC: 'device-nfc',
384
385
  FINGERPRINT: 'device-fingerprint',
385
386
  QR_CODE_SCANNER: 'device-qr-code-scanner',
386
- PRINTER: 'device-printer',
387
- REFRIGERATOR: 'device-fridge'
387
+ PRINTER: 'device-printer'
388
388
  });
389
389
 
390
390
  const HEARTBEAT_STATUS = Object.freeze({
@@ -411,7 +411,7 @@ if(typeof window !== 'undefined') {
411
411
  var utils = config$1;
412
412
 
413
413
  var name = "@cutos/core";
414
- var version = "0.0.11";
414
+ var version = "0.0.13";
415
415
  var description = "";
416
416
  var main = "dist/cutos.cjs.js";
417
417
  var module$1 = "dist/cutos.esm.js";
@@ -630,13 +630,13 @@ class Database {
630
630
  body.timestamp = dbResult.timestamp;
631
631
  break;
632
632
  }
633
- mirror.gwIPC.mirror(body, confirmCallback, {lwa_name: mirror.lwaName});
633
+ mirror.gwIPC.mirror(body, confirmCallback, {lwaName: mirror.lwaName});
634
634
  }
635
635
  callback && callback(dbResult);
636
636
  };
637
637
  }
638
638
  return publishRequest(topic, cb, body);
639
- };
639
+ }
640
640
  };
641
641
  this.db = db;
642
642
  this.retentionTime = opts.retentionTime ? opts.retentionTime : 48;// default 48 hours
@@ -883,13 +883,15 @@ class Driver {
883
883
  }
884
884
 
885
885
  onCommand(listener) {
886
- client.subscribe(this.topicCommand); // receive command from app
887
- listenerMap.set(this.topicCommand, listener);
886
+ if(listener) {
887
+ client.subscribe(this.topicCommand); // receive command from app
888
+ listenerMap.set(this.topicCommand, listener);
889
+ }
888
890
  }
889
891
  }
890
892
 
891
893
  const CoreAPI = {
892
- init(mqttHost = 'ws://localhost:1883') {
894
+ init(mqttHost = 'ws://localhost:1883', callback) {
893
895
  client = mqtt.connect(mqttHost);
894
896
 
895
897
  client.on('connect', function () {
@@ -903,6 +905,12 @@ const CoreAPI = {
903
905
  for (let api in cutosAPI.CORE_APP) {
904
906
  client.subscribe(cutosAPI.CORE_APP[api]);
905
907
  }
908
+ if(typeof(callback) === 'function') {
909
+ callback({
910
+ status: true,
911
+ msg: 'CUTOS CORE connected.'
912
+ });
913
+ }
906
914
  });
907
915
 
908
916
  client.on('message', function (topic, message, context) {
@@ -933,6 +941,12 @@ const CoreAPI = {
933
941
  });
934
942
 
935
943
  client.on("error", (e) => {
944
+ if(typeof(callback) === 'function') {
945
+ callback({
946
+ status: false,
947
+ msg: e.message
948
+ });
949
+ }
936
950
  console.error("CUTOS CORE error: ", e.message);
937
951
  });
938
952
  },
package/dist/cutos.esm.js CHANGED
@@ -651,6 +651,7 @@ const CORE = Object.freeze({ // core level api
651
651
  CONFIG: 'core-config',
652
652
  BOX_INFO: 'core-box-info',
653
653
  SIGN_INFO: 'core-sign-info',
654
+ DEVICE_INFO: 'core-device-info',
654
655
  SIGN_GROUP_INFO: 'core-sign-group-info',
655
656
  SHELL: 'core-shell',
656
657
  DATABASE: 'core-database',
@@ -675,8 +676,7 @@ const DEVICE = Object.freeze({ // core level api
675
676
  NFC: 'device-nfc',
676
677
  FINGERPRINT: 'device-fingerprint',
677
678
  QR_CODE_SCANNER: 'device-qr-code-scanner',
678
- PRINTER: 'device-printer',
679
- REFRIGERATOR: 'device-fridge'
679
+ PRINTER: 'device-printer'
680
680
  });
681
681
 
682
682
  const HEARTBEAT_STATUS = Object.freeze({
@@ -703,7 +703,7 @@ if(typeof window !== 'undefined') {
703
703
  var utils = config$1;
704
704
 
705
705
  var name = "@cutos/core";
706
- var version = "0.0.11";
706
+ var version = "0.0.13";
707
707
  var description = "";
708
708
  var main = "dist/cutos.cjs.js";
709
709
  var module = "dist/cutos.esm.js";
@@ -922,13 +922,13 @@ class Database {
922
922
  body.timestamp = dbResult.timestamp;
923
923
  break;
924
924
  }
925
- mirror.gwIPC.mirror(body, confirmCallback, {lwa_name: mirror.lwaName});
925
+ mirror.gwIPC.mirror(body, confirmCallback, {lwaName: mirror.lwaName});
926
926
  }
927
927
  callback && callback(dbResult);
928
928
  };
929
929
  }
930
930
  return publishRequest(topic, cb, body);
931
- };
931
+ }
932
932
  };
933
933
  this.db = db;
934
934
  this.retentionTime = opts.retentionTime ? opts.retentionTime : 48;// default 48 hours
@@ -1175,13 +1175,15 @@ class Driver {
1175
1175
  }
1176
1176
 
1177
1177
  onCommand(listener) {
1178
- client.subscribe(this.topicCommand); // receive command from app
1179
- listenerMap.set(this.topicCommand, listener);
1178
+ if(listener) {
1179
+ client.subscribe(this.topicCommand); // receive command from app
1180
+ listenerMap.set(this.topicCommand, listener);
1181
+ }
1180
1182
  }
1181
1183
  }
1182
1184
 
1183
1185
  const CoreAPI = {
1184
- init(mqttHost = 'ws://localhost:1883') {
1186
+ init(mqttHost = 'ws://localhost:1883', callback) {
1185
1187
  client = mqtt.connect(mqttHost);
1186
1188
 
1187
1189
  client.on('connect', function () {
@@ -1195,6 +1197,12 @@ const CoreAPI = {
1195
1197
  for (let api in cutosAPI.CORE_APP) {
1196
1198
  client.subscribe(cutosAPI.CORE_APP[api]);
1197
1199
  }
1200
+ if(typeof(callback) === 'function') {
1201
+ callback({
1202
+ status: true,
1203
+ msg: 'CUTOS CORE connected.'
1204
+ });
1205
+ }
1198
1206
  });
1199
1207
 
1200
1208
  client.on('message', function (topic, message, context) {
@@ -1225,6 +1233,12 @@ const CoreAPI = {
1225
1233
  });
1226
1234
 
1227
1235
  client.on("error", (e) => {
1236
+ if(typeof(callback) === 'function') {
1237
+ callback({
1238
+ status: false,
1239
+ msg: e.message
1240
+ });
1241
+ }
1228
1242
  console.error("CUTOS CORE error: ", e.message);
1229
1243
  });
1230
1244
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cutos/core",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "",
5
5
  "main": "dist/cutos.cjs.js",
6
6
  "module": "dist/cutos.esm.js",