I’m trying to view the data I am sending over the Sofar API (using tutorial 5’s instructions). I am getting the following error when attempting to view the “{“message”:“Authorization failed”}”
I believe I am using the correct account and the spotter should be registered to it. I also have checked the GO LED and it is red, so I have been using the raw-messages endpoint.
I also attempted to re generate a token but ran into the same issue.
Current bit offset: 230
Rounded bit offset: 232
New bit offset: 352
1804717t [MS] [INFO] Added message(id: 0 len: 44) to queue MS_Q_LEGACY: (1)!
Message: DE 00 00 00 00 DA 00 B0 12 00 6E D8 00 06 D4 00 00 91 B5 5F A5 B7 D1 84 CE 4B 28 D7 8C 48 65 6C 6C 6F 2C 20 53 70 6F 74 74 65 72 21
1804719t [BM_TX] [INFO] Submitted spotter/transmit-data message to sat/cell queue, Len: 16
1804719t [BM_TX] [DEBUG] Message:
48 65 6c 6c 6f 2c 20 53
70 6f 74 74 65 72 21
1804721t [ERR] [INFO] Cellular SignalErrorState changed from N/A to CONNECTING
1804721t [MS] [DEBUG] Sending legacy messages to Notecard.
1804758t [MS] [DEBUG] Notecard is 6.000000 pct full.
1804759t [MS] [INFO] Queuing message 0 20004558
1805109t [MS] [DEBUG] Attempting to Sync.
1805144t [MS] [DEBUG] Waiting for TX
1830435t [MS] [DEBUG] Notecard is 6.000000 pct full.
1830436t [MS] [INFO] All messages sent successfully!
1830436t [MS] [DEBUG] Checking for Rx Messages
1830476t [ERR] [INFO] Cellular SignalErrorState changed from CONNECTING to OK
Can you confirm that this is what I should expect when sending data from a sensor?
Good to know that I’m almost done with the tutorials. My goal is to integrate an off the shelf temp sensor and send data to the cloud. I think I should be able to figure out the firmware/device side of things, but am having some difficulty with viewing the data online! Sounds like I’m close…
I see 5 messages at the raw-messages endpoint for SPOT-31420C, using my own token. Those message are all stamped 2024-01-09, UTC.
Regarding the API tokens for the account which owns this Spotter/DevKit: I see a token was invalidated also on 2024-01-09. That one ended in 524. There is a new token available, which can be seen in the Spotter dashboard. When I use that token, I also see 5 messages at the raw-messages endpoint.
Here is a basic Unix shell script which can serve as an example. Note, it requires that the jq tool be in the PATH somewhere. This script is not guaranteed to work on Windows, as Windows default curl uses different syntax from Unix curl.
This script as-is expects there to be a file named sofar_api.env in the user’s HOME directory (~). This file is structured as follows:
WF_API_TOKEN=your_token_here
You can bypass this requirement by just replacing the token="$(...)" line in the script below with your actual token, a’la token=my_token_here.
#!/bin/bash
# pull & display raw messages from the raw messages API
# timjoh 2023-09-07
usage () {
echo "$(basename $0) [spotid]"
}
token="$(awk -F= '/WF_API_TOKEN/ { print $2 }' $HOME/sofar_api.env)"
case $# in
1) spotid=$1;;
*) usage; exit 1;
esac
echo "++ pulling messages for ${spotid}"
startDate="2023-07-01"
with_token() {
# note, startDate is unused here
url="https://api.sofarocean.com/api/raw-messages?token=${token}&spotterId=${spotid}"
curl -H "token: ${token}" "${url}" | jq .
}
with_token
Note: that script places the token both in the header of the HTTPS request, as well as in the query parameters in the URL. I believe you can choose to use either/or.
Thanks for this followup. I am confirming that I am using the latest token assigned to my account (ending in 5c19). Both the URL and script you provided (using said token) are returning 0 messages.
bash get_data.sh SPOT-31420C
++ pulling messages for SPOT-31420C
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 250 100 250 0 0 534 0 --:--:-- --:--:-- --:--:-- 536
{
"status": "success",
"data": {
"spotterId": "SPOT-31420C",
"messages": []
},
"metadata": {
"page": {
"nextPage": "https://api.sofarocean.com/api/raw-messages?cursor=eyJzcG90dGVySWQiOiJTUE9ULTMxNDIwQyIsImN1cnNvcklkIjowfQ%3D%3D",
"hasMoreData": false,
"pageSize": 20
}
}
}
Is this an issue with my account? I had an account while I worked at sofar that used the username: fiestapinguino (tied to my sofar email). I had to create a new account waltermunksalbatross (tied to aadu@uw.edu). Let me know if I goofed something up and activated the Spotter from the wrong account.
Hi Aadu — I think this is actually good progress. You have access to the device, but there are no messages available after the default startDate (I’m researching exactly how this works).
Try changing the script so there is a startDate, like:
The messages I see pasted above are a Spotter configuration message (header DC) (which is not shared over normal customer-accessible API endpoints) and a cellular HDR message (F3). I would not expect either of those to show up in the Bristlemouth API.
For normal Spotter API data endpoints, please see docs.sofarocean.com. Please note, the documentation often requires one to click the “>” symbols to expand various sections.
I will reiterate that the purpose of the raw-messages endpoint is to make available those Bristlemouth data packets which are transmitted during indoor testing, when GPS is unlikely to be available. I assume that the Bristlemouth API Explorer site uses official Sofar API endpoints, so messages will only be available there if those messages were transmitted while Spotter had a solid GPS signal.
You can acquire valid GPS reception by transmitting the messages while the Spotter is outdoors, with a clear view of sky/horizon, as close to 360° as possible.
I have confirmed that the /raw-messages endpoint will only show the last ~day or so of data if no startDate is supplied. It defaults to a startDate of (today - 1 day).
Hi @peterive — can you tell us whether the Bristlemouth Explorer supports the /raw-messages API endpoint, to retrieve messages that are missing valid GPS locations? Thanks