
#import <Foundation/Foundation.h>
#import "BTEvtDelegate.h"
#import "Tag.h"
#import "TagConnectStatus.h"




/*!
 @class BT
 @abstract BT class is the only way to use BLE moudle. NO need to create instance of BT. Just call its static functions.
 Please follow steps:
 1, initModule.
 2, listenBTEvent:true.
 3, startScan.
 4, deal with bt event.
 5, stopScan.
 6, listenBTEvent:false.
 7, releaseModule.
 */
@interface BT : NSObject

//BT基本函数---开始
/*!
 @abstract No use any more.
 */
+(float) get_MAX_CONNECT_DISTANCE;
/*!
 @abstract No use any more.
 */
+(void) set_MAX_CONNECT_DISTANCE:(float)distance;
/*!
 @abstract calculate distance between tag device and phone.
 */
+ (float)calculateDistanceForRssi:(int)rssi rssiAtOneMeter:(int)rssiAtOneMeter rssiDecreaseFactor:(float)rssiDecreaseFactor;
/*!
 @abstract calculate signal strength to grid value(min:0, max:5). It is used to show grid in UI.
 */
+(int)calculateSignalGridForRssi:(int)rssi rssiAtOneMeter:(int)rssiAtOneMeter rssiOfSensitivity:(int)rssiOfSensitivity;
/*!
 @abstract init bluetooth module in SDK.
 */
+(BOOL) initModuleWithReadingRssiTimeInterval:(NSTimeInterval)readRssiInterval;
/*!
 @abstract release resources used in bluetooth module in SDK.
 */
+(void) releaseModule;
/*!
 @abstract In your application, any class can listen and deal with BT event. Your class should implement event functions.
 Such as onTagScanned, onTagData, onTagRssiChanged, etc.
 */
+(BOOL) listenBTEvent: (id<BTEvtDelegate>)btEvtDelegate listen:(BOOL)listen;
/*!
 @abstract start bluetooth low energy scan, will trigger onTagScanned event if there are advertising BLE devices nearby.
 */
+(BOOL) startScanAllowDuplicatesKey:(BOOL)allowDuplicatesKey serviceUUIDs:(NSArray<NSString*>*) serviceUUIDStrings;
/*!
 @abstract Stop scan, you should call it to save energy if no need to search nearby BLE device.
 */
+(void) stopScan;
/*!
 @abstract add one tag name filter, onTagScanned event will be trigered only when the scanned device's name match this tagName param.
 */
+(BOOL) addScanFilter_tagNameEqual:(NSString*)tagName;
/*!
 @abstract remove one name filter.
 */
+(BOOL) removeScanFilter_tagNameEqual:(NSString*)tagName;
/*!
 @abstract set tag rssi filter, onTagScanned will be trigered only when the scanned device's rssi is bigger than this rssi param.
 */
+(BOOL) setScanRssiFilter:(int)minRssi;
/*!
 @abstract if BT module does not received any signal from the BLE tag for a specified time length, SDK will trigger event 'onTagLost'
 */
+(void) setThresholdTimeLengthForDecidingTagLost:(NSTimeInterval)timeLength;
/*!
 @abstract get current rssi filter value.
 */
+(int) getScanRssiFilter;
/*!
 @abstract connect tag immediately.
 */
+(BOOL) connectTag:(NSString*)tagMac;
/*!
 @abstract set specified BLE tag should be connected or not, SDK will auto-connect or disconnect it.
 */
+(void) setNeedConnect:(NSString*)tagMac needConnect:(BOOL)needConnect;
/*!
 @abstract disconnect tag immediately.
 */
+(BOOL) disconnectTag:(NSString*)tagMac;
/*!
 @abstract get tag object which contains all information of thie device.
 */
+(Tag*) getTag:(NSString*)tagMac;
/*!
 @abstract You should not use it.
 */
+(CBCentralManager*) getCentralManager;
/*!
 @abstract send string data to tag device by UTF8 coding.
 */
+(BOOL) sendStringToTag:(NSString*)tagMac stringToSend:(NSString*)str;
/*!
 @abstract send bytes data to tag device.
 */
+(BOOL) sendDataToTag:(NSString*)tagMac dataToSend:(NSData*)data;
/*!
 @abstract clear the cached scanned tag list in SDK module.
 */
+(BOOL) clearScannedTags;
/*!
 @abstract set the default name of scanned tag, this is used when creating instance of tag object in SDK.
 Otherwise tag.name field will be filled with tag advertising name.
 */
+(void) setTagDefaultName:(NSString*)defaultName;
/*!
 @abstract check if it is valid mac address string.
 */
+(BOOL) isMacAddress:(NSString*)mac;//判断这个字符串是不是mac地址
/*!
 @abstract return TRUE if BLE tag is connected with BT module.
 */
+(BOOL) isTagConnected:(NSString*)tagMac;
/*!
 @abstract get current connect status of the BLE tag, such as connecting, connected, disconnected.
 */
+(TagConnectStatus) getTagConnectStatus:(NSString*)tagMac;
/*!
 @abstract send command to anti-lost-alarm tag,  to make tag alerting.
 */
+(BOOL) sendCmdToTag_alert:(NSString*)tagMac;
/*!
 @abstract enable/disable smoothing rssi.  RssiFactors example: {0.1f, 0.4f, 0.4f, 0.1f}.
 */
+(void) enableRssiSmoother:(BOOL)enable rssiFactors:(NSArray*)rssiFactors;


@end










