2018-02-23 15:36:05 +00:00
|
|
|
.include "../inc/common.inc"
|
|
|
|
.include "../inc/commonprint.inc"
|
|
|
|
.include "../inc/net.inc"
|
2013-12-19 21:04:19 +00:00
|
|
|
|
2015-08-28 13:19:52 +00:00
|
|
|
.export start
|
|
|
|
|
2013-12-27 13:57:56 +00:00
|
|
|
.import exit_to_basic
|
2015-08-28 13:19:52 +00:00
|
|
|
|
2013-12-27 13:57:56 +00:00
|
|
|
.import dns_set_hostname
|
|
|
|
.import dns_resolve
|
|
|
|
.import dns_ip
|
|
|
|
.import dns_status
|
|
|
|
.import sntp_ip
|
|
|
|
.import sntp_utc_timestamp
|
|
|
|
.import sntp_get_time
|
2013-12-19 21:04:19 +00:00
|
|
|
|
|
|
|
|
2014-04-28 16:41:54 +00:00
|
|
|
; keep LD65 happy
|
2016-03-30 14:06:45 +00:00
|
|
|
.segment "INIT"
|
|
|
|
.segment "ONCE"
|
2014-04-28 16:41:54 +00:00
|
|
|
|
|
|
|
|
2013-12-27 13:57:56 +00:00
|
|
|
.segment "STARTUP"
|
2013-12-19 21:04:19 +00:00
|
|
|
|
2013-12-13 21:24:03 +00:00
|
|
|
lda #14
|
2013-12-27 13:57:56 +00:00
|
|
|
jsr print_a ; switch to lower case
|
2015-08-28 13:19:52 +00:00
|
|
|
|
|
|
|
start:
|
2013-12-13 21:24:03 +00:00
|
|
|
jsr print_cr
|
2013-12-27 13:57:56 +00:00
|
|
|
init_ip_via_dhcp
|
2013-12-13 21:24:03 +00:00
|
|
|
jsr print_ip_config
|
2013-12-19 21:04:19 +00:00
|
|
|
|
2013-12-13 21:24:03 +00:00
|
|
|
ldax #time_server_msg
|
2013-12-27 13:57:56 +00:00
|
|
|
jsr print
|
|
|
|
ldax #time_server_host
|
|
|
|
jsr print
|
2013-12-13 21:24:03 +00:00
|
|
|
jsr print_cr
|
2013-12-27 13:57:56 +00:00
|
|
|
ldax #time_server_host
|
2013-12-13 21:24:03 +00:00
|
|
|
jsr dns_set_hostname
|
|
|
|
bcs @dns_error
|
|
|
|
jsr dns_resolve
|
|
|
|
bcs @dns_error
|
2013-12-27 13:57:56 +00:00
|
|
|
ldx #3 ; set destination address
|
2013-12-13 21:24:03 +00:00
|
|
|
: lda dns_ip,x
|
2013-12-19 21:04:19 +00:00
|
|
|
sta sntp_ip,x
|
|
|
|
dex
|
|
|
|
bpl :-
|
|
|
|
|
2013-12-13 21:24:03 +00:00
|
|
|
ldax #sending_query
|
|
|
|
jsr print
|
|
|
|
ldax #sntp_ip
|
|
|
|
jsr print_dotted_quad
|
|
|
|
jsr print_cr
|
|
|
|
jsr sntp_get_time
|
|
|
|
bcc @ok
|
|
|
|
ldax #sntp_error
|
|
|
|
jmp @print_error
|
|
|
|
@ok:
|
|
|
|
ldy #3
|
2013-12-27 13:57:56 +00:00
|
|
|
: lda sntp_utc_timestamp,y
|
2013-12-13 21:24:03 +00:00
|
|
|
jsr print_hex
|
|
|
|
dey
|
|
|
|
bpl :-
|
|
|
|
jmp exit_to_basic
|
|
|
|
|
2013-12-19 21:04:19 +00:00
|
|
|
@dns_error:
|
2013-12-13 21:24:03 +00:00
|
|
|
ldax #dns_error
|
2013-12-19 21:04:19 +00:00
|
|
|
@print_error:
|
2013-12-13 21:24:03 +00:00
|
|
|
jsr print
|
|
|
|
jsr print_errorcode
|
|
|
|
jmp exit_to_basic
|
|
|
|
|
|
|
|
|
2013-12-19 21:04:19 +00:00
|
|
|
.data
|
2013-12-13 21:24:03 +00:00
|
|
|
|
|
|
|
time_server_msg:
|
|
|
|
.byte "TIME SERVER : ",0
|
|
|
|
|
|
|
|
time_server_host:
|
|
|
|
.byte "jamtronix.com",0
|
2013-12-27 13:57:56 +00:00
|
|
|
; .byte "150.101.112.134",0
|
2013-12-13 21:24:03 +00:00
|
|
|
.byte "0.POOL.SNTP.ORG",0
|
2013-12-19 21:04:19 +00:00
|
|
|
|
2013-12-13 21:24:03 +00:00
|
|
|
sending_query:
|
2013-12-27 13:57:56 +00:00
|
|
|
.byte "SENDING SNTP QUERY TO ",0
|
2013-12-13 21:24:03 +00:00
|
|
|
sntp_error:
|
|
|
|
.byte "ERROR DURING SNTP QUERY",13,0
|
|
|
|
dns_error:
|
|
|
|
.byte "ERROR RESOLVING HOSTNAME",13,0
|
2013-12-19 21:04:19 +00:00
|
|
|
|
2013-12-13 21:24:03 +00:00
|
|
|
divs:
|
|
|
|
.byte $02,$30,$00,$00
|
|
|
|
.byte $05,$00,$00,$00
|
2013-12-19 21:04:19 +00:00
|
|
|
|
2013-12-13 21:24:03 +00:00
|
|
|
|
|
|
|
|
2014-04-13 16:36:04 +00:00
|
|
|
; -- LICENSE FOR sntp.s --
|
2013-12-13 21:24:03 +00:00
|
|
|
; The contents of this file are subject to the Mozilla Public License
|
|
|
|
; Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
; compliance with the License. You may obtain a copy of the License at
|
|
|
|
; http://www.mozilla.org/MPL/
|
2013-12-27 13:57:56 +00:00
|
|
|
;
|
2013-12-13 21:24:03 +00:00
|
|
|
; Software distributed under the License is distributed on an "AS IS"
|
|
|
|
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
; License for the specific language governing rights and limitations
|
|
|
|
; under the License.
|
2013-12-27 13:57:56 +00:00
|
|
|
;
|
2013-12-13 21:24:03 +00:00
|
|
|
; The Original Code is ip65.
|
2013-12-27 13:57:56 +00:00
|
|
|
;
|
2013-12-13 21:24:03 +00:00
|
|
|
; The Initial Developer of the Original Code is Jonno Downes,
|
|
|
|
; jonno@jamtronix.com.
|
|
|
|
; Portions created by the Initial Developer are Copyright (C) 2009
|
2013-12-27 13:57:56 +00:00
|
|
|
; Jonno Downes. All Rights Reserved.
|
2013-12-13 21:24:03 +00:00
|
|
|
; -- LICENSE END --
|