capacitor-motioncal 0.0.4 → 0.0.5

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.
@@ -6,11 +6,8 @@ public class MotionCalibrationPlugin: CAPPlugin, CAPBridgedPlugin {
6
6
  public let identifier = "MotionCalibrationPlugin"
7
7
  public let jsName = "MotionCalibration"
8
8
  public let pluginMethods: [CAPPluginMethod] = [
9
- CAPPluginMethod(name: "updateBValue", returnType: CAPPluginReturnPromise),
10
- CAPPluginMethod(name: "getBValue", returnType: CAPPluginReturnPromise),
11
9
  CAPPluginMethod(name: "isSendCalAvailable", returnType: CAPPluginReturnPromise),
12
- CAPPluginMethod(name: "readDataFromFile", returnType: CAPPluginReturnPromise),
13
- CAPPluginMethod(name: "setResultFilename", returnType: CAPPluginReturnPromise),
10
+ CAPPluginMethod(name: "rawData", returnType: CAPPluginReturnPromise),
14
11
  CAPPluginMethod(name: "sendCalibration", returnType: CAPPluginReturnPromise),
15
12
  CAPPluginMethod(name: "getQualitySurfaceGapError", returnType: CAPPluginReturnPromise),
16
13
  CAPPluginMethod(name: "getQualityMagnitudeVarianceError", returnType: CAPPluginReturnPromise),
@@ -26,53 +23,20 @@ public class MotionCalibrationPlugin: CAPPlugin, CAPBridgedPlugin {
26
23
  CAPPluginMethod(name: "clearDrawPoints", returnType: CAPPluginReturnPromise)
27
24
  ]
28
25
 
29
- public override func load() {
30
- // Initialize the C struct if needed
31
- motioncal.B = 0.0
32
- }
33
-
34
- @objc func updateBValue(_ call: CAPPluginCall) {
35
- guard let value = call.getFloat("value") else {
36
- call.reject("Value is required")
37
- return
38
- }
39
- motioncal.B = value * 2
40
- call.resolve()
41
- }
42
-
43
- @objc func getBValue(_ call: CAPPluginCall) {
44
- let bValue = motioncal.B
45
- call.resolve(["value": bValue])
46
- }
47
-
48
26
  @objc func isSendCalAvailable(_ call: CAPPluginCall) {
49
27
  let available = is_send_cal_available()
50
28
  call.resolve(["available": Int(available)])
51
29
  }
52
30
 
53
- @objc func readDataFromFile(_ call: CAPPluginCall) {
54
- guard let filename = call.getString("filename") else {
55
- call.reject("Filename is required")
31
+ @objc func rawData(_ call: CAPPluginCall) {
32
+ guard let dataArray = call.getArray("data") as? [NSNumber], dataArray.count == 9 else {
33
+ call.reject("Expected array of 9 numbers")
56
34
  return
57
35
  }
58
-
59
- let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
60
- let fullPath = (documentsPath as NSString).appendingPathComponent(filename)
61
-
62
- let result = read_ipc_file_data(fullPath)
63
- call.resolve(["result": Int(result)])
64
- }
65
-
66
- @objc func setResultFilename(_ call: CAPPluginCall) {
67
- guard let filename = call.getString("filename") else {
68
- call.reject("Filename is required")
69
- return
36
+ var rawValues = dataArray.map { Int16(clamping: $0.intValue) }
37
+ rawValues.withUnsafeMutableBufferPointer { ptr in
38
+ raw_data(ptr.baseAddress!)
70
39
  }
71
-
72
- let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
73
- let fullPath = (documentsPath as NSString).appendingPathComponent(filename)
74
-
75
- set_result_filename(fullPath)
76
40
  call.resolve()
77
41
  }
78
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-motioncal",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Capacitor plugin for motion calibration using magnetometer data",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -9,6 +9,7 @@
9
9
  "files": [
10
10
  "android/src/main/",
11
11
  "android/build.gradle",
12
+ "android/CMakeLists.txt",
12
13
  "dist/",
13
14
  "ios/Sources/",
14
15
  "common/",
@@ -43,7 +44,7 @@
43
44
  "swiftlint": "node-swiftlint",
44
45
  "docgen": "docgen --api MotionCalibrationPlugin --output-readme README.md --output-json dist/docs.json",
45
46
  "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
46
- "clean": "rimraf ./dist",
47
+ "clean": "npx rimraf ./dist",
47
48
  "watch": "tsc --watch",
48
49
  "prepublishOnly": "npm run build"
49
50
  },
@@ -1,7 +0,0 @@
1
- #include "motioncalibration.h"
2
-
3
- MotionCalibration_t motioncal;
4
-
5
- void updateBValue(float B) {
6
- motioncal.B = B * 2;
7
- }
@@ -1,12 +0,0 @@
1
- #ifndef MOTION_CALIBRATION_H
2
- #define MOTION_CALIBRATION_H
3
-
4
- typedef struct {
5
- float B;
6
- } MotionCalibration_t;
7
-
8
- extern MotionCalibration_t motioncal;
9
-
10
- void updateBValue(float B);
11
-
12
- #endif