Beispiel #1
0
static void
remote_connect_cb(uv_connect_t *req, int status) {
    struct remote_context *remote = (struct remote_context *)req->data;
    struct client_context *client = remote->client;

    if (status == 0) {
        reset_timer(remote);
        client->stage = XSTAGE_FORWARD;
        remote->stage = XSTAGE_FORWARD;
        request_to_server(remote);
        receive_from_remote(remote);

    } else {
        if (status != UV_ECANCELED) {
            logger_log(LOG_ERR, "connect to server failed: %s", uv_strerror(status));
            close_client(client);
            close_remote(remote);
        }
    }
}
Beispiel #2
0
int main()
{

	uint8_t *httpchar = 0;
	MAP_WDT_A_holdTimer();

	UART_PC_init();
	init_timer32_0();
	SL_D_init();
	UART_GSM_init();

	while(1){
		if(call_server_flag){
			httpchar = request_to_server();
			update_display(httpchar);
			call_server_flag = false; //reset flag
			init_timer32_0();
		}
	}
}
Beispiel #3
0
static void
remote_connect_cb(uv_connect_t *req, int status) {
    struct remote_context *remote = (struct remote_context *)req->data;
    struct client_context *client = remote->client;

    if (status == 0) {
        reset_timer(remote);
        client->stage = XSTAGE_FORWARD;
        remote->stage = XSTAGE_FORWARD;
        request_to_server(remote);
        receive_from_remote(remote);

    } else {
        if (status != UV_ECANCELED) {
            char addrbuf[INET6_ADDRSTRLEN + 1];
            ip_name(&server_addr, addrbuf, sizeof(addrbuf));
            logger_log(LOG_ERR, "connect to %s failed: %s", addrbuf, uv_strerror(status));
            close_client(client);
            close_remote(remote);
        }
    }
}
int main(int argc, char *argv[])
{
	int	socket_fd;
	struct  sockaddr_in servaddr;

	if (argc != 3)
	{
		printf("Usage: caseClient <address> <port> \n");
    	return -1;
	}
	printf("Created socket\n");
	socket_fd = socket(AF_INET, SOCK_STREAM, 0);
	if (socket_fd < 0)
	{
        fprintf(stderr, "Error creating socket, errno = %d (%s) \n",
					errno, strerror(errno));
        return -1;
	}

	bzero(&servaddr, sizeof(servaddr));
	servaddr.sin_family = AF_INET;
	servaddr.sin_addr.s_addr = inet_addr(argv[1]);
	servaddr.sin_port = htons(atoi(argv[2]));
	printf("Making connection to server\n");
	if(connect(socket_fd, (struct sockaddr *)&servaddr, sizeof(servaddr)) == -1)
	{
        fprintf(stderr, "Error unable to connect to socket, errno = %d (%s) \n",
					errno, strerror(errno));
        return -1;
	}
	printf("calling method to read data from terminal\n");
	//str_client(stdin, socket_fd);
	request_to_server(stdin, socket_fd);
	close(socket_fd);
	printf("Stopping client\n");
	return 0;
}
Beispiel #5
0
void get_data_update_display() {
	int counter;
	uint8_t refreshCmd[3] = {0x24, 0x01, 0x00};
	uint8_t resetPtrCmd[3] = {0x20, 0x0D, 0x00};
	uint8_t packetSize = 0xFA;
	uint8_t *httpchar = 0;

	httpchar = request_to_server();
	SL_D_sendCmd(resetPtrCmd, 3);

	//Upload header (first 16 bytes)
	SL_D_uploadImgData(httpchar[0], 0x10);

	for(counter = 16; counter < 48016; counter+=packetSize)
	{
		//Upload image after the header
		//Upload in chunks of 250 bytes
		//SL_D_uploadImgData(httpchar[counter], packetSize);
		SL_D_uploadImgData(httpchar + counter, packetSize);
	}

	//Send refresh display command
	SL_D_sendCmd(refreshCmd, 3);
}