-
Notifications
You must be signed in to change notification settings - Fork 86
rupi client
Chris Petersen edited this page Oct 16, 2014
·
1 revision
rupi-client creates a rupi client instance.
Parameter | Description |
---|---|
keyidx | Encryption key index. Generally 0, unless connecting to two rupi servers simultaneously |
key | the u8vector encryption key used to communicate with the rupi server. (u8vector-length 8 or a multiple thereof < 64 preferred) |
addr | Hostname for the rupi server instance |
port | Port number of the rupi server instance |
Example 1: Make a rupi server and a client connecting to it to get some data. This example assumes that your console application has store and rupi in its MODULES file as well as libcrypto in its LIBRARIES file.
> (define rupi:key (string->u8vector "Lambda13"))
> (define rupi:port 8013)
> (define rupi:hostname "localhost")
> (define rupi:addr
(with-exception-catcher
(lambda (e) #f)
(lambda () (car(host-info-addresses (host-info rupi:hostname))))
)
)
;; Start a RUPI server with store, key-index key, IP, port and function to parse messages
> (define store (make-store "main"))
> (store-set! store "platform" "LambdaNative")
> (define (upi-cmd store cmd . arglist)
(let ((arg (if (fx>= (length arglist) 1) (car arglist) #f))
(arg2 (if (fx>= (length arglist) 2) (cadr arglist) #f)))
(cond
((string=? cmd "GETVALUE") (store-ref store arg))
((string=? cmd "SETVALUE") (store-set! store arg arg2))
(else
(log-error "RUPICMD: " cmd arg arg2)
"Invalid command"
)
)
))
> (define rs (rupi-server "main" 0 rupi:key rupi:addr rupi:port upi-cmd))
;; Make a rupi client, connect to the server and ask for some data
> (define rc (rupi-client 0 rupi:key rupi:addr rupi:port))
> (rupi-cmd rc "GETVALUE" "platform")
"LambdaNative"
> (rupi-cmd rc "GETVALUE" "version")
#f
> (rupi-cmd rc "SETVALUE" "version" 20130805)
#t
> (rupi-cmd rc "GETVALUE" "version")
20130805
> (rupi-cmd rc "SOMETHINGELSE")
"Invalid command"
-
- accelerometer
- alist
- audio
- audioaux
- base64
- btle-scan
- camera
- cdb
- cgi
- config
- csv
- curl
- digest
- dmtx
- download
- eventloop
- fcgi
- fft
- generalized-arrays
- gps
- graph
- gyro
- hidapi
- hpdf
- html
- httpsclient
- hybridapp
- json
- lmdb
- ln_core
- ln_glcore
- ln_glgui
- ln_store
- localization
- localization_gui
- localnotification
- magnetometer
- mdns
- mqtt
- mqtt-store
- multitouch
- oauth
- orientation
- p256ecdsa
- png
- portaudio
- pregexp
- pressure
- prime
- pushnotification
- redcap
- rsa
- rtaudio
- rupi
- rotation
- sanestring
- scheduler
- serial
- sets
- settings
- simplexnoise
- sqlite
- ssax
- syntax-case
- timestamp
- ttf
- uiform
- url
- uuid
- vibrate
- videoplayer
- watchdog
- website
- xml
- zip