Permalink
Browse files

Addition of Peer-2-Peer ( SNEP ) functionality

Uses the example of a vCard being exchanged over SNEP between two devices
  • Loading branch information...
1 parent 6ae60a3 commit ac7a409893bb5ea9815f492cb7c7a687ba017840 John Murray committed Jun 12, 2012
View
@@ -1,6 +1,6 @@
# NFC Tag Reading and Writing Sample
-The purpose of this application is to demonstrate how to read and write various sorts of NDEF messages from and to NFC tags using the BlackBerry 10 NFC APIs.
+The purpose of this application is to demonstrate how to use selected BlackBerry 10 NFC APIs. The Release History section gives details of those NFC APIs which are covered.
The sample code for this application is Open Source under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).
@@ -16,6 +16,11 @@ The sample code for this application is Open Source under the [Apache 2.0 Licens
* [Martin Woolley](https://github.com/mdwoolley)
+**Release History**
+V2 - Added transfer of vCard using SNEP
+V1 - Reading and Writing NDEF tags
+
+
**Dependencies**
1. BlackBerry Dev Alpha Device Software 10.0.4
@@ -46,9 +51,10 @@ Here's what you should do:
**But I don't want to build it myself**
-If you don't want to build this sample applictaion yourself we've included a pre-build and signed BAR file. You can find it in the folder "installable-bar-files" as follows:
+If you don't want to build this sample application yourself we've included a pre-build and signed BAR files for each version. You can find them in the folder "installable-bar-files" as follows:
-* NfcTool-1_0_0_1.bar
+* NfcTool-2_0_0_1.bar -- Signed BAR file for Version 2 (V2) of the application
+* NfcTool-1_0_0_1.bar -- Signed BAR file for Version 1 (V1) of the application
**Known Issues**
View
@@ -38,7 +38,7 @@ Page {
}
Label {
- text: " Welcome to NFC Tool"
+ text: " Welcome to NFC Tool V2.0"
textStyle {
base: SystemDefaults.TextStyles.TitleText
fontWeight: FontWeight.Light
@@ -33,14 +33,14 @@ Container {
id: itemBackground
imageSource: "asset:///images/white_item_bg.png"
preferredWidth: 768
- preferredHeight: 209
+ preferredHeight: 178
}
Container {
id: highlightContainer
background: Color.create ("#75b5d3")
opacity: 0.0
preferredWidth: 760
- preferredHeight: 168
+ preferredHeight: 166
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Center
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -4,5 +4,6 @@
<menuitem title="Write Smart Poster" image="asset:///images/sp.png" file="write_sp.qml" itemName="item_sp"/>
<menuitem title="Write Text" image="asset:///images/text.png" file="write_text.qml" itemName="item_text"/>
<menuitem title="Write Custom" image="asset:///images/custom.png" file="write_custom.qml" itemName="item_custom"/>
+ <menuitem title="Send vCard (SNEP)" image="asset:///images/snep.png" file="snep_vcard.qml" itemName="item_snep_vcard"/>
<menuitem title="About" image="asset:///images/about.png" file="about.qml" itemName="item_about"/>
</root>
View
@@ -0,0 +1,146 @@
+/* Copyright (c) 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/import bb.cascades 1.0
+import "common"
+
+Page {
+ content: MenuContainer {
+ id: sendVcard
+ objectName: "sendVcard"
+ signal sendVcardRequested ()
+ Container {
+ layout: StackLayout {
+ topPadding: 10
+ leftPadding: 30
+ rightPadding: 30
+ }
+ TextArea {
+ text: "SNEP: Send a vCard"
+ editable: false
+ textStyle {
+ base: SystemDefaults.TextStyles.BigText
+ color: Color.LightGray
+ fontWeight: FontWeight.Bold
+ }
+ }
+ Container {
+ layout: StackLayout {
+ }
+ topMargin: 70
+ bottomMargin: 50
+ TextArea {
+ editable: false
+ text: "First Name:"
+ textStyle {
+ base: SystemDefaults.TextStyles.BodyText
+ color: Color.LightGray
+ }
+ }
+ TextArea {
+ preferredHeight: 65
+ id: txf_first_name
+ objectName: "txf_first_name"
+ hintText: "Enter your first name"
+ text: _sendVcard._first_name
+ textStyle {
+ base: SystemDefaults.TextStyles.BodyText
+ }
+ }
+ TextArea {
+ editable: false
+ text: "Last Name:"
+ textStyle {
+ base: SystemDefaults.TextStyles.BodyText
+ color: Color.LightGray
+ }
+ }
+ TextArea {
+ preferredHeight: 65
+ id: txf_last_name
+ objectName: "txf_last_name"
+ hintText: "Enter your last name"
+ text: _sendVcard._last_name
+ textStyle {
+ base: SystemDefaults.TextStyles.BodyText
+ }
+ }
+ TextArea {
+ editable: false
+ text: "Address:"
+ textStyle {
+ base: SystemDefaults.TextStyles.BodyText
+ color: Color.LightGray
+ }
+ }
+ TextArea {
+ preferredHeight: 65
+ id: txf_address
+ objectName: "txf_address"
+ hintText: "Enter your address"
+ text: _sendVcard._address
+ textStyle {
+ base: SystemDefaults.TextStyles.BodyText
+ }
+ }
+ TextArea {
+ editable: false
+ text: "Email:"
+ textStyle {
+ base: SystemDefaults.TextStyles.BodyText
+ color: Color.LightGray
+ }
+ }
+ TextArea {
+ preferredHeight: 65
+ id: txf_email
+ objectName: "txf_email"
+ hintText: "Enter your email address"
+ text: _sendVcard._email
+ textStyle {
+ base: SystemDefaults.TextStyles.BodyText
+ }
+ }
+ }
+ TextArea {
+ editable: false
+ text: "Mobile:"
+ textStyle {
+ base: SystemDefaults.TextStyles.BodyText
+ color: Color.LightGray
+ }
+ }
+ TextArea {
+ preferredHeight: 65
+ id: txf_mobile
+ objectName: "txf_mobile"
+ hintText: "Enter your mobile number"
+ text: _sendVcard._mobile
+ textStyle {
+ base: SystemDefaults.TextStyles.BodyText
+ }
+ }
+ }
+ }
+ actions: [
+ ActionItem {
+ id: send_vcard_action
+ title: "Send vCard"
+ imageSource: "images/snep.png"
+ onTriggered: {
+ console.log ("Send vCard Triggered");
+ sendVcard.sendVcardRequested ();
+ }
+ }
+ ]
+}
Binary file not shown.
View
@@ -111,9 +111,7 @@ QString EventLog::appVersion() const {
void EventLog::setAppVersion(QString appVersion) {
if(_appVersion.compare(appVersion) == 0)
return;
-
_appVersion = appVersion;
-
emit detectAppVersionChanged();
}
View
@@ -30,7 +30,7 @@ using namespace bb::cascades;
class EventLog : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString _message READ getMessage WRITE setMessage)
+ Q_PROPERTY(QString message READ getMessage WRITE setMessage NOTIFY detectMessageChanged)
Q_PROPERTY(QString appVersion READ appVersion WRITE setAppVersion NOTIFY detectAppVersionChanged)
public:
@@ -65,6 +65,7 @@ private slots:
void back();
void hide();
void detectAppVersionChanged();
+ void detectMessageChanged();
};
#endif // ifndef EventLog_h
View
@@ -1,17 +1,17 @@
/* Copyright (c) 2012 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
@@ -26,7 +26,8 @@
using namespace bb::cascades;
-MainMenu::MainMenu() : _appVersion(QString(Settings::AppVersion)) {
+MainMenu::MainMenu() :
+ _appVersion(QString(Settings::AppVersion)) {
qDebug() << "NFC Tool V" << Settings::AppVersion;
@@ -48,6 +49,7 @@ MainMenu::~MainMenu() {
delete _writeSp;
delete _writeText;
delete _writeCustom;
+ delete _sendVcard;
delete _eventLog;
delete _about;
}
@@ -58,14 +60,16 @@ void MainMenu::createModules() {
_writeSp = new WriteSp();
_writeText = new WriteText();
_writeCustom = new WriteCustom();
+ _sendVcard = new SendVcard();
_eventLog = new EventLog("");
_about = new About();
qDebug() << "...done";
}
//only need to call this once, the signals should never get lost when switching scenes
void MainMenu::connectMainMenuReturnSignals() {
- qDebug() << "connecting 'return to main menu' signals for 'Read' use case...";
+ qDebug()
+ << "connecting 'return to main menu' signals for 'Read' use case...";
QObject::connect(_eventLog, SIGNAL(back()), this, SLOT(backFromEventLog()));
qDebug() << "...done";
}
@@ -75,7 +79,7 @@ void MainMenu::findAndConnectControls() {
qDebug() << "finding and cacheing NavigationPane object";
Navigator* nav = Navigator::getInstance();
- NavigationPane* navpane = dynamic_cast<NavigationPane*> (_root);
+ NavigationPane* navpane = dynamic_cast<NavigationPane*>(_root);
nav->setNavigationPane(navpane);
@@ -88,10 +92,11 @@ void MainMenu::findAndConnectControls() {
SLOT(onListSelectionChanged(const QVariantList, bool)));
QObject::connect(this, SIGNAL(read_selected()), _eventLog, SLOT(show()));
- QObject::connect(this, SIGNAL(write_uri()), _writeURI, SLOT(show()));
- QObject::connect(this, SIGNAL(write_sp()), _writeSp, SLOT(show()));
- QObject::connect(this, SIGNAL(write_text()), _writeText, SLOT(show()));
- QObject::connect(this, SIGNAL(write_custom()), _writeCustom, SLOT(show()));
+ QObject::connect(this, SIGNAL(write_uri()), _writeURI, SLOT(show()));
+ QObject::connect(this, SIGNAL(write_sp()), _writeSp, SLOT(show()));
+ QObject::connect(this, SIGNAL(write_text()), _writeText, SLOT(show()));
+ QObject::connect(this, SIGNAL(write_custom()), _writeCustom, SLOT(show()));
+ QObject::connect(this, SIGNAL(send_vcard_selected()), _sendVcard, SLOT(show()));
QObject::connect(this, SIGNAL(about_selected()), _about, SLOT(show()));
qDebug() << "...done";
@@ -119,7 +124,7 @@ void MainMenu::onListSelectionChanged(const QVariantList indexPath,
if (item.compare("item_read") == 0) {
qDebug() << "Read Tag was selected!";
startListening();
- _eventLog->setMessage("Hello");
+ _eventLog->setMessage("Bring a tag close");
emit read_selected();
} else if (item.compare("item_uri") == 0) {
@@ -140,6 +145,9 @@ void MainMenu::onListSelectionChanged(const QVariantList indexPath,
} else if (item.compare("item_about") == 0) {
qDebug() << "About was selected!";
emit about_selected();
+ } else if (item.compare("item_snep_vcard") == 0) {
+ qDebug() << "Send vCard (SNEP) was selected!";
+ emit send_vcard_selected();
}
}
}
@@ -177,7 +185,8 @@ void MainMenu::startListening() {
qDebug() << "startListening()";
NfcManager* nfc = NfcManager::getInstance();
- NdefType* type_sp = new NdefType(NDEF_TNF_WELL_KNOWN, Settings::NfcRtdSmartPoster);
+ NdefType* type_sp = new NdefType(NDEF_TNF_WELL_KNOWN,
+ Settings::NfcRtdSmartPoster);
NdefType* type_t = new NdefType(NDEF_TNF_WELL_KNOWN, Settings::NfcRtdText);
NdefType* type_u = new NdefType(NDEF_TNF_WELL_KNOWN, Settings::NfcRtdUri);
QList<NdefType *> types;
View
@@ -25,6 +25,7 @@
#include "WriteSp.hpp"
#include "WriteText.hpp"
#include "WriteCustom.hpp"
+#include "SendVcard.hpp"
#include "About.hpp"
#include "EventLog.hpp"
@@ -47,6 +48,7 @@ class MainMenu : public QObject
WriteSp* _writeSp;
WriteText* _writeText;
WriteCustom* _writeCustom;
+ SendVcard* _sendVcard;
EventLog* _eventLog;
About* _about;
@@ -68,6 +70,7 @@ class MainMenu : public QObject
void write_sp();
void write_text();
void write_custom();
+ void send_vcard_selected();
void about_selected();
public slots:
Oops, something went wrong.

0 comments on commit ac7a409

Please sign in to comment.