Skip to content

Commit 6ad2e45

Browse files
committed
Clean
1 parent e6af6bd commit 6ad2e45

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

iOS/BluetoothController/BluetoothController/AppDelegate.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
// AppDelegate.h
33
// BluetoothController
44
//
5-
// Created by Matthieu Cherubini on 16/11/2015.
6-
// Copyright © 2015 Beach Creative. All rights reserved.
5+
// Created by mchrbn on 20/11/2015.
76
//
8-
97
#import <UIKit/UIKit.h>
108

119
@interface AppDelegate : UIResponder <UIApplicationDelegate>

iOS/BluetoothController/BluetoothController/AppDelegate.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// AppDelegate.m
33
// BluetoothController
44
//
5-
// Created by Matthieu Cherubini on 16/11/2015.
6-
// Copyright © 2015 Beach Creative. All rights reserved.
5+
// Created by mchrbn on 20/11/2015.
76
//
87

98
#import "AppDelegate.h"

iOS/BluetoothController/BluetoothController/Bluetooth.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Bluetooth.h
33
// BluetoothController
44
//
5-
// Created by Matthieu Cherubini on 20/11/2015.
6-
// Copyright © 2015 Beach Creative. All rights reserved.
5+
// Created by mchrbn on 20/11/2015.
76
//
87

98
#import <Foundation/Foundation.h>

iOS/BluetoothController/BluetoothController/Bluetooth.m

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@
22
// Bluetooth.m
33
// BluetoothController
44
//
5-
// Created by Matthieu Cherubini on 20/11/2015.
6-
// Copyright © 2015 Beach Creative. All rights reserved.
5+
// Created by mchrbn on 20/11/2015.
76
//
87

98
#import "Bluetooth.h"
109

1110
@implementation Bluetooth
1211
@synthesize cbcManager;
1312

13+
//Might have to change these values
1414
#define ARDUINO_SHIELD_NAME @"ZBModlue"
1515
#define SHIELD_RW_CHARACTERISTIC @"FFC1"
1616

17-
17+
//Init the Bluetooth Service
1818
-(void) start{
1919
cbcManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
2020
}
2121

22+
//Call this method to send values over BLE
2223
-(void) sendValues:(NSString*)value{
2324
[self.peripheral writeValue:[value dataUsingEncoding:NSUTF8StringEncoding] forCharacteristic:self.characteristic type:CBCharacteristicWriteWithResponse];
2425
NSLog(@"Sent data %@ to %@", value, self.characteristic.UUID);
2526
}
2627

27-
//Delegate showing discovered peripherals
28+
//Step #1 : Delegate showing discovered peripherals
2829
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
2930
NSLog(@"%@",peripheral.name);
3031
//Connect the central manager to the peripheral (Arduino Shield)
@@ -38,7 +39,7 @@ - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeri
3839
}
3940

4041

41-
//Delegate when a central manager successfully connected to a peripheral
42+
//Step #2 : Delegate when a central manager successfully connected to a peripheral
4243
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral{
4344
NSString *log = [NSString stringWithFormat:@"Connecting to %@", peripheral.name];
4445
NSLog(@"%@",log);
@@ -49,13 +50,15 @@ - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPerip
4950
}
5051

5152

53+
//Step #3 : Delegate when a central manager start to look for services on a connected peripheral
5254
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error{
5355
for (CBService *service in peripheral.services) {
5456
NSLog(@"Discovered service: %@", service.UUID);
5557
[peripheral discoverCharacteristics:nil forService:service];
5658
}}
5759

58-
60+
//Step #4 : Delegate when a central manager start to look for characteristic on a service
61+
//In the case of the ZBModule BLE Shield, the characteristic where values have to be sent is called FFC1
5962
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error{
6063
for (CBCharacteristic *characteristic in service.characteristics) {
6164
if([characteristic.UUID.UUIDString isEqualToString:SHIELD_RW_CHARACTERISTIC]){

iOS/BluetoothController/BluetoothController/ViewController.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// ViewController.h
33
// BluetoothController
44
//
5-
// Created by Matthieu Cherubini on 16/11/2015.
6-
// Copyright © 2015 Beach Creative. All rights reserved.
5+
// Created by mchrbn on 20/11/2015.
76
//
87

98
#import <UIKit/UIKit.h>

iOS/BluetoothController/BluetoothController/ViewController.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// ViewController.m
33
// BluetoothController
44
//
5-
// Created by Matthieu Cherubini on 16/11/2015.
6-
// Copyright © 2015 Beach Creative. All rights reserved.
5+
// Created by mchrbn on 20/11/2015.
76
//
87

98
#import "ViewController.h"
@@ -16,13 +15,15 @@ @implementation ViewController
1615

1716

1817
-(IBAction)clickSend:(id)sender{
19-
//NSLog(@"%@ - %@", _txtAngle1.text, _txtAngle2.text);
18+
//Send string from text box when button is pressed
2019
NSString *rotation = [NSString stringWithFormat:@"%@#%@", _txtAngle1.text, _txtAngle2.text];
2120
[bluetooth sendValues:rotation];
2221
}
2322

2423
- (void)viewDidLoad {
2524
[super viewDidLoad];
25+
26+
//Init the bluetooth
2627
bluetooth = [[Bluetooth alloc] init];
2728
[bluetooth start];
2829
}

0 commit comments

Comments
 (0)