Refactored.
This commit is contained in:
+24
-46
@@ -104,48 +104,6 @@ void apdu_set_confirmed_handler(BACNET_CONFIRMED_SERVICE service_choice,
|
|||||||
Confirmed_Function[service_choice] = pFunction;
|
Confirmed_Function[service_choice] = pFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns true if the handler is set */
|
|
||||||
bool apdu_confirmed_handler(BACNET_CONFIRMED_SERVICE service_choice)
|
|
||||||
{
|
|
||||||
bool status = false;
|
|
||||||
if ((service_choice < MAX_BACNET_CONFIRMED_SERVICE) &&
|
|
||||||
(Confirmed_Function[service_choice] != NULL))
|
|
||||||
status = true;
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool apdu_service_supported(BACNET_SERVICES_SUPPORTED service_supported)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
bool status = false;
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
if (service_supported < MAX_BACNET_SERVICES_SUPPORTED) {
|
|
||||||
/* is it a confirmed service? */
|
|
||||||
for (i = 0; i < MAX_BACNET_CONFIRMED_SERVICE; i++) {
|
|
||||||
if (confirmed_service_supported[i] == service_supported) {
|
|
||||||
if (apdu_confirmed_handler(i))
|
|
||||||
status = true;
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
/* is it an unconfirmed service? */
|
|
||||||
for (i = 0; i < MAX_BACNET_UNCONFIRMED_SERVICE; i++) {
|
|
||||||
if (unconfirmed_service_supported[i] == service_supported) {
|
|
||||||
if (apdu_unconfirmed_handler(i))
|
|
||||||
status = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allow the APDU handler to automatically reject */
|
/* Allow the APDU handler to automatically reject */
|
||||||
static confirmed_function Unrecognized_Service_Handler;
|
static confirmed_function Unrecognized_Service_Handler;
|
||||||
|
|
||||||
@@ -169,14 +127,34 @@ void apdu_set_unconfirmed_handler(BACNET_UNCONFIRMED_SERVICE
|
|||||||
Unconfirmed_Function[service_choice] = pFunction;
|
Unconfirmed_Function[service_choice] = pFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool apdu_unconfirmed_handler(BACNET_UNCONFIRMED_SERVICE service_choice)
|
bool apdu_service_supported(BACNET_SERVICES_SUPPORTED service_supported)
|
||||||
{
|
{
|
||||||
|
int i = 0;
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
if ((service_choice < MAX_BACNET_UNCONFIRMED_SERVICE) &&
|
if (service_supported < MAX_BACNET_SERVICES_SUPPORTED) {
|
||||||
(Unconfirmed_Function[service_choice] != NULL))
|
/* is it a confirmed service? */
|
||||||
status = true;
|
for (i = 0; i < MAX_BACNET_CONFIRMED_SERVICE; i++) {
|
||||||
|
if (confirmed_service_supported[i] == service_supported) {
|
||||||
|
if (Confirmed_Function[i] != NULL)
|
||||||
|
status = true;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
/* is it an unconfirmed service? */
|
||||||
|
for (i = 0; i < MAX_BACNET_UNCONFIRMED_SERVICE; i++) {
|
||||||
|
if (unconfirmed_service_supported[i] == service_supported) {
|
||||||
|
if (Unconfirmed_Function[i] != NULL)
|
||||||
|
status = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,16 +128,9 @@ extern "C" {
|
|||||||
void apdu_set_confirmed_handler(BACNET_CONFIRMED_SERVICE
|
void apdu_set_confirmed_handler(BACNET_CONFIRMED_SERVICE
|
||||||
service_choice, confirmed_function pFunction);
|
service_choice, confirmed_function pFunction);
|
||||||
|
|
||||||
/* returns true if the handler is set */
|
|
||||||
bool apdu_confirmed_handler(BACNET_CONFIRMED_SERVICE service_choice);
|
|
||||||
|
|
||||||
void apdu_set_unconfirmed_handler(BACNET_UNCONFIRMED_SERVICE
|
void apdu_set_unconfirmed_handler(BACNET_UNCONFIRMED_SERVICE
|
||||||
service_choice, unconfirmed_function pFunction);
|
service_choice, unconfirmed_function pFunction);
|
||||||
|
|
||||||
/* returns true if the handler is set */
|
|
||||||
bool apdu_unconfirmed_handler(BACNET_UNCONFIRMED_SERVICE
|
|
||||||
service_choice);
|
|
||||||
|
|
||||||
/* returns true if the service is supported by a handler */
|
/* returns true if the service is supported by a handler */
|
||||||
bool apdu_service_supported(BACNET_SERVICES_SUPPORTED
|
bool apdu_service_supported(BACNET_SERVICES_SUPPORTED
|
||||||
service_supported);
|
service_supported);
|
||||||
|
|||||||
Reference in New Issue
Block a user