nn::cec::CTR Namespace

Description

The namespace of the CTR StreetPass library.
(This namespace can also be written without the ::CTR part.)

CTR StreetPass is an improved and easier-to-use iteration of a similar Nintendo DS feature called Chance Encounter Communication (CEC).
Because the system performs the communication in the background, sending and receiving data can be performed simply by preparing the send data, regardless of the application running or its status. However, because an application's original communication processes cannot be implemented, there is a chance that implementation of send/receive methods that require special conditions may not be possible.

StreetPass communication is enabled by creating a StreetPass box in the area prepared by the system and registering StreetPass data as the message to send in it. This allows the system to automatically send/receive StreetPass data with communication partners.
There are 12 StreetPass boxes available. In principle, one application can exclusively own one StreetPass box. If all StreetPass boxes are already in use, no new StreetPass boxes can be created until the user deletes unnecessary StreetPass settings on the StreetPass management screen in the system settings.
The StreetPass box contains a send box (outbox) and a receive box (inbox). Each is allocated as a region to register StreetPass data to be sent and as a region to store received StreetPass data, respectively.
When two units that can perform StreetPass approach and discover each other, they first scan the StreetPass box in each other's system regions. If they discover a StreetPass box created with the same StreetPass ID (as specified by MakeCecTitleId), they commence communications for just that portion required for the sending and receiving of StreetPass data. When StreetPass data are being sent from several StreetPass boxes, the data are sent in order starting from the smallest in size. Such factors as the communication environment, the distance between the communication partners, and the number of titles shared by the communication partners will vary every time. And the partners may not necessarily remain in communication range long enough to complete the sending and receiving of all StreetPass data. When they are in communication range for only a short time, it is possible that only the smallest data sent first can be successfully transmitted. So to increase the success rate for communication, it is effective to keep the StreetPass data size as small as possible.
In addition, the data sent from a StreetPass box is sent one data set at a time, provided they are not grouped.
A unit that has been configured to only receive data can save StreetPass data, but if two units both have been configured to only receive data, then they will not perform StreetPass with each other. This also applies to units configured to only send StreetPass data. Specifically, if the first registered data has been fixed as receive-only or send-only, StreetPass exchanges will never occur, no matter how much time passes.

During communication via StreetPass, the system checks whether data has been tampered with.
Specifically, an HMAC signature (where the key is specified by the application during box creation) is attached when a message is created and then checked when that message is received. Messages that do not pass the check are not put into the inbox.
However, the system only checks for tampering when data moves from a peer's outbox to a local inbox. If an application knows the PrivateId and accesses the StreetPass boxes to tamper with data, the system will not detect this tampering.
For this reason, it is more secure if the application also checks whether data is valid.

StreetPass does not use communication protocols that are used in relationship to those common to devices such as local communication and Internet.
In addition, you cannot configure StreetPass to start at a specific time, as the ndm (Network Daemon Manager) automatically schedules background communication. Use the CecControl::EnterExclusiveState function to change the ndm controls if you want to prioritize StreetPass while your application is running. (Only for debugging.)
The system performs StreetPass searches as a priority when the system is in Sleep Mode, but switches over to Internet communication if it discovers an available access point. During Internet communication, the system does not perform StreetPass searches.

Note: The system communicates once with each partner and remembers those partners. StreetPass with the same partner will not occur again until an average of 4 hours or a maximum of 8 hours elapses.
Note: StreetPass is not possible between a test unit (used for development) and a retail system.
Note: StreetPass searches for partners with registered boxes bearing the same StreetPass ID. StreetPass occurs even if the discovered partner and device are set to a different region.

Classes

nn::cec::CTR::CecControl Changes StreetPass (CEC) status and gets information.
nn::cec::CTR::Message Class that handles CEC Message objects.
nn::cec::CTR::MessageBox This class is used to access CEC MessageBox objects.
nn::cec::CTR::MessageId Class that handles message IDs.

Structures

nn::cec::CTR::CecNotificationParam Receive information for each box.
nn::cec::CTR::CecNotificationData Receive information.

Enumerated Types

CecBoxDataType Indicates the types of data associated with boxes.
CecBoxType Types used for inboxes and outboxes.

typedef Definitions

SendMode
SendMode The sending mode for messages. This value is specified in the message.( Message::NewMessage etc.)
MessageTypeFlag
MessageTypeFlag Flag for switching messages depending on the recipient. Specified in a message.( Message::NewMessage etc.)
MessageExHeaderType
MessageExHeaderType Data types for a message's extended header.
Other
TitleId StreetPass ID format. This 32-bit value can be generated with the MakeCecTitleId function.

Constants

SendMode
S SENDMODE_RECV const SendMode Receiving only.
S SENDMODE_SEND const SendMode Sending only.
S SENDMODE_SENDRECV const SendMode Sending and receiving.
S SENDMODE_EXCHANGE const SendMode Exchange.
MessageTypeFlag
S MESSAGE_TYPEFLAG_NON_FRIEND const MessageTypeFlag Non-friends can receive the message.
S MESSAGE_TYPEFLAG_FRIEND const MessageTypeFlag Friends can receive the message.
S MESSAGE_TYPEFLAG_ANYONE const MessageTypeFlag Receivable without checking whether the sender is a friend or not a friend.
MessageExHeaderType
S MESSAGE_EXHEADER_TYPE_ICON const MessageExHeaderType Description of each Message icon.
Use this to specify the MessageExHeaderType.
S MESSAGE_EXHEADER_TYPE_INFO const MessageExHeaderType Description of each Message data item.
Use this to specify the MessageExHeaderType.
Send Count and Propagation Count
S MESSAGE_SENDCOUNT_ONCE const u8 Specifies the number of times to send. The message is sent only once.
S MESSAGE_SENDCOUNT_UNLIMITED const u8 Specifies the number of times to send. It does not set a limit on the send count.
S MESSAGE_PROPAGATIONCOUNT_ONCE const u8 Specifies the number of times to propagate. It does not initiate propagation.
Other
S CEC_SIZEOF_MESSAGEID const s32 MessageId size.
S MESSAGE_BODY_SIZE_MAX const size_t Maximum size of the body of the message.
S CEC_INBOX_SIZE_DEFAULT const size_t Initial value for the size of the inbox.
S CEC_OUTBOX_SIZE_DEFAULT const size_t Initial value for the size of the outbox.
S CEC_INBOX_MESSNUM_DEFAULT const u8 Initial value of the maximum number of inbox messages.
S CEC_OUTBOX_MESSNUM_DEFAULT const u8 Initial value of the maximum number of outbox messages.

Functions

Initialize/Finalize
Initialize Connects to the CEC daemon. This must be called first to all access to the CEC functions.
Finalize Finalizes access to the CEC daemon.
Notification of Communication
GetCecRecvEventHandle Specifies the Event received as notification when StreetPass has occurred. (The name of this function is scheduled to be changed to "GetCecEvent.")
GetCecEvent Specifies the Event received as notification when StreetPass has occurred.
GetCecInfoBuffer Gets information about a message received in the previous communication.
Other
MakeCecTitleId Generates a 32-bit StreetPass ID (CecTitleId) used in StreetPass communications from a 20-bit unique ID.

Revision History

2011/01/24
Added information about the conditions for discovering a communication partner. Removed descriptions of the MessageBoxInfoReader class, since that class is not supported.
2010/08/16
Initial version.

CONFIDENTIAL