2013-12-27 13:57:56 +00:00
|
|
|
.include "../inc/common.i"
|
|
|
|
.include "../inc/commonprint.i"
|
|
|
|
.include "../inc/net.i"
|
2013-12-19 21:04:19 +00:00
|
|
|
|
2013-12-27 13:57:56 +00:00
|
|
|
.import exit_to_basic
|
|
|
|
.import cfg_get_configuration_ptr
|
|
|
|
.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
|
|
|
|
|
|
|
|
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
|
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 --
|