我正在开发一款从德州仪器SensorTag CC2650读取数据的Android应用程序。
我能够读取电池电量和温度,但我无法从opt传感器读取Lux数据。
var data = [{
"Name": "Ronan",
"Email": "sodales.elit@eratSed.co.uk",
"Company": "Malesuada Malesuada Ltd"
}, {
"Name": "Calvin",
"Email": "amet.nulla@Vestibulumante.ca",
"Company": "Donec Egestas Foundation"
}, {
"Name": "Kane",
"Email": "Duis.mi@consectetueradipiscingelit.net",
"Company": "Arcu Institute"
}, {
"Name": "Kasper",
"Email": "magna.Phasellus.dolor@velconvallisin.co.uk",
"Company": "Tempor LLP"
}];
var doc = new jsPDF('p', 'pt', 'a4');
//Dimension of A4 in pts: 595 × 842
var pageWidth = 595;
var pageHeight = 842;
var pageMargin = 20;
pageWidth -= pageMargin * 2;
pageHeight -= pageMargin * 2;
var cellPadding = 10;
var cellWidth = 180;
var cellHeight = 70;
var lineHeight = 20;
var startX = pageMargin;
var startY = pageMargin;
doc.setFontSize(12);
var page = 1;
function createCard(item) {
//cell projection
var requiredWidth = startX + cellWidth + (cellPadding * 2);
var requiredHeight = startY + cellHeight + (cellPadding * 2);
if (requiredWidth <= pageWidth) {
textWriter(item, startX + cellPadding, startY + cellPadding);
startX = requiredWidth;
// startY += cellHeight + cellPadding;
} else {
if (requiredHeight > pageHeight) {
doc.addPage();
page++;
doc.setPage(page);
startY = pageMargin;
} else {
startY = requiredHeight;
}
startX = pageMargin;
textWriter(item, startX + cellPadding, startY + cellPadding);
startX = startX + cellWidth + (cellPadding * 2);
}
}
function textWriter(item, xAxis, yAxis) {
doc.text(item.Name, xAxis, yAxis);
doc.text(item.Email, xAxis, yAxis + lineHeight);
doc.text(item.Company, xAxis, yAxis + (lineHeight * 2));
}
for (var i = 0; i < data.length; i++) {
createCard(data[i]);
}
doc.save('grid.pdf');
我从我的gatt获得了luxometer服务,然后获取特性,设置启用传感器的值,写下更改,最后设置通知。
问题在于
if(service.getUuid().equals(UUID_OPT_SERV)){
luxService = gatt.getService(UUID_OPT_SERV);
BluetoothGattCharacteristic characteristic = luxService.getCharacteristic(UUID_OPT_CONF);
characteristic.setValue(new byte[] {0x01});
gatt.writeCharacteristic(characteristic);
gatt.setCharacteristicNotification(luxService.getCharacteristic(UUID_OPT_DATA), true);
lux = false;
break;
}
方法永远不会用结果调用它。
错误在哪里?