Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface LM75B mbed-rtos mbed
Fork of communication by
Diff: master.cpp
- Revision:
- 2:067142778937
- Parent:
- 1:550192b4ae8e
- Child:
- 3:9c600fb19ed2
diff -r 550192b4ae8e -r 067142778937 master.cpp
--- a/master.cpp Tue Mar 13 10:31:27 2018 +0000
+++ b/master.cpp Tue Mar 13 12:15:05 2018 +0000
@@ -16,32 +16,10 @@
while(true){
char masterBuffer[512]={NULL};
- masterpc.printf("type for request:\n\r");
- for(int i = 0;i<512;i++){
- char key = masterpc.getc();
- if(key != 13){
- masterpc.putc(key);
- masterBuffer[i]=key;
- }
- else{
- masterBuffer[i]='\0';
- break;
- }
- }
+ typeRequest(masterBuffer);
char ipArray[14]={NULL};
- masterpc.printf("\n\rinsert ip address to send to:\n\r ");
- for(int i = 0;i<14;i++){
- char key = masterpc.getc();
- if(key != 13){
- masterpc.putc(key);
- ipArray[i]=key;
- }
- else{
- ipArray[i]='\0';
- break;
- }
- }
+ typeIp(ipArray);
sock.init();
const char *ECHO_SERVER_ADDRESS = ipArray;
@@ -55,4 +33,34 @@
masterpc.printf("Received message from server: '%s'\n\r", masterBuffer);
sock.close();
}
+}
+
+void typeRequest(char* buffer){
+ masterpc.printf("type for request:\n\r");
+ for(int i = 0;i<512;i++){
+ char key = masterpc.getc();
+ if(key != 13){
+ masterpc.putc(key);
+ buffer[i]=key;
+ }
+ else{
+ buffer[i]='\0';
+ break;
+ }
+ }
+}
+
+void typeIp(char* buffer){
+ masterpc.printf("\n\rinsert ip address to send to:\n\r ");
+ for(int i = 0;i<14;i++){
+ char key = masterpc.getc();
+ if(key != 13){
+ masterpc.putc(key);
+ buffer[i]=key;
+ }
+ else{
+ buffer[i]='\0';
+ break;
+ }
+ }
}
\ No newline at end of file
