## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
Sekilsgs2
@Sekilsgs2

And new question - i'm have problem with this function -

// Simple mjs solution to split string into an array
function splitString(inTxt, sepChr) {
let pos = inTxt.indexOf(sepChr);
let out = [];
let part = '';
while (pos !== -1) {
part = inTxt.slice(0, pos);
print("part == ", part);
if (part.length > 0)
out.push(part);
inTxt = inTxt.slice(pos + 1, inTxt.length);
print("inTxt == ", inTxt);
pos = inTxt.indexOf(sepChr);
print("pos == ", pos);
}
if (inTxt !== "")
out.push(inTxt);
return out;
}

Some time this not working as is should -
i'm need split this string with delim ";" -

1;2;1;0;38;2865.0

But from logs i'm see this -

[Mar 26 13:37:55.106] part ==  1  - //cutted first finded
[Mar 26 13:37:55.106] inTxt ==  2;1;0;38;2865.0  // new string without first
[Mar 26 13:37:55.106] pos ==  1  - ///pos of next
[Mar 26 13:37:55.106] part ==  2 - /next finded
[Mar 26 13:37:55.106] inTxt ==  1;0;38;2865.0 - // new string
[Mar 26 13:37:55.106] pos ==  -1   - ///WHYYYYY????

Why we have -1 after running this -

pos = inTxt.indexOf(";");
where inTxt === "1;0;38;2865.0"

??

Sekilsgs2
@Sekilsgs2
I'm compare with ffi c function strcspn and this working good without any problems
Jan
@janko.valiska:matrix.org
[m]
Hi, is it possible to compile esp8266 fw without mounting FS on boot?
Deomid Ryabkov
@rojer
no, minimal FS is required
Deomid Ryabkov
@rojer
@mamuesp would you like to move your https://github.com/mamuesp/timezones library to mongoose-os-libs?
Jan
@janko.valiska:matrix.org
[m]
Thank you Rojer. I have one more question regarding how daylight saving works in mongoose. Is device rebooted after time is changed?
Sergio R. Caprile
@scaprile
AFAIK there is a "time changed" event callback you can register. I guess this applies; however, I live in a country where DST is not used and haven't checked. Take it with a grain of salt. This event is fired on SNTP adjustments, for example.
DrBomb
@DrBomb
I believe, and I'm not completely sure this is the case. That the DST jump will not trigger or reboot the system
DST is only applied when you need local time, or for example, on cron jobs
And on those cases, I think if the invocation time lines after the DST, the time libs will make sure to get that sorted out
But when you call mg_time you're getting the UTC, unix time, as you should have
hence why it isn't affected by DST
I've used the cron lib for a couple years now on the US/Central timezone and DST has been adjusted automatically
Liviu
@nliviu
cron jobs are based on UTC time.
mgos_cron.c:231         Next invocation: 1617036555 [2021/03/29 16:49:15 UTC]
And yes, DST is applied when you need local time AND sys.tz_spec is set.
DrBomb
@DrBomb
cron job messages show a timestamp in UTC, but they will follow the timezone set on the tz_spec
@nliviu
Sergio R. Caprile
@scaprile
So hence DST "jumps" will not trigger time change events... now I know, thanks. It makes sense to just change the conversion factor to localtime...
Jan
@janko.valiska:matrix.org
[m]
Thanks for clarifications.
Jan
@janko.valiska:matrix.org
[m]
If I set oneshot timer, for example mgos_set_timer(1000, 0, &timer_cb, NULL) should i store timer_id and call mgos_clear_timer(id) to release internally allocated memory of this timer?
Jan
@janko.valiska:matrix.org
[m]
What is meaning of bool return value of mgos_mqtt_global_connect?
Sergio R. Caprile
@scaprile
I've found that if you hold a timer handler and later you cancel the timer as you suggest, you have to also invalidate your handler (timer_id = MGOS_INVALID_TIMER_ID). If you setup and cancel several timers you may get repeated ids because they are reused (iirc).
If you don't need to cancel the timer, it will clear itself when it fires (unless it repeats, of course...)
Clearing an already cleared (automatically or cancelled) timer is safe, but since ids are reused and you started another timer in between... you end up cancelling the new timer and not the old one (iirc, again)
Jim Archer
@jimarcher

