I know little about Objective-C and BLE and hope someone would be kind enough to give me a hand
I bought a DFRobot Bluno with Accessory Shield to learn about BLE.
Bluno reference:
http://www.dfrobot.com/index.php?route=product/product&product_id=1044#.VeDEJDOFNaQ
Bluno Accessory Shield reference:
http://www.dfrobot.com/index.php?route=DFblog/blog&id=56
DFRobot is kind to provide sample code: https://github.com/DFRobot/BlunoBasicDemo/tree/master/IOS/BlunoBasicDemo
and source code for the Accessory Shield Demo: https://github.com/DFRobot/BlunoAccessoryShieldDemo
I got the demo built on a Mac and it worked well on my iPad and iPhone.
I bought B4i because I don't know much about Objective-C but I want to get up and running on iOS
At this time, I am having difficulties linking what I learnt from single-stepping the demo code in Objective-C and the B4i BLE Example.
I got bits and pieces of information, but I don't know how to paste them together to make it all work in B4i. OK, I admit I am not experienced with B4i either
From the Objective-C demo code, I got these pieces:
where dsetValue is an NSMutableDictionary
I also got "configureSensorTag" as such:
I found these 2 lines that could be helpful:
To read the potentiometer on the Accessory Shield, I found
and the Bluno would return
<KNOB>196;
The two Objective-C functions used to Write to the Bluno:
By single-stepping the B4i BLE Example, I found 2 services on the Bluno:
180A
DFB0
Under service 180A, characteristics are available such as:
Model Number String, size = 8, 44462042 6C756E6F
Under service DFB0, I found 2 characteristics: DFB1 and DFB2.
I have no idea how they all relate to each other. Documentations I found on BLE didn't help much either.
I experimented with ReadData, ReadData2 and WriteData in B4i in an attempt to do an Objective-C equivalent of [self writeMessage:@"<KNOB>;"] to read the potentiometer value, but they failed. That's because I don't know what parameters to pass to those Subs.
Would someone point me in the right direction please
Thank you,
kc
I bought a DFRobot Bluno with Accessory Shield to learn about BLE.
Bluno reference:
http://www.dfrobot.com/index.php?route=product/product&product_id=1044#.VeDEJDOFNaQ
Bluno Accessory Shield reference:
http://www.dfrobot.com/index.php?route=DFblog/blog&id=56
DFRobot is kind to provide sample code: https://github.com/DFRobot/BlunoBasicDemo/tree/master/IOS/BlunoBasicDemo
and source code for the Accessory Shield Demo: https://github.com/DFRobot/BlunoAccessoryShieldDemo
I got the demo built on a Mac and it worked well on my iPad and iPhone.
I bought B4i because I don't know much about Objective-C but I want to get up and running on iOS
At this time, I am having difficulties linking what I learnt from single-stepping the demo code in Objective-C and the B4i BLE Example.
I got bits and pieces of information, but I don't know how to paste them together to make it all work in B4i. OK, I admit I am not experienced with B4i either
From the Objective-C demo code, I got these pieces:
B4X:
[dsetValue:@"dfb0"forKey:@"DF xiaomi service UUID"];
[dsetValue:@"dfb1"forKey:@"DF xiaomi data UUID"];
[dsetValue:@"dfb1"forKey:@"DF xiaomi config UUID"];
I also got "configureSensorTag" as such:
B4X:
sCBUUID = df b0 10 80 80 9b 34 fb (returned from key "DF xiaomi service UUID”)
cCBUUID = df b1 10 80 80 9b 34 fb (returned from key "DF xiaomi config UUID”)
I found these 2 lines that could be helpful:
B4X:
#define kServiceID @"0000dfb0-0000-1000-8000-00805f9b34fb"
#define TI_BASE_LONG_UUID @"F0000000-0451-4000-B000-000000000000"
To read the potentiometer on the Accessory Shield, I found
B4X:
[self writeMessage:@"<KNOB>;"];
and the Bluno would return
<KNOB>196;
The two Objective-C functions used to Write to the Bluno:
B4X:
+(void)writeCharacteristic:(CBPeripheral*)peripheral sCBUUID:(CBUUID*)sCBUUID cCBUUID:(CBUUID*)cCBUUID data:(NSData*)data {
// Sends data to BLE peripheral to process HID and send EHIF command to PC
for(CBService*serviceinperipheral.services) {
if([service.UUIDisEqual:sCBUUID]) {
for(CBCharacteristic*characteristicinservice.characteristics) {
if([characteristic.UUIDisEqual:cCBUUID]) {
/* EVERYTHING IS FOUND, WRITE characteristic ! */
[peripheralwriteValue:dataforCharacteristic:characteristictype:CBCharacteristicWriteWithResponse];
}
}
}
}
}
- (void)writeMessage:(NSString*)msg
{
if(!_bConnected)
{
return;
}
NSData* bytes = [msgdataUsingEncoding:NSUTF8StringEncoding];
[BLEUtilitywriteCharacteristic:self.bleDevice.peripheralsCBUUID:[CBUUIDUUIDWithString:[self.bleDevice.setupDatavalueForKey:@"DF xiaomi service UUID"]]cCBUUID:[CBUUIDUUIDWithString:@"dfb1"]data:bytes];
}
By single-stepping the B4i BLE Example, I found 2 services on the Bluno:
180A
DFB0
Under service 180A, characteristics are available such as:
Model Number String, size = 8, 44462042 6C756E6F
Under service DFB0, I found 2 characteristics: DFB1 and DFB2.
I have no idea how they all relate to each other. Documentations I found on BLE didn't help much either.
I experimented with ReadData, ReadData2 and WriteData in B4i in an attempt to do an Objective-C equivalent of [self writeMessage:@"<KNOB>;"] to read the potentiometer value, but they failed. That's because I don't know what parameters to pass to those Subs.
Would someone point me in the right direction please
Thank you,
kc