I'm developing an application, where I want my iPhone to touch information with the Arduino from bluetooth 4.0. I was able to connect to bluetooth and I can also send data through Serial, but I can not read Serial data. I used the example of evothings arduino-ble
as a base, I changed the linha 166
of the app.js
file as shown below:
startReading: function(deviceHandle)
{
console.log('Enabling notifications');
// Turn notifications on.
app.write(
'writeDescriptor',
deviceHandle,
app.descriptorNotification,
new Uint8Array([1,0]));
// Start reading notifications.
evothings.ble.enableNotification(
deviceHandle,
app.characteristicRead,
function(data)
{
//document.getElementById('dados').innerHTML = data;
app.drawLines([new DataView(data).getUint8(0, true)]);
},
function(errorCode)
{
console.log('enableNotification error: ' + errorCode);
});
},
And I also changed the values of caracteristic
to the specific values of my bluetooth in linha 230
of app.js
getServices: function(deviceHandle)
{
console.log('Reading services...');
evothings.ble.readAllServiceData(deviceHandle, function(services)
{
// Find handles for characteristics and descriptor needed.
for (var si in services)
{
var service = services[si];
for (var ci in service.characteristics)
{
var characteristic = service.characteristics[ci];
var resultado="";
for (propriedade in characteristic) {
resultado += propriedade + ": " + characteristic[propriedade] + "\n";
};
document.getElementById('carac').innerHTML = resultado;
if (characteristic.uuid == '0000ffe1-0000-1000-8000-00805f9b34fb') // This line changed for HM10
{ document.getElementById('funcao').innerHTML = "entrei 1 if uuid carac";
app.characteristicRead = characteristic.handle;
}
else if (characteristic.uuid == '0000ffe1-0000-1000-8000-00805f9b34fb') // This line changed for HM10
{
document.getElementById('funcao').innerHTML = "entrei 2 if uuid carac";
app.characteristicWrite = characteristic.handle;
}
for (var di in characteristic.descriptors)
{
var descriptor = characteristic.descriptors[di];
if (characteristic.uuid == '0000ffe1-0000-1000-8000-00805f9b34fb' && // This line changed for HM10
descriptor.uuid == '00002902-0000-1000-8000-00805F9B34FB')
{
app.descriptorNotification = descriptor.handle;
}
}
}
}
if (app.characteristicRead && app.characteristicWrite && app.descriptorNotification)
{
console.log('RX/TX services found.');
app.startReading(deviceHandle);
}
else
{
console.log('ERROR: RX/TX services not found!');
}
},
function(errorCode)
{
console.log('readAllServiceData error: ' + errorCode);
});
},
But it did not work and returns me Disconect
in the "Status" field of the application.
Can anyone help me solve this problem?