//
//  ASW.h
//  JoywayLib
//
//  Created by Bob Xia on 17/1/3.
//  Copyright © 2017年 ___JOYWAY___. All rights reserved.
//

#ifndef ASW_h
#define ASW_h
#import "ASWSdkEventDelegate.h"

//ASW SDK, based on ble technology

@interface ASW : NSObject


+(id)sharedInstance;


//call this method first, to init module.
//初始化蓝牙。
-(void)initModule;

//when you do not use this module, please call this method to release all resource used by module
//释放蓝牙资源
-(void)releaseModule;


//listen module event
-(void)listenModuleEvent:(id<ASWSdkEventDelegate>) delegate;


//delete the registered deivce, and start searching nearby device.
//if its rssi is bigger than rssi threshold, then add the device to module .
//user need to register device for the first time to use. he can also change device by register again.
//you can call 'getRegisteredDeviceMac' to check whether register succeed.(that means mac not nil)
//module will stop registering automatically if registered successfully.
//开始注册设备－－－搜寻并添加rssi大于rssiThreshold的设备，并保存mac
-(void)startRegisterDeviceWithRssiThreshold:(int)rssiThreshold;



//call this method to stop searching and adding.
//停止注册设备
-(void)stopRegisterDevice;



//get the mac address of registered deivce
-(NSString*) getRegisteredDeviceMac;



//keeping connection with device. get ready to send vibrate command to device
//读取注册的ble设备mac，如果有，就扫描并连接。
-(void)startWork;


//disconnect device
//断开连接，停止扫描
-(void)stopWork;



//send command to device: "start vibrate".
//param:
// 1, length and interval must be bigger than 100(ms)
// 2, times must be tigger than 1, which means vibrate and flash led for 1 time
-(void)startVibrate:(int)length interval:(int)interval times:(int)times;



//send command to device: stop vibrate
-(void)stopVibrate;


//turn off
-(void)turnOffDevice;


-(void)getDeviceFirmwareVersion;
-(BOOL)isDeviceConnected;

@end

#endif /* ASW_h */
