コード例 #1
0
ファイル: aprsis.c プロジェクト: TaylanUB/aprsmap
void aprsis_set_filter_string(aprsis_ctx *ctx, char *filter) {
	// send a filter string, for more complex filters
	if (ctx->sockfd != -1) {
		char buf[64];
		snprintf(buf, sizeof(buf), "#filter %s\n", filter);
		g_message("Sending filter: %s", buf);
		aprsis_write(ctx, buf, strlen(buf));
	}
}
コード例 #2
0
ファイル: aprsis.c プロジェクト: TaylanUB/aprsmap
void aprsis_set_filter(aprsis_ctx *ctx, double latitude, double longitude, int radius) {
	// sets a filter given latitude, longitude and radius
	ctx->latitude = latitude;
	ctx->longitude = longitude;
	ctx->radius = radius;

	if (ctx->sockfd != -1) {
		char buf[64];
		snprintf(buf, sizeof(buf), "#filter r/%.0f/%.0f/%d\n", latitude, longitude, radius);
		g_message("Sending filter: %s", buf);
		aprsis_write(ctx, buf, strlen(buf));
	}
}
コード例 #3
0
ファイル: aprsis.c プロジェクト: TaylanUB/aprsmap
int aprsis_login(aprsis_ctx *ctx) {
	// wait for prompt, send filter message
	char buf[256];
	int n;


	// note that this doesn't *actually* check what the prompt is
	n = aprsis_read(ctx, buf, 256);
	if (n<0) {
		g_error("couldn't read from socket");
	}
	g_message("got: %s",buf);

	sprintf(buf, APRSIS_LOGIN"\n", ctx->user, ctx->pass);
	g_message("sending: %s", buf);
	aprsis_write(ctx, buf, strlen(buf));
	n = aprsis_read(ctx, buf, 256);
	if (n<0) {
		g_error("couldn't read from socket");
	}
	g_message("got: %s",buf);
	
	return 0;
}
コード例 #4
0
ファイル: aprsbeacon.c プロジェクト: gordonjcp/aprsbeacon
static gboolean gpsd_data_cb(GIOChannel *src, GIOCondition condition, gpointer data) {
	int ret;

	char pbuf[256];
	
	time_t     now;
    struct tm *ts;
    char       buf[80];

	ret = gps_read(&gpsdata);

	if (!isnan(gpsdata.fix.latitude)) {
        lat = gpsdata.fix.latitude;
        lon = gpsdata.fix.longitude;
	}
	if (!isnan(gpsdata.fix.speed)) speed=gpsdata.fix.speed*2.24;
	if (!isnan(gpsdata.fix.track)) track=gpsdata.fix.track;
	
	
	if ((beacon_time==0) || (secs_since_beacon<0)) {
		printf("init beacon time\n");
		beacon_time=gtime;
	}
	
	


    if(!isnan(gpsdata.fix.time)) gtime = gpsdata.fix.time;



	if (gtime>next_time) {
		printf("3 min point\n");
		next_time = gtime+180;
	}
#if 0
printf("\n===============================================\n");	
printf("ssb: %f\ntime until beacon: %f\nbeacon_rate: %f\n", secs_since_beacon, beacon_rate-secs_since_beacon, beacon_rate);
printf("track: %f\noldtrack: %f\n", track, old_track);
printf("hcsb: %f\ntt: %f\nmtt: %f\n", hcsb, turn_threshold, min_turn_time);
#endif 

	// calculate smart beacon
	secs_since_beacon = gtime-beacon_time;
	if (speed < slow_speed) {
		//printf("low speed = %f\n", speed);
		beacon_rate = slow_rate;
	} else {
		if (speed > high_speed) {
			//printf("high speed = %f\n", speed);
			beacon_rate = fast_rate;
		} else {
			beacon_rate = fast_rate * high_speed/speed;
		}
		if (old_track == -1) old_track = track;
		hcsb = fabs(track - old_track);
		if (hcsb > 180) hcsb = 360 - hcsb;
		turn_threshold = min_turn_angle + turn_slope / speed;
		if (hcsb > turn_threshold && secs_since_beacon > min_turn_time) {
			secs_since_beacon = beacon_rate;
		}
	
	}
	if (secs_since_beacon >= beacon_rate) {
		//printf("***************************************** BEACON\n");
        printf("smart beacon\n");
        
    	now = (time_t) gtime;
    	ts = gmtime(&now);
        strftime(buf, sizeof(buf), "%d%H%Mz", ts);
//	char buf[256]="MM0YEQ-11>APZGJC:@112149z5551.30N/00430.60W$118/032/moving\r\n";
        float latmin, lonmin;
        latmin = (lat - trunc(lat))*60;
        lonmin = -(lon - trunc(lon))*60;
        
        printf("%f %f\n", lat, lon);
        sprintf(pbuf, "MM0YEQ-10>APZGJC:@%s%02.0f%05.2fN/%03.0f%05.2fW$%03.0f/%03.0f/message\n", buf, trunc(lat),latmin,-trunc(lon),lonmin, track, speed);
       if(&ctx !=0) {
            printf("sending\n");
       	aprsis_write(&ctx, pbuf, strlen(pbuf));
       	}
	printf("pbuf=%s\n", pbuf);
    	beacon_time = gtime;
    	old_track=track;
	}
	
	
	return TRUE;
	
}