Skip to content

Instantly share code, notes, and snippets.

@hakimio
hakimio / app-injector.ts
Last active September 6, 2022 07:22
Global App Injector in Angular below v14
import {Injector} from '@angular/core';
export class AppInjector {
private static injector: Injector;
static setInjector(injector: Injector) {
AppInjector.injector = injector;
}
<app-card>
<app-card-content>
<app-list-item
*ngFor="let student of students"
[name]="student.firstname"
></app-list-item>
</app-card-content>
</app-card>
@hakimio
hakimio / app.component.html
Last active January 11, 2023 09:23
"ngForTrackByKey" directive
<div
*ngFor="let item of items; trackByKey: 'id'"
>
{{item.name}}
</div>
@hakimio
hakimio / SpeechButton.tsx
Last active August 17, 2023 11:52
Speech recognition button (NextJS/React)
import React, {useContext, useState} from 'react';
import toast from 'react-hot-toast';
import {IconMicrophone, IconMicrophoneOff} from '@tabler/icons-react';
interface Props {
setContent: (content: string) => void;
}
const capitalizeFirstLetter = (message: string) => message.charAt(0).toUpperCase() + message.slice(1);
@hakimio
hakimio / ace2-pro-shell.py
Last active June 2, 2026 13:41
Anycubic ACE 2 Pro interactive shell and Protobuf protocol schema
#!/usr/bin/env python3
"""
Anycubic ACE 2 Pro — Protocol Driver & Interactive Shell
Protocol (reverse engineered from Kobra S1 firmware):
Physical: CH343 USB-UART, 230400 baud, 8N1
Frame: [FF AA] [flags] [seq_lo seq_hi] [cmd] [len] [protobuf] [CRC16_lo CRC16_hi] [FE]
CRC: CRC-16/KERMIT (poly 0x8408), init 0xFFFF, over flags..payload
Direction: flags=0x00 request, flags=0x80 response
Payload: Protocol Buffers proto3, package ace_com
@hakimio
hakimio / ace2-ota-update.py
Last active September 9, 2026 15:39
Anycubic ACE 2 Pro — OTA Firmware Updater
#!/usr/bin/env python3
"""
Anycubic ACE 2 Pro — OTA Firmware Updater
Implements the IAP (In-Application Programming) sequence reverse-engineered from the
Kobra S1 gklib binary (v2.7.0.9):
1. IAP_UPGRADE (cmd 2) — announce: total size + CRC-16/Kermit + version string
2. IAP_FIRMWARE (cmd 3) — send firmware in 64-byte chunks, each with its flash address
3. IAP_UPGRADE_FINISH (cmd 4) — commit: ACE reboots and runs new firmware
@hakimio
hakimio / feed-check.txt
Created May 12, 2026 19:11
Anycubic ACE 2 Pro Feed Check Analysis
ACE2 check_length / error_length — Complete Analysis
1. Validation limits (SET_FEED_CHECK handler, sub_800B3AC)
The MCU rejects the command (returns error code 1) if:
┌──────────────┬─────┬──────────────┬─────────────────────────────────────────────────────┐
│ Parameter │ Min │ Max │ Notes │
├──────────────┼─────┼──────────────┼─────────────────────────────────────────────────────┤
│ check_length │ 3 │ 254 │ 0–2 and 255+ → rejected │
@hakimio
hakimio / ACE2-firmware-analysis.md
Last active September 9, 2026 16:04
Anycubic ACE 2 Pro Firmware Behavior Analysis

Anycubic ACE 2 Pro — Firmware Behavior Analysis

Dual-source reverse-engineering:

  • gklib — Anycubic Kobra S1 "Klipper-Go" firmware, version 2.7.0.9.
    ARM 32-bit ELF binary, imagebase 0x10000. Analysis via IDA Pro decompilation.
  • ACE2 MCU firmware — ACE2_V1.1.31_20260306.bin, STM32F1 Cortex-M3.
    Loaded at 0x08008000. Analysis via IDA Pro disassembly/decompilation.