Skip to content

Commit

Permalink
Merge branch 'lts-develop/3.8.x' into lts-master/3.8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
slav-at-attachix committed Nov 3, 2019
2 parents 86a0314 + 2453017 commit 99bf268
Show file tree
Hide file tree
Showing 27 changed files with 591 additions and 455 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ esp-open-sdk (v1.5.x, v2.0.0, v3.0 **) | :sunny: | :sunny: | n/a | :sunny: |
- ** = experimental support

## Latest Stable Release
- [Sming V3.8.0](https://github.com/SmingHub/Sming/releases/tag/3.8.0)
- [Sming V3.8.1](https://github.com/SmingHub/Sming/releases/tag/3.8.1)


## Getting started
Expand Down
24 changes: 13 additions & 11 deletions Sming/Services/libb64/cdecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ For details, see http://sourceforge.net/projects/libb64
*/

#include "cdecode.h"
#include <stdint.h>

int base64_decode_value(char value_in)
int8_t base64_decode_value(char value_in)
{
static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
static const char decoding_size = sizeof(decoding);
value_in -= 43;
if (value_in < 0 || value_in >= decoding_size) return -1;
return decoding[(int)value_in];
static const int8_t decoding[] = {62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1,
-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51};
unsigned idx = (unsigned)value_in - 43U;
return (idx < sizeof(decoding)) ? decoding[idx] : -1;
}

void base64_init_decodestate(base64_decodestate* state_in)
Expand All @@ -26,7 +28,7 @@ unsigned base64_decode_block(const char* code_in, const int length_in, char* pla
{
const char* codechar = code_in;
char* plainchar = plaintext_out;
char fragment;
int8_t fragment;

*plainchar = state_in->plainchar;

Expand All @@ -42,7 +44,7 @@ unsigned base64_decode_block(const char* code_in, const int length_in, char* pla
state_in->plainchar = *plainchar;
return plainchar - plaintext_out;
}
fragment = (char)base64_decode_value(*codechar++);
fragment = base64_decode_value(*codechar++);
} while (fragment < 0);
*plainchar = (fragment & 0x03f) << 2;
case step_b:
Expand All @@ -53,7 +55,7 @@ unsigned base64_decode_block(const char* code_in, const int length_in, char* pla
state_in->plainchar = *plainchar;
return plainchar - plaintext_out;
}
fragment = (char)base64_decode_value(*codechar++);
fragment = base64_decode_value(*codechar++);
} while (fragment < 0);
*plainchar++ |= (fragment & 0x030) >> 4;
*plainchar = (fragment & 0x00f) << 4;
Expand All @@ -65,7 +67,7 @@ unsigned base64_decode_block(const char* code_in, const int length_in, char* pla
state_in->plainchar = *plainchar;
return plainchar - plaintext_out;
}
fragment = (char)base64_decode_value(*codechar++);
fragment = base64_decode_value(*codechar++);
} while (fragment < 0);
*plainchar++ |= (fragment & 0x03c) >> 2;
*plainchar = (fragment & 0x003) << 6;
Expand All @@ -77,7 +79,7 @@ unsigned base64_decode_block(const char* code_in, const int length_in, char* pla
state_in->plainchar = *plainchar;
return plainchar - plaintext_out;
}
fragment = (char)base64_decode_value(*codechar++);
fragment = base64_decode_value(*codechar++);
} while (fragment < 0);
*plainchar++ |= (fragment & 0x03f);
}
Expand Down
2 changes: 1 addition & 1 deletion Sming/SmingCore/Data/CStringArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int CStringArray::indexOf(const char* str) const
const char* CStringArray::getValue(unsigned index) const
{
if(index < count()) {
for(unsigned offset = 0; offset < length(); --index) {
for(unsigned offset = 0; offset <= length(); --index) {
const char* s = buffer + offset;
if(index == 0)
return s;
Expand Down
16 changes: 8 additions & 8 deletions Sming/SmingCore/Data/Stream/FileStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ size_t FileStream::write(const uint8_t* buffer, size_t size)
return 0;
}

int writePos = fileSeek(handle, 0, eSO_FileEnd);
if(!check(writePos)) {
return 0;
}
if(pos != this->size) {
int writePos = fileSeek(handle, 0, eSO_FileEnd);
if(!check(writePos)) {
return 0;
}

pos = size_t(writePos);
pos = size_t(writePos);
}

int written = fileWrite(handle, buffer, size);
if(check(written)) {
pos += size_t(written);
if(pos > this->size) {
this->size = pos;
}
this->size = pos;
}

return written;
Expand Down
2 changes: 1 addition & 1 deletion Sming/SmingCore/Data/Stream/MultipartStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const char* MultipartStream::getBoundary()
int len = sizeof(boundary);
memset(boundary, 0, len);
for(int i = 0; i < len - 1; ++i) {
boundary[i] = pool[os_random() % (sizeof(pool) - 1)];
boundary[i] = pool[os_random() % (sizeof(PSTR_pool) - 1)];
}
boundary[len - 1] = 0;
}
Expand Down
6 changes: 1 addition & 5 deletions Sming/SmingCore/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ typedef Delegate<void(Stream& source, char arrivedChar, uint16_t availableCharsC
*/
typedef Delegate<void(HardwareSerial& serial)> TransmitCompleteDelegate;

#if ENABLE_CMD_EXECUTOR
class CommandExecutor;
#endif

enum SerialConfig {
SERIAL_5N1 = UART_5N1,
Expand Down Expand Up @@ -438,9 +436,7 @@ class HardwareSerial : public ReadWriteStream
int uartNr = -1;
TransmitCompleteDelegate transmitComplete = nullptr; ///< Callback for transmit completion
StreamDataReceivedDelegate HWSDelegate = nullptr; ///< Callback for received data
#if ENABLE_CMD_EXECUTOR
CommandExecutor* commandExecutor = nullptr; ///< Callback for command execution (received data)
#endif
CommandExecutor* commandExecutor = nullptr; ///< Callback for command execution (received data)
uart_t* uart = nullptr;
uart_options_t options = _BV(UART_OPT_TXWAIT);
size_t txSize = DEFAULT_TX_BUFFER_SIZE;
Expand Down
12 changes: 6 additions & 6 deletions Sming/SmingCore/Network/Http/HttpResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ HttpResponse* HttpResponse::setHeader(const String& name, const String& value)

bool HttpResponse::sendString(const String& text)
{
if(buffer == nullptr) {
setBuffer(new MemoryDataStream());
if(buffer == nullptr) {
return false;
}
auto memoryStream = new MemoryDataStream();
if(memoryStream == nullptr) {
return false;
}

return buffer->print(text) == text.length();
setStream(memoryStream);

return memoryStream->print(text) == text.length();
}

bool HttpResponse::sendFile(String fileName, bool allowGzipFileCheck)
Expand Down
Loading

0 comments on commit 99bf268

Please sign in to comment.