Skip to content

Commit 8843f26

Browse files
authoredApr 5, 2024··
Improve sample applications (#2756)
This PR updates all the main Sming samples to try and demonstrate best practice when coding Sming applications. Specifically: - Initialise timers using templated methods where possible as this provides static range check on values - Using `SimpleTimer` is sufficient in most cases. This is both more efficient and avoids complication where compiler cannot distinguish between delegates and callback functions. - Use timer `startOnce()` method rather than `start(false)` - Use C++ iterators in preference to C-style loops `for(int i=0; i<list.count(); ++i) {...}` - Ensure consistent use of `WIFI_SSID` and `WIFI_PASSWORD` - Use `Serial` methods in preference to `debug_x` where intent is not actually for debugging - Use anonymous namespaces and remove redundant static declarations - Avoid nested `if` statements - Place `init()` function at end of main application source file - Reduce variable scope (declare at point of first use) - static/global variables do not require explicit initialisation to 0 Sample-specific changes: - Revise `HttpServer_AJAX` so that GPIO numbers are consistent with web code - Update Basic_Ssl keys, requires Bearssl - Update Basic_DateTime sample - Simplify code using LineBuffer - Accept either numeric timestamp or HTTP date string. Note: ISO8601 string conversion not currently supported by `DateTime`. - Don't emulate console via telnet, use default CLI - Rewrite Basic_Neopixel sample - Enumerate color values - Reduce global variables and duplicated code - Verify logic flow using Host - Rewrite Display_TM1637 as state machine (coroutine) - Fix Basic_Storage, didn't actually use RAM as indicated - Add Host `Print` stream support, update `Basic_Utility` sample Other changes - Update `jerryscript` library to latest. CI improvements and removes deprecation warnings. - Fix bad memory casts in si4432 library. Also builds for other architectures than esp8266, so remove SOC restrictions. - Fix unused variable warning in `CommandProcessing` library
1 parent c487f91 commit 8843f26

File tree

113 files changed

+1878
-1464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1878
-1464
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Streams.h - Print support for host output
3+
*
4+
* Copyright 2024 mikee47 <mike@sillyhouse.net>
5+
*
6+
* This file is part of the Sming Framework Project
7+
*
8+
* This library is free software: you can redistribute it and/or modify it under the terms of the
9+
* GNU General Public License as published by the Free Software Foundation, version 3 or later.
10+
*
11+
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12+
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+
* See the GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License along with SHEM.
16+
* If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
****/
19+
20+
#pragma once
21+
22+
#include <unistd.h>
23+
24+
namespace Host
25+
{
26+
class OutputStream : public Print
27+
{
28+
public:
29+
OutputStream(int fileno) : fileno(fileno)
30+
{
31+
}
32+
33+
virtual size_t write(uint8_t c) override
34+
{
35+
return write(&c, 1);
36+
}
37+
38+
size_t write(const uint8_t* buffer, size_t size) override
39+
{
40+
return ::write(fileno, buffer, size);
41+
}
42+
43+
private:
44+
int fileno;
45+
};
46+
47+
OutputStream standardOutput(STDOUT_FILENO);
48+
OutputStream standardError(STDERR_FILENO);
49+
50+
}; // namespace Host

‎Sming/Components/Storage/src/include/Storage/SysMem.h

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class SysMem : public Device
7373
class SysMemPartitionTable : public PartitionTable
7474
{
7575
public:
76+
using PartitionTable::add;
77+
7678
/**
7779
* @brief Add partition entry for FlashString data access
7880
*/

0 commit comments

Comments
 (0)
Please sign in to comment.