├── LICENSE ├── README.md ├── bin2asm ├── README.md ├── bin │ └── bin2asm.bin └── src │ ├── bin2asm.asm │ ├── mos.inc │ └── starcrt.inc └── esp8266 ├── esp-at-tester ├── README.md ├── bin │ └── tester.bin └── src │ ├── TESTER.ASM │ ├── crt.inc │ ├── mos.inc │ └── wifi.inc ├── esp-update ├── README.md ├── bin │ └── esp-update.bin └── src │ ├── crt.inc │ ├── esp-update.asm │ ├── mos.inc │ └── wifi.inc ├── netman ├── .gitignore ├── README.md ├── bin │ └── netman.bin └── src │ ├── crt.inc │ ├── mos.inc │ ├── netman.asm │ └── wifi.inc └── snail └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023 Aleksandr Sharikhin 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # My own tools for Agon Light(Agon Light 2) 2 | 3 | [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D6JVS74) 4 | 5 | Feel free explore and hack them 6 | 7 | ## Bin2asm 8 | 9 | Loadable MOS command that converts any file to includable assembly source(without label). 10 | 11 | Open projects directory for details 12 | 13 | ## ESP8266 Software 14 | 15 | ### Netman 16 | 17 | WiFi network manager and ESP chip configurer. 18 | 19 | Allows connect to ESP8266 to your wifi network. 20 | 21 | Open project directory for details. 22 | 23 | ### ESP Update 24 | 25 | Allows keep your ESP8266 module up to date. 26 | 27 | Can be required for using network software. 28 | 29 | Open project directory for details. 30 | 31 | ### ESP8266 AT Commands tester 32 | 33 | Allows test some AT-commands in interactive mode 34 | 35 | Open project directory for details. 36 | 37 | ### Snail - fast gopher browser for Agon Light 38 | 39 | Allows browse gophersphere and download files from network. 40 | 41 | Open project directory for details. 42 | 43 | ## License 44 | 45 | All this projects licensed under MIT -------------------------------------------------------------------------------- /bin2asm/README.md: -------------------------------------------------------------------------------- 1 | # bin2asm Agon MOS command 2 | 3 | ## Important notes! 4 | 5 | **DEPRECATED** Cause agon-ez80asm implement this feature native. 6 | 7 | **CAUTION** This code contains error - it lost last byte! But feel free discover and hack it. 8 | 9 | ## About it(but anyway it isn't actual) 10 | 11 | Allows you convert any binary to assembly source to include. 12 | 13 | I did it cause [agon-ez80asm](https://github.com/envenomator/agon-ez80asm) didn't support `incbin` directive yet. 14 | 15 | I just wanted make bouncing ball demo in assembly but written this instead. 16 | 17 | Code written directly on Agon Light and compiled with [agon-ez80asm](https://github.com/envenomator/agon-ez80asm). 18 | 19 | ## Usage 20 | 21 | Copy `bin2asm.bin` into your `/mos` directory of SD Card. 22 | 23 | ## Compilation 24 | 25 | Enter sources directory and call `asm bin2asm.asm`. 26 | 27 | It will produce `bin2asm.bin` binary. *IMPORTANT* It will be built for using as MOS command - won't work after `LOAD` and `RUN`. 28 | 29 | You can install into your system just by calling `copy bin2asm.bin /mos/bin2asm.bin` 30 | 31 | If you want use it as usual program via `LOAD` and `RUN` you should change origin address from `$B0000` to `40000` in `starcrt.inc` 32 | 33 | ## License 34 | 35 | Licensed under MIT License -------------------------------------------------------------------------------- /bin2asm/bin/bin2asm.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nihirash/Agon-MOS-Tools/617a465eb1fa4259548db0bb267820173f37d449/bin2asm/bin/bin2asm.bin -------------------------------------------------------------------------------- /bin2asm/src/bin2asm.asm: -------------------------------------------------------------------------------- 1 | MAX_ARGS: equ 2 2 | include "starcrt.inc" 3 | include "mos.inc" 4 | 5 | input_name: equ argv 6 | output_name: equ argv+3 7 | 8 | banner: 9 | db "bin2asm (c) 2023 Nihirash",13,10,0 10 | usage: 11 | db "bin2asm ",13,10,0 12 | 13 | txt_input: db "Input file: <",0 14 | txt_output: db "Output file: <", 0 15 | crlf: db ">",13, 10, 0 16 | 17 | _main: 18 | ld hl, banner 19 | call printZ 20 | 21 | ld a, (argc) 22 | cp 2 23 | jp c, show_usage 24 | 25 | ld hl, txt_input 26 | call printZ 27 | ld hl, (input_name) 28 | call printZ 29 | ld hl, crlf 30 | call printZ 31 | 32 | ld hl, txt_output 33 | call printZ 34 | ld hl, (output_name) 35 | call printZ 36 | ld hl, crlf 37 | call printZ 38 | 39 | ld hl, (input_name) 40 | ld c, fa_read 41 | MOSCALL mos_fopen 42 | or a 43 | jp z, i_open_err 44 | ld (ihandle), a 45 | 46 | ld hl, (output_name) 47 | ld c, fa_write+fa_cr_always 48 | MOSCALL mos_fopen 49 | or a 50 | jp z, o_open_err 51 | ld (ohandle), a 52 | 53 | store_loop: 54 | ld a, (ihandle) 55 | ld c, a 56 | MOSCALL mos_feof 57 | or a 58 | jr nz, exit 59 | 60 | ld a, '\t' 61 | call write 62 | ld a, 'd' 63 | call write 64 | ld a, 'b' 65 | call write 66 | ld a, ' ' 67 | call write 68 | ld a, '$' 69 | call write 70 | 71 | ld a, (ihandle) 72 | ld c, a 73 | MOSCALL mos_fgetc 74 | call write_hex 75 | 76 | ld a, 13 77 | call write 78 | ld a, 10 79 | call write 80 | jp store_loop 81 | 82 | 83 | exit: 84 | ; Close all files 85 | ld c, 0 86 | MOSCALL mos_fclose 87 | ret 88 | 89 | ; A - byte to write 90 | write: 91 | ld b, a 92 | ld a, (ohandle) 93 | ld c, a 94 | MOSCALL mos_fputc 95 | ret 96 | 97 | write_hex: 98 | ld h, a 99 | call @num1 100 | ld a, h 101 | call @num2 102 | ret 103 | @num1: 104 | rra 105 | rra 106 | rra 107 | rra 108 | @num2: 109 | or $f0 110 | daa 111 | add a,$a0 112 | adc a,$40 113 | push hl 114 | call write 115 | pop hl 116 | ret 117 | 118 | o_open_err: 119 | ld a, (ihandle) 120 | ld c, a 121 | MOSCALL mos_fclose 122 | 123 | ld hl, @msg1 124 | jp printZ 125 | @msg1: db "Output file can't be created", 13, 10, 0 126 | 127 | i_open_err: 128 | ld hl, @msg 129 | jp printZ 130 | @msg: db "Source file doesn't exists", 13,10, 0 131 | 132 | show_usage: 133 | ld hl, usage 134 | call printZ 135 | ret 136 | 137 | ihandle: db 0 138 | ohandle: db 0 139 | -------------------------------------------------------------------------------- /bin2asm/src/mos.inc: -------------------------------------------------------------------------------- 1 | ;; Constants 2 | mos_getkey: equ $00 3 | mos_load: equ $01 4 | mos_save: equ $02 5 | mos_cd: equ $03 6 | mos_dir: equ $04 7 | mos_del: equ $05 8 | mos_ren: equ $06 9 | mos_mkdir: equ $07 10 | mos_sysvars: equ $08 11 | mos_editline: equ $09 12 | mos_fopen: equ $0a 13 | mos_fclose: equ $0b 14 | mos_fgetc: equ $0c 15 | mos_fputc: equ $0d 16 | mos_feof: equ $0e 17 | mos_geterror: equ $0f 18 | mos_oscli: equ $10 19 | mos_copy: equ $11 20 | mos_getrtc: equ $12 21 | mos_setrtc: equ $13 22 | mos_setintvec: equ $14 23 | mos_uopen: equ $15 24 | mos_uclose: equ $16 25 | mos_ugetc: equ $17 26 | mos_uputc: equ $18 27 | 28 | ;; File modes 29 | fa_read: equ $01 30 | fa_write: equ $02 31 | fa_exist: equ $00 32 | fa_create: equ $04 33 | fa_cr_always: equ $08 34 | fa_op_always: equ $10 35 | fa_append: equ $30 36 | 37 | ;; A - character to print 38 | putc: 39 | rst.lil $10 40 | ret 41 | 42 | ;; HLU - pointer to string 43 | printZ: 44 | ld bc,0 45 | xor a 46 | rst.lil $18 47 | ret 48 | 49 | macro MOSCALL func 50 | ld a, func 51 | rst.lil $08 52 | endmacro 53 | 54 | 55 | -------------------------------------------------------------------------------- /bin2asm/src/starcrt.inc: -------------------------------------------------------------------------------- 1 | ASSUME ADL=1 2 | 3 | org $B0000 4 | jp _start 5 | align 64 6 | db "MOS" ; Header 7 | db 00 ; Version 8 | db 01 ; ADL 9 | _start: 10 | ld ix,argv 11 | call _parse_args 12 | ld a,c 13 | ld (argc),a 14 | 15 | call _main 16 | ld hl,0 17 | ret 18 | 19 | _parse_args: 20 | call _skip_spaces 21 | ld bc,0 22 | ld b,MAX_ARGS 23 | _parse1: 24 | push bc 25 | push hl 26 | call _get_token 27 | ld a,c 28 | pop de 29 | pop bc 30 | and a 31 | ret z 32 | 33 | ld (ix+0),de 34 | push hl 35 | pop de 36 | call _skip_spaces 37 | xor a 38 | ld (de),a 39 | inc ix 40 | inc ix 41 | inc ix 42 | inc c 43 | ld a, c 44 | cp b 45 | jr c,_parse1 46 | ret 47 | 48 | _get_token: 49 | ld c,0 50 | @loop: 51 | ld a,(hl) 52 | or a 53 | ret z 54 | 55 | cp 13 56 | ret z 57 | 58 | cp 32 59 | ret z 60 | 61 | inc hl 62 | inc c 63 | jr @loop 64 | 65 | _skip_spaces: 66 | ld a,(hl) 67 | cp 32 68 | ret nz 69 | inc hl 70 | jr _skip_spaces 71 | 72 | argc: db 0 73 | argv: ds 3*MAX_ARGS 74 | 75 | -------------------------------------------------------------------------------- /esp8266/esp-at-tester/README.md: -------------------------------------------------------------------------------- 1 | # ESP8266 AT Commands tester 2 | 3 | ## How to use? 4 | 5 | Load(`load tester.bin`) and run it(`run`) as usual application. 6 | 7 | Enter any AT-command(they're case sensitive - use caps lock) and get results. 8 | 9 | When you finished your session call `BYE` command. 10 | 11 | ## Requirements 12 | 13 | * ESP8266 chip(Espressif AT firmware out of the box - 115200 baud speed) on UART1. It's important! In other case my app will freeze 14 | 15 | * MOS 1.03 RC3 or above(cause UART api appears here first time) 16 | 17 | ## Compilation 18 | 19 | Code written directly on Agon Light and compiled with [agon-ez80asm](https://github.com/envenomator/agon-ez80asm). 20 | 21 | Enter sources directory and call `asm tester.asm`. 22 | 23 | It will produce `tester.bin` binary. 24 | 25 | ## License 26 | 27 | Licensed under MIT License -------------------------------------------------------------------------------- /esp8266/esp-at-tester/bin/tester.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nihirash/Agon-MOS-Tools/617a465eb1fa4259548db0bb267820173f37d449/esp8266/esp-at-tester/bin/tester.bin -------------------------------------------------------------------------------- /esp8266/esp-at-tester/src/TESTER.ASM: -------------------------------------------------------------------------------- 1 | MAX_ARGS: equ 1 2 | include "crt.inc" 3 | include "mos.inc" 4 | include "wifi.inc" 5 | 6 | banner: 7 | db "ESP8266 AT-commands tester",13,10 8 | db "(c) 2023 Nihirash",13,10,0 9 | 10 | _main: 11 | ld hl, banner 12 | call printZ 13 | 14 | call esp_init 15 | call esp_repl 16 | exit: 17 | call esp_free 18 | ret 19 | 20 | esp_repl: 21 | ld a, 13 22 | call putc 23 | ld a, 10 24 | call putc 25 | 26 | ld hl, buffer 27 | ld bc, 80 28 | ld e, 1 29 | MOSCALL mos_editline 30 | 31 | ld a, 13 32 | call putc 33 | ld a, 10 34 | call putc 35 | 36 | ld hl, buffer 37 | ld a, (hl) 38 | cp 'B' 39 | jr nz, @eval 40 | 41 | inc hl 42 | ld a, (hl) 43 | cp 'Y' 44 | jr nz, @eval 45 | 46 | inc hl 47 | ld a, (hl) 48 | cp 'E' 49 | jr nz, @eval 50 | jr exit 51 | 52 | @eval: 53 | ld hl, buffer 54 | call ok_err_cmd 55 | jr esp_repl 56 | 57 | buffer: ds 80 58 | 59 | 60 | -------------------------------------------------------------------------------- /esp8266/esp-at-tester/src/crt.inc: -------------------------------------------------------------------------------- 1 | ASSUME ADL=1 2 | ;; USE org $40000 for usual application 3 | ;; or $B0000 for MOS command 4 | org $40000 5 | jp _start 6 | align 64 7 | db "MOS" ; Header 8 | db 00 ; Version 9 | db 01 ; ADL 10 | _start: 11 | push ix 12 | push iy 13 | 14 | ld ix,argv 15 | call _parse_args 16 | ld a,c 17 | ld (argc),a 18 | 19 | call _main 20 | pop iy 21 | pop ix 22 | 23 | ld hl,0 24 | ret 25 | 26 | _parse_args: 27 | call _skip_spaces 28 | ld bc,0 29 | ld b,MAX_ARGS 30 | _parse1: 31 | push bc 32 | push hl 33 | call _get_token 34 | ld a,c 35 | pop de 36 | pop bc 37 | and a 38 | ret z 39 | 40 | ld (ix+0),de 41 | push hl 42 | pop de 43 | call _skip_spaces 44 | xor a 45 | ld (de),a 46 | inc ix 47 | inc ix 48 | inc ix 49 | inc c 50 | ld a, c 51 | cp b 52 | jr c,_parse1 53 | ret 54 | 55 | _get_token: 56 | ld c,0 57 | @loop: 58 | ld a,(hl) 59 | or a 60 | ret z 61 | 62 | cp 13 63 | ret z 64 | 65 | cp 32 66 | ret z 67 | 68 | inc hl 69 | inc c 70 | jr @loop 71 | 72 | _skip_spaces: 73 | ld a,(hl) 74 | cp 32 75 | ret nz 76 | inc hl 77 | jr _skip_spaces 78 | 79 | argc: db 0 80 | argv: ds 3*MAX_ARGS 81 | 82 | -------------------------------------------------------------------------------- /esp8266/esp-at-tester/src/mos.inc: -------------------------------------------------------------------------------- 1 | ;; Constants 2 | mos_getkey: equ $00 3 | mos_load: equ $01 4 | mos_save: equ $02 5 | mos_cd: equ $03 6 | mos_dir: equ $04 7 | mos_del: equ $05 8 | mos_ren: equ $06 9 | mos_mkdir: equ $07 10 | mos_sysvars: equ $08 11 | mos_editline: equ $09 12 | mos_fopen: equ $0a 13 | mos_fclose: equ $0b 14 | mos_fgetc: equ $0c 15 | mos_fputc: equ $0d 16 | mos_feof: equ $0e 17 | mos_geterror: equ $0f 18 | mos_oscli: equ $10 19 | mos_copy: equ $11 20 | mos_getrtc: equ $12 21 | mos_setrtc: equ $13 22 | mos_setintvec: equ $14 23 | mos_uopen: equ $15 24 | mos_uclose: equ $16 25 | mos_ugetc: equ $17 26 | mos_uputc: equ $18 27 | 28 | ;; File modes 29 | fa_read: equ $01 30 | fa_write: equ $02 31 | fa_exist: equ $00 32 | fa_create: equ $04 33 | fa_cr_always: equ $08 34 | fa_op_always: equ $10 35 | fa_append: equ $30 36 | 37 | ;; A - character to print 38 | putc: 39 | rst.lil $10 40 | ret 41 | 42 | ;; HLU - pointer to string 43 | printZ: 44 | ld bc,0 45 | xor a 46 | rst.lil $18 47 | ret 48 | 49 | macro MOSCALL func 50 | ld a, func 51 | rst.lil $08 52 | endmacro 53 | 54 | 55 | -------------------------------------------------------------------------------- /esp8266/esp-at-tester/src/wifi.inc: -------------------------------------------------------------------------------- 1 | 2 | esp_init: 3 | call uart_init 4 | 5 | ld hl, @cmd_at 6 | call ok_err_cmd 7 | jp z, @esp_init_error 8 | 9 | ld hl, @cmd_e0 10 | call ok_err_cmd 11 | jp z, @esp_init_error 12 | 13 | ld hl, @cmd_mode 14 | call ok_err_cmd 15 | jp z, @esp_init_error 16 | 17 | ld hl, @cmd_auto 18 | call ok_err_cmd 19 | 20 | ld hl, @cmd_info 21 | call ok_err_cmd 22 | 23 | ld hl, @cmd_mux 24 | call ok_err_cmd 25 | 26 | ret 27 | @esp_init_error: 28 | xor a 29 | ret 30 | @cmd_at: db "AT",0 31 | @cmd_e0: db "ATE0",0 32 | @cmd_mode: db "AT+CWMODE_DEF=1",0 33 | @cmd_auto: db "AT+CWAUTOCONN=1",0 34 | @cmd_info: db "AT+CIPDINFO=0",0 35 | @cmd_mux: db "AT+CIPMUX=0",0 36 | 37 | esp_free: 38 | MOSCALL mos_uclose 39 | ret 40 | 41 | uart_init: 42 | ld ix, serial_config 43 | MOSCALL mos_uopen 44 | ret 45 | 46 | macro UART_WAIT byte, if_err 47 | call uart_read 48 | cp byte 49 | jp nz, if_err 50 | endmacro 51 | 52 | 53 | ; hl -> cmd 54 | ; a <- 1 ok(nz flag),0 err(z flag) 55 | ok_err_cmd: 56 | call uart_writeZ 57 | ld a, 13 58 | call uart_write 59 | ld a, 10 60 | call uart_write 61 | ok_err_loop: 62 | call uart_read 63 | 64 | cp 'O' 65 | jr z, r_ok 66 | 67 | cp 'E' 68 | jp z, r_err 69 | 70 | cp 'F' 71 | jp z, r_fail 72 | 73 | jr ok_err_loop 74 | 75 | r_ok: 76 | UART_WAIT 'K', ok_err_loop 77 | UART_WAIT 13, ok_err_loop 78 | 79 | ld a, 1 80 | or a 81 | ret 82 | 83 | r_err: 84 | UART_WAIT 'R', ok_err_loop 85 | UART_WAIT 'R', ok_err_loop 86 | UART_WAIT 'O', ok_err_loop 87 | UART_WAIT 'R', ok_err_loop 88 | UART_WAIT 13, ok_err_loop 89 | 90 | xor a 91 | ret 92 | r_fail: 93 | UART_WAIT 'A', ok_err_loop 94 | UART_WAIT 'I', ok_err_loop 95 | UART_WAIT 'L', ok_err_loop 96 | UART_WAIT 13, ok_err_loop 97 | 98 | xor a 99 | ret 100 | 101 | ; A - byte that was read 102 | uart_read: 103 | MOSCALL mos_ugetc 104 | push af 105 | call putc 106 | pop af 107 | ret 108 | 109 | ; HL - pointer to string 110 | uart_writeZ: 111 | ld a, (hl) 112 | and a 113 | ret z 114 | push hl 115 | call uart_write 116 | pop hl 117 | inc hl 118 | jr uart_writeZ 119 | 120 | ; A - byte to send 121 | uart_write: 122 | ld c, a 123 | MOSCALL mos_uputc 124 | ret 125 | 126 | 127 | serial_config: 128 | dl 115200 129 | ; db $00, $c2, $01 ; 115200 130 | db 8 ; data bits 131 | db 1 ; 1 stop bit 132 | db 0 ; parity 133 | db 0 ; flow control 134 | db 0 ; interrupts 135 | 136 | 137 | -------------------------------------------------------------------------------- /esp8266/esp-update/README.md: -------------------------------------------------------------------------------- 1 | # ESP8266 Updater 2 | 3 | ## Why we need it? 4 | 5 | Olimex ships ESP8266 modules with outdated firmware. 6 | 7 | I've checked autoupdate routine and it worked fine and this utility will execute this autoupdate routine. 8 | 9 | ## How to use? 10 | 11 | Copy `esp-update.bin` into `/mos/` directory. 12 | 13 | Connect to access point via Network Manager(see netman directory) and execute `esp-update`. 14 | 15 | After successful update reconnect with `netman` to access point. 16 | 17 | ## Requirements 18 | 19 | * ESP8266 chip(Espressif AT firmware out of the box - 115200 baud speed) on UART1. It's important! In other case my app will freeze 20 | 21 | * MOS 1.03 RC3 or above(cause UART api appears here first time) 22 | 23 | ## Compilation 24 | 25 | Code written directly on Agon Light and compiled with [agon-ez80asm](https://github.com/envenomator/agon-ez80asm). 26 | 27 | Enter sources directory and call `asm esp-update.asm`. 28 | 29 | It will produce `esp-update.bin` binary. *IMPORTANT* It will be built for using as MOS command - won't work after `LOAD` and `RUN`. 30 | 31 | You can install into your system just by calling `copy esp-update.bin /mos/esp-update.bin` 32 | 33 | If you want use it as usual program via `LOAD` and `RUN` you should change origin address from `$B0000` to `40000` in `crt.inc` 34 | 35 | ## License 36 | 37 | Licensed under MIT License -------------------------------------------------------------------------------- /esp8266/esp-update/bin/esp-update.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nihirash/Agon-MOS-Tools/617a465eb1fa4259548db0bb267820173f37d449/esp8266/esp-update/bin/esp-update.bin -------------------------------------------------------------------------------- /esp8266/esp-update/src/crt.inc: -------------------------------------------------------------------------------- 1 | ASSUME ADL=1 2 | ;; USE org $40000 for usual application 3 | ;; or $B0000 for MOS command 4 | org $B0000 5 | jp _start 6 | align 64 7 | db "MOS" ; Header 8 | db 00 ; Version 9 | db 01 ; ADL 10 | _start: 11 | push ix 12 | push iy 13 | 14 | ld ix,argv 15 | call _parse_args 16 | ld a,c 17 | ld (argc),a 18 | 19 | call _main 20 | pop iy 21 | pop ix 22 | 23 | ld hl,0 24 | ret 25 | 26 | _parse_args: 27 | call _skip_spaces 28 | ld bc,0 29 | ld b,MAX_ARGS 30 | _parse1: 31 | push bc 32 | push hl 33 | call _get_token 34 | ld a,c 35 | pop de 36 | pop bc 37 | and a 38 | ret z 39 | 40 | ld (ix+0),de 41 | push hl 42 | pop de 43 | call _skip_spaces 44 | xor a 45 | ld (de),a 46 | inc ix 47 | inc ix 48 | inc ix 49 | inc c 50 | ld a, c 51 | cp b 52 | jr c,_parse1 53 | ret 54 | 55 | _get_token: 56 | ld c,0 57 | @loop: 58 | ld a,(hl) 59 | or a 60 | ret z 61 | 62 | cp 13 63 | ret z 64 | 65 | cp 32 66 | ret z 67 | 68 | inc hl 69 | inc c 70 | jr @loop 71 | 72 | _skip_spaces: 73 | ld a,(hl) 74 | cp 32 75 | ret nz 76 | inc hl 77 | jr _skip_spaces 78 | 79 | argc: db 0 80 | argv: ds 3*MAX_ARGS 81 | 82 | -------------------------------------------------------------------------------- /esp8266/esp-update/src/esp-update.asm: -------------------------------------------------------------------------------- 1 | MAX_ARGS: equ 1 2 | include "crt.inc" 3 | include "mos.inc" 4 | include "wifi.inc" 5 | 6 | banner: 7 | db "ESP8266 Update utility ", 13,10 8 | db "(c) 2023 Nihirash", 13, 10, 0 9 | 10 | _main: 11 | ld hl, banner 12 | call printZ 13 | 14 | call esp_init 15 | ld hl, at_update 16 | call ok_err_cmd 17 | jr z, err 18 | 19 | call esp_init 20 | 21 | ld hl, at_restore 22 | call ok_err_cmd 23 | 24 | 25 | ld hl, reconnect 26 | call printZ 27 | exit: 28 | call esp_free 29 | ret 30 | err: 31 | ld hl, err_msg 32 | call printZ 33 | jr exit 34 | err_msg: 35 | db "Update error! Make sure that you'd connected to Access Point", 13, 10, 0 36 | 37 | at_update: 38 | db "AT+CIUPDATE", 0 39 | 40 | at_restore: 41 | db "AT+RESTORE", 0 42 | 43 | reconnect: 44 | db 13, 10, "Run netman - reconfiguring ESP required", 13,10,0 45 | 46 | -------------------------------------------------------------------------------- /esp8266/esp-update/src/mos.inc: -------------------------------------------------------------------------------- 1 | ;; Constants 2 | mos_getkey: equ $00 3 | mos_load: equ $01 4 | mos_save: equ $02 5 | mos_cd: equ $03 6 | mos_dir: equ $04 7 | mos_del: equ $05 8 | mos_ren: equ $06 9 | mos_mkdir: equ $07 10 | mos_sysvars: equ $08 11 | mos_editline: equ $09 12 | mos_fopen: equ $0a 13 | mos_fclose: equ $0b 14 | mos_fgetc: equ $0c 15 | mos_fputc: equ $0d 16 | mos_feof: equ $0e 17 | mos_geterror: equ $0f 18 | mos_oscli: equ $10 19 | mos_copy: equ $11 20 | mos_getrtc: equ $12 21 | mos_setrtc: equ $13 22 | mos_setintvec: equ $14 23 | mos_uopen: equ $15 24 | mos_uclose: equ $16 25 | mos_ugetc: equ $17 26 | mos_uputc: equ $18 27 | 28 | ;; File modes 29 | fa_read: equ $01 30 | fa_write: equ $02 31 | fa_exist: equ $00 32 | fa_create: equ $04 33 | fa_cr_always: equ $08 34 | fa_op_always: equ $10 35 | fa_append: equ $30 36 | 37 | ;; A - character to print 38 | putc: 39 | rst.lil $10 40 | ret 41 | 42 | ;; HLU - pointer to string 43 | printZ: 44 | ld bc,0 45 | xor a 46 | rst.lil $18 47 | ret 48 | 49 | macro MOSCALL func 50 | ld a, func 51 | rst.lil $08 52 | endmacro 53 | 54 | 55 | -------------------------------------------------------------------------------- /esp8266/esp-update/src/wifi.inc: -------------------------------------------------------------------------------- 1 | 2 | esp_init: 3 | call uart_init 4 | 5 | ld hl, @cmd_at 6 | call ok_err_cmd 7 | jp z, @esp_init_error 8 | 9 | ld hl, @cmd_e0 10 | call ok_err_cmd 11 | jp z, @esp_init_error 12 | 13 | ld hl, @cmd_mode 14 | call ok_err_cmd 15 | jp z, @esp_init_error 16 | 17 | ld hl, @cmd_auto 18 | call ok_err_cmd 19 | 20 | ld hl, @cmd_info 21 | call ok_err_cmd 22 | 23 | ld hl, @cmd_mux 24 | call ok_err_cmd 25 | 26 | ret 27 | @esp_init_error: 28 | xor a 29 | ret 30 | @cmd_at: db "AT",0 31 | @cmd_e0: db "ATE1",0 32 | @cmd_mode: db "AT+CWMODE_DEF=1",0 33 | @cmd_auto: db "AT+CWAUTOCONN=1",0 34 | @cmd_info: db "AT+CIPDINFO=0",0 35 | @cmd_mux: db "AT+CIPMUX=0",0 36 | 37 | esp_free: 38 | MOSCALL mos_uclose 39 | ret 40 | 41 | uart_init: 42 | ld ix, serial_config 43 | MOSCALL mos_uopen 44 | ret 45 | 46 | macro UART_WAIT byte, if_err 47 | call uart_read 48 | cp byte 49 | jp nz, if_err 50 | endmacro 51 | 52 | 53 | ; hl -> cmd 54 | ; a <- 1 ok(nz flag),0 err(z flag) 55 | ok_err_cmd: 56 | call uart_writeZ 57 | ld a, 13 58 | call uart_write 59 | ld a, 10 60 | call uart_write 61 | ok_err_loop: 62 | call uart_read 63 | 64 | cp 'O' 65 | jr z, r_ok 66 | 67 | cp 'E' 68 | jp z, r_err 69 | 70 | cp 'F' 71 | jp z, r_fail 72 | 73 | jr ok_err_loop 74 | 75 | r_ok: 76 | UART_WAIT 'K', ok_err_loop 77 | UART_WAIT 13, ok_err_loop 78 | 79 | ld a, 1 80 | or a 81 | ret 82 | 83 | r_err: 84 | UART_WAIT 'R', ok_err_loop 85 | UART_WAIT 'R', ok_err_loop 86 | UART_WAIT 'O', ok_err_loop 87 | UART_WAIT 'R', ok_err_loop 88 | UART_WAIT 13, ok_err_loop 89 | 90 | xor a 91 | ret 92 | r_fail: 93 | UART_WAIT 'A', ok_err_loop 94 | UART_WAIT 'I', ok_err_loop 95 | UART_WAIT 'L', ok_err_loop 96 | UART_WAIT 13, ok_err_loop 97 | 98 | xor a 99 | ret 100 | 101 | ; A - byte that was read 102 | uart_read: 103 | MOSCALL mos_ugetc 104 | push af 105 | call putc 106 | pop af 107 | ret 108 | 109 | ; HL - pointer to string 110 | uart_writeZ: 111 | ld a, (hl) 112 | and a 113 | ret z 114 | push hl 115 | call uart_write 116 | pop hl 117 | inc hl 118 | jr uart_writeZ 119 | 120 | ; A - byte to send 121 | uart_write: 122 | ld c, a 123 | MOSCALL mos_uputc 124 | ret 125 | 126 | 127 | serial_config: 128 | dl 115200 129 | ; db $00, $c2, $01 ; 115200 130 | db 8 ; data bits 131 | db 1 ; 1 stop bit 132 | db 0 ; parity 133 | db 0 ; flow control 134 | db 0 ; interrupts 135 | 136 | 137 | -------------------------------------------------------------------------------- /esp8266/netman/.gitignore: -------------------------------------------------------------------------------- 1 | src/*.bin 2 | *.lst 3 | *.m.* -------------------------------------------------------------------------------- /esp8266/netman/README.md: -------------------------------------------------------------------------------- 1 | # Network Manager for ESP8266 on UART1 2 | 3 | ## About 4 | 5 | Simple network manager that inits your ESP-chip and connects it to your access point. 6 | 7 | I'm using it with [Olimex esp8266 dongle](https://www.olimex.com/Products/IoT/ESP8266/MOD-WIFI-ESP8266/open-source-hardware). 8 | 9 | ## How to use it? 10 | 11 | Copy binary into `/mos/` directory and call netman command. 12 | 13 | In case error you can try restart tool. 14 | 15 | ## Requirements 16 | 17 | * ESP8266 chip(Espressif AT firmware out of the box - 115200 baud speed) on UART1. It's important! In other case my app will freeze 18 | 19 | * MOS 1.03 RC3 or above(cause UART api appears here first time) 20 | 21 | ## Compilation 22 | 23 | Code written directly on Agon Light and compiled with [agon-ez80asm](https://github.com/envenomator/agon-ez80asm). 24 | 25 | Enter sources directory and call `asm netman.asm`. 26 | 27 | It will produce `netman.bin` binary. *IMPORTANT* It will be built for using as MOS command - won't work after `LOAD` and `RUN`. 28 | 29 | You can install into your system just by calling `copy netman.bin /mos/netman.bin` 30 | 31 | If you want use it as usual program via `LOAD` and `RUN` you should change origin address from `$B0000` to `40000` in `crt.inc` 32 | 33 | ## License 34 | 35 | Licensed under MIT License -------------------------------------------------------------------------------- /esp8266/netman/bin/netman.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nihirash/Agon-MOS-Tools/617a465eb1fa4259548db0bb267820173f37d449/esp8266/netman/bin/netman.bin -------------------------------------------------------------------------------- /esp8266/netman/src/crt.inc: -------------------------------------------------------------------------------- 1 | ASSUME ADL=1 2 | 3 | org $B0000 4 | jp _start 5 | align 64 6 | db "MOS" ; Header 7 | db 00 ; Version 8 | db 01 ; ADL 9 | _start: 10 | push ix 11 | push iy 12 | 13 | ld ix,argv 14 | call _parse_args 15 | ld a,c 16 | ld (argc),a 17 | 18 | call _main 19 | pop iy 20 | pop ix 21 | 22 | ld hl,0 23 | ret 24 | 25 | _parse_args: 26 | call _skip_spaces 27 | ld bc,0 28 | ld b,MAX_ARGS 29 | _parse1: 30 | push bc 31 | push hl 32 | call _get_token 33 | ld a,c 34 | pop de 35 | pop bc 36 | and a 37 | ret z 38 | 39 | ld (ix+0),de 40 | push hl 41 | pop de 42 | call _skip_spaces 43 | xor a 44 | ld (de),a 45 | inc ix 46 | inc ix 47 | inc ix 48 | inc c 49 | ld a, c 50 | cp b 51 | jr c,_parse1 52 | ret 53 | 54 | _get_token: 55 | ld c,0 56 | @loop: 57 | ld a,(hl) 58 | or a 59 | ret z 60 | 61 | cp 13 62 | ret z 63 | 64 | cp 32 65 | ret z 66 | 67 | inc hl 68 | inc c 69 | jr @loop 70 | 71 | _skip_spaces: 72 | ld a,(hl) 73 | cp 32 74 | ret nz 75 | inc hl 76 | jr _skip_spaces 77 | 78 | argc: db 0 79 | argv: ds 3*MAX_ARGS 80 | 81 | -------------------------------------------------------------------------------- /esp8266/netman/src/mos.inc: -------------------------------------------------------------------------------- 1 | ;; Constants 2 | mos_getkey: equ $00 3 | mos_load: equ $01 4 | mos_save: equ $02 5 | mos_cd: equ $03 6 | mos_dir: equ $04 7 | mos_del: equ $05 8 | mos_ren: equ $06 9 | mos_mkdir: equ $07 10 | mos_sysvars: equ $08 11 | mos_editline: equ $09 12 | mos_fopen: equ $0a 13 | mos_fclose: equ $0b 14 | mos_fgetc: equ $0c 15 | mos_fputc: equ $0d 16 | mos_feof: equ $0e 17 | mos_geterror: equ $0f 18 | mos_oscli: equ $10 19 | mos_copy: equ $11 20 | mos_getrtc: equ $12 21 | mos_setrtc: equ $13 22 | mos_setintvec: equ $14 23 | mos_uopen: equ $15 24 | mos_uclose: equ $16 25 | mos_ugetc: equ $17 26 | mos_uputc: equ $18 27 | 28 | ;; File modes 29 | fa_read: equ $01 30 | fa_write: equ $02 31 | fa_exist: equ $00 32 | fa_create: equ $04 33 | fa_cr_always: equ $08 34 | fa_op_always: equ $10 35 | fa_append: equ $30 36 | 37 | ;; A - character to print 38 | putc: 39 | rst.lil $10 40 | ret 41 | 42 | ;; HLU - pointer to string 43 | printZ: 44 | ld bc,0 45 | xor a 46 | rst.lil $18 47 | ret 48 | 49 | macro MOSCALL func 50 | ld a, func 51 | rst.lil $08 52 | endmacro 53 | 54 | 55 | -------------------------------------------------------------------------------- /esp8266/netman/src/netman.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Network manager for Agon Light and ESP8266 on UART1 3 | ; (c) 2023 Aleksandr Sharikhin aka Nihirash 4 | ; 5 | ; Licensed under MIT 6 | 7 | 8 | MAX_ARGS: equ 2 9 | include "crt.inc" 10 | include "mos.inc" 11 | include "wifi.inc" 12 | banner: 13 | db "Network Manager for ESP8266 v. 0.1.0",13,10 14 | db "(c) 2023 Aleksandr Sharikhin", 13, 10, 13, 10 15 | db "Initing UART and WiFi chip",13,10,0 16 | _main: 17 | ld hl, banner 18 | call printZ 19 | 20 | call esp_init 21 | jp z, err 22 | 23 | ld hl, cmd_quit 24 | call ok_err_cmd 25 | 26 | ld hl, cmd_list 27 | call uart_writeZ 28 | 29 | ld hl, txt_ap_list 30 | call printZ 31 | 32 | ;; Requesting AP list(AT+CWLAP command) 33 | load_list: 34 | call uart_read 35 | 36 | cp $2b ; + - begin of data line 37 | jr z, @r_plus 38 | 39 | cp 'O' 40 | jr z, @r_ok 41 | 42 | cp 'E' 43 | jr z, @r_err 44 | jr load_list 45 | @r_plus: 46 | call uart_read 47 | cp 'C' 48 | jr nz, load_list 49 | 50 | call uart_read 51 | cp 'W' 52 | jr nz, load_list 53 | 54 | call uart_read 55 | cp 'L' 56 | jr nz, load_list 57 | ;; By +CWL we can understand that it's our required line 58 | jr load_ap 59 | @r_ok: 60 | call uart_read 61 | cp 'K' 62 | jr nz, load_list 63 | 64 | call uart_read 65 | cp 13 66 | jr nz, load_list 67 | ;; It's "OK\r\n" response - end of list 68 | jp loaded_list 69 | @r_err: 70 | call uart_read 71 | cp 'R' 72 | jr nz, load_list 73 | 74 | call uart_read 75 | cp 'R' 76 | jr nz, load_list 77 | ;; "ERR" - looks too similar to ERROR 78 | jp err 79 | ;; Line format a bit more complex that we using. It looks like: 80 | ;; +CWLAP: (4, "name", -83, "c0:12:23:45:67....",2-7,0) 81 | ;; We looking only for "name" part. Starting search by first quot.mark 82 | load_ap: 83 | call uart_read 84 | cp '"' 85 | jr nz, load_ap 86 | ;; And show name until we meet quot. mark again 87 | load_name: 88 | call uart_read 89 | cp '"' 90 | jr z, loaded_name 91 | call putc 92 | jr load_name 93 | ;; Bang new line and space - it looks nice :) 94 | loaded_name: 95 | ld a, 13 96 | call putc 97 | ld a, 10 98 | call putc 99 | ld a, 32 100 | call putc 101 | jp load_list 102 | ;; Here we'll ask about selecting access point and entering password 103 | loaded_list: 104 | ld hl, txt_ssid 105 | call printZ 106 | ld hl, ssid 107 | ld bc, 80 108 | ld e, 1 109 | MOSCALL mos_editline 110 | cp 27 111 | jp z, abort 112 | 113 | ld hl, txt_pass 114 | call printZ 115 | ld hl, pass 116 | ld bc, 80 117 | ld e, 1 118 | MOSCALL mos_editline 119 | cp 27 120 | jp z, abort 121 | 122 | 123 | ;; AT+CWJAP="ssid","password"\r\n 124 | ld hl, cmd_cwjap 125 | call uart_writeZ 126 | 127 | ld hl, ssid 128 | call uart_writeZ 129 | 130 | ld hl, cmd_cwjap2 131 | call uart_writeZ 132 | 133 | ld hl, pass 134 | call uart_writeZ 135 | 136 | ld hl, cmd_cwjap3 137 | call uart_writeZ 138 | 139 | ld a, 13 140 | call putc 141 | connect: 142 | ;; We using ECHOed uart read to show connection stages on screen :) 143 | ;; Like "WIFI GOT IP" etc 144 | call echo_read 145 | 146 | cp 'O' 147 | jr z, @r_ok 148 | 149 | cp 'E' 150 | jr z, @r_err 151 | 152 | cp 'F' 153 | jr z, @r_fail 154 | 155 | jr connect 156 | @r_ok: 157 | call echo_read 158 | cp 'K' 159 | jr nz, connect 160 | 161 | call echo_read 162 | cp 13 163 | jr z, exit 164 | jr connect 165 | @r_err: 166 | call echo_read 167 | cp 'R' 168 | jr nz, connect 169 | 170 | call echo_read 171 | cp 'R' 172 | jr nz, connect 173 | jr err 174 | @r_fail: 175 | call echo_read 176 | cp 'A' 177 | jr nz, connect 178 | 179 | call echo_read 180 | cp 'I' 181 | jr nz, connect 182 | jr err 183 | 184 | abort: 185 | ld hl, @msg 186 | call printZ 187 | jr exit 188 | @msg: db 13,10,"Aborted", 13, 0 189 | 190 | ;; When all done - free UART and be nice :-) 191 | exit: 192 | ld a, 10 193 | call putc 194 | call esp_free 195 | 196 | ret 197 | err: 198 | ld hl, @err 199 | call printZ 200 | call esp_free 201 | ret 202 | @err: db 13,10, "Error happens on ESP's init stage",13,10,0 203 | 204 | ;; Just additional uart_read procedure for last step 205 | echo_read: 206 | call uart_read 207 | push af 208 | call putc 209 | pop af 210 | ret 211 | 212 | 213 | txt_ssid: db 13,10,"Enter SSID:",13,10,0 214 | txt_pass: db 13,10,"Enter password:",13,10,0 215 | txt_ap_list: db "SSIDs: ", 13, 10, 32, 0 216 | 217 | 218 | cmd_quit: db "AT+CWQAP", 0 219 | cmd_list: db "AT+CWLAP", 13, 10, 0 220 | cmd_cwjap: db "AT+CWJAP=\"",0 221 | cmd_cwjap2: db "\",\"",0 222 | cmd_cwjap3: db "\"",13,10,0 223 | 224 | 225 | ssid: ds 80 226 | pass: ds 80 227 | 228 | -------------------------------------------------------------------------------- /esp8266/netman/src/wifi.inc: -------------------------------------------------------------------------------- 1 | 2 | esp_init: 3 | call uart_init 4 | 5 | ld hl, @cmd_at 6 | call ok_err_cmd 7 | jp z, @esp_init_error 8 | 9 | ld hl, @cmd_e0 10 | call ok_err_cmd 11 | jp z, @esp_init_error 12 | 13 | ld hl, @cmd_mode 14 | call ok_err_cmd 15 | jp z, @esp_init_error 16 | 17 | ld hl, @cmd_auto 18 | call ok_err_cmd 19 | 20 | ld hl, @cmd_info 21 | call ok_err_cmd 22 | 23 | ld hl, @cmd_mux 24 | call ok_err_cmd 25 | 26 | ret 27 | @esp_init_error: 28 | xor a 29 | ret 30 | @cmd_at: db "AT",0 31 | @cmd_e0: db "ATE0",0 32 | @cmd_mode: db "AT+CWMODE_DEF=1",0 33 | @cmd_auto: db "AT+CWAUTOCONN=1",0 34 | @cmd_info: db "AT+CIPDINFO=0",0 35 | @cmd_mux: db "AT+CIPMUX=0",0 36 | 37 | esp_free: 38 | MOSCALL mos_uclose 39 | ret 40 | 41 | uart_init: 42 | ld ix, serial_config 43 | MOSCALL mos_uopen 44 | ret 45 | 46 | macro UART_WAIT byte, if_err 47 | call uart_read 48 | cp byte 49 | jp nz, if_err 50 | endmacro 51 | 52 | 53 | ; hl -> cmd 54 | ; a <- 1 ok(nz flag),0 err(z flag) 55 | ok_err_cmd: 56 | call uart_writeZ 57 | ld a, 13 58 | call uart_write 59 | ld a, 10 60 | call uart_write 61 | ok_err_loop: 62 | call uart_read 63 | 64 | cp 'O' 65 | jr z, r_ok 66 | 67 | cp 'E' 68 | jp z, r_err 69 | 70 | cp 'F' 71 | jp z, r_fail 72 | 73 | jr ok_err_loop 74 | 75 | r_ok: 76 | UART_WAIT 'K', ok_err_loop 77 | UART_WAIT 13, ok_err_loop 78 | 79 | ld a, 1 80 | or a 81 | ret 82 | 83 | r_err: 84 | UART_WAIT 'R', ok_err_loop 85 | UART_WAIT 'R', ok_err_loop 86 | UART_WAIT 'O', ok_err_loop 87 | UART_WAIT 'R', ok_err_loop 88 | UART_WAIT 13, ok_err_loop 89 | 90 | xor a 91 | ret 92 | r_fail: 93 | UART_WAIT 'A', ok_err_loop 94 | UART_WAIT 'I', ok_err_loop 95 | UART_WAIT 'L', ok_err_loop 96 | UART_WAIT 13, ok_err_loop 97 | 98 | xor a 99 | ret 100 | 101 | ; A - byte that was read 102 | uart_read: 103 | MOSCALL mos_ugetc 104 | ret 105 | 106 | ; HL - pointer to string 107 | uart_writeZ: 108 | ld a, (hl) 109 | and a 110 | ret z 111 | push hl 112 | call uart_write 113 | pop hl 114 | inc hl 115 | jr uart_writeZ 116 | 117 | ; A - byte to send 118 | uart_write: 119 | ld c, a 120 | MOSCALL mos_uputc 121 | ret 122 | 123 | 124 | serial_config: 125 | dl 115200 126 | db 8 ; data bits 127 | db 1 ; 1 stop bit 128 | db 0 ; parity 129 | db 0 ; flow control 130 | db 0 ; interrupts 131 | 132 | 133 | -------------------------------------------------------------------------------- /esp8266/snail/README.md: -------------------------------------------------------------------------------- 1 | # Project moved! 2 | 3 | Project was moved to sepparate [repository](https://github.com/nihirash/agon-snail). 4 | --------------------------------------------------------------------------------