Коммит 5cc76577 создал по автору OMP Education's avatar OMP Education
Просмотр файлов

NFCD API support

владелец ec089bb1
.apptool
.DS_Store
.mb2
.vscode
CMakeCache.txt
CMakeFiles
Makefile
QtCreatorDeployment.txt
RPMS
translations/*.qm
cmake_install.cmake
install_manifest.txt
*.autosave
*.list
*.md.backup
*.moc
*.o
*.pro.user*
Makefile
*.qm
*~
*_autogen
CMakeLists.txt.user*
moc_*.cpp
ru.auroraos.NfcUseCases
......@@ -9,3 +9,5 @@
* Icon Designer, 2022
* Alexey Andreev, <a.andreev@omp.ru>
* Reviewer, 2021-2022
* Vladislav Larionov
* Reviewer, 2023
# The 3-Clause BSD License
_Copyright (c) 2021-2022 Open Mobile Platform LLC_
_Copyright (c) 2021-2022 Open Mobile Platform LLC._
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
......
......@@ -5,28 +5,62 @@ The project provides an example of working with NFC stack.
The main purpose is to show not only what features are available to work with these API,
but also how to use them correctly.
The source code of the project is provided under [the license](LICENSE.BSD-3-CLAUSE.md),
## Terms of Use and Participation
The source code of the project is provided under [the license](LICENSE.BSD-3-Clause.md),
that allows it to be used in third-party applications.
The [contributor agreement](CONTRIBUTING.md) documents the rights granted by contributors
to the Open Mobile Platform.
of the Open Mobile Platform.
[Code of conduct](CODE_OF_CONDUCT.md) is a current set of rules of the Open Mobile
Platform which informs you how we expect the members of the community will interact
while contributing and communicating.
For information about contributors see [AUTHORS](AUTHORS.md).
Information about the contributors is specified in the [AUTHORS](AUTHORS.md) file.
## Project Structure
The project has a common structure of an application based on C++ and QML for Aurora OS.
All the C++ sources files are in [src](src) directory, QML sources are in [qml](qml) directory.
The project has a standard structure of an application based on C++ and QML for Aurora OS.
The features related to the examples are the following:
- The [PCSC Lite](submodules/pcschandler) module provides the ability to detect the connection of
NFC tags and output basic information on them. Also, when initializing this module, a list with
* **[ru.auroraos.NfcUseCases.pro](ru.auroraos.NfcUseCases.pro)** file
describes the project structure for the qmake build system.
* **[icons](icons)** directory contains application icons for different screen resolutions.
* **[qml](qml)** directory contains the QML source code and the UI resources.
* **[components](app/qml/components)** directory contains the custom UI components.
* **[cover](qml/cover)** directory contains the application cover implementations.
* **[images](qml/images)** directory contains the custom UI icons.
* **[pages](qml/pages)** directory contains the application pages.
* **[js](qml/js)** directory contains scripts for converting custom data types to strings.
* **[NfcUseCases.qml](qml/ru.auroraos.NfcUseCases.qml)** file
provides the application window implementation.
* **[rpm](rpm)** directory contains the rpm-package build settings.
* **[ru.auroraos.NfcUseCases.spec](rpm/ru.auroraos.NfcUseCases.spec)** file is used by rpmbuild tool.
* **[src](src)** directory contains the C++ source code.
* **[ru.auroraos.NfcUseCases.cpp](src/ru.auroraos.NfcUseCases.cpp)** file is the application entry point.
* **[translations](translations)** directory contains the UI translation files.
* **[ru.auroraos.NfcUseCases.desktop](ru.auroraos.NfcUseCases.desktop)** file
defines the display and parameters for launching the application.
* **[submodules](submodules)** directory contains implementations of modules to work with NFC.
* The [PCSC Lite](submodules/pcschandler) module provides the ability to detect the connection of
NFC tags and output a basic information on them. Also, when initializing this module, a list with
tag attributes and corresponding information is downloaded, which later also outputs on the screen.
- The pictures used for the UI are located in the [qml/images](qml/images) directory.
- QML documents of application pages are located in the [qml/pages](qml/pages) directory.
- Information about the project and the license is displayed in [AboutPage.qml](qml/pages/AboutPage.qml) file.
- The [main page](qml/pages/MainPage.qml) of the application provides a choice of the API used.
* The [NFCD](submodules/nfcdhandler) module is a DBus service for interaction with which a number
of [DBus interfaces](submodules/nfcdhandler/src/dbus) are implemented. A QML wrapper is implemented
for each interface class.
## Compatibility
The project is compatible with all current versions of the Aurora OS.
## Project Building
The project is built in the usual way using the Aurora SDK.
## Screenshots
![screenshots](screenshots/screenshots.png)
## This document in Russian / Перевод этого документа на русский язык
- [README.ru.md](README.ru.md)
# NFC Use Cases
В проекте приведен пример работы со стеком NFC.
Основная цель - показать не только, какие функции доступны для
работы с этими API, но и как их правильно использовать.
## Условия использования и участия
Исходный код проекта предоставляется по [лицензии](LICENSE.BSD-3-Clause.md),
которая позволяет использовать его в сторонних приложениях.
[Соглашение участника](CONTRIBUTING.md) регламентирует права,
предоставляемые участниками компании «Открытая Мобильная Платформа».
[Кодекс поведения](CODE_OF_CONDUCT.md) — это действующий набор правил
компании «Открытая Мобильная Платформа»,
который информирует об ожиданиях по взаимодействию между членами сообщества при общении и работе над проектами.
Информация об участниках указана в файле [AUTHORS](AUTHORS.md).
## Структура проекта
Проект имеет стандартную структуру приложения на базе C++ и QML для ОС Аврора.
* Файл **[ru.auroraos.NfcUseCases.pro](ru.auroraos.NfcUseCases.pro)**
описывает структуру проекта для системы сборки qmake.
* Каталог **[icons](icons)** содержит иконки приложения для поддерживаемых разрешений экрана.
* Каталог **[qml](qml)** содержит исходный код на QML и ресурсы интерфейса пользователя.
* Каталог **[components](app/qml/components)** содержит пользовательские компоненты пользовательского интерфейса.
* Каталог **[cover](qml/cover)** содержит реализации обложек приложения.
* Каталог **[images](qml/images)** содержит дополнительные иконки интерфейса пользователя.
* Каталог **[pages](qml/pages)** содержит страницы приложения.
* Каталог **[js](qml/js)** содержит скрипты для конвертации пользовательских типов данных в строки.
* Файл **[NfcUseCases.qml](qml/NfcUseCases.qml)**
предоставляет реализацию окна приложения.
* Каталог **[rpm](rpm)** содержит настройки сборки rpm-пакета.
* Файл **[ru.auroraos.NfcUseCases.spec](rpm/ru.auroraos.NfcUseCases.spec)**
используется инструментом rpmbuild.
* Каталог **[src](src)** содержит исходный код на C++.
* Файл **[main.cpp](src/main.cpp)** является точкой входа в приложение.
* Каталог **[translations](translations)** содержит файлы перевода интерфейса пользователя.
* Файл **[ru.auroraos.NfcUseCases.desktop](ru.auroraos.NfcUseCases.desktop)**
определяет отображение и параметры запуска приложения.
* Каталог **[submodules](submodules)** содержит реализацию модулей для работы с NFC.
* Модуль [PCSC Lite](submodules/pcschandler) обеспечивает возможность обнаружения подключения
NFC-меток и выводить основную информацию о них. Кроме того, при инициализации этого модуля загружается список
атрибутов меток и соответствующей информации, который впоследствии также выводится на экран.
* Модуль [NFCD](submodules/nfcdhandler) представляет собой DBus-сервис, для взаимодействия с которым реализован ряд
интерфейсов [DBus](submodules/nfcdhandler/src/dbus). Для каждого класса интерфейса реализована QML-обертка.
## Совместимость
Проект совместим с актуальными версиями ОС Аврора.
## Сборка проекта
Проект собирается обычным образом с помощью Аврора SDK.
## Снимки экранов
![screenshots](screenshots/screenshots.png)
## This document in English
- [README.md](README.md)
/*******************************************************************************
**
** Copyright (C) 2021-2022 Open Mobile Platform LLC.
** Contact: https://community.omprussia.ru/open-source
**
** This file is part of the NFC Use Cases project.
**
** Redistribution and use in source and binary forms,
** with or without modification, are permitted provided
** that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer
** in the documentation and/or other materials provided with the distribution.
** * Neither the name of the copyright holder nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
** OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS;
** OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*******************************************************************************/
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
import "pages"
......
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
DetailItem {
objectName: "alignedLabelItem"
alignment: Qt.AlignLeft
leftMargin: Theme.horizontalPageMargin
rightMargin: Theme.horizontalPageMargin
}
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
Item {
id: root
property alias buttonEnabled: button.enabled
property alias buttonText: button.text
property alias resultLabel: labelItem.label
property alias resultValue: labelItem.value
signal clicked()
objectName: "detailButtonItem"
anchors {
left: parent.left
right: parent.right
leftMargin: Theme.horizontalPageMargin
rightMargin: Theme.horizontalPageMargin
}
height: button.height
Button {
id: button
objectName: "button"
anchors {
top: parent.top
left: parent.left
}
width: Theme.buttonWidthExtraSmall
onClicked: root.clicked()
}
AlignedLabelItem {
id: labelItem
objectName: "labelItem"
anchors {
left: button.right
right: parent.right
verticalCenter: parent.verticalCenter
}
}
}
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
TextField {
objectName: "hexValueItem"
anchors {
left: parent.left
right: parent.right
}
horizontalAlignment: Text.AlignLeft
font.pixelSize: Theme.fontSizeSmall
color: errorHighlight ? Theme.errorColor : palette.highlightColor
inputMethodHints: Qt.ImhNoPredictiveText
validator: RegExpValidator {
objectName: "regExpValidator"
regExp: /^((0[xX])?([0-9a-fA-F]+))$/
}
}
/*******************************************************************************
**
** Copyright (C) 2021-2022 Open Mobile Platform LLC.
** Contact: https://community.omprussia.ru/open-source
**
** This file is part of the NFC Use Cases project.
**
** Redistribution and use in source and binary forms,
** with or without modification, are permitted provided
** that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer
** in the documentation and/or other materials provided with the distribution.
** * Neither the name of the copyright holder nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
** OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS;
** OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*******************************************************************************/
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
......
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
function yesOrNo(flag) {
return flag ? qsTr("yes") : qsTr("no");
}
function mapToString(map) {
var stringList = [];
for (var item in map) {
stringList.push(" · " + item + ": " + map[item]);
}
return stringList.join("\n");
}
function listToString(list) {
var stringList = [];
for (var i = 0; i < list.length; ++i) {
stringList.push(" · " + list[i]);
}
return stringList.join("\n");
}
function mode(mode) {
if (mode == NfcdMode.P2PInitiator) {
return qsTr("P2PInitiator");
} else if (mode == NfcdMode.ReaderWriter) {
return qsTr("ReaderWriter");
} else if (mode == NfcdMode.P2PTarget) {
return qsTr("P2PTarget");
} else if (mode == NfcdMode.CardEmulation) {
return qsTr("CardEmulation");
} else {
return qsTr("empty");
}
}
function modes(modes) {
return listToString(modes.map(UiStrings.mode));
}
function tagProtocol(tagProtocol) {
if (tagProtocol == NfcdTagProtocol.UnknownProtocol) {
return qsTr("unknown");
} else if (tagProtocol == NfcdTagProtocol.Type1) {
return qsTr("type 1");
} else if (tagProtocol == NfcdTagProtocol.Type2) {
return qsTr("type 2");
} else if (tagProtocol == NfcdTagProtocol.Type3) {
return qsTr("type 3");
} else if (tagProtocol == NfcdTagProtocol.Type4A) {
return qsTr("type 4A");
} else if (tagProtocol == NfcdTagProtocol.Type4B) {
return qsTr("type 4B");
} else if (tagProtocol == NfcdTagProtocol.DEP) {
return qsTr("DEP");
} else {
return qsTr("empty");
}
}
function tagTechnology(tagTechnology) {
if (tagTechnology == NfcdTagTechnology.UnknownTechnology) {
return qsTr("unknown");
} else if (tagTechnology == NfcdTagTechnology.NfcA) {
return qsTr("NFC A");
} else if (tagTechnology == NfcdTagTechnology.NfcB) {
return qsTr("NFC B");
} else if (tagTechnology == NfcdTagTechnology.NfcF) {
return qsTr("NFC F");
} else {
return qsTr("empty");
}
}
function tagType(tagType) {
return tagType;
}
function ndefFlag(ndefFlag) {
if (ndefFlag == NfcdNdefFlag.FirstRecord) {
return qsTr("first record");
} else if (ndefFlag == NfcdNdefFlag.LastRecord) {
return qsTr("last record");
} else {
return qsTr("empty");
}
}
function ndefFlags(ndefFlags) {
return listToString(ndefFlags.map(UiStrings.ndefFlag));
}
function ndefTNF(ndefTNF) {
if (ndefTNF == NfcdNdefTNF.TNF0) {
return qsTr("TNF0");
} else if (ndefTNF == NfcdNdefTNF.TNF1) {
return qsTr("TNF1");
} else if (ndefTNF == NfcdNdefTNF.TNF2) {
return qsTr("TNF2");
} else if (ndefTNF == NfcdNdefTNF.TNF3) {
return qsTr("TNF3");
} else if (ndefTNF == NfcdNdefTNF.TNF4) {
return qsTr("TNF4");
} else {
return qsTr("empty");
}
}
/*******************************************************************************
**
** Copyright (C) 2021-2022 Open Mobile Platform LLC.
** Contact: https://community.omprussia.ru/open-source
**
** This file is part of the NFC Use Cases project.
**
** Redistribution and use in source and binary forms,
** with or without modification, are permitted provided
** that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer
** in the documentation and/or other materials provided with the distribution.
** * Neither the name of the copyright holder nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
** OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS;
** OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*******************************************************************************/
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
......
/*******************************************************************************
**
** Copyright (C) 2021-2022 Open Mobile Platform LLC.
** Contact: https://community.omprussia.ru/open-source
**
** This file is part of the NFC Use Cases project.
**
** Redistribution and use in source and binary forms,
** with or without modification, are permitted provided
** that the following conditions are met:
**
** * Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright notice,
** this list of conditions and the following disclaimer
** in the documentation and/or other materials provided with the distribution.
** * Neither the name of the copyright holder nor the names of its contributors
** may be used to endorse or promote products derived from this software
** without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
** FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
** OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS;
** OR BUSINESS INTERRUPTION)
** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
** EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
*******************************************************************************/
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
......@@ -65,6 +29,13 @@ Page {
description: qsTr("Working with NFC cards using the PCSC Lite API")
page: "PcscPage.qml"
}
ListElement {
objectName: "nfcdItem"
name: qsTr("NFCD")
description: qsTr("Working with NFC cards using NFCD DBus interfaces")
page: "NfcdDaemonPage.qml"
}
}
Component {
......
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
import ru.auroraos.NfcUseCases 1.0
import "../js/UiStrings.js" as UiStrings
import "../components"
Page {
id: nfcdAdapterPage
property string title
property string path
objectName: "nfcdAdapterPage"
NfcdAdapterHandler {
id: nfcdAdapterHandler
objectName: "nfcdAdapterHandler"
adapterPath: path
}
SilicaFlickable {
objectName: "flickableArea"
anchors.fill: parent
contentHeight: mainColumn.implicitHeight
clip: true
VerticalScrollDecorator {
objectName: "scrollDecorator"
}
Column {
id: mainColumn
objectName: "mainColumn"
anchors.fill: parent
spacing: Theme.paddingMedium
PageHeader {
objectName: "pageHeader"
title: nfcdAdapterPage.title
}
SectionHeader {
objectName: "infoSection"
text: qsTr("Adapter info")
}
AlignedLabelItem {
objectName: "interfaceVersionItem"
label: qsTr("Interface version:")
value: nfcdAdapterHandler.interfaceVersion
}
AlignedLabelItem {
objectName: "enabledItem"
label: qsTr("Enabled:")
value: UiStrings.yesOrNo(nfcdAdapterHandler.enabled)
}
AlignedLabelItem {
objectName: "poweredItem"
label: qsTr("Powered:")
value: UiStrings.yesOrNo(nfcdAdapterHandler.powered)
}
AlignedLabelItem {
objectName: "targetPresentItem"
label: qsTr("Target present:")
value: UiStrings.yesOrNo(nfcdAdapterHandler.targetPresent)
}
AlignedLabelItem {
objectName: "supportedModesItem"
label: qsTr("Supported modes:")
value: UiStrings.modes(nfcdAdapterHandler.supportedModes)
}
AlignedLabelItem {
objectName: "modeItem"
label: qsTr("Mode:")
value: UiStrings.mode(nfcdAdapterHandler.mode)
}
SectionHeader {
objectName: "availableTagsSection"
text: qsTr("Available tags")
}
SilicaListView {
objectName: "tagsView"
width: parent.width
height: contentHeight
delegate: tagItemDelegateComponent
model: nfcdAdapterHandler.tagsModel
clip: true
}
Component {
id: tagItemDelegateComponent
ListItem {
id: tagItem
objectName: "tagItem_%1".arg(model.index)
width: parent.width
contentHeight: tagItemColumn.height + Theme.paddingLarge
onClicked: pageStack.push(Qt.resolvedUrl("NfcdTagPage.qml"), {
title: qsTr("Tag '%1'").arg(model.path),
path: model.path
})
HighlightImage {
id: tagItemIcon
objectName: "tagItemIcon"
anchors {
left: parent.left
leftMargin: Theme.horizontalPageMargin
}
source: "image://theme/icon-m-device"
sourceSize {
width: Theme.iconSizeLarge
height: Theme.iconSizeLarge
}
highlightColor: palette.highlightColor
highlighted: tagItem.highlighted
}
Column {
id: tagItemColumn
objectName: "tagItemColumn"
anchors {
left: tagItemIcon.right
right: parent.right
leftMargin: Theme.horizontalPageMargin
rightMargin: Theme.horizontalPageMargin
verticalCenter: parent.verticalCenter
}
Label {
objectName: "nameItem"
text: qsTr("Tag '%1'").arg(model.path)
color: tagItem.highlighted ? palette.highlightColor : palette.primaryColor
font.bold: true
}
AlignedLabelItem {
objectName: "protocolItem"
label: qsTr("Protocol:")
value: UiStrings.tagProtocol(model.protocol)
leftMargin: 0
}
AlignedLabelItem {
objectName: "technologyItem"
label: qsTr("Technology:")
value: UiStrings.tagTechnology(model.technology)
leftMargin: 0
}
AlignedLabelItem {
objectName: "typeItem"
label: qsTr("Type:")
value: UiStrings.tagType(model.type)
leftMargin: 0
}
}
}
}
}
}
}
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
import ru.auroraos.NfcUseCases 1.0
import "../js/UiStrings.js" as UiStrings
import "../components"
Page {
id: nfcdDaemonPage
property string title
property string path
property string description
objectName: "nfcdDaemonPage"
NfcdDaemonHandler {
id: nfcdDaemonHandler
objectName: "nfcdDaemonHandler"
}
SilicaFlickable {
objectName: "flickableArea"
anchors.fill: parent
contentHeight: mainColumn.implicitHeight
clip: true
VerticalScrollDecorator {
objectName: "scrollDecorator"
}
Column {
id: mainColumn
objectName: "mainColumn"
anchors.fill: parent
spacing: Theme.paddingMedium
PageHeader {
objectName: "pageHeader"
title: nfcdDaemonPage.title
description: nfcdDaemonPage.description
}
SectionHeader {
objectName: "daemonInfoSection"
text: qsTr("Daemon info")
}
AlignedLabelItem {
objectName: "daemonVersionItem"
label: qsTr("Daemon version:")
value: nfcdDaemonHandler.daemonVersion
}
AlignedLabelItem {
objectName: "interfaceVersionItem"
label: qsTr("Interface version:")
value: nfcdDaemonHandler.interfaceVersion
}
SectionHeader {
objectName: "availableAdaptersSection"
text: qsTr("Available adapters")
}
SilicaListView {
objectName: "adaptersView"
width: parent.width
height: contentHeight
delegate: adapterItemDelegateComponent
model: nfcdDaemonHandler.adaptersModel
clip: true
}
Component {
id: adapterItemDelegateComponent
ListItem {
id: adapterItem
objectName: "adapterItem_%1".arg(model.index)
anchors {
left: parent.left
right: parent.right
}
contentHeight: adapterItemColumn.height + Theme.paddingLarge
enabled: model.enabled && model.powered
opacity: enabled ? 1.0 : Theme.opacityLow
onClicked: pageStack.push(Qt.resolvedUrl("NfcdAdapterPage.qml"), {
title: qsTr("Adapter '%1'").arg(model.path),
path: model.path
})
HighlightImage {
id: adapterItemIcon
objectName: "adapterItemIcon"
anchors {
left: parent.left
leftMargin: Theme.horizontalPageMargin
}
source: "image://theme/icon-m-nfc"
sourceSize {
width: Theme.iconSizeLarge
height: Theme.iconSizeLarge
}
highlightColor: palette.highlightColor
highlighted: adapterItem.highlighted
}
Column {
id: adapterItemColumn
objectName: "adapterItemColumn"
anchors {
left: adapterItemIcon.right
right: parent.right
leftMargin: Theme.horizontalPageMargin
rightMargin: Theme.horizontalPageMargin
verticalCenter: parent.verticalCenter
}
Label {
objectName: "nameItem"
text: qsTr("Adapter '%1'").arg(model.path)
color: adapterItem.highlighted ? palette.highlightColor : palette.primaryColor
font.bold: true
}
AlignedLabelItem {
objectName: "enabledItem"
label: qsTr("Enabled:")
value: UiStrings.yesOrNo(model.enabled)
leftMargin: 0
}
AlignedLabelItem {
objectName: "poweredItem"
label: qsTr("Powered:")
value: UiStrings.yesOrNo(model.powered)
leftMargin: 0
}
}
}
}
}
}
}
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
import ru.auroraos.NfcUseCases 1.0
import "../components"
Item {
id: nfcdIsoDepIface
property string path
objectName: "nfcdIsoDepIface"
NfcdIsoDepHandler {
id: nfcdIsoDepHandler
objectName: "nfcdIsoDepHandler"
tagPath: nfcdIsoDepIface.path
}
SilicaFlickable {
objectName: "flickableArea"
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: buttonsArea.top
bottomMargin: Theme.paddingMedium
}
contentHeight: mainColumn.implicitHeight
clip: true
VerticalScrollDecorator {
objectName: "scrollDecorator"
}
Column {
id: mainColumn
objectName: "mainColumn"
anchors {
top: parent.top
left: parent.left
right: parent.right
}
spacing: Theme.paddingMedium
SectionHeader {
objectName: "isoDepInfoSection"
text: qsTr("IsoDep info")
}
AlignedLabelItem {
objectName: "interfaceVersionItem"
label: qsTr("Interface version:")
value: nfcdIsoDepHandler.interfaceVersion
}
SectionHeader {
objectName: "requestSection"
text: qsTr("Request")
}
HexValueItem {
id: claValueItem
objectName: "claValueItem"
label: qsTr("CLA")
text: "0x00"
}
HexValueItem {
id: insValueItem
objectName: "insValueItem"
label: qsTr("INS")
text: "0xA4"
}
HexValueItem {
id: p1ValueItem
objectName: "p1ValueItem"
label: qsTr("P1")
text: "0x04"
}
HexValueItem {
id: p2ValueItem
objectName: "p2ValueItem"
label: qsTr("P2")
text: "0x00"
}
HexValueItem {
id: dataValueItem
objectName: "dataValueItem"
label: qsTr("Data")
text: "0x325041592E5359532E444446303100"
}
HexValueItem {
id: leValueItem
objectName: "leValueItem"
label: qsTr("Length")
text: "0x0E"
}
SectionHeader {
objectName: "resultSection"
text: qsTr("Result")
}
AlignedLabelItem {
id: sw1ResultItem
objectName: "sw1ResultItem"
label: qsTr("SW1:")
}
AlignedLabelItem {
id: sw2ResultItem
objectName: "sw2ResultItem"
label: qsTr("SW2:")
}
AlignedLabelItem {
id: responseResultItem
objectName: "responseResultItem"
label: qsTr("Response:")
}
}
}
Rectangle {
id: buttonsArea
objectName: "buttonsArea"
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
topMargin: Theme.paddingMedium
}
height: buttonsLayout.implicitHeight + Theme.paddingMedium * 2
color: Theme.highlightDimmerColor
ButtonLayout {
id: buttonsLayout
objectName: "buttonsLayout"
anchors {
fill: parent
topMargin: Theme.paddingMedium
}
rowSpacing: Theme.paddingMedium
columnSpacing: Theme.paddingMedium
Button {
objectName: "transmitButton"
text: qsTr("Transmit")
onClicked: {
/*
* Example: SELECT PPSE = '00 A4 04 00 0E 32 50 41 59 2E 53 59 53 2E 44 44 46 30 31 00'
* 0x00 - CLA Class
* 0xA4 - INS Instruction
* 0x04 - P1 Parameter 1
* 0x00 - P2 Parameter 2
* 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31, 0x00 (ending marker) - AID
* 0x0E - Length
*/
var result = nfcdIsoDepHandler.transmit(Number(claValueItem.text), Number(insValueItem.text),
Number(p1ValueItem.text), Number(p2ValueItem.text),
dataValueItem.text, Number(leValueItem.text));
sw1ResultItem.value = "0x" + result.sw1.toString(16).toUpperCase();
sw2ResultItem.value = "0x" + result.sw2.toString(16).toUpperCase();
if (result.response.length > 0)
responseResultItem.value = "0x" + result.response.toString(16).toUpperCase();
}
}
Button {
objectName: "resetButton"
text: qsTr("Reset")
onClicked: nfcdIsoDepHandler.reset()
}
}
}
}
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
import ru.auroraos.NfcUseCases 1.0
import "../js/UiStrings.js" as UiStrings
import "../components"
Page {
id: nfcdNdefPage
property string title
property string path
objectName: "nfcdNdefPage"
NfcdNdefHandler {
id: nfcdNdefHandler
objectName: "nfcdNdefHandler"
recordPath: path
}
SilicaFlickable {
objectName: "flickableArea"
anchors.fill: parent
contentHeight: mainColumn.implicitHeight
clip: true
VerticalScrollDecorator {
objectName: "scrollDecorator"
}
Column {
id: mainColumn
objectName: "mainColumn"
anchors {
top: parent.top
left: parent.left
right: parent.right
}
spacing: Theme.paddingMedium
PageHeader {
objectName: "pageHeader"
title: nfcdNdefPage.title
}
SectionHeader {
objectName: "recordInfoSection"
text: qsTr("NDEF record info")
}
AlignedLabelItem {
objectName: "interfaceVersionItem"
label: qsTr("Interface version:")
value: nfcdNdefHandler.interfaceVersion
}
AlignedLabelItem {
objectName: "flagsItem"
label: qsTr("Flags:")
value: UiStrings.ndefFlags(nfcdNdefHandler.flags)
forceValueBelow: true
}
AlignedLabelItem {
objectName: "typeNameFormatItem"
label: qsTr("Type name format:")
value: UiStrings.ndefTNF(nfcdNdefHandler.typeNameFormat)
}
AlignedLabelItem {
objectName: "typeItem"
label: qsTr("Type:")
value: nfcdNdefHandler.type
}
AlignedLabelItem {
objectName: "idItem"
label: qsTr("ID:")
value: nfcdNdefHandler.id
}
AlignedLabelItem {
objectName: "payloadItem"
label: qsTr("Payload:")
value: nfcdNdefHandler.payload
}
AlignedLabelItem {
objectName: "rawDataItem"
label: qsTr("Raw data:")
value: nfcdNdefHandler.rawData
}
AlignedLabelItem {
objectName: "interfacesItem"
label: qsTr("Interfaces:")
value: UiStrings.listToString(nfcdNdefHandler.interfaces)
forceValueBelow: true
}
}
}
}
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
import ru.auroraos.NfcUseCases 1.0
import "../js/UiStrings.js" as UiStrings
import "../components"
Item {
id: nfcdTagIface
property string path
objectName: "nfcdTagIface"
NfcdTagHandler {
id: nfcdTagHandler
objectName: "nfcdTagHandler"
tagPath: nfcdTagIface.path
}
SilicaFlickable {
objectName: "flickableArea"
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: buttonsArea.top
bottomMargin: Theme.paddingMedium
}
contentHeight: mainColumn.implicitHeight
clip: true
VerticalScrollDecorator {
objectName: "scrollDecorator"
}
Column {
id: mainColumn
objectName: "mainColumn"
anchors {
top: parent.top
left: parent.left
right: parent.right
}
spacing: Theme.paddingMedium
SectionHeader {
objectName: "tagInfoSection"
text: qsTr("Tag info")
}
AlignedLabelItem {
objectName: "interfaceVersionItem"
label: qsTr("Interface version:")
value: nfcdTagHandler.interfaceVersion
}
AlignedLabelItem {
objectName: "presentItem"
label: qsTr("Present:")
value: UiStrings.yesOrNo(nfcdTagHandler.present)
}
AlignedLabelItem {
objectName: "protocolItem"
label: qsTr("Protocol:")
value: UiStrings.tagProtocol(nfcdTagHandler.protocol)
}
AlignedLabelItem {
objectName: "technologyItem"
label: qsTr("Technology:")
value: UiStrings.tagTechnology(nfcdTagHandler.technology)
}
AlignedLabelItem {
objectName: "typeItem"
label: qsTr("Type:")
value: UiStrings.tagType(nfcdTagHandler.type)
}
AlignedLabelItem {
objectName: "pollParametersItem"
label: qsTr("Poll parameters:")
value: UiStrings.mapToString(nfcdTagHandler.pollParameters)
forceValueBelow: true
}
SectionHeader {
objectName: "recordsSection"
text: qsTr("NDEF records")
}
SilicaListView {
id: listView
objectName: "recordsView"
width: parent.width
height: contentHeight
model: nfcdTagHandler.ndefRecords
delegate: Component {
ListItem {
id: clickableItem
objectName: "clickableItem"
width: listView.width
height: Theme.itemSizeSmall
Label {
objectName: "itemLabel"
anchors.verticalCenter: parent.verticalCenter
leftPadding: Theme.horizontalPageMargin
rightPadding: Theme.horizontalPageMargin
color: clickableItem.highlighted ? palette.highlightColor : palette.primaryColor
text: modelData
}
onClicked: pageStack.push(Qt.resolvedUrl("NfcdNdefPage.qml"), {
title: qsTr("Record '%1'").arg(modelData),
path: modelData
})
}
}
}
SectionHeader {
objectName: "funcTransceiveSection"
text: qsTr("Function 'transceive'")
}
HexValueItem {
id: transceiveDataValueItem
objectName: "transceiveDataValueItem"
label: qsTr("Data")
text: "0x0"
}
DetailButtonItem {
objectName: "transceiveResultItem"
buttonEnabled: !transceiveDataValueItem.errorHighlight
buttonText: qsTr("Send")
resultLabel: qsTr("Response:")
onClicked: {
var result = nfcdTagHandler.transceive(transceiveDataValueItem.text);
if (result.length > 0)
resultValue = "0x" + result.toString(16).toUpperCase();
}
}
}
}
Rectangle {
id: buttonsArea
objectName: "buttonsArea"
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
topMargin: Theme.paddingMedium
}
height: buttonsLayout.implicitHeight + Theme.paddingMedium * 2
color: Theme.highlightDimmerColor
ButtonLayout {
id: buttonsLayout
objectName: "buttonsLayout"
anchors {
fill: parent
topMargin: Theme.paddingMedium
}
rowSpacing: Theme.paddingMedium
columnSpacing: Theme.paddingMedium
Button {
objectName: "acquireButton"
text: qsTr("Acquire")
ButtonLayout.newLine: false
onClicked: nfcdTagHandler.acquire(true)
}
Button {
objectName: "releaseButton"
text: qsTr("Release")
ButtonLayout.newLine: false
onClicked: nfcdTagHandler.release()
}
}
}
}
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
import ru.auroraos.NfcUseCases 1.0
import "../components"
Page {
id: nfcdTagPage
property string title
property string path
property bool isoDepIsAvailable: false
property bool rwType2IsAvailable: false
objectName: "nfcdTagPage"
NfcdTagHandler {
id: nfcdTagHandler
objectName: "nfcdTagHandler"
tagPath: path
onRemoved: pageStack.pop(pageStack.previousPage(nfcdTagPage), PageStackAction.Animated)
}
Column {
id: mainColumn
objectName: "mainColumn"
anchors {
top: parent.top
left: parent.left
right: parent.right
}
spacing: Theme.paddingMedium
height: implicitHeight
PageHeader {
objectName: "pageHeader"
title: nfcdTagPage.title
}
ComboBox {
id: interfacesCmbBox
objectName: "interfacesCmbBox"
width: parent.width
label: qsTr("Interface:")
description: qsTr("Select the desired interface")
menu: ContextMenu {
Repeater {
model: ListModel {
id: itemsModel
objectName: "itemsModel"
ListElement {
objectName: "tagIfaceItem"
text: qsTr("org.sailfishos.nfc.Tag")
page: "NfcdTagIface.qml"
}
ListElement {
objectName: "tagType2IfaceItem"
text: qsTr("org.sailfishos.nfc.TagType2")
page: "NfcdTagType2Iface.qml"
}
ListElement {
objectName: "isoDepIfaceItem"
text: qsTr("org.sailfishos.nfc.IsoDep")
page: "NfcdIsoDepIface.qml"
}
}
MenuItem {
objectName: "menuItem"
text: model.text
enabled: interfacesCmbBox.interfaceIsAvailable(model.text)
}
}
}
onCurrentIndexChanged: setupIfaceView(currentIndex)
Component.onCompleted: setupIfaceView(currentIndex)
function interfaceIsAvailable(name) {
for (var i = 0; i < nfcdTagHandler.interfaces.length; ++i)
if (nfcdTagHandler.interfaces[i] === name)
return true;
return false;
}
function setupIfaceView(index) {
var page = itemsModel.get(index).page;
contentLoader.setSource(Qt.resolvedUrl(page), { path: nfcdTagPage.path });
}
}
}
Loader {
id: contentLoader
objectName: "contentLoader"
anchors {
top: mainColumn.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
}
}
// SPDX-FileCopyrightText: 2021-2023 Open Mobile Platform LLC <community@omp.ru>
// SPDX-License-Identifier: BSD-3-Clause
import QtQuick 2.6
import Sailfish.Silica 1.0
import ru.auroraos.NfcUseCases 1.0
import "../components"
Item {
id: nfcdTagType2Iface
property string path
objectName: "nfcdTagType2Iface"
NfcdTagType2Handler {
id: nfcdTagType2Handler
objectName: "nfcdTagType2Handler"
tagPath: path
}
SilicaFlickable {
objectName: "flickableArea"
anchors {
fill: parent
bottomMargin: Theme.paddingMedium
}
contentHeight: mainColumn.implicitHeight
clip: true
VerticalScrollDecorator {
objectName: "scrollDecorator"
}
Column {
id: mainColumn
objectName: "mainColumn"
anchors {
top: parent.top
left: parent.left
right: parent.right
}
spacing: Theme.paddingMedium
SectionHeader {
objectName: "tagType2InfoSection"
text: qsTr("Tag type 2 info")
}
AlignedLabelItem {
label: qsTr("Interface version:")
value: nfcdTagType2Handler.interfaceVersion
}
AlignedLabelItem {
objectName: "blockSizeItem"
label: qsTr("Block size:")
value: nfcdTagType2Handler.blockSize
}
AlignedLabelItem {
objectName: "dataSizeItem"
label: qsTr("Data size:")
value: nfcdTagType2Handler.dataSize
}
AlignedLabelItem {
objectName: "serialItem"
label: qsTr("Serial:")
value: nfcdTagType2Handler.serial
}
SectionHeader {
objectName: "funcWriteSection"
text: qsTr("Function 'write'")
}
HexValueItem {
id: writeSectorValueItem
objectName: "writeSectorValueItem"
label: qsTr("Sector")
text: "0"
}
HexValueItem {
id: writeBlockValueItem
objectName: "writeBlockValueItem"
label: qsTr("Block")
text: "0"
}
HexValueItem {
id: writeDataValueItem
objectName: "writeDataValueItem"
label: qsTr("Data")
text: "0x0"
}
DetailButtonItem {
objectName: "writeResultItem"
buttonEnabled: !writeSectorValueItem.errorHighlight
|| !writeBlockValueItem.errorHighlight
|| !writeDataValueItem.errorHighlight
buttonText: qsTr("Write")
resultLabel: qsTr("Result:")
onClicked: resultValue = nfcdTagType2Handler.write(writeSectorValueItem.text,
writeBlockValueItem.text,
writeDataValueItem.text)
}
SectionHeader {
objectName: "funcWriteDataSection"
text: qsTr("Function 'writeData'")
}
HexValueItem {
id: writeDataOffsetValueItem
objectName: "writeDataOffsetValueItem"
label: qsTr("Offset")
text: "0"
}
HexValueItem {
id: writeDataDataValueItem
objectName: "writeDataDataValueItem"
label: qsTr("Data")
text: "0x0"
}
DetailButtonItem {
objectName: "writeDataResultItem"
buttonEnabled: !writeDataOffsetValueItem.errorHighlight
|| !writeDataDataValueItem.errorHighlight
buttonText: qsTr("Write")
resultLabel: qsTr("Result:")
onClicked: resultValue = nfcdTagType2Handler.writeData(writeDataOffsetValueItem.text,
writeDataDataValueItem.text)
}
SectionHeader {
objectName: "funcReadSection"
text: qsTr("Function 'read'")
}
HexValueItem {
id: readSectorValueItem
objectName: "readSectorValueItem"
label: qsTr("Sector")
text: "0"
}
HexValueItem {
id: readBlockValueItem
objectName: "readBlockValueItem"
label: qsTr("Block")
text: "0"
}
DetailButtonItem {
objectName: "readResultItem"
buttonEnabled: !readSectorValueItem.errorHighlight
|| !readBlockValueItem.errorHighlight
buttonText: qsTr("Read")
resultLabel: qsTr("Result:")
onClicked: resultValue = nfcdTagType2Handler.read(readSectorValueItem.text,
readBlockValueItem.text)
}
SectionHeader {
objectName: "funcReadDataSection"
text: qsTr("Function 'readData'")
}
HexValueItem {
id: readDataOffsetValueItem
objectName: "readDataOffsetValueItem"
label: qsTr("Offset")
text: "0"
}
HexValueItem {
id: readDataMaxBytesValueItem
objectName: "readDataMaxBytesValueItem"
label: qsTr("Max bytes")
text: "0"
}
DetailButtonItem {
objectName: "readDataResultItem"
buttonEnabled: !readDataOffsetValueItem.errorHighlight
|| !readDataMaxBytesValueItem.errorHighlight
buttonText: qsTr("Read")
resultLabel: qsTr("Result:")
onClicked: resultValue = nfcdTagType2Handler.readData(readDataOffsetValueItem.text,
readDataMaxBytesValueItem.text)
}
SectionHeader {
objectName: "funcReadAllDataSection"
text: qsTr("Function 'readAllData'")
}
DetailButtonItem {
objectName: "readAllDataResultItem"
buttonText: qsTr("Read")
resultLabel: qsTr("Result:")
onClicked: resultValue = nfcdTagType2Handler.readAllData()
}
}
}
}
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать