Skip to content

Conversation

@jukkar
Copy link
Member

@jukkar jukkar commented May 2, 2017

This one replaces the very low level HTTP client sample application with a simple application that uses more user friendly HTTP client library.
Second patch creates a simple API for network application setup. So instead of each net sample application doing various configurations itself, there is now an API for doing that. Later patches will convert the net samples to use this new API.

@jukkar jukkar requested review from nashif, pfalcon and tbursztyka May 2, 2017 13:39
@nashif nashif added the In progress For PRs: is work in progress and should not be merged yet. For issues: Is being worked on label May 2, 2017
@pfalcon
Copy link
Contributor

pfalcon commented May 2, 2017

Second patch creates a simple API for network application setup.

Very cool, but why it's a part of PR titled "HTTP client API"? People interested in consistent netsamples API will never find it here. People who saw it once, later likely won't be able to find again where it was. I'd suggest to resubmit it as a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very simple...

@jukkar
Copy link
Member Author

jukkar commented May 2, 2017

The set cannot be used without the netsamples API in second commit. Why would we need to supply it in different PR?

@mbolivar
Copy link
Contributor

mbolivar commented May 2, 2017

I have a general question about code like this (which applies also to samples/bluetooth/gatt).

Is it expected that out of tree applications which want this functionality will be building against the files in samples/net/common, the same way the in-tree apps in samples/ do?

Copy link
Contributor

@pfalcon pfalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"net: samples: Common application init API" commit looks good.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This apparently should be removed before merge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling debug by default for sample apps is currently done on purpose. Because there is no kconfig for the sample apps debug options, it makes sense to activate the debugging by default for them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jukkar : Ack, so do we need "#if 1" line? If you say "yes", I'm only happy, I love these, and will include them in my patches ;-).

@pfalcon
Copy link
Contributor

pfalcon commented May 2, 2017

The set cannot be used without the netsamples API in second commit. Why would we need to supply it in different PR?

Because it's independent from "HTTP client API", and is a standalone feature. For example, it can be approved independently and be merged, not being blocked by review of completely different features.

Of course, I'm not in position to request splitting this particular PR, and a single case is not that important. I'm just expressing hope that switching to Github won't lead to proliferation of cases when unrelated features are submitted in one PR. With Gerrit, that's simply not possible - each commit is a separate review, even if one depends on another. I always thought of that as a limitation of Gerrit, but have to admit that disciplines developers. Multi-commit reviews should be an exception, not a rule. IMHO.

@pfalcon
Copy link
Contributor

pfalcon commented May 2, 2017

@mbolivar

Is it expected that out of tree applications which want this functionality will be building against the files in samples/net/common, the same way the in-tree apps in samples/ do?

My guess that as one of the next evolutionary steps we might want to convert it to Kconfig-driven "sub-subsystem". But trying to build OOT app against samples/net/common might be a good first step, to show how ugly it is, and the need for Kconfig-based selection ;-).

Copy link
Member

@nashif nashif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not create a generic client/server API that is not part of the samples and instead available to applications directly without having to include additional code? Samples need to work stand-alone and not by referencing additional code that is not part of Zephyr. What we need there is a simple way to initiate a client or a server and hook into it.

@pfalcon
Copy link
Contributor

pfalcon commented May 2, 2017

@nashif : I believe Jukka does exactly that in this patch. It introduces subsys/net/lib/http/http_client.c , and refactors existing samples to use it.

(Is it just me, or people review PRs on github less closer than it was on Gerrit? Perhaps we need to adjust to new look&feel ;-) Oh, and another reason to stuff less commits in every PR ;-) ).

@nashif
Copy link
Member

nashif commented May 2, 2017

@nashif : I believe Jukka does exactly that in this patch. It introduces subsys/net/lib/http/http_client.c , and refactors existing samples to use it.

No he does not, the only code I see in the first patch is adding some "common" code under samples, which is what I do not like, samples will have to reference code that is not part of Zephyr. I prefer to see this common server code implemented as an API, not some common code you include in your Makefile.

@pfalcon
Copy link
Contributor

pfalcon commented May 2, 2017

Is it just me, or people review PRs on github less closer than it was on Gerrit?

Who'd say!

It introduces subsys/net/lib/http/http_client.c

