Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packetizing, 1to1 connections, reconnections #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions BLEMeshChat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
5AFAD98C8D32B5D6E0EF9FA3 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D875EBA6B1062FD39A2B28A /* libPods.a */; };
AD24AEBE1A58AA6700431AF9 /* BLEWriteSendQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = AD24AEBD1A58AA6700431AF9 /* BLEWriteSendQueue.m */; };
AD24AEC21A58AA8E00431AF9 /* BLEReadSendQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = AD24AEC11A58AA8E00431AF9 /* BLEReadSendQueue.m */; };
D90CF5E519EC8D2E006222AB /* BLERemotePeer.m in Sources */ = {isa = PBXBuildFile; fileRef = D90CF5E419EC8D2E006222AB /* BLERemotePeer.m */; };
D90CF5E819EC8D3C006222AB /* BLEMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D90CF5E719EC8D3C006222AB /* BLEMessage.m */; };
D90CF5EB19EC8DD8006222AB /* BLEMessagesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D90CF5EA19EC8DD8006222AB /* BLEMessagesViewController.m */; };
Expand Down Expand Up @@ -48,6 +50,10 @@
/* Begin PBXFileReference section */
2D1361F7F24E9C6CD2AF9A4B /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
6D875EBA6B1062FD39A2B28A /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
AD24AEBC1A58AA6700431AF9 /* BLEWriteSendQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BLEWriteSendQueue.h; sourceTree = "<group>"; };
AD24AEBD1A58AA6700431AF9 /* BLEWriteSendQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BLEWriteSendQueue.m; sourceTree = "<group>"; };
AD24AEC01A58AA8E00431AF9 /* BLEReadSendQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BLEReadSendQueue.h; sourceTree = "<group>"; };
AD24AEC11A58AA8E00431AF9 /* BLEReadSendQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BLEReadSendQueue.m; sourceTree = "<group>"; };
D90CF5E319EC8D2E006222AB /* BLERemotePeer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BLERemotePeer.h; sourceTree = "<group>"; };
D90CF5E419EC8D2E006222AB /* BLERemotePeer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BLERemotePeer.m; sourceTree = "<group>"; };
D90CF5E619EC8D3C006222AB /* BLEMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BLEMessage.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -142,6 +148,17 @@
name = Pods;
sourceTree = "<group>";
};
AD24AEBF1A58AA7400431AF9 /* Packetization */ = {
isa = PBXGroup;
children = (
AD24AEBC1A58AA6700431AF9 /* BLEWriteSendQueue.h */,
AD24AEBD1A58AA6700431AF9 /* BLEWriteSendQueue.m */,
AD24AEC01A58AA8E00431AF9 /* BLEReadSendQueue.h */,
AD24AEC11A58AA8E00431AF9 /* BLEReadSendQueue.m */,
);
name = Packetization;
sourceTree = "<group>";
};
D90CF5F019ECC0B2006222AB /* Messaging */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -312,6 +329,7 @@
D9F49A6C1A0EF3050035B1C8 /* Transport */ = {
isa = PBXGroup;
children = (
AD24AEBF1A58AA7400431AF9 /* Packetization */,
D9C4260C19E8A513004F7335 /* BLEScanner.h */,
D9C4260D19E8A513004F7335 /* BLEScanner.m */,
D9C4260F19E8A52B004F7335 /* BLEBroadcaster.h */,
Expand Down Expand Up @@ -374,7 +392,7 @@
TargetAttributes = {
D9C425DD19E89D9D004F7335 = {
CreatedOnToolsVersion = 6.0.1;
DevelopmentTeam = 4T8JLQR6GR;
DevelopmentTeam = F24HVJVBZE;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
Expand All @@ -383,6 +401,7 @@
};
D9C425F619E89D9D004F7335 = {
CreatedOnToolsVersion = 6.0.1;
DevelopmentTeam = F24HVJVBZE;
TestTargetID = D9C425DD19E89D9D004F7335;
};
};
Expand Down Expand Up @@ -469,6 +488,7 @@
D92B37E819EA918C0047AB38 /* BLERemotePeerTableViewCell.m in Sources */,
D9C4260E19E8A513004F7335 /* BLEScanner.m in Sources */,
D99FEAB819EFB66F003AE5CF /* BLEIdentityPacket.m in Sources */,
AD24AEC21A58AA8E00431AF9 /* BLEReadSendQueue.m in Sources */,
D92B37E519EA8AE40047AB38 /* UIViewController+BLE.m in Sources */,
D90CF5E519EC8D2E006222AB /* BLERemotePeer.m in Sources */,
D9C425E719E89D9D004F7335 /* BLEAppDelegate.m in Sources */,
Expand All @@ -477,6 +497,7 @@
D9F49A661A0EE3D80035B1C8 /* BLEDataReceipt.m in Sources */,
D97B7B9919F5D3C2000E1B8B /* BLERemotePeerTableViewController.m in Sources */,
D99FEAAD19EF4071003AE5CF /* BLEDataPacket.m in Sources */,
AD24AEBE1A58AA6700431AF9 /* BLEWriteSendQueue.m in Sources */,
D9F49A6A1A0EED030035B1C8 /* BLETransport.m in Sources */,
D90CF5EB19EC8DD8006222AB /* BLEMessagesViewController.m in Sources */,
D9D828E619F4F6DE004266F6 /* BLETransportStorage.m in Sources */,
Expand Down Expand Up @@ -600,12 +621,14 @@
baseConfigurationReference = 2D1361F7F24E9C6CD2AF9A4B /* Pods.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer: Chris Ballinger (9P62QGET7G)";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PREFIX_HEADER = BLEMeshChat/PrefixHeader.pch;
INFOPLIST_FILE = BLEMeshChat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
};
name = Debug;
};
Expand All @@ -614,12 +637,14 @@
baseConfigurationReference = E1441CDBDA6F311CDCBA029F /* Pods.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Distribution: Chris Ballinger (4T8JLQR6GR)";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PREFIX_HEADER = BLEMeshChat/PrefixHeader.pch;
INFOPLIST_FILE = BLEMeshChat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
};
name = Release;
};
Expand Down
19 changes: 17 additions & 2 deletions BLEMeshChat/BLEAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ @implementation BLEAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[DDLog addLogger:[DDTTYLogger sharedInstance]];
[DDLog addLogger:[DDASLLogger sharedInstance]];

/*
[[BLEDatabaseManager sharedInstance].readWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[transaction removeAllObjectsInAllCollections];
}];
*/

NSArray *centralManagerIdentifiers = launchOptions[UIApplicationLaunchOptionsBluetoothCentralsKey];
if (centralManagerIdentifiers) {
DDLogInfo(@"didFinishLaunchingWithOptions with UIApplicationLaunchOptionsBluetoothCentralsKey %@", centralManagerIdentifiers);
Expand Down Expand Up @@ -54,7 +61,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[BLELocalPeer setPrimaryIdentity:localPeer];
}
self.transportStorage = [[BLETransportStorage alloc] init];
self.transportManager = [[BLETransportManager alloc] initWithDataStorage:self.transportStorage];
self.transportManager = [[BLETransportManager sharedManager] addDataStorage:self.transportStorage];

if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeSound categories:nil];
Expand Down Expand Up @@ -97,7 +104,15 @@ - (void)applicationDidBecomeActive:(UIApplication *)application {
}

- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
[[BLETransportManager sharedManager] disconnectFromPeers];
[BLETransportManager sharedManager].remoteDevices = nil;
[[BLEDatabaseManager sharedInstance].readWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[transaction enumerateKeysInCollection:[[BLERemotePeer class] yapCollection] usingBlock:^(NSString *key, BOOL *stop) {
BLERemotePeer *peer = [transaction objectForKey:key inCollection:[[BLERemotePeer class] yapCollection]];
//NSLog(@"possible messages to send: %@", message);
peer.deviceID = nil;
}];
}];
}

@end
4 changes: 4 additions & 0 deletions BLEMeshChat/BLEBroadcaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
+ (CBUUID*) identityReadCharacteristicUUID;
+ (CBUUID*) identityWriteCharacteristicUUID;

- (void)writeMessage:(NSData*)data forPeer:(BLERemotePeer*)peer;
- (void)sendMessagesToPeer:(BLERemotePeer*)peer;


@end
Loading