diff --git a/.github/workflows_json/release.json b/.github/workflows/release.json similarity index 100% rename from .github/workflows_json/release.json rename to .github/workflows/release.json diff --git a/.github/workflows_json/test.json b/.github/workflows/test.json similarity index 96% rename from .github/workflows_json/test.json rename to .github/workflows/test.json index d8fb271..bb23b94 100644 --- a/.github/workflows_json/test.json +++ b/.github/workflows/test.json @@ -2,8 +2,8 @@ "name": "test", "on": { "push": { - "branches": [ - "dev" + "branches-ignore": [ + "master" ], "paths-ignore": [ ".git*", @@ -13,8 +13,7 @@ }, "pull_request": { "branches": [ - "master", - "dev" + "master" ], "paths-ignore": [ ".git*", diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a7dd708..de841c1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,8 +1,8 @@ name: test on: push: - branches: - - dev + branches-ignore: + - master paths-ignore: - .git* - '**.md' @@ -10,7 +10,6 @@ on: pull_request: branches: - master - - dev paths-ignore: - .git* - '**.md' diff --git a/.github/workflows/to_yaml.sh b/.github/workflows/to_yaml.sh new file mode 100644 index 0000000..cea5c29 --- /dev/null +++ b/.github/workflows/to_yaml.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu + +cd ${0%/*} + +for _v in $(find ./ -maxdepth 1 -type f -name '*.json'); do + yq -I 4 -o y ${_v} | head -c -1 > ${_v%.*}.yaml +done; unset _v \ No newline at end of file diff --git a/.github/workflows_json/to_yaml.sh b/.github/workflows_json/to_yaml.sh deleted file mode 100644 index 4878624..0000000 --- a/.github/workflows_json/to_yaml.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -eu - -cd ${0%/*} - -yq -o y -I 4 ./${1}.json | head -c -1 > ../workflows/${1}.yaml \ No newline at end of file diff --git a/README.md b/README.md index 1e5c3e5..91097f7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # **Arduino Base64** ![actions:test](https://github.com/dojyorin/arduino_base64/actions/workflows/test.yaml/badge.svg) ![actions:release](https://github.com/dojyorin/arduino_base64/actions/workflows/release.yaml/badge.svg) +![shields:license](https://img.shields.io/github/license/dojyorin/arduino_base64) +![shields:release](https://img.shields.io/github/release/dojyorin/arduino_base64) Convert between binary and base64 encoded string. Easily convert sensor raw values, structures, etc... diff --git a/library.properties b/library.properties index 418cc0f..86d078f 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=base64_encode author=dojyorin -version=2.0.1 +version=2.0.2 architectures=* includes=arduino_base64.hpp sentence=Convert between binary and base64 encoded string. diff --git a/src/base64.cpp b/src/base64.cpp index 4797b03..0f6604e 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -1,11 +1,11 @@ #include "./arduino_base64.hpp" namespace{ - constexpr char symbols[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + constexpr char CODE[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; uint8_t indexOf(char search){ for(uint8_t i = 0; i < 64; i++){ - if(symbols[i] == search){ + if(::CODE[i] == search){ return i; } } @@ -36,10 +36,10 @@ void base64::encode(const uint8_t* input, size_t inputLength, char* output){ bit8x3[position++] = *input++; if(position == 3){ - to6x4(bit8x3, bit6x4); + ::to6x4(bit8x3, bit6x4); for(const auto &v: bit6x4){ - *output++ = symbols[v]; + *output++ = ::CODE[v]; } position = 0; @@ -51,10 +51,10 @@ void base64::encode(const uint8_t* input, size_t inputLength, char* output){ bit8x3[i] = 0x00; } - to6x4(bit8x3, bit6x4); + ::to6x4(bit8x3, bit6x4); for(uint8_t i = 0; i < position + 1; i++){ - *output++ = symbols[bit6x4[i]]; + *output++ = ::CODE[bit6x4[i]]; } while(position++ < 3){ @@ -80,10 +80,10 @@ void base64::decode(const char* input, uint8_t* output){ break; } - bit6x4[position++] = indexOf(*input++); + bit6x4[position++] = ::indexOf(*input++); if(position == 4){ - to8x3(bit6x4, bit8x3); + ::to8x3(bit6x4, bit8x3); for(const auto &v: bit8x3){ *output++ = v; @@ -98,7 +98,7 @@ void base64::decode(const char* input, uint8_t* output){ bit6x4[i] = 0x00; } - to8x3(bit6x4, bit8x3); + ::to8x3(bit6x4, bit8x3); for(uint8_t i = 0; i < position - 1; i++){ *output++ = bit8x3[i];