using System; using CoreBluetooth; using Foundation; using ObjCRuntime; namespace HdlBlufi { #region espclient // @interface BlufiConstants : NSObject [BaseType(typeof(NSObject))] interface BlufiConstants { } // @interface BlufiStatusResponse : NSObject [BaseType(typeof(NSObject))] interface BlufiStatusResponse { // @property (assign, nonatomic) OpMode opMode; [Export("opMode", ArgumentSemantic.Assign)] OpMode OpMode { get; set; } // @property (assign, nonatomic) SoftAPSecurity softApSecurity; [Export("softApSecurity", ArgumentSemantic.Assign)] SoftAPSecurity SoftApSecurity { get; set; } // @property (assign, nonatomic) int softApConnectionCount; [Export("softApConnectionCount")] int SoftApConnectionCount { get; set; } // @property (assign, nonatomic) int softApMaxConnection; [Export("softApMaxConnection")] int SoftApMaxConnection { get; set; } // @property (assign, nonatomic) int softApChannel; [Export("softApChannel")] int SoftApChannel { get; set; } // @property (nonatomic, strong) NSString * _Nonnull softApPassword; [Export("softApPassword", ArgumentSemantic.Strong)] string SoftApPassword { get; set; } // @property (nonatomic, strong) NSString * _Nonnull softApSsid; [Export("softApSsid", ArgumentSemantic.Strong)] string SoftApSsid { get; set; } // @property (assign, nonatomic) int staConnectionStatus; [Export("staConnectionStatus")] int StaConnectionStatus { get; set; } // @property (nonatomic, strong) NSString * _Nonnull staBssid; [Export("staBssid", ArgumentSemantic.Strong)] string StaBssid { get; set; } // @property (nonatomic, strong) NSString * _Nonnull staSsid; [Export("staSsid", ArgumentSemantic.Strong)] string StaSsid { get; set; } // @property (nonatomic, strong) NSString * _Nonnull staPassword; [Export("staPassword", ArgumentSemantic.Strong)] string StaPassword { get; set; } // -(BOOL)isStaConnectWiFi; [Export("isStaConnectWiFi")] //[Verify(MethodToProperty)] bool IsStaConnectWiFi { get; } // -(NSString * _Nonnull)getStatusInfo; [Export("getStatusInfo")] //[Verify(MethodToProperty)] string StatusInfo { get; } } // @interface BlufiScanResponse : NSObject [BaseType(typeof(NSObject))] interface BlufiScanResponse { // @property (assign, nonatomic) int type; [Export("type")] int Type { get; set; } // @property (nonatomic, strong) NSString * _Nonnull ssid; [Export("ssid", ArgumentSemantic.Strong)] string Ssid { get; set; } // @property (assign, nonatomic) int8_t rssi; [Export("rssi")] sbyte Rssi { get; set; } } // @interface BlufiVersionResponse : NSObject [BaseType(typeof(NSObject))] interface BlufiVersionResponse { // @property (assign, nonatomic) Byte bigVer; [Export("bigVer")] byte BigVer { get; set; } // @property (assign, nonatomic) Byte smallVer; [Export("smallVer")] byte SmallVer { get; set; } // -(NSString * _Nonnull)getVersionString; [Export("getVersionString")] //[Verify(MethodToProperty)] string VersionString { get; } } // @interface BlufiConfigureParams : NSObject [BaseType(typeof(NSObject))] interface BlufiConfigureParams { // @property (assign, nonatomic) OpMode opMode; [Export("opMode", ArgumentSemantic.Assign)] OpMode OpMode { get; set; } // @property (nonatomic, strong) NSString * _Nonnull staBssid; [Export("staBssid", ArgumentSemantic.Strong)] string StaBssid { get; set; } // @property (nonatomic, strong) NSString * _Nonnull staSsid; [Export("staSsid", ArgumentSemantic.Strong)] string StaSsid { get; set; } // @property (nonatomic, strong) NSString * _Nonnull staPassword; [Export("staPassword", ArgumentSemantic.Strong)] string StaPassword { get; set; } // @property (assign, nonatomic) SoftAPSecurity softApSecurity; [Export("softApSecurity", ArgumentSemantic.Assign)] SoftAPSecurity SoftApSecurity { get; set; } // @property (nonatomic, strong) NSString * _Nonnull softApSsid; [Export("softApSsid", ArgumentSemantic.Strong)] string SoftApSsid { get; set; } // @property (nonatomic, strong) NSString * _Nonnull softApPassword; [Export("softApPassword", ArgumentSemantic.Strong)] string SoftApPassword { get; set; } // @property (assign, nonatomic) NSInteger softApChannel; [Export("softApChannel")] nint SoftApChannel { get; set; } // @property (assign, nonatomic) NSInteger softApMaxConnection; [Export("softApMaxConnection")] nint SoftApMaxConnection { get; set; } } // @interface BlufiClient : NSObject [BaseType(typeof(NSObject))] interface BlufiClient { [Wrap("WeakBlufiDelegate")] [NullAllowed] BlufiDelegate BlufiDelegate { get; set; } // @property (nonatomic, weak) id _Nullable blufiDelegate; [NullAllowed, Export("blufiDelegate", ArgumentSemantic.Weak)] NSObject WeakBlufiDelegate { get; set; } // @property (nonatomic, weak) id _Nullable centralManagerDelete; [NullAllowed, Export("centralManagerDelete", ArgumentSemantic.Weak)] CBCentralManagerDelegate CentralManagerDelete { get; set; } [Wrap("WeakPeripheralDelegate")] [NullAllowed] CBPeripheralDelegate PeripheralDelegate { get; set; } // @property (nonatomic, weak) id _Nullable peripheralDelegate; [NullAllowed, Export("peripheralDelegate", ArgumentSemantic.Weak)] NSObject WeakPeripheralDelegate { get; set; } // @property (assign, nonatomic) NSInteger postPackageLengthLimit; [Export("postPackageLengthLimit")] nint PostPackageLengthLimit { get; set; } // -(void)connect:(NSString * _Nonnull)identifier; [Export("connect:")] void Connect(string identifier); // -(void)close; [Export("close")] void Close(); // -(void)negotiateSecurity; [Export("negotiateSecurity")] void NegotiateSecurity(); // -(void)requestCloseConnection; [Export("requestCloseConnection")] void RequestCloseConnection(); // -(void)requestDeviceVersion; [Export("requestDeviceVersion")] void RequestDeviceVersion(); // -(void)requestDeviceStatus; [Export("requestDeviceStatus")] void RequestDeviceStatus(); // -(void)requestDeviceScan; [Export("requestDeviceScan")] void RequestDeviceScan(); // -(void)configure:(BlufiConfigureParams * _Nonnull)params; [Export("configure:")] void Configure(BlufiConfigureParams @params); // -(void)postCustomData:(NSData * _Nonnull)data; [Export("postCustomData:")] void PostCustomData(NSData data); } // @protocol BlufiDelegate [Protocol, Model(AutoGeneratedName = true)] [BaseType(typeof(NSObject))] interface BlufiDelegate { // @optional -(void)blufi:(BlufiClient * _Nonnull)client gattPrepared:(BlufiStatusCode)status service:(CBService * _Nullable)service writeChar:(CBCharacteristic * _Nullable)writeChar notifyChar:(CBCharacteristic * _Nullable)notifyChar; [Export("blufi:gattPrepared:service:writeChar:notifyChar:")] void Blufi_gattPrepared(BlufiClient client, BlufiStatusCode status, [NullAllowed] CBService service, [NullAllowed] CBCharacteristic writeChar, [NullAllowed] CBCharacteristic notifyChar); // @optional -(BOOL)blufi:(BlufiClient * _Nonnull)client gattNotification:(NSData * _Nonnull)data packageType:(PackageType)pkgType subType:(SubType)subType; [Export("blufi:gattNotification:packageType:subType:")] bool Blufi_gattNotification(BlufiClient client, NSData data, PackageType pkgType, uint subType); // @optional -(void)blufi:(BlufiClient * _Nonnull)client didReceiveError:(NSInteger)errCode; [Export("blufi:didReceiveError:")] void Blufi_didReceiveError(BlufiClient client, nint errCode); // @optional -(void)blufi:(BlufiClient * _Nonnull)client didNegotiateSecurity:(BlufiStatusCode)status; [Export("blufi:didNegotiateSecurity:")] void Blufi_didNegotiateSecurity(BlufiClient client, BlufiStatusCode status); // @optional -(void)blufi:(BlufiClient * _Nonnull)client didPostConfigureParams:(BlufiStatusCode)status; [Export("blufi:didPostConfigureParams:")] void Blufi_didPostConfigureParams(BlufiClient client, BlufiStatusCode status); // @optional -(void)blufi:(BlufiClient * _Nonnull)client didReceiveDeviceVersionResponse:(BlufiVersionResponse * _Nullable)response status:(BlufiStatusCode)status; [Export("blufi:didReceiveDeviceVersionResponse:status:")] void Blufi_didReceiveDeviceVersionResponse(BlufiClient client, [NullAllowed] BlufiVersionResponse response, BlufiStatusCode status); // @optional -(void)blufi:(BlufiClient * _Nonnull)client didReceiveDeviceStatusResponse:(BlufiStatusResponse * _Nullable)response status:(BlufiStatusCode)status; [Export("blufi:didReceiveDeviceStatusResponse:status:")] void Blufi_didReceiveDeviceStatusResponse(BlufiClient client, [NullAllowed] BlufiStatusResponse response, BlufiStatusCode status); // @optional -(void)blufi:(BlufiClient * _Nonnull)client didReceiveDeviceScanResponse:(NSArray * _Nullable)scanResults status:(BlufiStatusCode)status; [Export("blufi:didReceiveDeviceScanResponse:status:")] void Blufi_didReceiveDeviceScanResponse(BlufiClient client, [NullAllowed] BlufiScanResponse[] scanResults, BlufiStatusCode status); // @optional -(void)blufi:(BlufiClient * _Nonnull)client didPostCustomData:(NSData * _Nonnull)data status:(BlufiStatusCode)status; [Export("blufi:didPostCustomData:status:")] void Blufi_didPostCustomData(BlufiClient client, NSData data, BlufiStatusCode status); // @optional -(void)blufi:(BlufiClient * _Nonnull)client didReceiveCustomData:(NSData * _Nonnull)data status:(BlufiStatusCode)status; [Export("blufi:didReceiveCustomData:status:")] void Blufi_didReceiveCustomData(BlufiClient client, NSData data, BlufiStatusCode status); } #endregion #region 搜索蓝牙到客户端 // @interface ESPPeripheral : NSObject [BaseType(typeof(NSObject))] interface ESPPeripheral { // @property (nonatomic, strong) CBPeripheral * _Nonnull peripheral; [Export("peripheral", ArgumentSemantic.Strong)] CBPeripheral Peripheral { get; set; } // @property (nonatomic, strong) NSString * _Nonnull name; [Export("name", ArgumentSemantic.Strong)] string Name { get; set; } // @property (nonatomic, strong) NSUUID * _Nonnull uuid; [Export("uuid", ArgumentSemantic.Strong)] NSUuid Uuid { get; set; } // @property (assign, nonatomic) int rssi; [Export("rssi")] int Rssi { get; set; } // -(instancetype _Nonnull)initWithPeripheral:(CBPeripheral * _Nonnull)peripheral; [Export("initWithPeripheral:")] IntPtr Constructor(CBPeripheral peripheral); } // @interface HdlBluWi : NSObject [BaseType(typeof(NSObject))] interface HdlBluWi { // @property (copy, nonatomic) FBYBleDeviceBackBlock bleScanSuccessBlock; [Export("bleScanSuccessBlock", ArgumentSemantic.Copy)] FBYBleDeviceBackBlock BleScanSuccessBlock { get; set; } // +(instancetype)share; [Static] [Export("share")] HdlBluWi Share(); // -(void)stopScan; [Export("stopScan")] void StopScan(); // -(void)startScan:(FBYBleDeviceBackBlock)device; [Export("startScan:")] void StartScan(FBYBleDeviceBackBlock device); } // typedef void (^FBYBleDeviceBackBlock)(ESPPeripheral *); delegate void FBYBleDeviceBackBlock(ESPPeripheral arg0); #endregion }