Description
utils/consoleCANIP.h
provides the following function (from CANIP – Library) to a console application:
s_console_CANIP()
: delivers the following commands- canip get <URL> – processes a HTTP example GET request to server www.di-ce.de
- canip download <URL> <version> – downloads a file to SerialFlash, optional: save a version number with the file
- canip socket <server> <port> – opens a TCP socket on <port> to <server> via CANIP
- canip post <URL> <Element> <Value> – sends a POST request to a server
- canip SysSync <account> – Starts a remote update process, optional for first registration, opt. <account> for first registration.
In case of an internet capable device (e.g. dice-ETH, dice-WiFi etc.) the following additional commands are provided:
- canip info – returns if any other node is requesting an internet connection service (within the last 20 sec)
- canip provide x – x:1 provide internet to other nodes, x:0 don’t
Syntax (example)
#include "utils/consoleCANIP.h"
. . .
SerialFlash.begin();
. . .
s_console_string = s_console_CANIP( s_console_string );
Parameters
String s_console_string – String that holds the user command. Normally returned by s_console_routine() or a previous console function.
Returns
String : the user command or an empty String “” if the user command was recognised and processed by this function. (see of commands above)
Example Codes (CANIP Client):
The following example runs on all devices. It uses CANIP services from providers on the CAN bus e.g. from the CAN2SER monitor (see misc – menu).
#include "consoleLogin.h"
#include "utils/consoleCANIP.h"
void setup() {
SerialFlash.begin();
console_init(&Serial);
}
void loop() {
String s_console_string = s_console_routine();
s_console_CANIP(s_console_string);
}
Example Code (WiFi provider):
This runs on dice-WiFis. It shows how to provide (or use) internet access to other nodes on the CAN.
#include "consoleLogin.h"
#include "utils/consoleCANIP.h"
#define SECRET_SSID "myssid"
#define SECRET_PASS "mypasswd"
void setup() {
SerialFlash.begin();
console_init(&Serial);
}
void loop() {
String s_console_string = s_console_routine();
s_console_CANIP(s_console_string);
if(WiFi.status() != WL_CONNECTED)
{
Serial.print("Dailing in ...");
WiFi.begin(SECRET_SSID, SECRET_PASS);
if(WiFi.status() == WL_CONNECTED)
Serial.println("OK");
else
Serial.println("FAIL");
}
}
Notes and Warnings
This console-function and its commands might be helpful to test and learn how to work with the CANIP library. See the source code as example code for your own application:
C:\Users\yourName\AppData\Local\Arduino15\packages\dice\hardware\samc\1.0.0\libraries\Console\src\...
In a ‘real world’ application, these commands might not be required but during development it could be helpful to create certain conditions with CANIP. Still it is recommended not to include theses CANIP-console commands in your final application but to use the CANIP library only.
Please keep in mind that each included file and its used function increase the size of the resulting application. So in order to keep the application binaries as small as possible, include only functions that are really necessary for the final application.
An example can be found in the Arduino IDE menu:
File -> Examples -> Consoles ->
Dev_Console