| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514 |
- //
- // SensorlistVCViewController.m
- // FunSDKDemo
- //
- // Created by Megatron on 2019/3/25.
- // Copyright © 2019 Megatron. All rights reserved.
- //
- #import "SensorlistVCViewController.h"
- #import "SensorListCell.h"
- #import <FunSDK/FunSDK.h>
- #import <Masonry/Masonry.h>
- #import "SensorDeviceModel.h"
- #import "SensorInfo.h"
- #import "XMLinkWallSwitchCell.h"
- #import "Header.h"
- static NSString *const kSensorListCell = @"kSensorListCell";
- static NSString *const kXMLinkWallSwitchCell = @"kXMLinkWallSwitchCell";
- @interface SensorlistVCViewController () <UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic,assign) int msgHandle;
- @property (nonatomic,strong) NSMutableArray <SensorDeviceModel *>*dataSource;
- @property (nonatomic,strong) UITableView *tbList;
- @property (nonatomic,copy) NSString *curSceneID;
- @property (nonatomic,assign) int tempRow;
- @property (nonatomic,copy) NSString *tempName;
- @end
- @implementation SensorlistVCViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.view.backgroundColor = [UIColor whiteColor];
- self.automaticallyAdjustsScrollViewInsets = NO;
- self.navigationController.navigationBar.translucent = NO;
- self.edgesForExtendedLayout = UIRectEdgeNone;
-
- self.curSceneID = @"001";
-
- self.msgHandle = FUN_RegWnd((__bridge void*)self);
-
- [self configNav];
-
- [self configSubviews];
-
- [self myLayout];
-
- [self getSensorList];
- }
- #pragma mark - UIConfig
- - (void)configNav{
- self.edgesForExtendedLayout = UIRectEdgeBottom;
- self.navigationItem.title = TS("Sensor_Config");
- self.navigationController.navigationBar.titleTextAttributes=
- @{NSForegroundColorAttributeName:[UIColor whiteColor],
- NSFontAttributeName:[UIFont systemFontOfSize:17]};
- UIButton *btnLeft = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
- [btnLeft setBackgroundImage:[UIImage imageNamed:@"new_back.png"] forState:UIControlStateNormal];
- [btnLeft addTarget:self action:@selector(btnNavLeftClicked) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *btnNavLeft = [[UIBarButtonItem alloc] initWithCustomView:btnLeft];
- self.navigationItem.leftBarButtonItem = btnNavLeft;
-
- UIButton *btnRight = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
- [btnRight setBackgroundImage:[UIImage imageNamed:@"device_list_add"] forState:UIControlStateNormal];
- [btnRight addTarget:self action:@selector(btnNavRightClicked) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *btnNavRight = [[UIBarButtonItem alloc] initWithCustomView:btnRight];
-
- self.navigationItem.rightBarButtonItem = btnNavRight;
- }
- - (void)configSubviews{
- [self.view addSubview:self.tbList];
- }
- - (void)myLayout{
- [self.tbList mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self);
- }];
- }
- #pragma mark - EventAction
- - (void)btnNavLeftClicked{
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)btnNavRightClicked{
- [self beginAddSensor];
- }
- - (void)longPressHappened:(UILongPressGestureRecognizer *)gesture{
- CGPoint point = [gesture locationInView:self.tbList];
- NSIndexPath *indexPath = [self.tbList indexPathForRowAtPoint:point];
-
- if (indexPath.row >= self.dataSource.count || !indexPath) {
- return;
- }
-
- self.tempRow = (int)indexPath.row;
-
- __weak typeof(self)weakSelf = self;
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
- UIAlertAction *deleteAction = [UIAlertAction actionWithTitle:TS("Delete") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- NSDictionary *dicInfo = [weakSelf.dataSource objectAtIndex:self.tempRow].dicListInfo;
- [weakSelf beginDeleteSensor:[dicInfo objectForKey:@"DevID"]];
- }];
- UIAlertAction *changeNameAction = [UIAlertAction actionWithTitle:TS("Change_Name") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- [weakSelf showNameInputView];
- }];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:TS("Cancel") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-
- }];
- [alert addAction:deleteAction];
- [alert addAction:changeNameAction];
- [alert addAction:cancelAction];
- [self.navigationController presentViewController:alert animated:YES completion:nil];
- }
- - (void)showNameInputView{
- __weak typeof(self)weakSelf = self;
-
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:TS("Change_Name") message:nil preferredStyle:UIAlertControllerStyleAlert];
-
-
- UIAlertAction *actionOK = [UIAlertAction actionWithTitle:TS("OK") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- NSString *name = alert.textFields[0].text;
- if (name.length <= 0) {
- name = alert.textFields[0].placeholder;
- }
-
- self.tempName = name;
- NSDictionary *dicInfo = [weakSelf.dataSource objectAtIndex:self.tempRow].dicListInfo;
- [weakSelf changeSensorName:name sensorID:[dicInfo objectForKey:@"DevID"]];
- }];
-
- UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:TS("Cancel") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }];
-
- [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
- textField.placeholder = TS("Input_Name");
- }];
-
- [alert addAction:actionCancel];
- [alert addAction:actionOK];
-
- [self presentViewController:alert animated:YES completion:nil];
- }
- #pragma mark - Action
- #pragma mark GetList
- - (void)getSensorList{
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- [SVProgressHUD showWithStatus:@"Getting sensor list...."];
- //请求传感器列表
- char cfg[1024];
- sprintf(cfg, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"GetAllDevList\", \"Arg1\" : \"\", \"Arg2\" : \"\"} }");
- FUN_DevCmdGeneral(self.msgHandle, [channel.deviceMac UTF8String], 2046, "GetAllDevList", 0, \
- 20000, (char *)cfg, (int)strlen(cfg) + 1, -1, 0);
- }
- #pragma mark BeginAdd
- - (void)beginAddSensor{
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- [SVProgressHUD showWithStatus:@"Adding sensor...."];
- //开始配对
- char cfg[1024];
- sprintf(cfg, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"StartAddDev\", \"Arg1\" : \"60000\", \"Arg2\" : \"\"} }");
- FUN_DevCmdGeneral(self.msgHandle, [channel.deviceMac UTF8String], 2046, "StartAddDev", 4096, \
- 60000, (char *)cfg, (int)strlen(cfg) + 1, -1, 0);
- }
- - (void)stopAddSensor{
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- [SVProgressHUD showWithStatus:@"Stop Add sensor...."];
-
- char cfg[] = "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"StopAddDev\", \"Arg1\" : \"\", \"Arg2\" : \"\"} }";
- FUN_DevCmdGeneral(self.msgHandle, [channel.deviceMac UTF8String], 2046, "StopAddDev", 4096, \
- 5000, (char *)cfg, (int)strlen(cfg) + 1, -1, 0);
- }
- - (void)beginDeleteSensor:(NSString *)devID{
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- [SVProgressHUD showWithStatus:@"Deleting sensor...."];
- char cfg[1024];
- sprintf(cfg, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"DeleteDev\", \"Arg1\" : \"%s\", \"Arg2\" : \"\"} }", [devID UTF8String]);
- FUN_DevCmdGeneral(self.msgHandle, [channel.deviceMac UTF8String], 2046, "DeleteDev", 4096, 5000, (char *)cfg, (int)strlen(cfg) + 1, -1, 0);
- }
- #pragma mark ChangeName
- - (void)changeSensorName:(NSString *)name sensorID:(NSString *)devID{
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- [SVProgressHUD showWithStatus:@"Changing sensor name...."];
- char cfg[1024];
- sprintf(cfg, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"ChangeDevName\", \"Arg1\" : \"%s\", \"Arg2\" : \"%s\"} }", [devID UTF8String], [name UTF8String]);
- FUN_DevCmdGeneral(self.msgHandle, [channel.deviceMac UTF8String], 2046, "ChangeDevName", 4096, 5000, (char *)cfg, (int)strlen(cfg) + 1, -1, 0);
- }
- #pragma mark ChangeStatue
- - (void)beginChangeStatueOpen:(BOOL)ifOpen devID:(NSString *)devID{
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- [SVProgressHUD showWithStatus:@"Changing sensor statue...."];
- char cfg[1024];
- sprintf(cfg, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"ChangeDevStatus\", \"Arg1\" : \"%s\", \"Arg2\" : {\"sceneId\":\"%s\", \"status\":%d}} }", [devID UTF8String], [devID UTF8String], ifOpen ? 1 : 0);
- FUN_DevCmdGeneral(self.msgHandle, [channel.deviceMac UTF8String], 2046, "ChangeDevStatus", 4096, 5000, (char *)cfg, (int)strlen(cfg) + 1, -1, 0);
- }
- #pragma mark GetSceneMode
- - (void)beginGetSceneMode{
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- [SVProgressHUD showWithStatus:@"Getting sensor mode...."];
- char cfg3[1024];
- sprintf(cfg3, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"GetModeConfig\", \"Arg1\" : \"\", \"Arg2\" : \"\"} }");
- FUN_DevCmdGeneral(self.msgHandle, [channel.deviceMac UTF8String], 2046, "GetModeConfig", 0, \
- 20000, (char *)cfg3, (int)strlen(cfg3) + 1, -1, 0);
- }
- #pragma mark ChangeSceneMode
- - (void)beginChangeMode:(NSString *)modeID{
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- [SVProgressHUD showWithStatus:@"Changing sensor mode...."];
-
- char cfg[1024];
- sprintf(cfg, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"ChangeMode\", \"Arg1\" : \"%s\", \"Arg2\" : \"\"} }", [modeID UTF8String]);
- FUN_DevCmdGeneral(self.msgHandle, [channel.deviceMac UTF8String], 2046, "ChangeMode", 4096, 5000, (char *)cfg, (int)strlen(cfg) + 1, -1, 0);
- }
- #pragma mark GetSensorOnlineState
- - (void)requestSensorState:(NSString *)sensorID{
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- char cfg[1024];
- sprintf(cfg, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"GetLinkState\", \"Arg1\" : \"%s\", \"Arg2\" : \"%s\"} }", [channel.deviceMac UTF8String], [sensorID UTF8String]);
- FUN_DevCmdGeneral(self.msgHandle, [channel.deviceMac UTF8String], 2046, "GetLinkState", 4096, 5000, (char *)cfg, (int)strlen(cfg) + 1, -1, 0);
- }
- - (void)requestSensorDetailStatus:(NSString *)sensorID{
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- //请求设备信息
- char cfg2[1024];
- sprintf(cfg2, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"InquiryStatus\", \"Arg1\" : \"%s\", \"Arg2\" : \"\"} }", [sensorID UTF8String]);
- FUN_DevCmdGeneral(self.msgHandle, [channel.deviceMac UTF8String], 2046, "InquiryStatus", 4096, 5000, (char *)cfg2, (int)strlen(cfg2) + 1, -1, 0);
- }
- #pragma mark - Delegate
- #pragma mark UITableViewDataSource
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 55;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.dataSource.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- SensorDeviceModel *model = [self.dataSource objectAtIndex:indexPath.row];
- if ([[model.dicListInfo objectForKey:@"DevType"] intValue] == DEV_TYPE_WALLSWITCH) {
- XMLinkWallSwitchCell *cell = [tableView dequeueReusableCellWithIdentifier:kXMLinkWallSwitchCell];
- [cell configureCellWithModel:[self.dataSource objectAtIndex:indexPath.row]];
- __weak typeof(self) weakSelf = self;
- cell.WallSwitchClickedAction = ^(NSInteger index, BOOL selected) {
- int controlMask = 0;
- int ignoreMask = 0;
-
- if (selected) {
- if (index == 1) {
- ignoreMask = ignoreMask | 6;
- controlMask = controlMask | 1;
- }
- else if (index == 2){
- ignoreMask = ignoreMask | 5;
- controlMask = controlMask | 2;
- }
- else{
- ignoreMask = ignoreMask | 3;
- controlMask = controlMask | 4;
- }
- }
- else{
- if (index == 1) {
- ignoreMask = ignoreMask | 6;
- }
- else if (index == 2){
- ignoreMask = ignoreMask | 5;
- }
- else{
- ignoreMask = ignoreMask | 3;
- }
- }
-
-
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- char cfg[1024];
- sprintf(cfg, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"ChangeSwitchState\", \"Arg1\" : \"%s\", \"SensorState\" : {\"ControlMask\":%d,\"IgnoreMask\":%d}} }", [[model.dicListInfo objectForKey:@"DevID"] UTF8String], controlMask,ignoreMask);
- FUN_DevCmdGeneral(weakSelf.msgHandle, [channel.deviceMac UTF8String], 2046, "ChangeSwitchState", 4096, 5000, (char *)cfg, (int)strlen(cfg) + 1, -1, (int)indexPath.row);
- };
-
- return cell;
- }else{
- SensorListCell *cell = [tableView dequeueReusableCellWithIdentifier:kSensorListCell];
- cell.indexRow = indexPath.row;
-
- [cell listenStatue:^(int statue, int indexRow) {
- __weak typeof(self)weakSelf = self;
- NSDictionary *info = [self.dataSource objectAtIndex:indexRow].dicListInfo;
-
- if ([[info objectForKey:@"DevType"] intValue] == DEV_TYPE_SOCKET) {
- ChannelObject *channel = [[DeviceControl getInstance] getSelectChannel];
-
- char cfg[1024];
- sprintf(cfg, "{ \"Name\" : \"OPConsumerProCmd\", \"SessionID\" : \"0x00000002\", \"OPConsumerProCmd\" : {\"Cmd\" : \"ChangeSocketState\", \"Arg1\" : \"%s\", \"SensorState\" : {\"Command\":%d}} }", [[model.dicListInfo objectForKey:@"DevID"] UTF8String], statue);
- FUN_DevCmdGeneral(weakSelf.msgHandle, [channel.deviceMac UTF8String], 2046, "ChangeSocketState", 4096, 5000, (char *)cfg, (int)strlen(cfg) + 1, -1, (int)indexPath.row);
- }else{
- [weakSelf beginChangeStatueOpen:statue devID:[info objectForKey:@"DevID"]];
- }
-
- }];
-
- cell.lbTitle.text = [NSString stringWithFormat:@"Name:%@Type:%i",[model.dicListInfo objectForKey:@"DevName"],[[model.dicListInfo objectForKey:@"DevType"] intValue]];
-
- if ([[model.dicListInfo objectForKey:@"DevType"] intValue] == DEV_TYPE_SOCKET) {
- int status = [[model.dicStatusInfo objectForKey:@"DevStatus"] intValue];
- cell.statueSwitch.on = status == 1 ? YES : NO;
- }else{
- cell.statueSwitch.on = [[model.dicListInfo objectForKey:@"Status"] boolValue];
- }
-
-
- return cell;
- }
- }
- #pragma mark - FunSDK Result
- -(void)OnFunSDKResult:(NSNumber *)pParam {
- NSInteger nAddr = [pParam integerValue];
- MsgContent *msg = (MsgContent *)nAddr;
- switch (msg->id) {
- case EMSG_DEV_CMD_EN:
- {
- if (msg->param1 < 0) {
- [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%l",msg->param1]];
- } else{
- if (msg->param3 == 2046) {
- [SVProgressHUD dismiss];
-
- NSString *cmdName = [NSString stringWithUTF8String:msg->szStr];
- NSData *retJsonData = [NSData dataWithBytes:msg->pObject length:strlen(msg->pObject)];
-
- NSError *error;
- NSDictionary *retDic = [NSJSONSerialization JSONObjectWithData:retJsonData options:NSJSONReadingMutableLeaves error:&error];
- if (!retDic) {
- return;
- }
-
- int ret = [retDic[@"Ret"] intValue];
- if (ret != 100) {
- [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"ret%i",ret]];
- } else {
- if ([cmdName isEqualToString:@"StartAddDev"]) {
- NSDictionary *startAddDevDic = retDic[@"StartAddDev"];
- if (startAddDevDic) {
- [SVProgressHUD showSuccessWithStatus:@"Add Success"];
-
- // startAddDevDic contains sensor device info
- // key @"DevID" use this to modify sensor info like change DevName or Status
- // key @"DevName"
- // key @"DevType" distinguish device type just like gass or smoke sensor ,they have different DevType
- // key @"Status" this value meas alarm message will send to camera .Only keep it open (Status = 1) ,you can get push message.
- SensorDeviceModel *device = [[SensorDeviceModel alloc] init];
- device.dicListInfo = [startAddDevDic mutableCopy];
- [self.dataSource addObject:device];
- [self.tbList reloadData];
- }
- }else if ([cmdName isEqualToString:@"ChangeDevName"]){
- NSMutableDictionary *dicChange = [[self.dataSource objectAtIndex:self.tempRow] mutableCopy];
- [dicChange setObject:self.tempName forKey:@"DevName"];
- //[self.dataSource replaceObjectAtIndex:self.tempRow withObject:dicChange];
-
- [self.tbList reloadData];
- }else if ([cmdName isEqualToString:@"GetAllDevList"]){
- NSArray *arr = [retDic objectForKey:@"GetAllDevList"];
- if (arr && ![[NSNull null] isEqual:arr]) {
- [self.dataSource removeAllObjects];
- for (int i = 0; i < arr.count; i ++) {
- SensorDeviceModel *device = [[SensorDeviceModel alloc] init];
- device.dicListInfo = [[arr objectAtIndex:i] mutableCopy];
- [self.dataSource addObject:device];
-
- [self requestSensorState:[device.dicListInfo objectForKey:@"DevID"]];
- }
- }
-
- [self.tbList reloadData];
- }else if ([cmdName isEqualToString:@"GetLinkState"]){
- NSDictionary *linkStateDic = retDic[@"GetLinkState"];
- if (linkStateDic) {
- NSString *sensorID = linkStateDic[@"DevID"];
- int num = [linkStateDic[@"LinkState"] intValue];
- BOOL bOnline = num == 1 ? YES : NO;
-
- for (int i = 0; i < self.dataSource.count; i ++) {
- SensorDeviceModel *linkDev = self.dataSource[i];
- if ([[linkDev.dicListInfo objectForKey:@"DevID"] isEqualToString:sensorID]) {
- linkDev.ifOnline = bOnline;
- if (bOnline) {
- [self requestSensorDetailStatus:sensorID];
- }
-
- break;
- }
- }
-
- [self.tbList reloadData];
- }
- }else if ([cmdName isEqualToString:@"InquiryStatus"]){
- NSDictionary *inquiryStatusDic = retDic[@"InquiryStatus"];
- if (inquiryStatusDic) {
- NSString *sensorID = inquiryStatusDic[@"DevID"];
-
- for (int i = 0; i < self.dataSource.count; i ++) {
- SensorDeviceModel *linkDev = self.dataSource[i];
- if ([[linkDev.dicListInfo objectForKey:@"DevID"] isEqualToString:sensorID]) {
- linkDev.dicStatusInfo = [inquiryStatusDic mutableCopy];
- }
- }
- }
-
- [self.tbList reloadData];
- }else if ([cmdName isEqualToString:@"DeleteDev"]){
- [self.dataSource removeObjectAtIndex:self.tempRow];
-
- [self.tbList reloadData];
- }else if ([cmdName isEqualToString:@"ChangeSwitchState"]){
- if (msg->seq < self.dataSource.count) {
- SensorDeviceModel *model = [self.dataSource objectAtIndex:msg->seq];
- NSString *sensorID = [model.dicListInfo objectForKey:@"DevID"];
- [self requestSensorDetailStatus:sensorID];
- }
- }else if ([cmdName isEqualToString:@"ChangeSocketState"]){
- if (msg->seq < self.dataSource.count) {
- SensorDeviceModel *model = [self.dataSource objectAtIndex:msg->seq];
- NSString *sensorID = [model.dicListInfo objectForKey:@"DevID"];
- [self requestSensorDetailStatus:sensorID];
- }
- }else if ([cmdName isEqualToString:@"GetModeConfig"]) {
- NSDictionary *modeConfigDic = retDic[@"GetModeConfig"];
-
- NSString *sceneId = modeConfigDic[@"CurMode"];
-
- self.curSceneID = sceneId;
- }else if ([cmdName isEqualToString:@"StopAddDev"]){
-
- }
- }
- }
- }
- }
- }
- }
- #pragma mark - LazyLoad
- - (UITableView *)tbList{
- if (!_tbList) {
- _tbList = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tbList.delegate = self;
- _tbList.dataSource = self;
- [_tbList registerClass:[SensorListCell class] forCellReuseIdentifier:kSensorListCell];
- [_tbList registerClass:[XMLinkWallSwitchCell class] forCellReuseIdentifier:kXMLinkWallSwitchCell];
- UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHappened:)];
- longPress.minimumPressDuration = 0.5;
-
- [_tbList addGestureRecognizer:longPress];
-
- _tbList.tableFooterView = [[UIView alloc] init];
- }
-
- return _tbList;
- }
- - (NSMutableArray *)dataSource{
- if (!_dataSource) {
- _dataSource = [NSMutableArray arrayWithCapacity:0];
- }
-
- return _dataSource;
- }
- - (void)dealloc{
- FUN_UnRegWnd(self.msgHandle);
- }
- @end
|