Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: Turn On NFC programatically

[ Edited ]

Can you post the entire build log?

 

Those 4 lines don't really have anything useful...

 

Thanks!

--
Rob is no longer associated with BlackBerry.
Please use plain text.
Developer
SuhairZain
Posts: 121
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Turn On NFC programatically

this is the entire build log:

 

19:30:27 **** Incremental Build of configuration Device-Debug for project ConnecTappTest ****
make -j4 Device-Debug
make -C .//translations -f Makefile update
make[1]: Entering directory `E:/WorK FileS/QNX Momentics IDE/ConnecTappTest/translations'
C:/bbndk/host_10_2_0_15/win32/x86/usr/bin/lupdate ConnecTappTest.pro
Updating 'ConnecTappTest_fr.ts'...
Found 6 source text(s) (0 new and 6 already existing)
Updating 'ConnecTappTest.ts'...
Found 6 source text(s) (0 new and 6 already existing)
make[1]: Leaving directory `E:/WorK FileS/QNX Momentics IDE/ConnecTappTest/translations'
make -C .//translations -f Makefile release
make[1]: Entering directory `E:/WorK FileS/QNX Momentics IDE/ConnecTappTest/translations'
C:/bbndk/host_10_2_0_15/win32/x86/usr/bin/lrelease ConnecTappTest.pro
Updating 'E:/WorK FileS/QNX Momentics IDE/ConnecTappTest/translations/ConnecTappTest_fr.qm'...
Generated 5 translation(s) (5 finished and 0 unfinished)
Ignored 1 untranslated source text(s)
Updating 'E:/WorK FileS/QNX Momentics IDE/ConnecTappTest/translations/ConnecTappTest.qm'...
Generated 0 translation(s) (0 finished and 0 unfinished)
Ignored 6 untranslated source text(s)
make[1]: Leaving directory `E:/WorK FileS/QNX Momentics IDE/ConnecTappTest/translations'
make -C ./arm -f Makefile debug
make[1]: Entering directory `E:/WorK FileS/QNX Momentics IDE/ConnecTappTest/arm'
make -f Makefile.Debug
make[2]: Entering directory `E:/WorK FileS/QNX Momentics IDE/ConnecTappTest/arm'
qcc -Vgcc_ntoarmv7le -c -Wc,-include -Wc,o.le-v7-g/.obj/ConnecTappTest -Wno-psabi -lang-c++ -fstack-protector -fstack-protector-all -mcpu=cortex-a9 -g -Wno-psabi -Wall -W -D_REENTRANT -DQT_NO_IMPORT_QT47_QML -DQ_OS_BLACKBERRY -DQT_DECLARATIVE_DEBUG -DQT_DECLARATIVE_LIB -DQT_CORE_LIB -DQT_SHARED -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/share/qt4/mkspecs/blackberry-armv7le-qcc -I../../ConnecTappTest -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtCore -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtDeclarative -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4 -I../src -Io.le-v7-g/.moc -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/freetype2 -I. -o o.le-v7-g/.obj/applicationui.o ../src/applicationui.cpp
qcc -Vgcc_ntoarmv7le -c -Wc,-include -Wc,o.le-v7-g/.obj/ConnecTappTest -Wno-psabi -lang-c++ -fstack-protector -fstack-protector-all -mcpu=cortex-a9 -g -Wno-psabi -Wall -W -D_REENTRANT -DQT_NO_IMPORT_QT47_QML -DQ_OS_BLACKBERRY -DQT_DECLARATIVE_DEBUG -DQT_DECLARATIVE_LIB -DQT_CORE_LIB -DQT_SHARED -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/share/qt4/mkspecs/blackberry-armv7le-qcc -I../../ConnecTappTest -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtCore -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtDeclarative -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4 -I../src -Io.le-v7-g/.moc -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/freetype2 -I. -o o.le-v7-g/.obj/main.o ../src/main.cpp
C:/bbndk/host_10_2_0_15/win32/x86/usr/bin/moc.exe -DQT_NO_IMPORT_QT47_QML -DQ_OS_BLACKBERRY -DQT_DECLARATIVE_DEBUG -DQT_DECLARATIVE_LIB -DQT_CORE_LIB -DQT_SHARED -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/share/qt4/mkspecs/blackberry-armv7le-qcc -I../../ConnecTappTest -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtCore -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtDeclarative -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4 -I../src -Io.le-v7-g/.moc -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/freetype2 -I. -D__QNXNTO__ ../src/applicationui.hpp -o o.le-v7-g/.moc/moc_applicationui.cpp
qcc -Vgcc_ntoarmv7le -c -Wc,-include -Wc,o.le-v7-g/.obj/ConnecTappTest -Wno-psabi -lang-c++ -fstack-protector -fstack-protector-all -mcpu=cortex-a9 -g -Wno-psabi -Wall -W -D_REENTRANT -DQT_NO_IMPORT_QT47_QML -DQ_OS_BLACKBERRY -DQT_DECLARATIVE_DEBUG -DQT_DECLARATIVE_LIB -DQT_CORE_LIB -DQT_SHARED -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/share/qt4/mkspecs/blackberry-armv7le-qcc -I../../ConnecTappTest -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtCore -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtDeclarative -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/qt4 -I../src -Io.le-v7-g/.moc -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include -Ic:/bbndk/target_10_2_0_1155/qnx6/usr/include/freetype2 -I. -o o.le-v7-g/.obj/moc_applicationui.o o.le-v7-g/.moc/moc_applicationui.cpp
../src/applicationui.cpp: In constructor 'ApplicationUI::ApplicationUI(bb::cascades::Application*)':
../src/applicationui.cpp:26:15: warning: unused variable 'result' [-Wunused-variable]
qcc -Vgcc_ntoarmv7le -lang-c++ -Wl,-rpath-link,C:/bbndk/target_10_2_0_1155/qnx6/armle-v7/lib -Wl,-rpath-link,C:/bbndk/target_10_2_0_1155/qnx6/armle-v7/usr/lib -Wl,-rpath-link,C:/bbndk/target_10_2_0_1155/qnx6/armle-v7/usr/lib/qt4/lib -o o.le-v7-g/ConnecTappTest o.le-v7-g/.obj/applicationui.o o.le-v7-g/.obj/main.o o.le-v7-g/.obj/moc_applicationui.o -LC:/bbndk/target_10_2_0_1155/qnx6/armle-v7/lib -LC:/bbndk/target_10_2_0_1155/qnx6/armle-v7/usr/lib -LC:/bbndk/target_10_2_0_1155/qnx6/armle-v7/usr/lib/qt4/lib -LC:/bbndk/target_10_2_0_1155/qnx6//usr/lib/qt4/lib -lbbsystem -lbbplatformbbm -libnfc -lbbcascades -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lsqlite3 -lz -lQtXmlPatterns -lQtGui -lQtNetwork -lsocket -lQtCore -lm -lbps
C:\bbndk\host_10_2_0_15\win32\x86\usr\bin\ntoarm-ld: cannot find -libnfc
make[2]: Leaving directory `E:/WorK FileS/QNX Momentics IDE/ConnecTappTest/arm'
cc: C:/bbndk/host_10_2_0_15/win32/x86/usr/bin/ntoarm-ld caught signal 1
make[1]: Leaving directory `E:/WorK FileS/QNX Momentics IDE/ConnecTappTest/arm'
make[2]: *** [o.le-v7-g/ConnecTappTest] Error 1
make[1]: *** [debug] Error 2
make: *** [Device-Debug] Error 2

 

