diff --git a/afsk/ax25.c b/afsk/ax25.c index 66588ed4..8b42ca90 100644 --- a/afsk/ax25.c +++ b/afsk/ax25.c @@ -93,15 +93,28 @@ int ax25_tx_frame(ax25_conf_t *hax25, ax5043_conf_t *hax, memcpy(__tx_buffer + hax25->addr_field_len, payload, len); printf("\n"); + + char post_data[512]; + char hex_data[118]; + 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); - printf("curl --data \"noradID=99999&source=KU2Y×tamp=%d-%d-%dT%d:%d:%d.500Z&frame=", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour + 4, tm.tm_min, tm.tm_sec); int jj; for(jj = 0; jj < 118; jj++) { - printf("%02x",__tx_buffer[jj]); + sprintf(hex_octet, "%02x",__tx_buffer[jj]); + strcat(hex_data, hex_octet); } - printf("&locator=longLat&longitude=75.3492W&latitude=40.0376N&&azimuth=360&elevation=90.0\" https://db.satnogs.org/api/telemetry/\n\n"); + memset(post_data,0,strlen(post_data)); + printf("2:%s\n",post_data); + + //sprintf(post_data,"curl --data \"noradID=99999&source=KU2Y×tamp=%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×tamp=%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, 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("3:%s\n",post_data); CURL *curl; CURLcode res; @@ -110,6 +123,12 @@ int ax25_tx_frame(ax25_conf_t *hax25, ax5043_conf_t *hax, 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);