1.2.0 • Published 2 years ago

own2mesh-capacitor-plugin-oklok v1.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Own2Mesh - Capacitor plugin OKLOK

Plugin for capacitor to open locks from OKLOK with OKLOK Protocol Version ONE

You can find a demo app here: Demo App

SUPPORT

If you are a student of the HS Osnabrück contact us here: MSTeams

Otherwise contact us via email: own2mesh@gmail.com

Install

  • Install own2mesh-capacitor-plugin-oklok

    npm i own2mesh-capacitor-plugin-oklok

Info

  • You must provide a lock name on IOS (IOS doesn't support MAC-Address with BLE)
  • You must provide a lock address on Android.
  • This plugin has no web implementation. Test only on your phone.

Import the plugin (Typescript)

import {Plugins} from '@capacitor/core';
const {Own2MeshOkLokPlugin} = Plugins;

How to use a methode

Own2MeshOkLokPlugin.theMethodeYouLike();

(Android only)

Add our installed plugin to the MainActivity

File Path: myApp/android/app/src/main/java/io/ionic/starter/MainActivity.java

import de.own2mesh.plugin.oklok.Own2MeshOkLokPlugin;

add(Own2MeshOkLokPlugin.class);

The MainActivity.java should look like this:

package de.own2mesh.own2mesh_demo;

import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;

import java.util.ArrayList;

import de.own2mesh.plugin.oklok.Own2MeshOkLokPlugin;

public class MainActivity extends BridgeActivity {
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);

   // Initializes the Bridge
   this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
     // Additional plugins you've installed go here
     // Ex: add(TotallyAwesomePlugin.class);
     add(Own2MeshOkLokPlugin.class);
   }});
 }
}

Usage

Import

Import the plugin

import {Plugins} from '@capacitor/core';
const {Own2MeshOkLokPlugin} = Plugins;

How to use a methode

Own2MeshOkLokPlugin.theMethodeYouLike();

Example lock

lockName = {
    name: string, // Physical lock name
    address: string, // MAC Address (for android)
    secret: string[16], // lock key as hexadecimal integer literal string array[16 items] (Begins with the 0 digit followed by either an x or X, followed by any combination of the digits 0 through 9 and the letters a through f or A through F.)
    pw: string[6] // password as hexadecimal integer literal string array[6 items] (Begins with the 0 digit followed by either an x or X, followed by any combination of the digits 0 through 9 and the letters a through f or A through F.)
}

Important Hex Strings have to start with a leading 0 if they are single digit

lockOKGSS101 = {
    name: 'OKGSS101',
    address: 'F8:45:65:64:CC:B4',
    secret: ['0x4c', '0x5f', '0x0c', '0x3c', '0x4c', '0x28', '0x53', '0x24', '0x23', '0x36', '0x12', '0x5b', '0x33', '0x59', '0x21', '0x04'],
    pw: ['0x33', '0x32', '0x31', '0x39', '0x33', '0x37'] 
}

Methods

echo()

  • Test Methode

Call this methode to make sure you can communicate with the plugin. Result by success: {"value":"Hello back from own-2-mesh plugin!"}

Plugin Methode
echo(options: { value: string }): Promise<{ value: string }>;
Example
echo() {
   Own2MeshOkLokPlugin.echo({
       value: 'Hello Own2MeshOkLokPlugin!'
   }).then(result => {
       console.log(result.value);
   });
}

open()

  • Open lock

Call this methode to open a lock.

Plugin Methode
open(options: { name: string, address: string, secret: string[], pw: string[] }): Promise<{ opened: boolean }>;
Example
openLock() {
   Own2MeshOkLokPlugin.open({
      name: lock.name,
       address: lock.address,
       secret: lock.secret,
       pw: lock.pw
   }).then(result => {
       console.log(result.opened);
   });
}

battery_status()

  • Get battery status

Call this methode to get the battery status.

Plugin Methode
battery_status(options: { name: string, address: string, secret: string[] }): Promise<{ percentage: number }>;
Example
batteryInfo() {
   Own2MeshOkLokPlugin.battery_status({
     name: lock.name,
     secret: lock.secret,
   }).then(result => {
     console.log(result.percentage);
   });
}

lock_status()

  • Get lock status

Call this methode to get the lock status.

Plugin Methode
lock_status(options: { name: string, address: string, secret: string[] }): Promise<{ locked: boolean }>;
Example
lockStatus() {
Own2MeshOkLokPlugin.lock_status({
     name: lock.name,
     secret: lock.secret,
   }).then(result => {
     console.log(result.locked);
   });
}

close()

  • Get lock status

Call this methode to close a lock.

Plugin Methode
close(options: { name: string, address: string, secret: string[] }): Promise<{ closed: boolean }>;
Example
closeLock() {
   Own2MeshOkLokPlugin.close({
       name: lock.name,
       address: lock.address,
       secret: lock.secret,
       pw: lock.pw
   }).then(result => {
       this.openLockStatus = result.closed;
   });
}

1.2.0

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.30

4 years ago

0.0.27

4 years ago

0.0.28

4 years ago

0.0.29

4 years ago

0.0.25

4 years ago

0.0.26

4 years ago

0.0.23

4 years ago

0.0.24

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago