summaryrefslogtreecommitdiff
path: root/ebus-racket/inserter.rkt
diff options
context:
space:
mode:
Diffstat (limited to 'ebus-racket/inserter.rkt')
-rwxr-xr-xebus-racket/inserter.rkt29
1 files changed, 16 insertions, 13 deletions
diff --git a/ebus-racket/inserter.rkt b/ebus-racket/inserter.rkt
index d72d2ea..b234ad9 100755
--- a/ebus-racket/inserter.rkt
+++ b/ebus-racket/inserter.rkt
@@ -19,19 +19,22 @@
;; Send field and value to database server
(define (insert-field sensor-name datatype value)
- (define url (format "~a/~a" (baseurl?) sensor-name))
- (define raw-value
- (cond ((member datatype '(data1c data2b data2c)) (real->decimal-string value))
- ((member datatype '(bit byte data1b word bcd)) (format "~s" value))
- ((member datatype '(byteEnum)) value)
- (else (error 'invalid-datatype))))
- (define input-port (put-impure-port (string->url url) (string->bytes/utf-8 raw-value)))
- (define server-response (read-line input-port))
- (close-input-port input-port)
- (cond ((string=? (list-ref (string-split server-response) 1) "200")
- (log-inserter-info "OK: ~a : ~a" url raw-value))
- (else
- (error "server-error" url raw-value server-response))))
+ (if (layer7-ersatzwert? value)
+ (log-inserter-info "Skipping Ersatzwert for ~a/~a" sensor-name datatype)
+ (let ()
+ (define url (format "~a/~a" (baseurl?) sensor-name))
+ (define raw-value
+ (cond ((member datatype '(data1c data2b data2c)) (real->decimal-string value))
+ ((member datatype '(bit byte data1b word bcd)) (format "~s" value))
+ ((member datatype '(byteEnum)) value)
+ (else (error 'invalid-datatype))))
+ (define input-port (put-impure-port (string->url url) (string->bytes/utf-8 raw-value)))
+ (define server-response (read-line input-port))
+ (close-input-port input-port)
+ (cond ((string=? (list-ref (string-split server-response) 1) "200")
+ (log-inserter-info "OK: ~a : ~a" url raw-value))
+ (else
+ (error "server-error" url raw-value server-response))))))
(define (handle-packet packet)
(for ([field packet])