Skip to content

Commit 3dd6522

Browse files
committed
Initial import
1 parent 68ed7ae commit 3dd6522

File tree

7 files changed

+3518
-0
lines changed

7 files changed

+3518
-0
lines changed

examples/BasicUsage/BasicUsage.ino

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "QZSSDCX.h"
2+
3+
byte l1s_msgbuf[] = { 0xC6, 0xB0, 0x60, 0x0D, 0xE2, 0xBF, 0x88, 0xE9, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x11, 0xA1, 0xC8, 0x4E, 0xD4 };
4+
5+
void setup() {
6+
Serial.begin(115200);
7+
while (!Serial)
8+
; //ターミナルを開くまでまつ
9+
delay(1000);
10+
11+
// DCXDecoderインスタンスを作成
12+
DCXDecoder dec;
13+
// 250ビットのL1Sメッセージが入ったバッファを入力する
14+
// デコードした結果はDCXDecoderのメンバ変数 DCXMessage r に格納される
15+
dec.decode(l1s_msgbuf);
16+
// デコード結果のサマリーをSerialに出力
17+
dec.printSummary(Serial, dec.r);
18+
// デコード結果すべてをSerialに出力
19+
dec.printAll(Serial, dec.r);
20+
}
21+
22+
void loop() {
23+
// put your main code here, to run repeatedly:
24+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#include "QZSSDCX.h"
2+
3+
// 1文字の16進数を数値に変換するヘルパー関数
4+
uint8_t hex_char_to_value(char c) {
5+
if (c >= '0' && c <= '9') {
6+
return c - '0';
7+
} else if (c >= 'A' && c <= 'F') {
8+
return c - 'A' + 10;
9+
} else if (c >= 'a' && c <= 'f') {
10+
return c - 'a' + 10;
11+
}
12+
return 0; // 無効な入力に対するデフォルト値
13+
}
14+
15+
byte l1s_msgbuf[64];
16+
17+
// 16進文字列をバイト配列に変換
18+
byte *str2byte(const char *mst) {
19+
size_t hex_length = strlen(mst);
20+
size_t byte_array_size = hex_length / 2;
21+
for (size_t i = 0; i < byte_array_size; i++) {
22+
// 上位4ビット(1文字目)と下位4ビット(2文字目)を計算
23+
l1s_msgbuf[i] = (hex_char_to_value(mst[2 * i]) << 4)
24+
| hex_char_to_value(mst[2 * i + 1]);
25+
}
26+
return l1s_msgbuf;
27+
}
28+
29+
void test(const char *msg) {
30+
DCXDecoder dec;
31+
Serial.println(msg);
32+
dec.decode(str2byte(msg));
33+
dec.printSummary(Serial, dec.r);
34+
Serial.println();
35+
dec.printAll(Serial, dec.r);
36+
}
37+
38+
void setup() {
39+
// put your setup code here, to run once:
40+
Serial.begin(115200);
41+
while (!Serial)
42+
; //ターミナルを開くまでまつ
43+
44+
delay(1000);
45+
46+
// J Alert
47+
test("C6B0600DE2BF88E9200000000000000000001FFFFFFFFFFFC0000011A1C84ED4");
48+
test("9AB0600DE21188EA208000000000000000001FFFFFFFFFFFC00000138C7533B1");
49+
test("C6B0600DE21188EA208100000000000000001FFFFFFFFFFFC00000113F4B1B94");
50+
test("9AB0600DE21188EB208200000000000000001FFFFFFFFFFFC000001339BF5A31");
51+
test("C6B0600DE21188EB208300000000000000001FFFFFFFFFFFC0000010AE78CA54");
52+
test("53B0600DE21188EC208500000000000000001FFFFFFFFFFFC00000104D84DFE6");
53+
test("9AB0600DE21188ED208600000000000000001FFFFFFFFFFFC0000012233F80B1");
54+
test("C6B0600DE21188ED208700000000000000001FFFFFFFFFFFC00000139C985E94");
55+
test("C6B0600DE2E208EE20880000000000000000000000000000400000130C9DA654");
56+
test("9AB0600DE2E208EF2088000000000000000000000000001F800000113C0237B1");
57+
test("C6B0600DE2E208EF20880000000000000000000000000FE000000012A3C82914");
58+
test("9AB0600DE2E208F02088000000000000000000000003F00000000010905F49F1");
59+
test("C6B0600DE2E208F0208800000000000000000000003C0000000000121BF87454");
60+
test("9AB0600DE2E208F12088000000000000000000000FC000000000001015A2A271");
61+
test("C6B0600DE2E208F1208800000000000000000001F000000000000011B864C094");
62+
test("9AB0600DE2E208F220880000000000000000001E000000000000001386CA21B1");
63+
test("9AB0600DE2E208F320880000000000000000100000000000000000130FA51EF1");
64+
65+
// L Alert
66+
test("C6B0440DE10208ADE00000000000000000000113400000000000001395E136D4");
67+
test("9AB0440DE10408ADE000000000000000000001134000000000000011940F6AF1");
68+
test("C6B0440DE12288B5E00000000000000000000CCB4000000000000013B3960CD4");
69+
test("C6B2E40DE12888B7E00000000000000000000CCB40000000000000114F8BC354");
70+
test("C6B0440DE13F08BCE00000000000000000001A770000000000000010286BB654");
71+
test("53B0440DE14708BEE00000000000000000001A77000000000000001358AC5F66");
72+
test("9AB0440DE16188C5E00000000000000000002E1840000000000000122F1985F1");
73+
test("53B0440DE16B88C7E00000000000000000002E184000000000000012EFDE17A6");
74+
test("53B0440DE17E08CCE000BD36E47A359984BA011340000000000000106031CF66");
75+
test("9AB0600DE1A488D6E000B2C1E361A5190C460CCB4000000000000011B0C18CB1");
76+
test("9AB0600DE1DD88E4E000A545DACBB58D907E2E184000000000000012A0AA9B71");
77+
test("C6B2E40DE1B488DAE000B2C1E361A5190C460CCB4000000000000013C7201F14");
78+
}
79+
80+
void loop() {
81+
// put your main code here, to run repeatedly:
82+
}

keywords.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#######################################
2+
# Syntax Coloring Map For QZQSM
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
DCXMessage KEYWORD1
10+
DCXDecoder KEYWORD1
11+
12+
#######################################
13+
# Methods and Functions (KEYWORD2)
14+
#######################################
15+
16+
decode KEYWORD2
17+
printAll KEYWORD2
18+
printSummary KEYWORD2
19+
20+
#######################################
21+
# Constants (LITERAL1)
22+
#######################################
23+

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=QZSSDCX
2+
version=1.0.0
3+
author=arms22
4+
maintainer=arms22
5+
sentence=QZSS DCX Decode Library
6+
paragraph=This library is designed to decode DCX messages delivered by QZSS.
7+
category=Other
8+
url=https://github.com/SWITCHSCIENCE/QZSSDCX
9+
architectures=esp32

0 commit comments

Comments
 (0)