예제 #1
0
파일: test.c 프로젝트: gherlein/libcf2
int main(void)
{

	openRadio();
	printf("success\n");

	uint8_t header;
	CRTPPacket p;
	CRTPPacket* r;
	uint8_t port=0;
	uint8_t channel=0;

	int x;

	x=scanChannels();


	x=getNumberOfMems();
	

/*
	for(int x=0;x<1;x++)
	{
		x=sendCommander(0.0,0.0,0.0,15000);
		sleep(1);
	}

	sleep(15);
*/
	closeRadio();
	return 0;
}
예제 #2
0
int sendString(uint32_t Time, double latitude, double longitude, double altitude, double intTemp, double exTemp, int satalites, int pressure, int geigerCount, short UV){

	openRadio();

	char* string;
	int len;
	uint16_t checksum;
	char* packet;
	int packetSize = 0;

	packetID++;

	const char* format = "ZN1,%i,%i,%F,%F,%.1f,%i,%.1f,%.3f,%i,%i,%i";

       len = snprintf(NULL, 0, format, packetID, Time, latitude, longitude, altitude, satalites, intTemp, exTemp, pressure, geigerCount, UV) + 1;

	if (!(string = malloc((len + 1) * sizeof(char))))
            return 0;

	snprintf(string, len, format, packetID, Time, latitude, longitude, altitude, satalites, intTemp, exTemp, pressure, geigerCount, UV);

	checksum = getCRC16Checksum(string);

	packetSize = len+8;

	if (!(packet = malloc((packetSize + 1) * sizeof(char))))
            return 0;

	len = snprintf(packet, packetSize, "$$%s*%04X\n", string, checksum);

	printf(packet);

	write(radio, packet, len);

	free(string);
	free(packet);

	//printf("L: %i", strlen(string));
}