Provided a feedback path, so we can find out if our foreign device registration has been NAK'd.
This commit is contained in:
@@ -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.
|
/** 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,
|
* @return Positive number (of bytes sent) if registration was successful,
|
||||||
* 0 if no registration request was made, or
|
* 0 if no registration request was made, or
|
||||||
* -1 if registration attempt failed.
|
* -1 if registration attempt failed.
|
||||||
*/
|
*/
|
||||||
int dlenv_bbmd_result( void )
|
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;
|
return bbmd_result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -101,6 +101,11 @@ struct sockaddr_in; /* Defined elsewhere, needed here. */
|
|||||||
uint8_t * npdu,
|
uint8_t * npdu,
|
||||||
uint16_t received_bytes);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
+14
-1
@@ -883,7 +883,7 @@ uint16_t bvlc_receive(
|
|||||||
Foreign-Device message. At the expiration of the timer, the
|
Foreign-Device message. At the expiration of the timer, the
|
||||||
foreign device shall re-register with the BBMD by sending a BVLL
|
foreign device shall re-register with the BBMD by sending a BVLL
|
||||||
Register-Foreign-Device message */
|
Register-Foreign-Device message */
|
||||||
/* FIXME: clients may need this result */
|
/* Clients can now get this result */
|
||||||
(void) decode_unsigned16(&npdu[4], &result_code);
|
(void) decode_unsigned16(&npdu[4], &result_code);
|
||||||
BVLC_Result_Code = (BACNET_BVLC_RESULT) result_code;
|
BVLC_Result_Code = (BACNET_BVLC_RESULT) result_code;
|
||||||
debug_printf("BVLC: Result Code=%d\n", BVLC_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
|
#ifdef TEST
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user