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/HS4SModule.m | 257 +++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100644 libs/ihealth-sdk/ios/ReactNativeIOSLibrary/HS4SModule.m (limited to 'libs/ihealth-sdk/ios/ReactNativeIOSLibrary/HS4SModule.m') diff --git a/libs/ihealth-sdk/ios/ReactNativeIOSLibrary/HS4SModule.m b/libs/ihealth-sdk/ios/ReactNativeIOSLibrary/HS4SModule.m new file mode 100644 index 0000000..8538c6f --- /dev/null +++ b/libs/ihealth-sdk/ios/ReactNativeIOSLibrary/HS4SModule.m @@ -0,0 +1,257 @@ +// +// HS4SModule.m +// ReactNativeIOSLibrary +// +// Created by ihealth on 16/12/2. +// Copyright © 2016年 daiqingquan. All rights reserved. +// + +#import "HS4SModule.h" +#import "HSProfileModule.h" +#import "HSMacroFile.h" +#import "HS4Controller.h" +#import "HS4.h" +#import "iHealthDeviceManagerModule.h" +#import "ManageDeviceController.h" + + +#define EVENT_NOTIFY @"HS4.MODULE.NOTIFY" + +@implementation HS4SModule + + +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"]; +} + + +#pragma mark-init + +-(NSDictionary *)constantsToExport{ + return @{ + @"Event_Notify" : EVENT_NOTIFY + }; +} + ++ (BOOL)requiresMainQueueSetup +{ + return YES; +} +-(HS4 *)getHS4WithMac:(NSString *)mac{ + HS4Controller *controller = [HS4Controller shareIHHs4Controller]; + NSArray *hs4DeviceArray = [controller getAllCurrentHS4Instace]; + for (HS4 *tempHS4 in hs4DeviceArray) { + if ([mac isEqualToString:tempHS4.deviceID]){ + return tempHS4; + break; + } + } + return nil; +} + +#pragma mark +#pragma mark - Notification +#pragma mark - HS4 +-(void)DeviceConnectForHS4S:(NSNotification *)notify{ + HS4Controller *controller = [HS4Controller shareIHHs4Controller]; + NSArray *hs4DeviceArray = [controller getAllCurrentHS4Instace]; + + HS4 *hs4Instance = [hs4DeviceArray objectAtIndex:0]; +} + +#pragma mark +#pragma mark - Method + + +#pragma mark-获取连接设备 +RCT_EXPORT_METHOD(getAllConnectedDevices){ + + + NSArray*hs4array= [[HS4Controller shareIHHs4Controller] getAllCurrentHS4Instace]; + + NSMutableArray*deviceMacArray=[NSMutableArray array]; + + for (int i=0; i<[hs4array count]; i++) { + + HS4*hs4=[hs4array objectAtIndex:i]; + + [deviceMacArray addObject:hs4.deviceID]; + + } + + NSDictionary* deviceInfo = @{@"action":@"action_get_all_connected_devices",@"devices":deviceMacArray}; + [self sendEventWithName:EVENT_NOTIFY body:deviceInfo]; + + +} + + +RCT_EXPORT_METHOD(getOfflineData:(nonnull NSString*)mac){ + if ([self getHS4WithMac:mac] != nil) { + + NSLog(@"上传离线数据"); + [[self getHS4WithMac:mac]commandTransferMemorryData:^(NSDictionary *startDataDictionary) { + + + } DisposeProgress:^(NSNumber *progress) { + + } MemorryData:^(NSArray *historyDataArray) { + + if(historyDataArray != nil){ + + if(historyDataArray.count){ + + NSMutableArray*dataArray=[NSMutableArray array]; + + for (int i=0; i