Skip to content

Commit

Permalink
fix(ObjC): fix build warning
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Froment <sfroment42@gmail.com>
  • Loading branch information
sfroment committed Dec 11, 2018
1 parent 66c1d32 commit a51aa24
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 71 deletions.
12 changes: 5 additions & 7 deletions core/network/ble/BertyCentralManagerDelegate.h
Expand Up @@ -6,16 +6,14 @@
// Copyright © 2018 berty. All rights reserved.
//

#ifndef BertyCentralManagerDelegate_h
#define BertyCentralManagerDelegate_h

#import "BertyUtils.h"
#import "BertyPeripheralDelegate.h"
#import "BertyDevice.h"
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "BertyPeripheralDelegate.h"

#ifndef BertyCentralManagerDelegate_h
#define BertyCentralManagerDelegate_h

extern void setConnClosed(char *);
//extern void setConnClosed(char *);

@interface BertyCentralManagerDelegate : NSObject <CBCentralManagerDelegate>

Expand Down
3 changes: 3 additions & 0 deletions core/network/ble/BertyCentralManagerDelegate.m
Expand Up @@ -8,6 +8,9 @@
//

#import "BertyCentralManagerDelegate.h"
#import "_cgo_export.h"
#import "BertyUtils.h"
#import "BertyDevice.h"

@implementation BertyCentralManagerDelegate

Expand Down
9 changes: 4 additions & 5 deletions core/network/ble/BertyDevice.h
Expand Up @@ -6,14 +6,14 @@
// Copyright © 2018 Facebook. All rights reserved.
//

#ifndef BertyDevice_h
#define BertyDevice_h

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "CountDownLatch.h"

extern void AddToPeerStoreC(char *, char*);
#ifndef BertyDevice_h
#define BertyDevice_h

//extern void AddToPeerStoreC(char *, char*);

@interface BertyDevice : NSObject

Expand Down Expand Up @@ -45,7 +45,6 @@ extern void AddToPeerStoreC(char *, char*);
- (void)write:(NSData *)data;
- (void)checkAndWrite;
- (void)popToSend;
- (void)writeIsRdy;

@end

Expand Down
1 change: 1 addition & 0 deletions core/network/ble/BertyDevice.m
Expand Up @@ -9,6 +9,7 @@

#import "BertyDevice.h"
#import "BertyUtils.h"
#import "_cgo_export.h"

@implementation BertyDevice

Expand Down
6 changes: 2 additions & 4 deletions core/network/ble/BertyPeripheralDelegate.h
Expand Up @@ -6,13 +6,11 @@
// Copyright © 2018 berty. All rights reserved.
//

#ifndef BertyCentralDelegate_h
#define BertyCentralDelegate_h

#import "BertyUtils.h"
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>

#ifndef BertyCentralDelegate_h
#define BertyCentralDelegate_h

@interface BertyPeripheralDelegate: NSObject <CBPeripheralDelegate>

Expand Down
2 changes: 2 additions & 0 deletions core/network/ble/BertyPeripheralDelegate.m
Expand Up @@ -8,6 +8,8 @@
//

#import "BertyPeripheralDelegate.h"
#import "BertyUtils.h"
#import "ble.h"

@implementation BertyPeripheralDelegate

Expand Down
11 changes: 5 additions & 6 deletions core/network/ble/BertyPeripheralManagerDelegate.h
Expand Up @@ -6,15 +6,14 @@
// Copyright © 2018 berty. All rights reserved.
//

#ifndef BertyPeripheralManagerDelegate_h
#define BertyPeripheralManagerDelegate_h

#import "BertyUtils.h"
#import "BertyPeripheralDelegate.h"
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "BertyPeripheralDelegate.h"

#ifndef BertyPeripheralManagerDelegate_h
#define BertyPeripheralManagerDelegate_h

extern void sendBytesToConn(char *, void *, int);
//extern void sendBytesToConn(char *, void *, int);

@interface BertyPeripheralManagerDelegate: NSObject <CBPeripheralManagerDelegate>

Expand Down
2 changes: 2 additions & 0 deletions core/network/ble/BertyPeripheralManagerDelegate.m
Expand Up @@ -8,6 +8,8 @@
//

#import "BertyPeripheralManagerDelegate.h"
#import "BertyUtils.h"
#import "_cgo_export.h"

@implementation BertyPeripheralManagerDelegate

Expand Down
64 changes: 31 additions & 33 deletions core/network/ble/BertyUtils.h
Expand Up @@ -8,50 +8,48 @@


#import "BertyDevice.h"
#import <CoreBluetooth/CoreBluetooth.h>
#import <Foundation/Foundation.h>

#ifndef BertyUtils_h
#define BertyUtils_h

#import <CoreBluetooth/CoreBluetooth.h>
#import <Foundation/Foundation.h>

extern CBCentralManager *centralManager;
extern CBPeripheralManager *peripheralManager;
extern CBCentralManager *__nullable centralManager;
extern CBPeripheralManager *__nullable peripheralManager;

@interface BertyUtils : NSObject

