// File: CDISC2020[P]Projet_satellite_agile/src/communication/Ground.cpp
// Function: main
int main (int argc,char* argv[])
{
	char cmde[100];
	char name[9];

	cout << "Welcome to the Ground Station, ";

	while (1)
	{
		cout << "what do you want to do ?"<< endl;
		cout << "'p' to send a plan\n" << "'c' to send a commande\n" << "'r' to receive the photos\n" << endl;
		char c;
		scanf(" %c", &c);

		if (c == 'p')	// Envoi d'un plan
		{
			cout << "What is the plan name ? (end it by '.txt')" << endl;
			scanf("%9s[^\n]", name);
			cout << "Sending Plan..." << endl;
			sprintf(cmde, "sh ../src/communication/uploadGtoSplans.sh %s", name);
			system(cmde);
			sleep(2);

			cout << "Plan sent !" << endl;
		}

		else if (c=='c')  // Envoi d'une commande
		{
			cout << "What is the commande name ? (end it by '.txt')" << endl;
			scanf("%9s[^\n]", name);
			cout << "Sending Commande..." << endl;
			sprintf(cmde, "sh ../src/communication/uploadGtoStm.sh %s", name);
			system(cmde);
			sleep(2);

			cout << "Commande sent !" << endl;
		}

		else if (c=='r')  // Demande des photos
		{
			sprintf(cmde, "sh ../src/communication/uploadGtoSplans.sh demande_imgs.txt");
			system(cmde);
			printf("Demande image envoyée");
			cout << "Receiving the images..." << endl;
			sleep(2);
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x2db8(%rip), %rdi      # 0x3fd8
leaq 0xddd(%rip), %rsi       # 0x2004
callq 0x1080
movq 0x2da5(%rip), %rdi      # 0x3fd8
leaq 0xdea(%rip), %rsi       # 0x2024
callq 0x1080
movq %rax, %rdi
movq 0x2d7f(%rip), %rsi      # 0x3fc8
callq 0x1090
movq 0x2d83(%rip), %rdi      # 0x3fd8
leaq 0xde1(%rip), %rsi       # 0x203d
callq 0x1080
movq %rax, %rdi
leaq 0xde6(%rip), %rsi       # 0x2051
callq 0x1080
movq %rax, %rdi
leaq 0xdef(%rip), %rsi       # 0x2069
callq 0x1080
movq %rax, %rdi
movq 0x2d3f(%rip), %rsi      # 0x3fc8
callq 0x1090
leaq 0xdef(%rip), %rdi       # 0x2084
leaq -0x8a(%rbp), %rsi
movb $0x0, %al
callq 0x10a0
movsbl -0x8a(%rbp), %eax
cmpl $0x70, %eax
jne 0x135f
movq 0x2d1e(%rip), %rdi      # 0x3fd8
leaq 0xdc7(%rip), %rsi       # 0x2088
callq 0x1080
movq %rax, %rdi
movq 0x2cf8(%rip), %rsi      # 0x3fc8
callq 0x1090
leaq -0x89(%rbp), %rsi
leaq 0xdd0(%rip), %rdi       # 0x20b3
movb $0x0, %al
callq 0x10a0
movq 0x2ce7(%rip), %rdi      # 0x3fd8
leaq 0xdc3(%rip), %rsi       # 0x20bb
callq 0x1080
movq %rax, %rdi
movq 0x2cc1(%rip), %rsi      # 0x3fc8
callq 0x1090
leaq -0x80(%rbp), %rdi
leaq -0x89(%rbp), %rdx
leaq 0xdad(%rip), %rsi       # 0x20cb
movb $0x0, %al
callq 0x1040
leaq -0x80(%rbp), %rdi
callq 0x1060
movl $0x2, %edi
callq 0x1050
movq 0x2c99(%rip), %rdi      # 0x3fd8
leaq 0xdb3(%rip), %rsi       # 0x20f9
callq 0x1080
movq %rax, %rdi
movq 0x2c73(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x147d
movsbl -0x8a(%rbp), %eax
cmpl $0x63, %eax
jne 0x1418
movq 0x2c62(%rip), %rdi      # 0x3fd8
leaq 0xd88(%rip), %rsi       # 0x2105
callq 0x1080
movq %rax, %rdi
movq 0x2c3c(%rip), %rsi      # 0x3fc8
callq 0x1090
leaq -0x89(%rbp), %rsi
leaq 0xd14(%rip), %rdi       # 0x20b3
movb $0x0, %al
callq 0x10a0
movq 0x2c2b(%rip), %rdi      # 0x3fd8
leaq 0xd80(%rip), %rsi       # 0x2134
callq 0x1080
movq %rax, %rdi
movq 0x2c05(%rip), %rsi      # 0x3fc8
callq 0x1090
leaq -0x80(%rbp), %rdi
leaq -0x89(%rbp), %rdx
leaq 0xd6e(%rip), %rsi       # 0x2148
movb $0x0, %al
callq 0x1040
leaq -0x80(%rbp), %rdi
callq 0x1060
movl $0x2, %edi
callq 0x1050
movq 0x2bdd(%rip), %rdi      # 0x3fd8
leaq 0xd71(%rip), %rsi       # 0x2173
callq 0x1080
movq %rax, %rdi
movq 0x2bb7(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x147b
movsbl -0x8a(%rbp), %eax
cmpl $0x72, %eax
jne 0x1479
leaq -0x80(%rbp), %rdi
leaq 0xd54(%rip), %rsi       # 0x2183
movb $0x0, %al
callq 0x1040
leaq -0x80(%rbp), %rdi
callq 0x1060
leaq 0xd79(%rip), %rdi       # 0x21bf
movb $0x0, %al
callq 0x1030
movq 0x2b84(%rip), %rdi      # 0x3fd8
leaq 0xd7b(%rip), %rsi       # 0x21d6
callq 0x1080
movq %rax, %rdi
movq 0x2b5e(%rip), %rsi      # 0x3fc8
callq 0x1090
movl $0x2, %edi
callq 0x1050
jmp 0x147b
jmp 0x147d
jmp 0x122c