It doesn't introduce it, it moves bunch of functionality into it, apparently from samples, even bigger bunch hopefully newly added. My biggest interest whether it handles multiple TCP packets, by looking at the serve counterpart at zephyrproject-rtos/net-tools#1, it should. Because older "http client" was funny and supported only single HTTP packet ;-).

@pfalcon
Copy link
Contributor

pfalcon commented May 2, 2017

the only code I see in the first patch is adding some "common" code under samples

I believe there can't be better argument against adding unrelated commits into one PR ;-). For me, the patch @nashif describes is "last" :-D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/the Qemu/QEMU/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/active/activate/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/qemu/QEMU/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these lines need to be indented 3 spaces to be part of the code-block

Copy link
Contributor

@dbkinder dbkinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some misspellings and format fixes

@jukkar
Copy link
Member Author

jukkar commented May 3, 2017

Is it expected that out of tree applications which want this functionality will be building against the files in samples/net/common, the same way the in-tree apps in samples/ do?

Currently the sample-app setup API was only meant for network sample applications as we cannot really know what kind of requirements the out-of-tree apps have.

@jukkar
Copy link
Member Author

jukkar commented May 3, 2017

Because it's independent from "HTTP client API", and is a standalone feature. For example, it can be approved independently and be merged, not being blocked by review of completely different features.

Without the sample-app API patch, the http-client application will not work properly. That is why they are submitted together. Besides the sample-app API patch is meant to be "internal" api and only usable for sample apps (at least in this stage), so we can change it at will atm.

@jukkar
Copy link
Member Author

jukkar commented May 3, 2017

Why not create a generic client/server API that is not part of the samples and instead available to applications directly without having to include additional code? Samples need to work stand-alone and not by referencing additional code that is not part of Zephyr. What we need there is a simple way to initiate a client or a server and hook into it.

Please, one step at a time. We can create certainly more APIs on top of this HTTP client API and then we can remove some of the samples if needed.
For the testing, currently some components from net-tools is needed if one follows the HTTP client directory README file. We could make this self contained if really needed, but at a later stage.

@jukkar
Copy link
Member Author

jukkar commented May 3, 2017

No he does not, the only code I see in the first patch is adding some "common" code under samples, which is what I do not like, samples will have to reference code that is not part of Zephyr. I prefer to see this common server code implemented as an API, not some common code you include in your Makefile.

The "common" sample code API is there so we can get rid of the similar startup functionality that is found in several net sample applications. I though this was something @nashif wanted earlier, but perhaps I misunderstood. At this point the sample app API is very internal code and not meant to be used any out-of-tree application.

So there are two things in this patchset:

  1. HTTP client API implementation and convert http-client app to use it
  2. Net sample app startup API and convert http-client to use it

I could have sent 2) as a separate patch but then the two PRs would be need to be applied in certain order, so it is more convenient to anyone testing this if the patches are groupped in the same set.

@jukkar
Copy link
Member Author

jukkar commented May 3, 2017

It doesn't introduce it, it moves bunch of functionality into it, apparently from samples, even bigger bunch hopefully newly added. My biggest interest whether it handles multiple TCP packets, by looking at the serve counterpart at zephyrproject-rtos/net-tools#1, it should. Because older "http client" was funny and supported only single HTTP packet ;-).

The HTTP client API expects the caller to supply the HTTP context and "response" buffer where the HTTP response is stored. Currently there is only one HTTP context and one such buffer in the sample http-client, so only one HTTP query at the time for that sample app. The API itself does not limit the number of queries.

@pfalcon
Copy link
Contributor

pfalcon commented May 3, 2017

Without the sample-app API patch, the http-client application will not work properly. That is why they are submitted together. Besides the sample-app API patch is meant to be "internal" api and only usable for sample apps (at least in this stage), so we can change it at will atm.

That's all good, but my point is that not these criteria should be deciding whether patches should be submitted as one PR or as different. Instead, only one factor should be enough: whether they reasonably can be submitted separately. Of course, there's enough fuzz factor and subjectivity in that, and in this case, we apparently have different opinions on that.

