2
I am developing an application, where I want my iPhone touch information with Arduino from bluetooth 4.0. I was able to connect to Bluetooth and also send data through Serial, but I’m not able to read the Serial data. I used as a basis the example of evothings arduino-ble
, changed the linha 166
of the archive app.js
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
for the specific values of my bluetooth on 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 didn’t work and call me back Disconect
in the application’s "Status" field.
Can someone help me solve this problem?
Put to the question which lines 166 and 230.
– Taisbevalle
I put, line 166 refers to the first line of the first code placed in the question and line 230 refers to the first line of the second piece of code made available in the question
– Izabela Bastos
Put highlighted, there’s no way we know which line is only with this code.
– Taisbevalle