ayushsharma82 / WebSerial

A remote terminal library for wireless microcontrollers to log, monitor or debug your firmware/product
https://webserial.pro
GNU Affero General Public License v3.0
461 stars 107 forks source link

Inherit from Print class #57

Closed jksemple closed 1 year ago

jksemple commented 1 year ago

Inherit from Arduino Print class.

This fixes Issue #55 (cannot do WebSerial.print(WiFi.localIP()) and possibly Issue #53 (memory leak) It also allows WebSerial.print(millis()) which otherwise fails. And allows WebSerial.printf(.....)

ayushsharma82 commented 1 year ago

This is such a good solution and I kind of feel dumb on why I didn't think of it before! haha. Kudos for sharing it with everyone :)

I'll test this soon and merge it.

ayushsharma82 commented 1 year ago

@jksemple , There is a minor incompatibility in examples with ESP32 platform. Can you please fix it?, other than that it looks very promising.

Reference: here

jksemple commented 1 year ago

Fixed - my apologies for a dumb error!

asjdf commented 1 year ago

Great PR, but I thought WebSerial.printf("Free heap=[%u]\n", ESP.getFreeHeap()); should use %u instead of %lu.

jksemple commented 1 year ago

Odd that both millis() and getFreeHeap() apparently return uint32_t but millis() needs %ul and getFreeHeap() needs %u. I must be missing something. I have fixed the examples anyway.

jksemple commented 1 year ago

Um... So what now?

ayushsharma82 commented 1 year ago

Sorry, I had to devote some time to my office work. I’ll test this by Thursday.

ayushsharma82 commented 1 year ago

Tested and merged :) Brilliant solution.

jksemple commented 1 year ago

The joy of Open Source :-)