Anyway, this isn't much related to this specific patch, instead to a general "migration to github" discussion. So, I'm finishing with that, though my original point remains - having more commits in one PR complicates the review.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's "Callback used when reply has been received", why is it called http_request_cb_t?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I will rename it to http_response_cb_t

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use enum http_method in some places, and char* in other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from HTTP client application, it wanted to add a space after the method which required a separate string. I will investigate if we can use directly the strings that are available from the http_parser.c.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to add a note about format of header_fields.

@pfalcon
Copy link
Contributor

pfalcon commented May 3, 2017

@jukkar :

The HTTP client API expects the caller to supply the HTTP context and "response" buffer where the HTTP response is stored.

I see, and it's capable to accumulate response spread over different TCP packets. So, that's good, maybe the problem I saw was in different protocol handling.

So, this is definitely a good evolutionary update of HTTP client. Thanks for accepting suggestions for better naming of different pieces. I think that it's still not last time when we may need to tweak the HTTP client, but for now, this is definitely a good improvement, +1.

@mbolivar
Copy link
Contributor

mbolivar commented May 3, 2017

Is it expected that out of tree applications which want this functionality will be building against the files in samples/net/common, the same way the in-tree apps in samples/ do?

Currently the sample-app setup API was only meant for network sample applications as we cannot really know what kind of requirements the out-of-tree apps have.

I assumed that the main point of adding to samples/ is to provide working reference code, that does something useful, which Zephyr's users can try out and modify to write their own applications. Especially so since there is already a tests/ directory for exercising functionality. If it's more of an internal exercise for the satisfaction of Zephyr's developers, then never mind.

If the audience for samples/ includes the users, though, then having these "common" directories presents a problem. People who want to build applications similar to a given sample are either going to build directly against the code in the common directories, which is ugly and something of a layering violation, or they'll copy/paste it, which is also problematic in that updates and fixes to the in-tree versions imply manual maintenance for the users.

jukkar added 2 commits May 3, 2017 17:03
Instead of separate sample application that does everything
related to HTTP client connectivity, create a HTTP client library
that hides nasty details that are related to sending HTTP methods.
After this the sample HTTP client application is very simple and
only shows how to use the client HTTP API.

Signed-off-by: Jukka Rissanen <[email protected]>
This creates a common API for network sample applications for
setting up IP addresses etc. The HTTP client application is modified
to use this API.

Signed-off-by: Jukka Rissanen <[email protected]>
@jukkar
Copy link
Member Author

jukkar commented May 3, 2017

I assumed that the main point of adding to samples/ is to provide working reference code, that does something useful, which Zephyr's users can try out and modify to write their own applications. Especially so since there is already a tests/ directory for exercising functionality. If it's more of an internal exercise for the satisfaction of Zephyr's developers, then never mind.

