-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MINIFICPP-558: initial provisioning for CoAP #437
Conversation
Adding tests presently, but providing a wip view. |
extensions/coap/CMakeLists.txt
Outdated
|
||
set(BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}/extensions/coap") | ||
if (APPLE) | ||
set(BYPRODUCT "${BASE_DIR}/extensions/coap/thirdparty/libcoap-src/.libs/libcoap-2-gnutls.a") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may need a little modification as artifacts can vary depending on what is used for building TLS
@@ -42,6 +42,8 @@ def __init__(self, output_validator): | |||
|
|||
self.segfault = False | |||
|
|||
self.segfault = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already there two lines above.
// initialization mutex. | ||
std::mutex initialization_mutex_; | ||
|
||
std::atomic<bool> initialized_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we plan to have multiple instances of COAPConnectorSerivce?
|
||
void no_acknowledgement(struct coap_context_t *ctx, coap_session_t *session, coap_pdu_t *sent, coap_nack_reason_t reason, const coap_tid_t id){ | ||
if (global_ptrs.received_error){ | ||
global_ptrs.received_error(receiver, ctx, -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
} | ||
|
||
int coap_event(struct coap_context_t *ctx, coap_event_t event, struct coap_session_t *session){ | ||
if (event == COAP_EVENT_SESSION_FAILED && global_ptrs.received_error){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please indent with 2 spaces
size_t data_len; | ||
coap_opt_iterator_t opt_iter; | ||
coap_opt_t * block_opt = coap_check_option(received, COAP_OPTION_BLOCK1, &opt_iter); | ||
if (block_opt) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
if(!block_opt)
?
return -1; | ||
} | ||
|
||
int8_t CoapProtocol::getString(const C2ContentResponse * const cmp, const std::string &name, std::string *value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it's C++, why value is a pointer (ref would be fine)?
Moreover I don't see why to have 0 or -1 return codes, empty string would be fine as well to indicate the lack of existence.
} | ||
|
||
const C2Payload * const CoapProtocol::getPayload(const std::string &name, const C2Payload &payload) { | ||
if (payload.getLabel() == name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return getPayLoad(&payload);
As the pointer version exists, why to duplicate?
|
||
coap_str_const_t pld; | ||
pld.length = size; | ||
pld.s = payload; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given .s is const uint8_t* ( https://github.com/obgm/libcoap/blob/develop/include/coap2/str.h ), could you change the signature of the function to handle the payload as const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to look what it is now, but we'll probably keep with that the outer facing types are and translate as needed/ I don't know if we can move to const as we'll probably be taking ownership of that buffer in the next commit. that is what the initial version did per libcoap did ( not sure if they do that in coap 2 ) . It ultimately depends on what we end up with ( coap vs coap2 ), but appreciate the request!
|
||
coap_address_t dst_addr, src_addr; | ||
coap_uri_t uri; | ||
uri.host.s = reinterpret_cast<unsigned char *>(const_cast<char*>(host_.c_str())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uri.host is coap_str_const_t, which has "s" as const uint8_t*, so there is no need of const cast here, just reinterpret cast to "const uint8_t*".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks for the diligence. This was changed last minute ( from coap to coap2 ) and I may return back to coap1 ( in libcoap) where the signature is unsigned char. I posted this early for someone to take a gander from an integration perspective, so this is a WIP.
ff26f81
to
4a667b7
Compare
test framework still under dev MINIFICPP-683: Remove extraneous std::move
3d07f09
to
77d6c08
Compare
77d6c08
to
13157cb
Compare
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically master)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.