CreateMessageBox

nn::cec::CTR::MessageBox::CreateMessageBox Member Function

Syntax

nn::Result CreateMessageBox(
     const TitleId cecTitleId,
     const u32 privateId,
     const char * hmacKey,
     const void * icon,
     size_t iconSize,
     const wchar_t * name,
     size_t nameSize,
     size_t inboxSizeMax = CEC_INBOX_SIZE_DEFAULT,
     size_t outboxSizeMax = CEC_OUTBOX_SIZE_DEFAULT,
     size_t inboxMessNumMax = CEC_INBOX_MESSNUM_DEFAULT,
     size_t outboxMessNumMax = CEC_OUTBOX_MESSNUM_DEFAULT,
     size_t size = CEC_MESSSIZEMAX_DEFAULT
);

Parameters

Name Description
in cecTitleId A 32-bit StreetPass ID. Can be generated with MakeCecTitleId.
in privateId The key needed to open a message box.→ OpenMessageBox
The value used must be stored by the application accessing the message box.
in hmacKey Specifies the key needed to read a Message. Specifies a 32-byte value. This must be a secret key shared with the communication partner.
This value is used to check if the transmitted data has been tampered with. Transmitted data is signed with a signature generated using this key. Use a value stored by the application.
If it is a 32-byte value, you can also use characters other than (0x200x7e).
in icon Specifies an icon.
Format: RGB565 (little-endian).
Size: 48x48 (4.5 KB).
in iconSize Specifies the size of the icon data.
in name Specifies an application name.
Encoding: UTF16-LE.
Display size: Equivalent of the width of 17 full-width characters.
Maximum buffer size: 64 x 2 bytes (including the NULL terminator).
in nameSize Specifies the size of the application name.
in inboxSizeMax Specifies the maximum amount of data that can be saved in the inbox. The combined size of the inbox and outbox must be no more than 1 MB. The default size is 512 * 1024 bytes.
in outboxSizeMax Specifies the maximum amount of data that can be saved in the outbox. The combined size of the inbox and outbox must be no more than 1 MB. The default size is 512 * 1024 bytes.
in inboxMessNumMax Specifies the maximum number of messages that can be saved in the inbox. The default is 99, which is the maximum specifiable value.
in outboxMessNumMax Specifies the maximum number of messages that can be saved in the outbox. The default is 99, which is the maximum specifiable value.
in size This value is not used.

Return Values

nn::Result

Value Description
Result::IsSuccess Process succeeded.
ResultBoxAlreadyExists Could not create box, because box already exists.
If this error is returned when the current status is OpenMessageBox == nn::cec::ResultNoData(), it might have been caused by an already-existing box with a different lower 8 bits of its CecTitleId.→ MakeCecTitleId, OpenMessageBox
ResultBoxNumFull The maximum number of boxes have been created. To create a new box, you must delete a box for another game title.
ResultInvalidArgument An argument was specified incorrectly.
ResultInvalidData There is a problem with the data, icon, or name being set.
ResultTooLarge There is a problem with the size of data being set.
ResultStateBusy Unable to access because the daemon is busy (BUSY state). This may succeed if you wait some time before accessing again.
A value other than the above. Process failed.

Description

Creates a MessageBox. An inbox and outbox are created within the message box. Any message set in the outbox is automatically sent during StreetPass communication, and any received data is stored in the inbox.

MessageBox objects are created in NAND memory. Only one box may be created for each application. Only 12 boxes may be created in total. Attempting to create a new message box when 12 already exist will not create a new box.
When a box is created, it immediately enters the "opened" state (OpenMessageBox).
The privateId and hmacKey values are used to restrict access. Decide and set these values on the application side.
The privateId value is the key needed to open a message box and is intended to be limited to one system. The hmacKey value is a secret key common to all instances of an application and is used to prevent data tampering and application spoofing. Set a value that cannot be guessed by analogy. These keys are stored in the message box. Create and set shared keys in an appropriate configuration if you need to access the same message box from multiple save-data files or applications.

You can restrict the number and size of messages placed in the INBOX and OUTBOX. If not specified, these number of messages is limited to 99 and their size is limited to 512KB. You can get the limit on the number of messages using GetBoxMessageNum and the size limitation using GetBoxSize (the total of message sizes given by GetMessageSize for each message). Messages will not be saved if either the number of messages or the message size exceeds the specified limit. To limit the box size in terms of number of messages, be sure to set values so that box size is not limited by message size first.
When specifying a propagation count, note that there must be available space in the OUTBOX as well.
Note: When this function is called, the CEC (StreetPass) daemon operating in the background stops. Be aware that background communication might be interrupted.→ See CecControl::StopScanning.

There are two types of StreetPass icons used on System Settings screens and other screens.
There is a box icon and an icon for individual messages. You must specify both. This function sets the box icon.

Please note that if there is no data in the outbox or if send counts for all messages are zero, then communications with that title will not be performed, even if it has an exclusive box.
If the inbox becomes full, communication with the partner that was discovered will be recorded as complete, but messages will not be received in the application's box. After communication with a partner is recorded as complete, no communication will be conducted with that partner for a set period of time.

Revision History

2010/08/16
Initial version.

CONFIDENTIAL