示例#1
0
static ll_compare_result_t
smcp_timer_compare_func(
	const void* lhs_, const void* rhs_, void* context
) {
	const smcp_timer_t lhs = (smcp_timer_t)lhs_;
	const smcp_timer_t rhs = (smcp_timer_t)rhs_;
	smcp_cms_t x = smcp_plat_timestamp_diff(lhs->fire_date, rhs->fire_date);

	if(x > 0) {
		return 1;
	}

	if(x < 0) {
		return -1;
	}

	return 0;
}
示例#2
0
void
dump_test_results(const test_data_s *test_data) {
	printf("\tURL: %s\n",test_data->url);
	if(test_data->inbound_code)
		printf("\tinbound_code: %s (%d)\n", coap_code_to_cstr(test_data->inbound_code), COAP_TO_HTTP_CODE(test_data->inbound_code));

	if(test_data->error || test_data->failed) {
		if(test_data->error)
			printf("\terror: %s (%d)\n", smcp_status_to_cstr(test_data->error), test_data->error);
	}
	{
		smcp_cms_t duration = smcp_plat_timestamp_diff(test_data->stop_time,test_data->start_time);
		printf("\tduration: %dms\n", (int)duration);

	}
	if(test_data->has_block1_option) {
		struct coap_block_info_s block_info;
		coap_decode_block(&block_info, test_data->block1_option);
		printf("\tblock1: %d/%d/%d\n", block_info.block_offset,block_info.block_m,block_info.block_size);
	}
	if(test_data->has_block2_option) {
		struct coap_block_info_s block_info;
		coap_decode_block(&block_info, test_data->block2_option);
		printf("\tblock2: %d/%d/%d\n", block_info.block_offset,block_info.block_m,block_info.block_size);
	}
	printf("\tlast_msg_id: 0x%04X\n", (int)test_data->msg_id);
	printf("\tinbound_content_len: %d\n", (int)test_data->inbound_content_len);
	if(test_data->inbound_packets!=1) {
		printf("\tinbound_packets: %d\n", test_data->inbound_packets);
	}
	if(test_data->inbound_dupe_packets!=0) {
		printf("\tinbound_dupes: %d\n", test_data->inbound_dupe_packets);
	}
	if(test_data->outbound_attempts!=1) {
		printf("\toutbound_attempts: %d\n", test_data->outbound_attempts);
	}
	if(test_data->response[0]!=0) {
		printf("\tresponse: \"%s\"\n", test_data->response);
	}
}
示例#3
0
smcp_cms_t
smcp_plat_timestamp_to_cms(smcp_timestamp_t ts) {
	return smcp_plat_timestamp_diff(ts, monotonic_get_time_ms());
}
示例#4
0
smcp_cms_t
smcp_plat_timestamp_to_cms(smcp_timestamp_t ts) {
	return smcp_plat_timestamp_diff(ts, clock_time());
}