Hello,
I am a complete noobie with Bluetooth LE as well as the CC2540. I recently acquired a Droid Razr and the CC2540 Dev Kit and have been messing around with the sample programs provided by T.I. and Motorola. The Razr is apparently connecting with the 2540 running the SimpleBLEPeripheral as both the phone and the screen on the dev board indicate a connection, however whenever I try to readGattCharacteristics, the application crashes. Like I said, I have very little experience with this stuff. All I want to do is reimplement the SimpleBLEMaster functionality using the Razr to read values off the 2540 instead of another 2540 running the master program. If there are any tutorials or if anyone can provide sample code of the Razr reading values off of the 2540, even if it is another program running on the 2540 (not necessarily the SimpleBLEPeripheral program) and spitting back any sort of data I would be highly appreciative.
Here is the part of code in quesiton, which is pretty much taken straight from the Motorola sample
boolean status = false;
Toast.makeText(mContext, "connectifpending "+ device.getAddress(), Toast.LENGTH_SHORT).show();
if (device == null || callback1 == null) {
Log.i(TAG, "Enter Error condition");
String message = "Connection failed ! device=" + "";
Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
return;
}
String[] primaryServices = {};
Log.v(TAG, "connectLE call GATT get primary services ");
try {
primaryServices = mGattService.getGattPrimaryServices(device);
} catch (Exception e) {
Log.v(TAG,"Exception while calling Gatt getPrimaryServices");
}
if (primaryServices == null) {
String message = "Connection failed !primary device="+ "";
Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
return;
}
for (i = 0; i < primaryServices.length; i++) {
Log.v(TAG, "primary service " + primaryServices[i]);
if (primaryServices[i].equalsIgnoreCase(hrmUUID)) {
try {
status = mGattService.connectGatt(device, hrmUUID, callback1);
if (status == true){
mLeState = CONNECTING;
BluetoothLeReceiver.isDevicePickerPending = false;
} else {
String message = "Connection failed ! loop device="+ "";
Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Log.e(TAG,"Exception while calling gatt Connect");
}
//************THIS IS WHERE IT FAILS********************
mGattService.readGattCharacteristics(device, hrmUUID);
//*************************************************************
return;
}
}
if (i == primaryServices.length) {
Log.v(TAG,"Primary Service not found");
String message = "Connection failed!primary =" + Arrays.toString(primaryServices)+" hrm="+hrmUUID;
Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
}
Thanks a bundle