Provided a feedback path, so we can find out if our foreign device registration has been NAK'd.

This commit is contained in:
tbrennan3
2011-09-12 21:21:39 +00:00
parent 364293b075
commit ce7e651156
3 changed files with 26 additions and 1 deletions
+7
View File
@@ -79,12 +79,19 @@ void dlenv_bbmd_ttl_set( int ttl_secs )
}
/** Get the result of the last attempt to register with the indicated BBMD.
* If we sent a foreign registration request, then see if we've received
* a NAK in our BVLC handler.
*
* @return Positive number (of bytes sent) if registration was successful,
* 0 if no registration request was made, or
* -1 if registration attempt failed.
*/
int dlenv_bbmd_result( void )
{
if ( (bbmd_result > 0) &&
(bvlc_get_last_result() == BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK) )
return -1;
/* Else, show our send: */
return bbmd_result;
}
#endif
+5
View File
@@ -101,6 +101,11 @@ struct sockaddr_in; /* Defined elsewhere, needed here. */
uint8_t * npdu,
uint16_t received_bytes);
/** Returns the last BVLL Result we received, either as the result of a BBMD
* request we sent, or (if not a BBMD or Client), from trying to register
* as a foreign device. */
BACNET_BVLC_RESULT bvlc_get_last_result();
#ifdef __cplusplus
}
#endif /* __cplusplus */
+14 -1
View File
@@ -883,7 +883,7 @@ uint16_t bvlc_receive(
Foreign-Device message. At the expiration of the timer, the
foreign device shall re-register with the BBMD by sending a BVLL
Register-Foreign-Device message */
/* FIXME: clients may need this result */
/* Clients can now get this result */
(void) decode_unsigned16(&npdu[4], &result_code);
BVLC_Result_Code = (BACNET_BVLC_RESULT) result_code;
debug_printf("BVLC: Result Code=%d\n", BVLC_Result_Code);
@@ -1286,6 +1286,19 @@ void bvlc_for_non_bbmd(
}
}
/** Returns the last BVLL Result we received, either as the result of a BBMD
* request we sent, or (if not a BBMD or Client), from trying to register
* as a foreign device.
*
* @return BVLC_RESULT_SUCCESSFUL_COMPLETION on success,
* BVLC_RESULT_REGISTER_FOREIGN_DEVICE_NAK if registration failed,
* or one of the other codes (if we are a BBMD).
*/
BACNET_BVLC_RESULT bvlc_get_last_result()
{
return BVLC_Result_Code;
}
#ifdef TEST
#include <assert.h>
#include <string.h>