@property (nonatomic, strong) CBMutableService *bertyService;
@property (nonatomic, strong) CBMutableCharacteristic *maCharacteristic;
@property (nonatomic, strong) CBMutableCharacteristic *peerIDCharacteristic;
@property (nonatomic, strong) CBMutableCharacteristic *writerCharacteristic;
@property (nonatomic, strong) CBMutableCharacteristic *closerCharacteristic;
@property (nonatomic, strong) NSString *ma;
@property (nonatomic, strong) NSString *peerID;
@property (nonatomic, strong) CBUUID *serviceUUID;
@property (nonatomic, strong) CBUUID *maUUID;
@property (nonatomic, strong) CBUUID *peerUUID;
@property (nonatomic, strong) CBUUID *writerUUID;
@property (nonatomic, strong) CBUUID *closerUUID;
@property (nonatomic, strong) NSMutableDictionary *bertyDevices;
@property (nonatomic, strong, nonnull) CBMutableService *bertyService;
@property (nonatomic, strong, nonnull) CBMutableCharacteristic *maCharacteristic;
@property (nonatomic, strong, nonnull) CBMutableCharacteristic *peerIDCharacteristic;
@property (nonatomic, strong, nonnull) CBMutableCharacteristic *writerCharacteristic;
@property (nonatomic, strong, nonnull) CBMutableCharacteristic *closerCharacteristic;
@property (nonatomic, strong, nullable) NSString *ma;
@property (nonatomic, strong, nullable) NSString *peerID;
@property (nonatomic, strong, nonnull) CBUUID *serviceUUID;
@property (nonatomic, strong, nonnull) CBUUID *maUUID;
@property (nonatomic, strong, nonnull) CBUUID *peerUUID;
@property (nonatomic, strong, nonnull) CBUUID *writerUUID;
@property (nonatomic, strong, nonnull) CBUUID *closerUUID;
@property (nonatomic, strong, nonnull) NSMutableDictionary *bertyDevices;
@property (nonatomic, assign) BOOL CentralIsOn;
@property (nonatomic, assign) BOOL PeripharalIsOn;
@property (atomic, assign) BOOL serviceAdded;


+ (NSString *)arrayServiceToSting:(NSArray *)array;
+ (NSString *)arrayCharacteristicToSting:(NSArray *)array;
+ (BertyUtils *)sharedUtils;
+ (nullable BertyDevice *)getDevice:(CBPeripheral *)peripheral;
+ (nullable BertyDevice *)getDeviceFromRequest:(CBATTRequest *)request;
+ (nullable BertyDevice *)getDeviceFromMa:(NSString *)ma;
+ (nullable BertyDevice *)getDeviceFromPeerID:(NSString *)peerID;
+ (Boolean)inDevices:(CBPeripheral *)peripheral;
+ (Boolean)inDevicesWithPeerID:(NSString *)peerID;
+ (Boolean)inDevicesWithMa:(NSString *)Ma;
+ (void)setMa:(NSString *)ma;
+ (void)setPeerID:(NSString *)peerID;
+ (void)addDevice:(BertyDevice *)device;
+ (void)removeDevice:(BertyDevice *)device;
+ (nonnull NSString *)arrayServiceToSting:(nonnull NSArray *)array;
+ (nonnull NSString *)arrayCharacteristicToSting:(nonnull NSArray *)array;
+ (nonnull BertyUtils *)sharedUtils;
+ (nullable BertyDevice *)getDevice:(nonnull CBPeripheral *)peripheral;
+ (nullable BertyDevice *)getDeviceFromRequest:(nonnull CBATTRequest *)request;
+ (nullable BertyDevice *)getDeviceFromMa:(nonnull NSString *)ma;
+ (nullable BertyDevice *)getDeviceFromPeerID:(nonnull NSString *)peerID;
+ (Boolean)inDevices:(nonnull CBPeripheral *)peripheral;
+ (Boolean)inDevicesWithPeerID:(nonnull NSString *)peerID;
+ (Boolean)inDevicesWithMa:(nonnull NSString *)Ma;
+ (void)setMa:(nonnull NSString *)ma;
+ (void)setPeerID:(nonnull NSString *)peerID;
+ (void)addDevice:(nonnull BertyDevice *)device;
+ (void)removeDevice:(nonnull BertyDevice *)device;

@end

Expand Down
1 change: 1 addition & 0 deletions core/network/ble/BertyUtils.m
Expand Up @@ -8,6 +8,7 @@
//

#import "BertyUtils.h"
#import "ble.h"

@implementation BertyUtils

Expand Down
4 changes: 2 additions & 2 deletions core/network/ble/CountDownLatch.h
Expand Up @@ -6,11 +6,11 @@
// Copyright © 2018 berty. All rights reserved.
//

#import <Foundation/Foundation.h>

#ifndef CountDownLatch_h
#define CountDownLatch_h

#import <Foundation/Foundation.h>

@interface CountDownLatch : NSObject

@property (nonatomic, assign) int count;
Expand Down
19 changes: 8 additions & 11 deletions core/network/ble/ble.h
Expand Up @@ -6,22 +6,19 @@
// Copyright © 2018 sacha. All rights reserved.
//

#ifndef ble_h
#define ble_h

#import "BertyUtils.h"
#import "BertyCentralManagerDelegate.h"
#import "BertyPeripheralManagerDelegate.h"
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "BertyDevice.h"
#import <signal.h>

#ifndef ble_h
#define ble_h

void init(char *ma, char *peerID);
int startAdvertising();
int startDiscover();
int isDiscovering();
int startAdvertising(void);
int startDiscover(void);
int isDiscovering(void);
void connDevice(CBPeripheral *peripheral);
int isAdvertising();
int isAdvertising(void);
int dialPeer(char *peerID);
char *readPeerID(char *peerID);
NSData *Bytes2NSData(void *bytes, int length);
Expand Down
7 changes: 4 additions & 3 deletions core/network/ble/ble.m
Expand Up @@ -8,9 +8,10 @@
//

#import "ble.h"
#import <CoreBluetooth/CoreBluetooth.h>
#import <Foundation/Foundation.h>
#include <signal.h>
#import "BertyUtils.h"
#import "BertyDevice.h"
#import "BertyCentralManagerDelegate.h"
#import "BertyPeripheralManagerDelegate.h"

CBCentralManager *centralManager;
CBPeripheralManager *peripheralManager;
Expand Down

0 comments on commit a51aa24

Please sign in to comment.