-
Notifications
You must be signed in to change notification settings - Fork 24
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
New feature: begin() #36
Comments
This library needs some new love(!) Thanks for the update, I'll take a look and see what I can integrate in. |
@chunkysteveo I will put in a pull request later this week. Headers would look like below for a quick understanding on how I implemented it.
The original create methods now just call the associated init method. Doing it this way allows existing Examples to continue to be valid. A minor update to include how to use the init methods would be another update I would do. A minor update to the Keywords file is also needed. |
@jcassel |
@DigiHzData |
As it is now of OctoPrintAPI (V1.1.15) it is only possible to initialize it before setup.
This makes problems for dynamic variables.
But i changed the source so that OctoPrintAPI will work from within setup now with success.
Here is what needs to be changed:
In OctoPrintAPI.h
class OctoprintApi {
public:
//OctoprintApi(Client &client, IPAddress octoPrintIp, int octoPrintPort, String apiKey);//DigiHzData removed.
//OctoprintApi(Client &client, char *octoPrintUrl, int octoPrintPort, String apiKey);//DigiHzData removed.
OctoprintApi(Client &client);//DigiHzData added.
void begin(IPAddress octoPrintIp, int octoPrintPort, String apiKey);//DigiHzData added.
void begin(char *octoPrintUrl, int octoPrintPort, String apiKey);//DigiHzData added.
...
In OctoPrintAPI.cpp
#include "OctoPrintAPI.h"
#include "Arduino.h"
OctoprintApi::OctoprintApi(Client &client){//DigiHzData added.
_client = &client;//DigiHzData added.
}//DigiHzData added.
/** OctoprintApi()
//OctoprintApi::OctoprintApi(Client &client, IPAddress octoPrintIp, int octoPrintPort, String apiKey) {//DigiHzData removed.
void OctoprintApi::begin(IPAddress octoPrintIp, int octoPrintPort, String apiKey) {//DigiHzData added.
//_client = &client;//DigiHzData removed.
_apiKey = apiKey;
_octoPrintIp = octoPrintIp;
_octoPrintPort = octoPrintPort;
_usingIpAddress = true;
}
/** OctoprintApi()
//OctoprintApi::OctoprintApi(Client &client, char *octoPrintUrl, int octoPrintPort, String apiKey) {//DigiHzData removed.
void OctoprintApi::begin(char *octoPrintUrl, int octoPrintPort, String apiKey) {//DigiHzData added.
//_client = &client;//DigiHzData removed.
_apiKey = apiKey;
_octoPrintUrl = octoPrintUrl;
_octoPrintPort = octoPrintPort;
_usingIpAddress = false;
}
/** GET YOUR ASS TO OCTOPRINT...
*
...
After these changes has been made, then you initiate OctoPrintApi before setup with:
OctoprintApi api(client);
And in setup you do either:
api.begin(ip, octoprint_httpPort, octoprint_apikey);//If using IP address
OR
api.begin(octoprint_host, octoprint_httpPort, octoprint_apikey);//If using hostname.
This way, we can pull ip, octoprint_host, octoprint_httpPort and octoprint_apikey from eeprom or sd card.
The text was updated successfully, but these errors were encountered: