Skip to content

Commit

Permalink
Add rs-tftp project and overall fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
altugbakan committed Nov 19, 2023
1 parent da040c8 commit 55de456
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 40 deletions.
7 changes: 4 additions & 3 deletions src/components/BlogImage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ interface Props {
src: ImageMetadata;
width: number;
alt: string;
description: string;
className?: string;
}
const { src, alt, description, className } = Astro.props;
const { src, alt, className } = Astro.props;
---

<div class="my-4">
<Image {src} {alt} width={src.width} class={`mx-auto ${className}`} />
<em class="text-center mx-auto block">{description}</em>
<em class="text-center mx-auto block">
<slot />
</em>
</div>
2 changes: 1 addition & 1 deletion src/components/Project.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { project } = Astro.props;
<div class="mb-5">
<a
class="text-2xl font-bold mb-2 hover:underline"
href={project.slug}
href={`/projects/${project.slug}`}
aria-label={`Details about ${project.data.name}`}>{project.data.name}</a
>
<p class="text-gray- dark:text-gray-400 mb-2">
Expand Down
10 changes: 0 additions & 10 deletions src/content/projects/rs-tftpd.md

This file was deleted.

45 changes: 45 additions & 0 deletions src/content/projects/rs-tftpd.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: TFTP Server Daemon
description: Purely Rust-based TFTP server daemon.
url: https://crates.io/crates/tftpd
github: https://github.com/altugbakan/rs-tftpd
technologies: [Rust]
date: 2023-03
---

import BlogImage from "../../components/BlogImage.astro";
import TftpTimeout from "../../images/tftp-timeout.jpg";
import TftpHelp from "../../images/tftp-help.png";

I was working with microcontrollers at work, and we were using [TFTP](https://www.rfc-editor.org/rfc/rfc1350) to upload the firmware. We sometimes had issues with the u-boot firmware upload — sometimes the board was unable to receive a packet. This issue was quite annoying, as when it worked, it was quite fast, and it made the development and production process much easier.

<BlogImage src={TftpTimeout} alt="Timeout on u-boot upload.">
Timeout on u-boot upload. Image by [Lup Yuen
Lee](https://lupyuen.github.io/articles/tftp2)
</BlogImage>

I think that [Rust](https://www.rust-lang.org/) is a great language for writing system software, and to learn it, I decided to write a TFTP server daemon in Rust. I was also interested in learning more about networking, and this project was a great opportunity to learn more about it.

## The Project

The TFTP Server Daemon is a TFTP server written in pure Rust. I challenged myself to not use any external libraries to gain a deeper understanding of the language. I also wanted it to be an actual production-ready server, so I based it on [RFC 1350](https://www.rfc-editor.org/rfc/rfc1350) with [RFC 2347](https://www.rfc-editor.org/rfc/rfc2347) TFTP Option Extensions. I implemented all the features that I could think of, such as:

- [RFC 2348](https://www.rfc-editor.org/rfc/rfc2348) Blocksize Option
- [RFC 2349](https://www.rfc-editor.org/rfc/rfc2349) Timeout Interval Option
- [RFC 2349](https://www.rfc-editor.org/rfc/rfc2349) Transfer Size Option
- [RFC 7440](https://www.rfc-editor.org/rfc/rfc7440) Windowsize Option

There are also additional features that I added, such as multi-client communication, read-only mode, packet duplication, and more. I also added quality of life features, such as configuring the upload and download directories, port selection, and more. Check out the [config.rs](https://github.com/altugbakan/rs-tftpd/blob/main/src/config.rs) file to learn more about the configuration options.

To install and run the server, you can use the following command:

```bash
cargo install tftpd
tftpd --help
```

<BlogImage src={TftpHelp} alt="Help for TFTP Server.">
Help for TFTP Server.
</BlogImage>

I'm really glad to see that the project is being [used by people](https://github.com/altugbakan/rs-tftpd/issues?q=is%3Aissue). I've received a lot of feedback and [contributions](https://github.com/altugbakan/rs-tftpd/graphs/contributors), and I'm planning to add more features to the project in case someone needs them for their use case. If you have any feedback or feature requests, feel free to open an issue on the <a href={frontmatter.github}>GitHub repository</a>.
23 changes: 9 additions & 14 deletions src/content/projects/spotify-controller.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,20 @@ import SpotifyController from "../../images/spotify-controller.png";

I stumbled upon [Arduino Cloud Games](https://blog.arduino.cc/2022/01/13/let-your-ideas-take-flight-in-the-arduino-cloud-games/), and saw that in the first part attendees were supposed to pitch their idea for a free [Arduino Oplà IoT Kit](https://store.arduino.cc/products/arduino-opla-iot-kit?selectedStore=eu) to be incorporated in the following steps. Since I did not have any other electronic components or a workshop of my own, I decided to build a project that would only use the Oplà IoT Kit.

<BlogImage
src={OplaKit}
alt="Arduino Oplà IoT Kit"
className="w-96"
description="Arduino Oplà IoT Kit. Image by Arduino."
/>

I thought that this kit would be perfect for a Spotify Controller, since it has a display, a Wi-Fi module, and a few buttons. I pitched my idea, and I was lucky enough to be selected as one of the 100 participants to receive a free kit.
<BlogImage src={OplaKit} alt="Arduino Oplà IoT Kit" className="w-96">
Arduino Oplà IoT Kit. Image by Arduino.
</BlogImage>
I thought that this kit would be perfect for a Spotify Controller, since it has a
display, a Wi-Fi module, and a few buttons. I pitched my idea, and I was lucky enough
to be selected as one of the 100 participants to receive a free kit.

## The Project

The project is a Spotify Controller that can be used to play/pause, skip, and go back to the previous song. It also displays the current song and artist on the screen. The project is built using the Arduino Oplà IoT Kit, and it is connected to the Spotify API. The project is open source, and you can find the code on <a href={frontmatter.github}>GitHub</a> and <a href={frontmatter.url}>Arduino Project Hub</a>.

<BlogImage
src={SpotifyController}
alt="Spotfiy Controller"
className="w-96"
description="Spotify Controller."
/>
<BlogImage src={SpotifyController} alt="Spotfiy Controller" className="w-96">
Spotify Controller.
</BlogImage>

It works by first making the device acting as a server, and then displaying the user a link to connect their Spotify account. After the user connects their account, the device gets an access token from the Spotify API, and starts displaying the current song and artist on the screen. The user can then use the buttons to control the playback.

Expand Down
Binary file added src/images/tftp-help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/tftp-timeout.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: 3 additions & 3 deletions src/layouts/PostLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const { post } = Astro.props;
---

<style is:global>
.post > h2 {
.post h2 {
@apply text-2xl font-bold mt-4 mb-2;
}
.post > p {
.post p {
@apply mb-4;
}
.post > p > a {
.post a {
@apply text-blue-700 dark:text-blue-500 hover:underline;
}
</style>
Expand Down
15 changes: 6 additions & 9 deletions src/layouts/ProjectLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,23 @@ const { project } = Astro.props;
---

<style is:global>
.post > h1 {
.project > h1 {
@apply text-4xl font-bold;
}
.post > h2 {
.project > h2 {
@apply text-2xl font-bold mt-4 mb-2;
}
.post > p > a {
@apply text-blue-700 dark:text-blue-500 hover:underline;
}
.post > p {
.project p {
@apply mb-4;
}
.post > img {
@apply my-4;
.project a {
@apply text-blue-700 dark:text-blue-500 hover:underline;
}
</style>

<BaseLayout title={project.data.name}>
<h1 class="text-4xl font-bold mb-4">{project.data.name}</h1>
<div class="post">
<div class="project">
<slot />
</div>
<h2 class="text-2xl font-bold mt-4 mb-2">Technologies</h2>
Expand Down

0 comments on commit 55de456

Please sign in to comment.