Merge pull request #12 from alanbjohnston/satnogs-upload

Satnogs upload
pull/18/head
alanbjohnston 7 years ago committed by GitHub
commit dfa2252e44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -57,7 +57,7 @@ radiocw: cw/cw_main.o
radiocw: afsk/ax25.o
radiocw: afsk/ax5043.o
radiocw: afsk/send_afsk.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radiocw -L./ afsk/ax25.o afsk/ax5043.o afsk/send_afsk.o cw/cw_main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o radiocw -L./ afsk/ax25.o afsk/ax5043.o afsk/send_afsk.o cw/cw_main.o -lwiringPi -lax5043 -lcurl
radiopiglatin: libax5043.a
radiopiglatin: piglatin/piglatin_main.o
@ -69,21 +69,21 @@ testax5043tx: transmit/transmit_main.o
testax5043rx: libax5043.a
testax5043rx: receive/receive_main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043rx -pedantic -Wall -Wextra -L./ receive/receive_main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043rx -pedantic -Wall -Wextra -L./ receive/receive_main.o -lwiringPi -lax5043 -lcurl
testax5043init: libax5043.a
testax5043init: init/init_main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043init -pedantic -Wall -Wextra -L./ init/init_main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax5043init -pedantic -Wall -Wextra -L./ init/init_main.o -lwiringPi -lax5043 -lcurl
testax50432freq: libax5043.a
testax50432freq: transmit2freq/transmit2freq_main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax50432freq -pedantic -Wall -Wextra -L./ transmit2freq/transmit2freq_main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testax50432freq -pedantic -Wall -Wextra -L./ transmit2freq/transmit2freq_main.o -lwiringPi -lax5043 -lcurl
testafsktx: libax5043.a
testafsktx: afsktx/ax25.o
testafsktx: afsktx/ax5043.o
testafsktx: afsktx/main.o
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testafsktx -pedantic -Wall -Wextra -L./ afsktx/ax25.o afsktx/ax5043.o afsktx/main.o -lwiringPi -lax5043
gcc -std=gnu99 $(DEBUG_BEHAVIOR) -o testafsktx -pedantic -Wall -Wextra -L./ afsktx/ax25.o afsktx/ax5043.o afsktx/main.o -lwiringPi -lax5043 -lcurl
radioafsk: libax5043.a
radioafsk: afsk/ax25.o
@ -92,8 +92,7 @@ radioafsk: afsk/main.o
radioafsk: afsk/ina219.h
radioafsk: Adafruit_INA219/Adafruit_INA219.o
radioafsk: Adafruit_INA219/Adafruit_INA219.h
gcc $(DEBUG_BEHAVIOR) -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o Adafruit_INA219/Adafruit_INA219.o -lwiringPi -lax5043
gcc $(DEBUG_BEHAVIOR) -o radioafsk -pedantic -Wall -Wextra -L./ afsk/ax25.o afsk/ax5043.o afsk/main.o Adafruit_INA219/Adafruit_INA219.o -lwiringPi -lax5043 -lcurl
Adafruit_INA219/Adafruit_INA219.o: Adafruit_INA219/Adafruit_INA219.c
Adafruit_INA219/Adafruit_INA219.o: Adafruit_INA219/Adafruit_INA219.h

@ -18,8 +18,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <curl/curl.h>
#include "ax25.h"
#include <string.h>
#include <time.h>
#include <stdio.h>
#include "ax5043.h"
#include "status.h"
@ -88,6 +91,58 @@ int ax25_tx_frame(ax25_conf_t *hax25, ax5043_conf_t *hax,
memcpy(__tx_buffer, hax25->addr_field, hax25->addr_field_len);
memcpy(__tx_buffer + hax25->addr_field_len, payload, len);
printf("\n");
char post_data[1024];
char hex_data[512];
char hex_octet[4];
time_t t = time(NULL);
struct tm tm = *localtime(&t);
memset(post_data,0,strlen(post_data));
memset(hex_data,0,strlen(hex_data));
//printf("1:%s\n",post_data);
int jj;
for(jj = 0; jj < 118; jj++) {
sprintf(hex_octet, "%02x",__tx_buffer[jj]);
strcat(hex_data, hex_octet);
}
//memset(post_data,0,strlen(post_data));
//printf("2:%s\n",post_data);
//sprintf(post_data,"curl --data \"noradID=99999&source=KU2Y&timestamp=%d-%d-%dT%d:%d:%d.500Z&frame=%s&locator=longLat&longitude=75.3492W&latitude=40.0376N&&azimuth=360&elevation=90.0\" https://db.satnogs.org/api/telemetry/", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour + 4, tm.tm_min, tm.tm_sec, hex_data);
sprintf(post_data,"noradID=99999&source=KU2Y&timestamp=%d-%d-%dT%d:%d:%d.500Z&frame=%s&locator=longLat&longitude=75.3492W&latitude=40.0376N&&azimuth=360&elevation=90.0", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, (tm.tm_hour + 4) % 24, tm.tm_min, tm.tm_sec, hex_data);
//printf("%s&locator=longLat&longitude=75.3492W&latitude=40.0376N&&azimuth=360&elevation=90.0\" https://db.satnogs.org/api/telemetry/\n\n", hex_data);
printf("curl post data: %s\n",post_data);
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
//curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_setopt(curl, CURLOPT_URL, "https://db.satnogs.org/api/telemetry/");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_data);
/* if we don't provide POSTFIELDSIZE, libcurl will strlen() by
itself */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(post_data));
/* example.com is redirected, so we tell libcurl to follow redirection */
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
}
return ax5043_tx_frame(hax, __tx_buffer, len + hax25->addr_field_len,
hax25->preamble_len, hax25->postable_len, 1000);

Loading…
Cancel
Save

Powered by TurnKey Linux.