я на коленках написал:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtQml.Models 2.12
import QtNfc 5.12
ApplicationWindow {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
ListModel {
id: listModel
}
NearField {
//filter: [
// NdefFilter {
// type: "urn:nfc:wkt:U"
// minimum: 1
// maximum: 1
// }
//]
//orderMatch: false
onMessageRecordsChanged: {
try {
console.log('messageRecordsChanged ')
listModel.append({
"name": JSON.stringify(messageRecords)
})
} catch (e) {
console.log('messageRecordsChanged error' + JSON.stringify(e))
}
}
onPollingChanged: {
console.log('pollingChanged ' + polling)
listModel.append({
"name": 'pollingChanged ' + polling
})
}
onTagFound: {
console.log('tagFound')
listModel.append({
"name": "tagFound"
})
}
onTagRemoved: {
console.log('tagRemoved')
listModel.append({
"name": "tagRemoved"
})
}
Component.onCompleted: {
// Polling should be true if
// QNearFieldManager::registerNdefMessageHandler() was successful;
// otherwise the platform requires manual polling mode.
if (!polling) {
polling = true
}
listModel.append({
"name": "onCompleted"
})
}
}
ColumnLayout {
anchors.fill: parent
Text {
text: qsTr("NFC Test Application")
}
ListView {
model: listModel
delegate: Text {
text: name
width: ListView.view.width
wrapMode: Text.WordWrap
}
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}
но получают onTagFound/onTagRemove, но не получаю данных о сообщении onMessageRecordsChanged не приходит.
Qt 5.15.2
2021-12-24 15:43:54.051 17986-18019/org.qtproject.example.nfcreader D/libnfcreader_arm64-v8a.so: qml: tagFound 2021-12-24 15:43:55.034 17986-18019/org.qtproject.example.nfcreader D/libnfcreader_arm64-v8a.so: qml: tagRemoved 2021-12-24 15:43:54.051 17986-18019/org.qtproject.example.nfcreader D/libnfcreader_arm64-v8a.so: qml: tagFound 2021-12-24 15:43:55.448 489-10879/? D/NxpTml: PN54X - I2C Read successful.....len = 6 2021-12-24 15:43:55.958 17986-18019/org.qtproject.example.nfcreader D/libnfcreader_arm64-v8a.so: qml: tagFound 2021-12-24 15:43:55.735 489-10880/? D/NxpTml: PN54X - Invoking I2C Write..... 2021-12-24 15:43:55.450 489-10879/? D/NxpTml: PN54X - I2C Read successful.....len = 5
Обсуждают сегодня