From d6d9a09d505d11148599a95a5be3e1351edbe0ac Mon Sep 17 00:00:00 2001 From: hc Date: Mon, 13 Apr 2026 15:17:52 +0800 Subject: Local iHealth SDK, device detail screen, iOS event fixes --- .../ios/ReactNativeIOSLibrary/NT13BModule.m | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 libs/ihealth-sdk/ios/ReactNativeIOSLibrary/NT13BModule.m (limited to 'libs/ihealth-sdk/ios/ReactNativeIOSLibrary/NT13BModule.m') diff --git a/libs/ihealth-sdk/ios/ReactNativeIOSLibrary/NT13BModule.m b/libs/ihealth-sdk/ios/ReactNativeIOSLibrary/NT13BModule.m new file mode 100644 index 0000000..158de43 --- /dev/null +++ b/libs/ihealth-sdk/ios/ReactNativeIOSLibrary/NT13BModule.m @@ -0,0 +1,103 @@ +// +// NT13BModule.m +// ReactNativeIOSLibrary +// +// Created by user on 2019/11/12. +// Copyright © 2019 daiqingquan. All rights reserved. +// + +#import "NT13BModule.h" +#import "NT13BHeader.h" +#import "NT13BProfileModule.h" + +@implementation NT13BModule +RCT_EXPORT_MODULE() +- (NSArray *)supportedEvents { + return @[@"event_notify", @"event_scan_device", @"event_scan_finish", + @"event_device_connected", @"event_device_connect_failed", + @"event_device_disconnect", @"event_authenticate_result", + @"event_notify_ts28b", @"event_notify_bg1", + @"action_connect_result_for_bg1"]; +} + + +- (NSDictionary *)constantsToExport +{ + return @{ @"Event_Notify": NT13B_EVENT_NOTIFY , + + }; +} + ++ (BOOL)requiresMainQueueSetup +{ + return YES; +} + + +-(NT13B*)getDeviceWithMac:(NSString*)mac{ + + NT13BController *controller = [NT13BController shareIHNT13BController]; + NSArray *nt13bDeviceArray = [controller getAllCurrentNT13BInstace]; + + for(NT13B *tempDevice in nt13bDeviceArray){ + if([mac isEqualToString:tempDevice.serialNumber]){ + + return tempDevice; + } + } + return nil; +} + +RCT_EXPORT_METHOD(getAllConnectedDevices){ + + + NSArray*nt13bDeviceArray= [[NT13BController shareIHNT13BController] getAllCurrentNT13BInstace]; + + NSMutableArray*deviceMacArray=[NSMutableArray array]; + + for (int i=0; i<[nt13bDeviceArray count]; i++) { + + NT13B *nt13b = [nt13bDeviceArray objectAtIndex:i]; + + [deviceMacArray addObject:nt13b.serialNumber]; + + } + + NSDictionary* deviceInfo = @{NT13B_ACTION:kACTION_GET_ALL_CONNECTED_DEVICES,NT13B_DEVICE:deviceMacArray}; + + [self sendEventWithName:NT13B_EVENT_NOTIFY body:deviceInfo]; +} + +RCT_EXPORT_METHOD(measure:(nonnull NSString *)mac){ + + + if ([self getDeviceWithMac:mac] != nil) { + + [[self getDeviceWithMac:mac] commandStartMeasure:^(NSDictionary *result) { + + NSDictionary* deviceInfo = @{NT13B_ACTION:@"action_measurement_result",NT13B_THERMOMETER_TYPE:[result objectForKey:@"bodyFlag"],NT13B_UNIT_FLAG:[result objectForKey:@"unit"],NT13B_RESULT:[result objectForKey:@"result"]}; + + [self sendEventWithName:NT13B_EVENT_NOTIFY body:deviceInfo]; + + + + }]; + + } + +} + +//断开连接 +RCT_EXPORT_METHOD(disconnect:(nonnull NSString *)mac){ + if ([self getDeviceWithMac:mac]!=nil) { + + [[self getDeviceWithMac:mac] commandDisconnect:^(BOOL result) { + + + }]; + }else{ + + } +} + +@end -- cgit