I have used only a single line of code:

 

nfc_result_t result = nfc_set_setting(NFC_SETTING_ENABLED_ASYNC, TRUE); //within class constructor

 

Also, i have included <nfc/nfc.h>, added -libnfc to my .pro file

Please use plain text.
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: Turn On NFC programatically

First problem:

 

The problem you talked about previously is not in this complete log.

 

Second problem:

 

Wrong name is used for the library;

C:\bbndk\host_10_2_0_15\win32\x86\usr\bin\ntoarm-ld: cannot find -libnfc

 You need to have

-lnfc

As it is currently, you've asked the linker to use a library called ibnfc.

 

Thanks.

 

--
Rob is no longer associated with BlackBerry.
Please use plain text.
Developer
BBSJdev
Posts: 5,948
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: Turn On NFC programatically

To be fair to SuhairZain this is what is in the documentation and it's an easy mistake to forget the extra l.

 

http://developer.blackberry.com/native/reference/core/nfc_libref/topic/nfc_connect.html

 

In fact in searching I couldn't find the correct library inclusion at all.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
SuhairZain
Posts: 121
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Turn On NFC programatically

[ Edited ]

@robbie that solves the problem with the inclusion of the library, but still it doesnt work.. 

 

NFC_API nfc_result_t result = NFC_API nfc_set_setting(NFC_SETTING_ENABLED_ASYNC, TRUE);

nfc_result_t result = NFC_API nfc_set_setting(NFC_SETTING_ENABLED_ASYNC, TRUE);

nfc_result_t result = nfc_set_setting(NFC_SETTING_ENABLED_ASYNC, TRUE);

nfc_set_setting(NFC_SETTING_ENABLED_ASYNC, TRUE);

 

none of this turns the NFC on.. also, when i try 1,2&3, a warning shows up - unused variable 'result'

Please use plain text.
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: Turn On NFC programatically

Yes - it's a really common and easy mistake.

 

I'll suggest some documentation updates against https://developer.blackberry.com/native/documentation/cascades/getting_started/tools/build_and_run.h...

 

It's a little compounded by the fact that the c++ libraries (eg: bbsystem) list only their name but the C libraries include the lib in their name...

 

 

--
Rob is no longer associated with BlackBerry.
Please use plain text.
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: Turn On NFC programatically

Going to run a quick test...

--
Rob is no longer associated with BlackBerry.
Please use plain text.
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: Turn On NFC programatically

Hi,

 

You should always check or log the return value from functions - the variable the compiler is warning about might be holding the answer!

 

I just did this on 10.2.0.1743,

	nfc_result_t result = nfc_connect();
	qDebug() << "Connect" << result;
	result = nfc_set_setting(NFC_SETTING_ENABLED, true);
	qDebug() << "Set" << result;

 (note - not using _ASYNC)

 

And it did work - and I saw 0 for both system calls.

 

Two questions:

1. Are you connecting to the nfc subsystem before using it?

2. What's the error code (if any) coming back from nfc_set_setting?

 

Thanks!

 

 

 

--
Rob is no longer associated with BlackBerry.
Please use plain text.
Developer
SuhairZain
Posts: 121
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Turn On NFC programatically

it worked.. :smileyhappy:

 

the problem that happened earlier was that i forgot to use connect_nfc()

 

thanks a ton, man.. :smileyhappy:

Please use plain text.
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: Turn On NFC programatically

Great! You're welcome!

--
Rob is no longer associated with BlackBerry.
Please use plain text.