Hi Everyone, I have been fighting an issue with Little FS and the Winbond W25Nxxx device driver / VFS driver for some time now. Using an ESP32-WROOM-32U with a W25N 2 Gbit device (I have not tried the 2 Gbit) I am able to start Mongoose and create the file system. But if I open a file using fopen() and start appending data, after just a few hundred bytes LFS reports the device is fill. Also, if I create a number of small files, after about 18 or so, it reports that the superblock is full.

Does this ring any bells?

55 replies
Oops.. I'm using the 1 Gbit device, have not tried the 2 Gbit
Deomid Ryabkov
@rojer
hm, that definitely shouldn't happen.
Anshu694
@Anshu694
can someon help me out with cron task in mongoose ?
Any examples??
Liviu
@nliviu
@Anshu694 Assuming you have added the cron library in your mos.yml
#include "mgos.h"
#include "mgos_cron.h"

static void cron_1min_cb(void *user_data, mgos_cron_id_t id) {
time_t now = time(0);
struct tm *tm = localtime(&now);
char t[32];
strftime(t, sizeof(t), "%T", tm);
LOG(LL_INFO,
("Uptime: %.2lf, time: %s, free_heap_size: %lu, min_free_heap_size: %lu",
mgos_uptime(), t, (unsigned long) mgos_get_free_heap_size(),
(unsigned long) mgos_get_min_free_heap_size()));
(void) user_data;
(void) id;
}

enum mgos_app_init_result mgos_app_init(void) {
/*
* Add a cron job at every 5 seconds of a minute.
*/
mgos_cron_add("5 */1 * * * *", cron_1min_cb, NULL);

return MGOS_APP_INIT_SUCCESS;
}
Anshu694
@Anshu694
Thanks @nliviu
Jan Knieling
@janknieling
Supports Mongoose OS secure boot on ESP32?
Moa doesn’t yet support secure boot. I think it’s on @rojer list but no timescales unfortunately.
David Cruchon
@Enophi
Hello! I'm trying to configure a ATEC608A (a barebone and the Qiic by Sparkfun) and get this error back : "No handler for ATCA.GetConfig". I dont find any good results on google. Any ideas ?
And the error occurs when i try to pass the atca-set-config command : mos atca-set-config proto-config.yaml --dry-run=true
DrBomb
@DrBomb
Means that the firmware you're using does not contain the RPC command it is trying to call
The latter is most likely the one that registers the methods you're missing
David Cruchon
@Enophi
@DrBomb Thx a lot :) I was totally missing the libs :/
DrBomb
@DrBomb
:+1:
Ivan Polchenko
@i5okie
Hi, dumb question... how do I interpolate a string into a variable? do something with that variable and then make sure that variable does not take up any buffer / ram space?? "key: value, key:value2, key:value3" ?
DrBomb
@DrBomb
There are many ways. but it depends on the format you're using. If it is json you could use cesanta's json parser, frozen, but it really depends on what you have to work with
and regarding the question of memory, that's something for you to figure out
Ivan Polchenko
@i5okie
I can't figure out how to use frozen.
Ivan Polchenko
@i5okie
or rather, I got it working. But my esp32 keeps doing core dumps after a few seconds.
maqilin6753123
@maqilin6753123
Hi ,boss, when I finished installed the Mongoose OS IDE in visual studio ,there is an error indication "command 'mos.showPanel' not found"? What should I do?
DrBomb
@DrBomb
As far as I know @maqilin6753123 The Visual Studio extension is outdated and doesn't work
Jan
@janko.valiska:matrix.org
[m]
Hello, is there in mongoose os option to set AP advertising beacon timeout? Like send beacon every 500ms or every 1s.
d4rkmen
@d4rkmen

As far as I know @maqilin6753123 The Visual Studio extension is outdated and doesn't work

It works fine :) All you need to do is to add mos.exe to PATH variable

David Cruchon
@Enophi
Hello everyone. I'm stuck with an ATECC608A. I set the sample config file and lock the config/data zone. I re-provisionned the chip with the command : mos aws-iot-setup --use-atca .... The process succeed but when i check the log, there is a invalid SSL key error. When I check the config device for the mqtt section, there is "ssl_key": "ATCA:0" as it suppose to be. Do you have any ideas ? Maybe it's because of the re-provision. Thank you in advance for your help.
15 replies