The samples are meant to be example how to do things. What this "things" means is the question. If you look at the various network samples in samples/net/*, they do these setup etc. things a bit differently. There are multiple ways of setting up network etc, it really depends on what the application is expected to do.
Many of these "things" are similar to each other so that is why I started to build an API that initially would be used by the sample apps. We could expand the scope to create a set of APIs for general applications to use. It is just that currently we are just experimenting with this API. So lets see how far we can go with it. If we find out that we cannot generalize some kind of network setup API, then that is fine too.

If the audience for samples/ includes the users, though, then having these "common" directories presents a problem. People who want to build applications similar to a given sample are either going to build directly against the code in the common directories, which is ugly and something of a layering violation, or they'll copy/paste it, which is also problematic in that updates and fixes to the in-tree versions imply manual maintenance for the users.

I agree with you. As mentioned in my comment above, lets try to build up some generalized API for applications to use for network setup.

@jukkar jukkar changed the base branch from net to master May 3, 2017 14:21
@mbolivar
Copy link
Contributor

mbolivar commented May 3, 2017

I agree with you. As mentioned in my comment above, lets try to build up some generalized API for applications to use for network setup.

Cool, thanks, glad to hear it! Sorry, as your initial response had me wondering...

My main concern is about this becoming a pattern which grows the way samples/bluetooth/gatt has grown. There are already 500+ SLOC in there, which provide really useful things like IPSS. Our application has a copy of that in https://github.com/Linaro/zephyr-fota-hawkbit/blob/master/src/bt_ipss.c. That diverged a bit, and has had to be maintained for little things like converting to SPDX, the new integer types, etc. that could have taken no effort on our part if we used a common library in the kernel instead.

@jukkar
Copy link
Member Author

jukkar commented May 4, 2017

@nashif @dbkinder Fixed the documentation and sanitychecks, are you guys ok with these patches?

@nashif
Copy link
Member

nashif commented May 4, 2017

The "common" sample code API is there so we can get rid of the similar startup functionality that is found in several net sample applications. I though this was something @nashif wanted earlier, but perhaps I misunderstood. At this point the sample app API is very internal code and not meant to be used any out-of-tree application.

Yes, i want this, but done as part of Zephyr and through well documented APIs, not additional source files we include in the sample. The cross referencing of source files across the sample tree has always been a problem, especially with the build system right now. I want basically to be able to copy a sample and build it out of tree without having to deal with additional files, i want to setup client/server using well defined APIs.

@nashif
Copy link
Member

nashif commented May 4, 2017

@jukkar
I understand we have too many samples doing the same thing in different ways and that your change would at leat fix this to some level. I want to know what is the plan with moving this code into the zephyr code and providing this functionality using APIs instead of source code inclusion and things like

#include "net_sample_app.h"

@pfalcon
Copy link
Contributor

pfalcon commented May 4, 2017

+1 for not setting unrealistic expectations for the usual incremental patches. I recently did a change similar to that - exposed to 3rd-party apps previously internal net shell options: ff3b019 . So, @mbolivar interested in that, me potentially interested in that, @jukkar likely interested in that too, but his time currently better be used on real bugs in the stack. We'll get there.

#include "net_sample_app.h"

IMHO, that name is lousy and needs more bikeshedding ;-). Ditto for Kconfig names which will activate it, etc. Again, let's do it outside of this initial patch which already makes a good progress.

@mbolivar
Copy link
Contributor

mbolivar commented May 4, 2017

but his time currently better be used on real bugs in the stack. We'll get there.

Makes sense to me 👍

@jukkar
Copy link
Member Author

jukkar commented May 4, 2017

Yes, i want this, but done as part of Zephyr and through well documented APIs, not additional source files we include in the sample. The cross referencing of source files across the sample tree has always been a problem, especially with the build system right now. I want basically to be able to copy a sample and build it out of tree without having to deal with additional files, i want to setup client/server using well defined APIs.

Well, my immediate plan was to

  1. Fix http_client by moving some of the code from the sample to library (patch 1 in this set)
  2. Modify http_client application startup and move common code (shared between various network samples) into an internal library (patch 2 in this set). So internal library only at this first stage as we probably need to tweak the APIs a lot.
  3. Rework the internal library and generalize it into something that out-of-tree apps can use it. There seems to be some interest to this kind of library as there has been lot of comments about this in this PR. This is future work.
  4. Investigate/create some kind of client/server API for even more easier use of the various net APIs in current Zephyr. This seems to be in wishlist from @nashif. We can discuss that in other forum as this PR is not a proper forum for that.

Anyway, I already started to convert HTTP server to have a similar http-server library as the client one. If the there is too much resistance against about merging this patch, please tell me know so I do not waste any more time for http-server fixes.

@lpereira
Copy link
Member

lpereira commented May 4, 2017

You might want to take a look at a review I made a few months ago on the original HTTP patches, it has some comments on how to design a good client API.

@nashif
Copy link
Member

nashif commented May 4, 2017

@jukkar ok, we have a deal then, can we have JIRAs for all those points so we wont forget them and potentially have them for 1.9?

Thanks.

@nashif nashif merged commit dc0fc57 into zephyrproject-rtos:master May 4, 2017
@nashif nashif removed the In progress For PRs: is work in progress and should not be merged yet. For issues: Is being worked on label May 4, 2017
nagineni pushed a commit to nagineni/zephyr that referenced this pull request Nov 20, 2017
@jukkar jukkar deleted the http-client branch July 20, 2018 19:13
LukaszMrugala pushed a commit to LukaszMrugala/zephyr that referenced this pull request Jul 3, 2024
…rtos#50)

Build ISH kernel using wiki steps. The kernel can be built with provided inputs or with default values.

Signed-off-by: Mateusz Redzynia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants