Function |
|
Ask Coordinator for bonding or other Node for prebonding to the network via RF. Bond the Node in cooperation with the Coordinator or prebond the Node in cooperation with an already bonded Node. See IQRF OS User’s guide, chapter Bonding for more information. |
Purpose |
|
Request by the Node to be included into the network on both Coordinator's and Node's sides. Moreover, 4 B user data is exchanged between prebonded device and the device providing prebonding. |
Syntax |
|
bit bondRequestAdvanced() |
Parameters |
|
– |
Input values |
|
• _3CHTX: • 1 Bonding will be accomplished via 3 service channels. This flag is automatically post-cleared after bondRequestAdvanced is finished. 0 Exclusively intended for preboding only. Prebonding will be accomplished via the operation channel. This is the default value. It is not necessary to pre-clear this flag before bondRequestAdvanced during normal operation because it is post-cleared by OS after every previous bondRequestAdvanced usage (see above). • nodeUserDataToSend[4] - user data to be delivered to the Node or Coordinator providing prebonding. |
Return value |
|
• 1 – Node has been bonded or prebonded • 0 – Node has neither been bonded nor prebonded |
Output values |
|
• Information about (pre)bonding is recorded in EEPROM. • The amIBonded function starts to return TRUE whenever is called while the Node is bonded by bondRequestAdvanced and not being unbonded by removeBond. • hostUserDataReceived[4] - user data delivered from the Node or Coordinator providing prebonding. • Every bondRequestAdvanced call pre-increments the value of the internal bondingCounter variable (it is sent with the request). This counter is used with the bondingMask register to handle the situation when more than one Node with enabled prebonding would respond to the request. See IQRF OS User’s guide, chapter Bonding. The bondingCounter is cleared after reset. |
Preconditions |
|
• The same Access password must be set (in TR configuration or by setAccessPassword) as at the Coordinator. |
Remarks |
|
• Bonding is a mutual relationship between Coordinator and Node. The Coordinator assigns a Node number (1 to 239 or 0xFE) to the Node which serves as the Node address within the network. (Coordinator itself has the address 0.) Bonding accomplishes via exchanging system RF packets and results are stored in the system part of internal EEPROMs.The user can check the result later on by amIBonded and possibly change it by removeBond or removeBondAddress. • Prebonding is an initial phase of remote bonding. The new (bond requesting) Node gets the network ID, the universal address 0xFE, and the Network password from another (already bonded) Node or the Coordinator. Prebonded Node becomes accessible RX only in the given network and can be authorized by the Coordinator to get a requested address. • This function takes approx. 60 ms. It sends just one request for bonding and then waits for some time for confirmation. • Requesting packet is sent in the currently selected RF TX mode (STD or LP). • RF power and RF channel are not affected. • The assigned address can be found by function getNetworkParams. |
Side effects |
|
• DLEN, PIN, bufferRF, and bufferINFO are modified. • IQMESH mode must be restored by setNodeMode after bondRequestAdvanced. • A/D converter control registers are modified. |
See also |
|
amIBonded, removeBond, rebondNode, getNetworkParams, setNodeMode, setRFmode |
Example |
|
while (!amIBonded()) // Request for beeing bonded (if not bonded yet) { clrwdt(); // If WDT active pulseLEDG(); // Data to be delivered to the prebonding device nodeUserDataToSend[0] = myDataToPrebondingDevice[0]; ... nodeUserDataToSend[3] = myDataToPrebondingDevice[3]; if (bondRequestAdvanced()) // Repeatedly try to bond { pulseLEDR(); // Data received from the prebonding device myDataFromPrebondingDevice[0] = hostUserDataReceived[0]; ... myDataFromPrebondingDevice[3] = hostUserDataReceived[3]; } waitDelay(1); } // Until successful setNodeMode(); // Restore |