/**
 * @providesModule bleno
 * @flow
 */

import EventEmitter from 'events';

export type AdapterState =
  'unknown' |
  'resetting' |
  'unsupported' |
  'unauthorized' |
  'poweredOff' |
  'poweredOn';

export type WriteAttributeCallback = (result: number) => void;
export type ReadAttributeCallback = (result: number, data: Buffer) => void;
export type NotifyAttributeCallback = (data: Buffer) => void;

export type ErrorCallback = (error: ?Error) => void;

declare export class Bleno extends EventEmitter {
  platform: string;
  state: AdapterState;
  address: string;
  rssi: number;
  mtu: number;

  stopAdvertising(callback?: ErrorCallback): void;
  startAdvertising(
    name: string,
    serviceUuids: Array<string>,
    callback?: ErrorCallback,
  ): void;
  startAdvertisingIBeacon(
    uuid: string,
    major: number,
    minor: number,
    measuredPower: number,
    callback?: ErrorCallback,
  ): void;
}

declare var bleno: Bleno;
declare export default typeof bleno;
