whitespace and function reordering

main
Daniel Barlow 2022-09-16 21:59:34 +01:00
parent 5f71c2158f
commit d795d5a4a1
1 changed files with 8 additions and 11 deletions

19
sms.fnl
View File

@ -54,6 +54,9 @@
(expect fd pattern fail-pattern))
nil)))
(fn command [fd s]
(tx fd (.. s "\r\n"))
(expect fd "OK" "ERROR"))
(fn even? [x]
@ -66,13 +69,11 @@
(test= (phone-number->hex "85291234567") "5892214365F7")
(test= (phone-number->hex "447785016005") "447758100650")
(fn mask [start end]
(let [width (+ 1 (- end start))]
(lshift (rshift 0xff (- 8 width)) start)))
(fn bit-range [i start end]
(rshift (band i (mask start end)) start))
(let [width (+ 1 (- end start))
mask (lshift (rshift 0xff (- 8 width)) start)]
(rshift (band i mask) start)))
(fn septets->hex [body]
;; 0 body0[0-6] | body1[0] << 7
@ -92,7 +93,7 @@
;; nth byte is bits n..6 of nth septet,
;; and bits 0..n of(n+1)th septet
;; for n>=7,
;; for all n including n>=7,
;; bits n%7..6 of floor(n+ (n/7))th septet
;; and 0..(n%7) of the next one
@ -138,10 +139,6 @@
(test= (message->pdu "85291234567" "It is easy to send text messages.") "01000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E")
(fn command [fd s]
(tx fd (.. s "\r\n"))
(expect fd "OK" "ERROR"))
(fn send-message [{: fd} number body]
(let [pdu (message->pdu number (unicode->gsm body))
payload (.. "00" pdu)]
@ -163,7 +160,7 @@
(bnot ISIG)))
(tset termios :oflag (band termios.oflag ( bnot OPOST)))
(doto fd
(tcsetattr 0 termios)
(tcsetattr 0 termios)
(tcdrain)
(command "AT") ; hello ?