//
//  iHeraLib.h
//  iHeraLib
//
//  Created by Simone Ceccato on 12/05/2020.
//  Copyright © 2020 Simone Ceccato. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <iCore/iCore.h>
#import <Hera_Lib_iOS_Swift/Hera_Lib_iOS_Swift-Swift.h>

@class B4I;
//~dependson: Hera_Lib_iOS_Swift.framework.swift.3
//~shortname:iHeraLib
//~event:OnBluetoothStatusChanged (BluetoothStatus as String)
//~event:OnScanResult (Device as BLEDevice)
//~event:OnScanStatusChanged (ScanStatus as String)
//~event:OnDeviceComStatusChanged (DeviceComStatus as String)
//~event:OnMessageReceived (Message as String)
//~event:OnProcedureStatusChanged (ProcedureStatus as String)
//~event:OnProcedureCompleted
//~event:OnProcedureFailed (Error as String)
//~event:OnGenericError (Error as String)
//~event:OnConnectionFailed (Message as String)
//~event:OnConnectionFailed (Message as String)
//~event:OnKeyRingFound
//~event:OnKeyRingNotFound
//~version:0.8
@interface iHeraLib : NSObject<HeraLibWrapperDelegate>
/**
 Initialize the object
 */
- (void)Initialize:(B4I *)bi :(NSString *)EventName;

/**
 Start listening for IOEK BLEDevices.
 The scan is already filtered in order to provide only devices containing the IOEK custom service.
 In order to receive the device, the application has to implement the OnScanResult event.
 The method returns a boolean representing whether the service has correctly started the scan or not.
 */
- (BOOL)StartBleScan;

/**
 Stop listening for IOEK BLEDevices.
 The method returns a boolean representing whether the service has correctly stopped the scan or not.
 */
- (BOOL)StopBleScan;

/**
 Set the device UUID and the TMD serial.
 DeviceID - String UUID representing the device.
 TmdSerial - String representing the serial of the TMD device connected to the IOEK expander.
 */
- (BOOL)SelectDevice:(NSString *)DeviceID :(NSString *)TmdSerial;

/**
 Start the connection procedure to the selected device.
 It is possible to listen for the different phases of the connection procedure by looking at the OnDeviceComStatusChanged events raised from the service.
 The method returns a boolean representing whether the service has correctly started the connection procedure or not.
 */
- (BOOL)ConnectToSelectedDevice;

/**
 Start the disconnection procedure from the currently connected device.
 It is possible to listen for the different phases of the disconnection procedure by looking at the OnDeviceComStatusChanged events raised from the service.
 The method returns a boolean representing whether the service has correctly started the disconnection procedure or not.
 */
- (BOOL)DisconnectFromDevice;

/**
 Check the keyring status.
 DeviceAddress - TBD
 */
- (BOOL)CheckKeyStatus:(NSString *)DeviceAddress;

/**
 Send a message to perform an action.
 MessageType - String representing the type of command to execute. Supported commands are "OpenDoors", "CloseDoors", "UnlockEngine", "LockEngine".
 The method returns a boolean representing whether the MessageType parameter is valid or not.
 */
- (BOOL)SendMessage:(NSString *)MessageType;

/**
 Return the current SDK version.
 */
- (NSString *)GetSDKVersion;

/**
 Return the current Bluetooth status.
 Currently the possible return strings could be "ON" or "OFF".
 */
- (NSString *)GetBluetoothStatus;

/**
Return the current scan service status.
Currently the possible return strings could be "IDLE" or "SCANNING".
*/
- (NSString *)GetScanServiceStatus;

/**
Return the current device connection status.
Currently the possible return strings could be "NOT_SELECTED", "NOT_CONNECTED", "CONNECTING", "CONNECTED", "DISCONNECTING"
*/
- (NSString *)GetDeviceConnectionStatus;

/**
Return an instance of the currently selected IOEK BLEDevice.
*/
- (BLEDeviceComp *)GetSelectedDevice;
@end
//~shortName:BLEDevice
//~ObjectWrapper:BLEDeviceComp*
@interface B4IBLEDeviceWrapper : B4IObjectWrapper
//String UUID for the current device.
@property (nonatomic, readonly) NSString* ID;
//Name of the device.
@property (nonatomic, readonly) NSString* Name;
//MAC address of the device. If the application has never connected to the device, this value will be an empty string.
@property (nonatomic, readonly) NSString* Address;
@end
