Web terminal made with Thinger.io

After some efforts I finally managed to configure something what resembles terminal function known like Serial.print output. But with all output directed to web with Thinger.io.

This code put in setup will enable you a terminal like console, which you can easily implement either as instant output (make widget type Text/Value, connect to thing variable “terminal”, set refresh mode to Update by device) or as recorded output (make Data bucket, select Data Source - From device, select device and variable “terminal”, set refresh mode to Update by device).

So:

void setup () {

...

thing.handle();
thing["terminal"] >> [](pson& out) {
    String t = String(console);
    out = t;
};
delay(200);
thing.handle();

and then immeditatelly after this you can use:

strcpy(console, "First message sent to console...");
thing.stream(thing["terminal"]);

strcpy(console, "Hi again, I'm your terminal!");
thing.stream(thing["terminal"]);

Or you can place it wherever you like in the loop.

(variable declaration is
char console[128];
)

Hope this helps.

Nice idea!. Data bucket has a limit of one call every minute. Is there a way to stream data into a Bucket with a refresh mode below one minute?

Have you tried to use String object which gives you more functionality than character arrays do (at the cost of more memory) ?

I mean something like my example below:

String console = ""    // define an instance of the String class as a global variable.

void setup() {
  
// Output resource
  thing["console"] >> [](pson& out){   
         out = console.c_str();    
    };
}

void loop() {
  thing.handle();
  
  // put some code here
  
  console = String("some text..") + <any variable> + String("some text...");
  thing.stream(thing["console"]);
}
1 Like

Hi @szormpas, absolutely you can rewrite it using String instead of Char. Just my poor knowledge of C++ forced me to not play with pointers and string functions :slight_smile:.

And regarding the frequency - this is unfortunatelly true on public thinger.io server. I understand this limitation because with unproper code the database behind data bucket can grow rapidly, so unfortunatelly the procedure above is suitable only for usage with thinger.io running on your own server.

By the way - the speed limit of records flowing from your thing into bucket on own server (without imposed speed limit) seems to me about 0.010 - 0.015 seconds per record, which is about 60-100 hits per second. Not bad!

Hi @Tomas, good to know these bits of knowledge.

Thanks

Yes, the current public thinger.io server have a write limit of about 1 write per minute to prevent hundred of devices writing without any control. The private server deployment have no such limitation (but is configurable) and it will depend on your server hardware. Paid accounts (that will be available quite soon), will have a different (lower) restriction.

By the way, the new library version, that will be released probably this week (along with the required server/client functionality), introduces a new command called write_bucket that will allow writing any bucket. This way, you can push data to buckets when required (without requiring the server to subscribe to a resource), or have different devices writing to the same bucket, that could be interesting in some use cases.

Regarding the logging functionality, I am thinking that it could be interesting to have a widget to show more than one line… appending new lines at the bottom… what do you think?

@alvarolb This would be just briliant! If you could connect this either to bucket for recorded log or to the stream/thing output for online console, that would be great. Also limit the number of record being displayed (to prevent your browser crash when you let it run through the night and thing fires 10 milions of records to console :slight_smile: ).
And also would be very helpful to have opportunity to change font size of Text/Value widget. Now it is just for brief info like short number as letter as quite big.

Awesome!!:slight_smile:
Just make text widget as close as possible to a text editor.

Thanks

By the way, there is so much fun with Data bucket terminal! :slight_smile:
(this is my thing boot process)

Hi @Tomas! Nice use of the bucket! but I think that something is wrong with the server side, as it is letting you write at more rate interval than expected! It may not work this way when fixed. Note that free accounts cannot write more than 1 data per minute! I suppose that you are using the write_bucket call? is it? :slight_smile:

I am thinking now that you can be making that on your own host, is it?. So, I hope there is no problem with the server! :slight_smile:

Sorry for making you troubles - that’s my server with your app :slight_smile: And bucket is just used to capture streamed data flowing from the thing.

   strcpy(console, "[STATUS] Terminal ready");
   thing.stream(thing["terminal"]);
1 Like

@alvarolb one thing regarding the thinger console - when on mobile, the component showing data in bucket is not very good as due to long timestamp representantion one can’t basically see what’s corresponding value. Would’nt make sense to add also horizontal scrolling possibility to this table view?

Will take a look on that @Tomas.