npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

own2mesh-capacitor-plugin-oklok

v1.2.0

Published

An awesome plugin!

Downloads

9

Readme

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: [email protected]

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;
   });
}