| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Launch app message generation

NFC launch app messages consist of up to two records: an Android Application Record (AAR) and a Windows LaunchApp record. These records launch applications on Android devices and Windows Phone devices, respectively. To launch an application on either device, both records must be included in the message. You can also generate messages that contain only one of those records and therefore work only for Android or only for Windows Phone.

An Android Application Record (AAR) contains a string with the Android package name. A Windows LaunchApp record contains a string with the Windows application ID.

The Launch app records module provides functions for creating the records, and the Launch app messages module provides functions for creating and encoding the message.

The following code snippets show how to generate a launch app message that contains records for Android and Windows Phone. First, define the app strings and create a buffer for the message:

/* nRF Toolbox Android application package name */
static const uint8_t m_android_package_name[] = {'n', 'o', '.', 'n', 'o', 'r', 'd', 'i', 'c', 's',
'e', 'm', 'i', '.', 'a', 'n', 'd', 'r', 'o', 'i',
'd', '.', 'n', 'r', 'f', 't', 'o', 'o', 'l', 'b',
'o', 'x'};
/* nRF Toolbox application ID for Windows phone */
static const uint8_t m_windows_application_id[] = {'{', 'e', '1', '2', 'd', '2', 'd', 'a', '7', '-',
'4', '8', '8', '5', '-', '4', '0', '0', 'f', '-',
'b', 'c', 'd', '4', '-', '6', 'c', 'b', 'd', '5',
'b', '8', 'c', 'f', '6', '2', 'c', '}'};
uint8_t m_ndef_msg_buf[256];

Then create the launch app message with two records. As parameters, provide the app strings and their lengths, the message buffer, and the size of the available memory in the buffer:

uint32_t len;
uint32_t err_code;
/* Provide information about available buffer size to encoding function. */
len = sizeof(m_ndef_msg_buf);
/* Encode launchapp message into buffer */
err_code = nfc_launchapp_msg_encode(m_android_package_name,
sizeof(m_android_package_name),
m_windows_application_id,
sizeof(m_windows_application_id),
m_ndef_msg_buf,
&len);
APP_ERROR_CHECK(err_code);

To generate a message with only one record, pass NULL instead of an app string for the OS that you do not want to include.