Protocol Documentation

@jlewallen Is there some documentation on the protocol to access the hardware using network sockets? I could dig around in the github codes but it may be quicker if I could have a few pointers on where to look!

@shashikiran.ganesh

1 Like

Hey there!

Unfortunately, documentation isn’t something I’ve got a lot of bandwidth for but I can definitely help to point out some resources for anybody feeling adventurous.

FieldKit uses Google’s Protocol Buffers to encode/decode to define the structure of its various messages and saved data.

GitHub - fieldkit/app-protocol: protocol buffers for hardware communications, primarily used by the mobile app. This repository contains the schema for communicating with the stations over WiFi. Stations create a web server that has various endpoints. It’s a good resource for seeing the kinds of things you can ask of stations, as well as the source code for the HTTP routing itself on the stations:

GitHub - fieldkit/fkc This is a golang client that can be run on a desktop and used to communicate with stations. Querying status, live readings, etc… You can also use curl to download data off of them.

GitHub - fieldkit/data-protocol: protocol buffers for stored/logged data and information. This repository contains the schema for persisted data. Any data you download off the device will have these messages.

I hope this is enough to get started!

Jacob

1 Like

Thanks @jlewallen
This is good to start with. I’ll post here if any further queries.

Regards,
Shashi

fkc worked well. I could get the live readings. Now, I have to work out a shell script to read the weather parameters.

I could read the binary data file directly using http:///fk/v1/download/data but have to understand the format.

Looks like a good start though!
Thanks,
Shashi

Hi,
I worked out the following script to run as a cron job on a raspberry pi. It appends readings to a file in the format:
YYYYMMDD HH:mm:ss humidity temp1 pressure rain windspeed wind_dir

I had initially connected the FieldKit station to my desktop via my home wifi router. Seemed to be working fine except that it would lose connection once in a while. After making the FK as an AP and using a raspberry pi to access the data it is better.


#!/bin/bash
. /home/pi/.bashrc

/usr/local/bin/fkc --address 192.168.2.1 -get 2>&1 > /dev/null | awk -v d="date '+%Y%m%d%H%M%S'" ‘BEGIN{print d," \n { \n"}{if (NR > 5) print $0}END{print “\r\n”}’ | awk ‘{if (NR > 1) print $0}’ | jq ‘.liveReadings[0].modules[1].readings[0,1,2,4,5,6].value’ | tr -s ‘\n’ ‘\t’ |awk -v d="date '+%Y%m%d %H:%M:%S'" ‘{print d,$0}’ >> /home/pi/Instruments/FieldKit/sensor_data_fk.log


Planning to take the setup to our observatory now for deployment. Fingers crossed that I wouldn’t have issues there.
Thanks,
Shashi

1 Like

Very cool! Please report back if you are able.

Hi,

Since last few days my station is not responding to the fkc commands. I had someone remotely restart the system but the problem persists.

pi@raspberrypi:~ $ fkc -address 192.168.2.1 -status
2021/12/29 15:07:21 Sending: {
  "type": 18,
  "time": 1640770641
}
[33 68 79 67 84 89 80 69 32 104 116 109 108 32 80 85 66 76 73 67 32 34 45 47 47 87 51 67 47 47 68 84 68 32 72 84 77 76 32 52 46 48 49 47 47 69 78 34 32 34 104 116 116 112 58 47 47 119 119 119]
2021/12/29 15:08:21 error: proto: cannot parse invalid wire-format data
pi@raspberrypi:~ $ 

I am able to connect to the system on HTTP://192.168.2.1/ and am connected to the station with the station as the access-point. I would be able to connect to the system via mobile app only sometime next month when I plan to visit the observatory. Till then any debugging would have to be via remote communication. Any suggestions @jlewallen @Sara ?

Season’s greetings and happy holidays!
Shashi

Hello Shashi!

Do you have an SD card in your station? If so, can you please send the contents of the card in a zip file to me?

Thank you and happiest holidays!

Sara

1 Like