Skip to content

Commit

Permalink
rtl-sdr decoded table
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykorwat committed Dec 23, 2024
1 parent 1115755 commit 6786d7c
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Spectrum analyzer allows for showing available spectrum for requested frequencie
## Data decoding

![decode](decode.jpg)
![decode](rtl-sdr-ads-b.jpg)

Data decode sets a trigger and upon detection of a signal, the device captures it for decoding purposes.

Expand Down
6 changes: 3 additions & 3 deletions docs/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files": {
"main.css": "./static/css/main.f2783ece.css",
"main.js": "./static/js/main.055c60dc.js",
"main.js": "./static/js/main.affb141b.js",
"static/js/453.3991db68.chunk.js": "./static/js/453.3991db68.chunk.js",
"static/media/roboto-latin-700-normal.woff2": "./static/media/roboto-latin-700-normal.4535474e1cf8598695ad.woff2",
"static/media/roboto-latin-500-normal.woff2": "./static/media/roboto-latin-500-normal.7077203b1982951ecf76.woff2",
Expand Down Expand Up @@ -61,11 +61,11 @@
"static/media/roboto-greek-ext-400-normal.woff": "./static/media/roboto-greek-ext-400-normal.16eb83b4a3b1ea994243.woff",
"index.html": "./index.html",
"main.f2783ece.css.map": "./static/css/main.f2783ece.css.map",
"main.055c60dc.js.map": "./static/js/main.055c60dc.js.map",
"main.affb141b.js.map": "./static/js/main.affb141b.js.map",
"453.3991db68.chunk.js.map": "./static/js/453.3991db68.chunk.js.map"
},
"entrypoints": [
"static/css/main.f2783ece.css",
"static/js/main.055c60dc.js"
"static/js/main.affb141b.js"
]
}
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="./logo192.png"/><link rel="manifest" href="./manifest.json"/><title>Web Spectrum</title><script defer="defer" src="./static/js/main.055c60dc.js"></script><link href="./static/css/main.f2783ece.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="./favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="./logo192.png"/><link rel="manifest" href="./manifest.json"/><title>Web Spectrum</title><script defer="defer" src="./static/js/main.affb141b.js"></script><link href="./static/css/main.f2783ece.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1 change: 0 additions & 1 deletion docs/static/js/main.055c60dc.js.map

This file was deleted.

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions docs/static/js/main.affb141b.js.map

Large diffs are not rendered by default.

Binary file added rtl-sdr-ads-b.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/device/sample_receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ class ReceiverSequence implements SampleReceiver {

export class LoggingReceiver implements SampleReceiver {
private demodulator: Demodulator;
private onMsg;

constructor() {
constructor(onMsg) {
this.onMsg = onMsg;
this.demodulator = new Demodulator();
}

Expand All @@ -79,7 +81,7 @@ export class LoggingReceiver implements SampleReceiver {
const samples = new Uint8Array(data);
console.log("got samples", samples.length);
this.demodulator.process(samples, 256000, (msg) => {
console.log(msg);
this.onMsg(msg);
});
}

Expand Down
53 changes: 46 additions & 7 deletions src/pages/RtlDecoder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,23 @@ import { RTL2832U_Provider } from "../device/rtlsdr/rtl2832u.ts";
import { Radio } from '../device/radio.ts';
import { LoggingReceiver } from '../device/sample_receiver.ts';

let latestDecodedItems = [];

function toHex(buffer) {
return Array.prototype.map.call(buffer, x => ('00' + x.toString(16)).slice(-2)).join('');
}

function RtlDecoder() {
const [radio, setRadio] = useState<Radio>();
const [frequency, setFrequency] = useState<number>(1090);
const [frequencyMag, setFrequencyMag] = useState<number>(1000000);

const [decodedItems, setDecodedItems] = useState<any>([]);

useEffect(() => {
latestDecodedItems = decodedItems;
}, [decodedItems]);

return (
<Container maxWidth="lg">
<Box display="flex"
Expand All @@ -63,7 +75,20 @@ return (
console.log("frequency to be set", freqHz);
if (radio === undefined) {
const rtlProvider = new RTL2832U_Provider();
const rtlRadio = new Radio(rtlProvider, new LoggingReceiver())
const rtlRadio = new Radio(rtlProvider, new LoggingReceiver((msg) => {
console.log(msg);
const nonEmptyFields = {};
Object.keys(msg).forEach(field => {
if (msg[field] && field !== 'msg') {
nonEmptyFields[field] = msg[field];
}
})
setDecodedItems([{
time: new Date(),
msg: msg.msg,
decoded: JSON.stringify(nonEmptyFields)
}, ...latestDecodedItems]);
}))
rtlRadio.setFrequency(freqHz);
rtlRadio.setGain(40);
rtlRadio.start();
Expand All @@ -72,7 +97,7 @@ return (
radio.setFrequency(freqHz);
radio.start();
}
}}>Trigger&Decode</Button>
}}>Listen&Decode</Button>
<Button onClick={async ()=>{
await radio?.stop();
}}>Disconnect</Button>
Expand Down Expand Up @@ -106,17 +131,31 @@ return (
justifyContent='center'
>
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }} aria-label="simple table">
<Table sx={{ minWidth: 850 }} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>Decoded</TableCell>
<TableCell>Time</TableCell>
<TableCell>Data</TableCell>
<TableCell align="right">Time</TableCell>
<TableCell align="right">Frequency</TableCell>
<TableCell align="right">Sweep time</TableCell>
<TableCell align="right">Trigger level</TableCell>
</TableRow>
</TableHead>
<TableBody>
{decodedItems.map((row, index) => (
<TableRow
key={index}
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
>
<TableCell sx={{'fontSize': 9}} component="th" scope="row">
{row.decoded}
</TableCell>
<TableCell component="th" scope="row">
{row.time.toISOString()}
</TableCell>
<TableCell component="th" scope="row">
{toHex(row.msg).replace(/0+$/, '')}
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
Expand Down

0 comments on commit 6786d7c

Please sign in to comment.