Skip to content
Extraits de code Groupes Projets
Valider 373daf4a rédigé par François De Keersmaeker's avatar François De Keersmaeker
Parcourir les fichiers

CoAP: check if request

parent d052494c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -63,6 +63,17 @@ typedef struct coap_message
*/
coap_message_t coap_parse_message(uint8_t *data, uint16_t length);
/**
* @brief Check if a CoAP message is a request.
*
* A CoAP message is a request if its type is Confirmable or Non-Confirmable.
*
* @param coap_message CoAP message to check
* @return true if the given CoAP message is a request
* @return false if the given CoAP message is a response
*/
bool coap_is_request(coap_message_t coap_message);
///// DESTROY /////
......
......@@ -146,6 +146,20 @@ coap_message_t coap_parse_message(uint8_t *data, uint16_t length)
return message;
}
/**
* @brief Check if a CoAP message is a request.
*
* A CoAP message is a request if its type is Confirmable or Non-Confirmable.
*
* @param coap_message CoAP message to check
* @return true if the given CoAP message is a request
* @return false if the given CoAP message is a response
*/
bool coap_is_request(coap_message_t coap_message)
{
return coap_message.type == COAP_CON || coap_message.type == COAP_NON;
}
///// DESTROY /////
......
......@@ -45,6 +45,7 @@ void test_coap_non_get() {
expected.uri = "/oic/res?rt=x.com.samsung.provisioninginfo";
// Compare messages
CU_ASSERT_TRUE(coap_is_request(actual));
CU_ASSERT_EQUAL(actual.type, expected.type);
CU_ASSERT_EQUAL(actual.method, expected.method);
CU_ASSERT_STRING_EQUAL(actual.uri, expected.uri);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter