1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5    <meta http-equiv="Content-Style-Type" content="text/css" />
6    <link rel="stylesheet" href="../../../css/manpage.css" type="text/css" />
7<title>CreateNetwork</title>
8  </head>
9  <body>
10<h1><CODE><a href="../../../nn/Overview.html">nn</a>::<a href="../../../nn/uds/Overview.html">uds</a>::<a href="../../../nn/uds/CTR/Overview.html">CTR</a>::CreateNetwork</CODE> Function</h1>
11<h2>Syntax</h2>
12    <div class="section">
13      <pre class="definition">
14<a href="../../../nn/Result/Overview.html">nn::Result</a> CreateNetwork(
15     <a href="../../../nn_types/u8.html">u8</a> subId,
16     <a href="../../../nn_types/u8.html">u8</a> maxEntry,
17     <a href="../../../nn_types/bit32.html">bit32</a> localId,
18     const char passphrase[],
19     size_t passphraseLength,
20     const void * pData,
21     size_t dataSize
22);
23</pre>
24    </div>
25<h2>Arguments</h2>
26    <div class="section">
27      <table class="arguments">
28        <thead>
29          <tr>
30            <td width="15" />
31<th>Name</th>
32<td>Description</td>
33          </tr>
34        </thead>
35        <tr>
36<td>in</td>
37<th>subId</th>
38<td>Communication mode ID. Set this to a value between <CODE>0x00</CODE> and <CODE>0xFE</CODE>.</td>
39        </tr>
40        <tr>
41<td>in</td>
42<th>maxEntry</th>
43<td>Maximum number of nodes that can connect to the network. This value can be up to <a href="../../../nn/uds/CTR/NODE_MAX.html"><CODE>NODE_MAX</CODE></a>, including the local device.</td>
44        </tr>
45        <tr>
46<td>in</td>
47<th>localId</th>
48<td>The local communication ID. Specify the value generated by <a href="../../../nn/uds/CTR/CreateLocalCommunicationId.html"><CODE>CreateLocalCommunicationId</CODE></a>.</td>
49        </tr>
50        <tr>
51<td>in</td>
52<th>passphrase[]</th>
53<td>String holding the seed of the passphrase to use for wireless layer encryption. With UDS, communication can only be established if <SPAN class="argument">uniqueId</SPAN> and <SPAN class="argument">passphrase</SPAN> match.</td>
54        </tr>
55        <tr>
56<td>in</td>
57<th>passphraseLength</th>
58<td>Passphrase length. Specify a value between <a href="../../../nn/uds/CTR/UDS_PASSPHRASE_LENGTH_MIN.html"><CODE>UDS_PASSPHRASE_LENGTH_MIN</CODE></a> and <a href="../../../nn/uds/CTR/UDS_PASSPHRASE_LENGTH_MAX.html"><CODE>UDS_PASSPHRASE_LENGTH_MAX</CODE></a>, inclusive.</td>
59        </tr>
60        <tr>
61<td>in</td>
62<th><CODE>pData</CODE></th>
63<td>Pointer to the optional data you want to set for the beacon.</td>
64        </tr>
65        <tr>
66<td>in</td>
67<th><CODE>dataSize</CODE></th>
68<td>Size of the optional data you want to set for the beacon. Specify a number equal to or less than <a href="../../../nn/uds/CTR/NET_DESC_APPDATA_SIZE_MAX.html"><CODE>NET_DESC_APPDATA_SIZE_MAX</CODE></a>.</td>
69        </tr> </table>
70    </div>
71<h2>Return Values</h2>
72<div class="section">Returns the function's execution result. Returns one of the <a href="../../../nn/Result/Overview.html"><CODE>Result</CODE></A> values listed below. <br />
73      <table class="arguments">
74        <thead>
75          <tr>
76<th>Value</th>
77<td>Description</td>
78          </tr>
79        </thead>
80        <tr>
81<th><CODE>Result::IsSuccess</CODE></th>
82<td>Successfully established local communication and began operating as a master.</td>
83        </tr>
84        <tr>
85<th><CODE>ResultNotInitialized</CODE></th>
86<td>The library is not initialized. Execute the <CODE><a href="../../../nn/uds/CTR/Initialize.html">Initialize</a></CODE> function.</td>
87        </tr>
88        <tr>
89<th><CODE>ResultInvalidState</CODE></th>
90<td>Not in an executable state. Returned when executed in a state other than <CODE>STATE_DISCONNECTED</CODE>.</td>
91        </tr>
92        <tr>
93<th><CODE>ResultOutOfRange</CODE></th>
94<td>The specified argument value was not in the valid range for the argument. Try again, specifying a valid value for the argument.</td>
95        </tr>
96        <tr>
97<th><CODE>ResultWirelessOff</CODE></th>
98<td>Entered wireless-disabled mode. Re-initialization is required.</td>
99        </tr>
100        <tr>
101<th><CODE>ResultTooLarge</CODE></th>
102<td>The <SPAN class="argument">dataSize</SPAN> exceeds <CODE><a href="../../../nn/uds/CTR/NET_DESC_APPDATA_SIZE_MAX.html">NET_DESC_APPDATA_SIZE_MAX</a></CODE>.</td>
103        </tr>
104        <tr>
105<th><CODE>ResultInvalidPointer</CODE></th>
106<td><SPAN class="argument">pData</SPAN> is <CODE>NULL</CODE>. <CODE>NULL</CODE> is allowed when <SPAN class="argument">dataSize</SPAN> is <CODE>0</CODE>.</td>
107        </tr>
108        <tr>
109<th>A value other than the above</th>
110<td>Failed for reasons other than those given above.</td>
111        </tr>
112      </table> </div>
113<h2>Description</h2>
114    <div class="section">
115<p>Sets optional data for the beacon and builds a new network.</p><p>Approximately 800 ms is needed to complete this because auto-selection of channels and other operations must be performed. </p><p>Using this <CODE>API</CODE> function allows you to set optional data for the beacon, when building the network. To update the optional data for the beacon after the network has been constructed, use the <CODE><a href="../../../nn/uds/CTR/SetApplicationDataToBeacon.html">SetApplicationDataToBeacon</a></CODE> function. The maximum size of this optional data is <CODE><a href="../../../nn/uds/CTR/NET_DESC_APPDATA_SIZE_MAX.html">NET_DESC_APPDATA_SIZE_MAX</a></CODE> bytes. Since it is not encrypted, note that it can be collected by any general device, such as a computer. Other devices can obtain this data by calling <CODE><A>Scan</A></CODE>, while they are connected as clients or spectators. This function is thread-safe.</p><!-- write here --></div>
116<h2>Revision History</h2>
117    <div class="section">
118      <dl class="history">
119        <dt>2011/09/07</dt>
120<dd>Standardized notation for wireless-disabled mode.<br />
121        </dd>
122        <dt>2011/02/21</dt>
123<dd>Added a timing guideline to the Description. Indicated that the maximum value for <CODE>maxEntry</CODE> is <CODE>NODE_MAX</CODE>.<br />
124        </dd>
125        <dt>2011/01/25</dt>
126<dd>Changed size of passphrase used from &quot;fewer than 255 (provisional)&quot; to &quot;at least 8 and no more than 255,&quot; and confirmed.<br />Changed to automatically set the channel to use, with the old function to specify the channel now limited to debugging purposes.<br />
127        </dd>
128        <dt>2010/10/15</dt>
129<dd>Expanded the information on the return values.<br />
130        </dd>
131        <dt>2010/06/14</dt>
132<dd>Initial version.<br />
133        </dd>
134      </dl>
135    </div>
136  <hr><p>CONFIDENTIAL</p></body>
137</html>