-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYYPeripheralModel.m
More file actions
59 lines (48 loc) · 1.52 KB
/
YYPeripheralModel.m
File metadata and controls
59 lines (48 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// YYPeripheralModel.m
// 优悦一族
//
// Created by MYO on 16/6/13.
// Copyright © 2016年 umed. All rights reserved.
//
#import "YYPeripheralModel.h"
@implementation YYPeripheralModel
+(instancetype)peripheralModel:(NSString *)name
address:(NSString *)address
peripheral:(CBPeripheral *)peripheral{
return [[self alloc] initWithModel:name address:address peripheral:peripheral];
}
-(instancetype)initWithModel:(NSString *)name
address:(NSString *)address
peripheral:(CBPeripheral *)peripheral {
self = [super init];
self.deviceName = name;
self.macAddress = address;
self.peripheral = peripheral;
return self;
}
-(NSUInteger)hash {
//long v1 = (long)(__bridge void *)_peripheral;
return 1;
}
-(BOOL)isEqual:(id)object {
if (self == object) return YES;
if (![object isMemberOfClass:self.class]) return NO;
YYPeripheralModel *other = object;
if (other.peripheral == _peripheral) {
return YES;
}
if ([other.peripheral.identifier.UUIDString isEqualToString:self.peripheral.identifier.UUIDString]) {
return YES;
}
if (!self.peripheral) {
self.peripheral = other.peripheral;
self.deviceName = other.peripheral.name;
return YES;
}
return NO;
}
-(NSString *)description {
return [NSString stringWithFormat:@"mac:%@,name:%@,uuidString:%@",self.macAddress,self.peripheral.name,self.peripheral.identifier.UUIDString];
}
@end