ESP32 - combining two or more SDK example projects into one - python

tl;dr -- how do I combine a pair of SDK projects together and have the "menuconfig" system work properly?
I have a simple project in mind for an ESP32 module: Have the ESP32 provide a new dedicated WiFi network that allows a smart phone to connect directly to the ESP32. Once connected, the phone can point its web browser to the IP address of the ESP32 (hard-coded as 192.168.1.1) and the ESP32 will accept HTTP connections from the phone. Thus the user will have a simple interface through which to interact with the ESP32 using HTML data-entry forms, buttons and so on.
Note, this connection goes no further than the ESP32, no internet connection is required at all for this project.
Luckily, the SDK for the module includes lots of examples, and I have managed to get the web server working, and also the WiFi access point, but not both at the same time. These are two example projects ("... examples/protocols/http_server/simple" and "... examples/wifi/getting_started/softAP").
So far I've managed to discover that the WiFi access point software runs in the "background" and continues even after the main() function has ended. This means that I should be able to bring in the web-server code from the other example and execute it in the main() function. I'm pretty sure that will be feasible (please correct me if I'm mistaken).
The Question:
Each of these two example projects contain a "idf.py menuconfig" command that lets the user quickly change any of the important settings such as the WiFi SSID or the HTTP basic authentication password.
I'd like to retain this menu system after the two projects have been combined because it's extremely useful and somewhat reduces the human error involved in altering the code before recompiling.
Is there a simple way to combine the menuconfig systems from two SDK example projects into a single one that can be used to fully configure a project that is a combination of both code-bases?
Further info: I'm using the ESP-IDF dev kit on an Ubuntu 20 virtual machine, connecting to the ESP32 via USB.

It's very simple. The menuconfig items are described in the component's Kconfig.projbuild file. If you want add those items from one project to the other, you can simply copy-paste the content of one main/Kconfig.projbuild file to the other one and that's it. See ESP IDF documentation for details.

Related

How can I access the "Documents" section on an IceWarp server using python?

My internet provider uses IceWarp as an interface to my mails, notes, documents (and stuff) on their server. I'd like to use the Documents section to exchange files with my computer without having to resort to a web browser. Therefore I'd like to use Python scripts.
Can it be done at all and, if yes, where can I find hints? I know the product is proprietary so I don't expect tons of documentation to be freely available.
Probably no need to script it, there's an app from the vendor that is supposed to do the file synchronization between server and your computer. See IceWarp FileSync!
If you still want to script it, the most flexible approach would be through WebDAV protocol

Python implementing simple web data storage

I am trying to develop a python PyQt program that allow user to enter data about personal particulars and review them at a later time for processing purpose.
The program will be used by less than 5 persons at the same time. So, i am thinking to use Sqlite3 database as i believe it should be able to cope for that amount of traffic.
The frame work i have in mind is that, the clients will have their own copy of my python pyqt program on each machine. Whenever they perform any operations that required data read/write, it will connect to the server thorough internet and read/write from the sqlite.db on the server.
Basically, the server will be nothing but a remote data storage.
Currently, i am able to create the required GUI for data inputs by using various widgets like QlineEdit, QCombobox, QTextEdit and so on.
But i have never done network programming before, thus i have no idea how to implement a server that store the sqlite data file for my software. So my questions are
(1) if i have a PC that has 24/7 internet connection, how do i set it up so that it can act as a server that store the data file for my software?
(2)In what way can/should my program communicate to that server through internet.
Even if you can't give me exact answer, i would appreciate if you can provide me some information of so that i look up and study about it.
Any constructive advice will be appreciated.
FYI: all the PCs will be running windows XP SP3 32 bits.
There are different ways for a client to communicate with a server.
You can use
XMLRPC to create an object with methods that are called on the server side
You can use HTTP and REST for the server with the library requests or urllib for the client
For the latter you can use flask, bottle, django or other frameworks to create a website that serves the content
(tutorials)
You can use Pyro to remotely access the objects on the server. Useful if the clients should also communicate with eachother.
You can create your own protocol. You will learn a lot and value the other options.
The list is not complete
I suggest that you have a look at XMLRPC if that fits. For number 2 I can say that many APIs use such a HTTP-interface (twitter, github, facebok, google). It is easy to use also for other people.
Security is important. I am not an expert. If you send username and password in plain text then use SSL to encrypt the connection. If you can not get ssl to work with python you can use stunnel.

Changing a program to be used on a webserver

Say I have code written in python that analyzes files on my computer and returns a result. It works great locally on my HD, but now I'd like to turn it into a mobile app. This means I'll require a server of some kind (cloud for instance) where users can access it.
It is my understanding that all that would be required is a method to grant user credentials and permissions to the patrons so they can access the "run" command in my analysis program. But honestly, I have no ZERO visibility in this area and don't really know where to begin.
I only have two questions:
Users & their credentials are endless, but they all have to share the same analysis program. I don't know much about servers, but wouldn't this method cause long queue times? Generally-speaking what considerations would I have to make in my analysis code to avoid this?
Can someone just point me in the direction of what I'd need to learn in order to answer the above question? This topic is a bottomless pit of information and I don't wanna get trapped.
Thanks.
Django is an MVC Web framework which possesses all features required for doing Web applications with Python. Simply go through the tutorial and you should be up and running in no time, on your local machine.
To deploy there are various options, be it a cloud instance (a lot of providers here, including Rackspace and Amazon, Google for "django web hosting"), or "traditional" server machines (again a lot of providers here).
The "mobile" part is just the user interface. This affects decisions in the presentation part of your application, and you can restricted this to the View part in Django jargon (i.e. the HTML templates) of your Web application. You can look for frameworks which allow the production of aesthetically decent (or better) user interfaces HTML tailored for mobile/tablet devices, e.g. JQueryMobile.
Therefore direction: start with Django -> deploy on a server "somewhere" -> tailor your user interface for mobile devices.

Cross Platform Event Notification

I hope you guys can spare a moment with some ideas on how to develop my idea.
I have an Asterisk-based telephone switch . When an incoming call is arriving, I can make sure the server runs an external script of any language.
Here comes my development work. I would like to notify a group of listening clients about the call, and probably open a browser page on their computer.
What kind of approach would you take for this sort of server-based push notification? (with no iPhone involved)
I am open to any language.
Thanks
You can use or build off a tool like callPopPy, which interacts with Asterisk's existing notification subsystem. More options are listed here.
Maybe have a look at www.pubnub.com .. its commercial, but lets you send 5 million messages a month for free. Essentially it lets you create a named channel, and have X number of clients connect to it and send messages back and forth.
Using one of these services would of course require you to write a client to distribute to your users (in your language of choice) and tie's you in somewhat (shouldn't really be a problem as you could swap in some other solution later if they go under or whatever.)
The upside would be, very good x-platform support and a very clean API, infrastructure taken care of for you (for example clients can still connect the the channel even if your asterisk box is down or whatever)
(and no, I don't work for pubnub! but it seems like a no-brainer to use it with the 5mil messages free deal!)

Can I "embed" a Python back-end in an AIR application?

I'm trying to find out if there is a way I could embed a Python back-end into an AIR application? I'm looking to employ an approach similar to the one outlined here to implement the business logic for my application, but additionally, I would like to provide the user with a single binary which they can load. I don't want the user to have to fire up a seperate server process to make this work. Is this possible in some way or am I out of luck?
You cannot embed your Python server in an AIR application. So basically you are out of luck.
The simplest solution probably is to run a server on a central location that all your users can connect to from their AIR apps. That means that all/most of the data will be on your server, and not on the users computer, I don't know if that is a big issue but I guess it is.
Also depending on your target systems you could create the program you want yourself without (fully) depending on AIR. You can generate executables for windows and osx from Flash CS3/4 or you can use a special (commercial) executable-maker that provides some more functionality. Wrapping this exe and your python program in a meta-executable that launches both should be possible with some work. Of course you won't have the benefits if the AIR installer etc in this case.
OK, so since it didn't seem possible to go that way around, I came up with an alternative that seems to work for what I want.
Instead of trying to embed Python inside AIR, I've gone the other way around: I'm building my Python code into a stand-alone executable using PyInstaller and bundling the AIR application as a resource. The Python code then starts up it's webserver and fires off the AIR app which can then connect to the (local) remote services as required.
Probably. We are using a J2EE server side which uses SOAP webservices to talk to our AIR application on the frontend. You should be able to do the same because soap doesn't care which technology sits on either side of it.
You can always have the application launch from a single binary which first fires up the server, then the client, if both are expected to sit on the users system. Also it gives you flexibility to have a more service oriented model later, if you want to. Without knowing what your app does, it is hard to know if that makes sense or not.
For setting up the python side of SOAP webservices, here's a useful link to a diveintopython article. Then, if you have your server running with the wsdl, FlexBuilder can generate the AIR side of the webservices for you.

Categories