Boks SDK Documentation - v0.0.11
    Preparing search index...

    Class BoksController

    High-level controller for Boks devices. Manages version-specific logic, feature flags, and complex workflows.

    Index

    Constructors

    Accessors

    Methods

    • Converts a code type (Single <-> Multi).

      Parameters

      • pin: string

        The PIN code to convert.

      • targetType: BoksCodeType

        The target type (Single or Multi).

      Returns Promise<boolean>

    • Requests the number of active codes.

      Returns Promise<{ masterCount: number; singleCount: number }>

      An object containing the count of master codes and other codes.

    • Creates a new master code at the specified index.

      Parameters

      • index: number
      • pin: string

      Returns Promise<boolean>

    • Creates a new multi-use code.

      Parameters

      • pin: string

      Returns Promise<boolean>

    • Creates a new single-use code.

      Parameters

      • pin: string

      Returns Promise<boolean>

    • Deletes a master code at the specified index.

      Parameters

      • index: number

      Returns Promise<boolean>

    • Deletes a multi-use code.

      Parameters

      • pin: string

      Returns Promise<boolean>

    • Deletes a single-use code.

      Parameters

      • pin: string

      Returns Promise<boolean>

    • Edits a master code at the specified index.

      Parameters

      • index: number

        The index of the master code (0-9).

      • newPin: string

        The new PIN code.

      Returns Promise<boolean>

    • Reads the current battery level (standard Bluetooth characteristic).

      Returns Promise<number | undefined>

      Battery level (0-100) or undefined if unreliable.

    • Requests the current status of the door (open or closed).

      Returns Promise<boolean>

      True if the door is open, false if closed.

    • Requests the number of logs stored in the device.

      Returns Promise<number>

      The number of logs.

    • Experimental

      Gets raw sensor data from the scale.

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Initializes a factory-fresh Boks device with a Master Key seed. ⚠️ This operation is theoretical and risky. Use with caution.

      Parameters

      • seed: string | Uint8Array<ArrayBufferLike>

        The 32-byte seed for the Master Key (hex string or Uint8Array).

      • OptionalonProgress: (progress: number) => void

        Callback for progress updates (0-100%).

      Returns Promise<boolean>

      True if initialization was successful.

    • Subscribes to all incoming packets.

      Parameters

      • callback: (packet: BoksPacket) => void

        Function called for every parsed packet received.

      Returns () => void

      A function to unsubscribe.

    • Opens the door using the provided PIN code.

      Parameters

      • pin: string

        The PIN code to use.

      Returns Promise<boolean>

      True if the door opened successfully, false if the PIN was invalid.

    • Reactivates a disabled code.

      Parameters

      • pin: string

        The PIN code to reactivate.

      Returns Promise<boolean>

    • Regenerates the master key (Provisioning).

      Parameters

      • newMasterKey: string | Uint8Array<ArrayBufferLike>

        The new 32-byte master key (as hex string or Uint8Array).

      • OptionalonProgress: (progress: number) => void

        Callback for progress updates (0-100%).

      Returns Promise<boolean>

      True if regeneration was successful, false otherwise.

    • Registers a specific NFC tag by its UID. Requires HW >= 4.0 and SW >= 4.3.3. Uses the derived Config Key.

      Parameters

      • tagId: string

        The UID of the NFC tag (hex string, optional colons).

      Returns Promise<boolean>

      True if registered successfully, false if the tag already exists.

    • Starts an NFC tag scan sequence. Requires HW >= 4.0 and SW >= 4.3.3.

      Parameters

      • timeoutMs: number = 10000

        Timeout in milliseconds for the scan operation.

      Returns Promise<NfcScanResult>

      A promise resolving to an NfcScanResult containing the tagId and a register method.

      BoksClientError if timeout occurs or tag already exists.

    • Sets a configuration parameter.

      Parameters

      • params: { type: number; value: boolean }

        The configuration parameters (type and value).

      Returns Promise<boolean>

    • Sets the Master Key and derives the Config Key, or sets Config Key directly.

      Parameters

      • key: string | Uint8Array<ArrayBufferLike>

        The 32-byte Master Key or 4-byte Config Key (as hex string or Uint8Array).

      Returns void

    • Experimental

      Tares the scale.

      Parameters

      • empty: boolean

        If true, tares as empty. If false, tares as loaded.

      Returns Promise<boolean>

    • Unregisters a specific NFC tag by its UID. Requires HW >= 4.0 and SW >= 4.3.3. Uses the derived Config Key.

      Parameters

      • tagId: string

        The UID of the NFC tag (hex string, optional colons).

      Returns Promise<boolean>

      True if unregistered successfully.