bus

Dependencies:   Servo WIZnetInterface mbed-src

Fork of My_Weatherforecast_WIZwiki-W7500 by Lawrence Lee

Committer:
john135x
Date:
Mon Oct 05 06:20:55 2015 +0000
Revision:
19:420c2480c2a6
Parent:
18:a02a73acd3c8
bus

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:bb128f0e952f 1 #include "mbed.h"
donatien 0:bb128f0e952f 2 #include "EthernetInterface.h"
joon874 17:ca0b0402a4fe 3 #include "Servo.h"
joon874 17:ca0b0402a4fe 4
john135x 19:420c2480c2a6 5 //internal led
john135x 19:420c2480c2a6 6 DigitalOut rled(LED1,1);
john135x 19:420c2480c2a6 7 DigitalOut gled(LED2,1);
john135x 19:420c2480c2a6 8 DigitalOut bled(LED3,1);
joon874 17:ca0b0402a4fe 9
john135x 19:420c2480c2a6 10 //gpio
john135x 19:420c2480c2a6 11 DigitalOut wealed(D2);
john135x 19:420c2480c2a6 12 DigitalOut busled_00(D15);
john135x 19:420c2480c2a6 13 DigitalOut busled_01(D14);
john135x 19:420c2480c2a6 14 DigitalOut busled_02(D13);
john135x 19:420c2480c2a6 15 DigitalOut busled_03(D12);
john135x 19:420c2480c2a6 16 DigitalOut busled_10(D11);
john135x 19:420c2480c2a6 17 DigitalOut busled_11(D10);
john135x 19:420c2480c2a6 18 DigitalOut busled_12(D9);
john135x 19:420c2480c2a6 19 DigitalOut busled_13(D8);
john135x 19:420c2480c2a6 20 DigitalOut busled_20(D7);
john135x 19:420c2480c2a6 21 DigitalOut busled_21(D6);
john135x 19:420c2480c2a6 22 DigitalOut busled_22(D5);
john135x 19:420c2480c2a6 23 DigitalOut busled_23(D4);
donatien 0:bb128f0e952f 24
john135x 19:420c2480c2a6 25 int main()
john135x 19:420c2480c2a6 26 {
joon874 17:ca0b0402a4fe 27 int phy_link;
joon874 17:ca0b0402a4fe 28 printf("Wait a second...\r\n");
john135x 19:420c2480c2a6 29 uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x09};
joon874 17:ca0b0402a4fe 30
donatien 0:bb128f0e952f 31 EthernetInterface eth;
joon874 17:ca0b0402a4fe 32 eth.init(mac_addr); //Use DHCP
joon874 17:ca0b0402a4fe 33
donatien 0:bb128f0e952f 34 eth.connect();
donatien 0:bb128f0e952f 35
john135x 19:420c2480c2a6 36 //phy link
joon874 17:ca0b0402a4fe 37 do{
joon874 17:ca0b0402a4fe 38 phy_link = eth.ethernet_link();
joon874 17:ca0b0402a4fe 39 printf("...");
joon874 17:ca0b0402a4fe 40 wait(2);
joon874 17:ca0b0402a4fe 41 }while(!phy_link);
john135x 19:420c2480c2a6 42 printf("PHY_LINK_OK\n");
john135x 19:420c2480c2a6 43 printf("IP Address is %s\r\n", eth.getIPAddress());
joon874 17:ca0b0402a4fe 44
john135x 19:420c2480c2a6 45 //get info
john135x 19:420c2480c2a6 46 char buffer_wea[1000];
john135x 19:420c2480c2a6 47 char buffer_0[1000];
john135x 19:420c2480c2a6 48 char buffer_1[1000];
john135x 19:420c2480c2a6 49 char buffer_2[1000];
john135x 19:420c2480c2a6 50 int ret_wea;
john135x 19:420c2480c2a6 51 int ret_0;
john135x 19:420c2480c2a6 52 int ret_1;
john135x 19:420c2480c2a6 53 int ret_2;
joon874 17:ca0b0402a4fe 54
john135x 19:420c2480c2a6 55 //weather
john135x 19:420c2480c2a6 56 char http_cmd_wea[] = "GET /data/2.5/weather?q=Seongnam,kr HTTP/1.0\n\n";
john135x 19:420c2480c2a6 57
john135x 19:420c2480c2a6 58
john135x 19:420c2480c2a6 59 //BUS
john135x 19:420c2480c2a6 60 //char http_cmd[] = "GET /ws/rest/busarrivalservice/station?serviceKey=test&stationId=206000606 \n\n";
john135x 19:420c2480c2a6 61 char http_cmd_0[] = "GET /ws/rest/busarrivalservice?serviceKey=test&routeId=204000039&stationId=206000606 \n\n"; //330
john135x 19:420c2480c2a6 62 char http_cmd_1[] = "GET /ws/rest/busarrivalservice?serviceKey=test&routeId=204000044&stationId=206000606 \n\n"; //350
john135x 19:420c2480c2a6 63 char http_cmd_2[] = "GET /ws/rest/busarrivalservice?serviceKey=test&routeId=204000079&stationId=206000606 \n\n"; //380
donatien 0:bb128f0e952f 64
john135x 19:420c2480c2a6 65
john135x 19:420c2480c2a6 66 while(1)
john135x 19:420c2480c2a6 67 {
john135x 19:420c2480c2a6 68 //TCP socket[weather] connect
john135x 19:420c2480c2a6 69 TCPSocketConnection sock_wea;
john135x 19:420c2480c2a6 70 sock_wea.connect("api.openweathermap.org", 80);
john135x 19:420c2480c2a6 71 printf("Socket[weather] connected\n");
john135x 19:420c2480c2a6 72
john135x 19:420c2480c2a6 73 sock_wea.send_all(http_cmd_wea, sizeof(http_cmd_wea)-1);
john135x 19:420c2480c2a6 74
john135x 19:420c2480c2a6 75 while (true)
john135x 19:420c2480c2a6 76 {
john135x 19:420c2480c2a6 77 ret_wea = sock_wea.receive(buffer_wea, sizeof(buffer_wea)-1);
john135x 19:420c2480c2a6 78 if (ret_wea <= 0)
john135x 19:420c2480c2a6 79 printf("fail\n");
john135x 19:420c2480c2a6 80 break;
john135x 19:420c2480c2a6 81
john135x 19:420c2480c2a6 82 buffer_wea[ret_wea] = '\0';
john135x 19:420c2480c2a6 83 }
john135x 19:420c2480c2a6 84
john135x 19:420c2480c2a6 85 //TCP socket0 connect
john135x 19:420c2480c2a6 86 TCPSocketConnection sock_0;
john135x 19:420c2480c2a6 87 sock_0.connect("openapi.gbis.go.kr", 80);
john135x 19:420c2480c2a6 88 printf("Socket0 connected\n");
emilmont 7:65188f4a8c25 89
john135x 19:420c2480c2a6 90 sock_0.send_all(http_cmd_0, sizeof(http_cmd_0)-1);
john135x 19:420c2480c2a6 91
john135x 19:420c2480c2a6 92 while (true)
john135x 19:420c2480c2a6 93 {
john135x 19:420c2480c2a6 94 ret_0 = sock_0.receive(buffer_0, sizeof(buffer_0)-1);
john135x 19:420c2480c2a6 95 if (ret_0 <= 0)
john135x 19:420c2480c2a6 96 printf("fail\n");
john135x 19:420c2480c2a6 97 break;
john135x 19:420c2480c2a6 98
john135x 19:420c2480c2a6 99 buffer_0[ret_0] = '\0';
emilmont 7:65188f4a8c25 100 }
joon874 17:ca0b0402a4fe 101
john135x 19:420c2480c2a6 102
john135x 19:420c2480c2a6 103 //TCP socket1 connect
john135x 19:420c2480c2a6 104 TCPSocketConnection sock_1;
john135x 19:420c2480c2a6 105 sock_1.connect("openapi.gbis.go.kr", 80);
john135x 19:420c2480c2a6 106 printf("Socket1 connected\n");
john135x 19:420c2480c2a6 107
john135x 19:420c2480c2a6 108 sock_1.send_all(http_cmd_1, sizeof(http_cmd_1)-1);
john135x 19:420c2480c2a6 109 while (true)
john135x 19:420c2480c2a6 110 {
john135x 19:420c2480c2a6 111 ret_1 = sock_1.receive(buffer_1, sizeof(buffer_1)-1);
john135x 19:420c2480c2a6 112 if (ret_1 <= 0)
john135x 19:420c2480c2a6 113 printf("fail\n");
john135x 19:420c2480c2a6 114 break;
john135x 19:420c2480c2a6 115
john135x 19:420c2480c2a6 116 buffer_1[ret_1] = '\0';
john135x 19:420c2480c2a6 117 }
john135x 19:420c2480c2a6 118
john135x 19:420c2480c2a6 119
john135x 19:420c2480c2a6 120 //TCP socket2 connect
john135x 19:420c2480c2a6 121 TCPSocketConnection sock_2;
john135x 19:420c2480c2a6 122 sock_2.connect("openapi.gbis.go.kr", 80);
john135x 19:420c2480c2a6 123 printf("Socket2 connected\n");
john135x 19:420c2480c2a6 124
john135x 19:420c2480c2a6 125 sock_2.send_all(http_cmd_2, sizeof(http_cmd_2)-1);
john135x 19:420c2480c2a6 126
john135x 19:420c2480c2a6 127 while (true)
john135x 19:420c2480c2a6 128 {
john135x 19:420c2480c2a6 129 ret_2 = sock_2.receive(buffer_2, sizeof(buffer_2)-1);
john135x 19:420c2480c2a6 130 if (ret_2 <= 0)
john135x 19:420c2480c2a6 131 printf("fail\n");
john135x 19:420c2480c2a6 132 break;
john135x 19:420c2480c2a6 133
john135x 19:420c2480c2a6 134 buffer_2[ret_0] = '\0';
john135x 19:420c2480c2a6 135 }
john135x 19:420c2480c2a6 136
john135x 19:420c2480c2a6 137
john135x 19:420c2480c2a6 138 //print
john135x 19:420c2480c2a6 139 //printf("\nWeather\n\n Received %d chars from server=> \n%s\n\n", ret_wea, buffer_wea);
john135x 19:420c2480c2a6 140 //wait(2);
john135x 19:420c2480c2a6 141 //printf("\n330\n\n Received %d chars from server=> \n%s\n\n", ret_0, buffer_0);
john135x 19:420c2480c2a6 142 //wait(2);
john135x 19:420c2480c2a6 143 //printf("\n350\n\n Received %d chars from server=> \n%s\n\n", ret_1, buffer_1);
john135x 19:420c2480c2a6 144 //wait(2);
john135x 19:420c2480c2a6 145 //printf("\n380\n\n Received %d chars from server=> \n%s\n\n", ret_2, buffer_2);
john135x 19:420c2480c2a6 146 //wait(2);
john135x 19:420c2480c2a6 147
john135x 19:420c2480c2a6 148
john135x 19:420c2480c2a6 149 //get weather, city, tempurature
joon874 17:ca0b0402a4fe 150 char *weather;
joon874 17:ca0b0402a4fe 151 char *city;
joon874 17:ca0b0402a4fe 152 char *tempure;
john135x 19:420c2480c2a6 153
joon874 17:ca0b0402a4fe 154 char weather_stu[3];
joon874 17:ca0b0402a4fe 155 char tempure_data[6];
john135x 19:420c2480c2a6 156
john135x 19:420c2480c2a6 157 int weather_id;
john135x 19:420c2480c2a6 158 int weather_id_[3];
john135x 19:420c2480c2a6 159
john135x 19:420c2480c2a6 160 int tempure_d;
john135x 19:420c2480c2a6 161 int tempure_[3];
john135x 19:420c2480c2a6 162
john135x 19:420c2480c2a6 163 weather = strstr(buffer_wea, "id");
john135x 19:420c2480c2a6 164 printf("\nWeather ID=> %.3s\n", weather+4);
john135x 19:420c2480c2a6 165 for(int i=0; i<3; i++)
john135x 19:420c2480c2a6 166 {
john135x 19:420c2480c2a6 167 weather_stu[i] = (weather[i+4]);
john135x 19:420c2480c2a6 168 weather_id_[i] = weather_stu[i]-'0';
john135x 19:420c2480c2a6 169 //printf("%c", weather_stu[i]);
john135x 19:420c2480c2a6 170 }
john135x 19:420c2480c2a6 171 weather_id = weather_id_[0]*100+weather_id_[1]*10*weather_id_[2];
john135x 19:420c2480c2a6 172 //printf("%d\n", weather_id);
john135x 19:420c2480c2a6 173
john135x 19:420c2480c2a6 174 city = strstr(buffer_wea, "name");
john135x 19:420c2480c2a6 175 printf("City Name=> %.8s\n", city + 7);
john135x 19:420c2480c2a6 176
john135x 19:420c2480c2a6 177 tempure = strstr(buffer_wea, "temp");
john135x 19:420c2480c2a6 178 printf("Tempurature=> %.3sK\n", tempure + 6);
john135x 19:420c2480c2a6 179 for(int i=0; i<3; i++)
john135x 19:420c2480c2a6 180 {
john135x 19:420c2480c2a6 181 tempure_data[i] = (tempure[i+6]);
john135x 19:420c2480c2a6 182 tempure_[i] = tempure_data[i]-'0';
john135x 19:420c2480c2a6 183 //printf("%c", tempure_data[i]);
john135x 19:420c2480c2a6 184 }
john135x 19:420c2480c2a6 185 tempure_d = tempure_[0]*100+tempure_[1]*10+tempure_[2];
john135x 19:420c2480c2a6 186
john135x 19:420c2480c2a6 187 printf("Tempurature=> %dC\n\n", (tempure_d - 273));
john135x 19:420c2480c2a6 188
john135x 19:420c2480c2a6 189
john135x 19:420c2480c2a6 190 //weather display
john135x 19:420c2480c2a6 191 if((weather_id>=200)&&(weather_id<300))
john135x 19:420c2480c2a6 192 {
john135x 19:420c2480c2a6 193 printf("<<< Thunderstom >>>\n");
john135x 19:420c2480c2a6 194 printf("<<< You need an umbrella >>>\n");
john135x 19:420c2480c2a6 195 //rled = 1;gled = 0;bled = 0;
john135x 19:420c2480c2a6 196 wealed = 1;
john135x 19:420c2480c2a6 197 }
john135x 19:420c2480c2a6 198 else if((weather_id>=300)&&(weather_id<400))
john135x 19:420c2480c2a6 199 {
john135x 19:420c2480c2a6 200 printf("<<< Drizzle >>>\n");
john135x 19:420c2480c2a6 201 printf("<<< You need an umbrella >>>\n");
john135x 19:420c2480c2a6 202 //rled = 1;gled = 0;bled = 0;
john135x 19:420c2480c2a6 203 wealed = 1;
john135x 19:420c2480c2a6 204 }
john135x 19:420c2480c2a6 205 else if((weather_id>=500)&&(weather_id<600))
john135x 19:420c2480c2a6 206 {
john135x 19:420c2480c2a6 207 printf("<<< Rain >>>\n");
john135x 19:420c2480c2a6 208 printf("<<< You need an umbrella >>>\n");
john135x 19:420c2480c2a6 209 //rled = 1;gled = 0;bled = 0;
john135x 19:420c2480c2a6 210 wealed = 1;
john135x 19:420c2480c2a6 211 }
john135x 19:420c2480c2a6 212 else if((weather_id>=600)&&(weather_id<700))
john135x 19:420c2480c2a6 213 {
john135x 19:420c2480c2a6 214 printf("<<< Snow >>>\n");
john135x 19:420c2480c2a6 215 printf("<<< You need an umbrella >>>\n");
john135x 19:420c2480c2a6 216 //rled = 1;gled = 0;bled = 0;
john135x 19:420c2480c2a6 217 wealed = 1;
john135x 19:420c2480c2a6 218 }
john135x 19:420c2480c2a6 219 else
john135x 19:420c2480c2a6 220 {
john135x 19:420c2480c2a6 221 printf("<<< You don't need an umbrella >>>\n");
john135x 19:420c2480c2a6 222 //rled = 0;gled = 1;bled = 0;
john135x 19:420c2480c2a6 223 wealed = 0;
john135x 19:420c2480c2a6 224 }
john135x 19:420c2480c2a6 225
john135x 19:420c2480c2a6 226
john135x 19:420c2480c2a6 227 //get location
john135x 19:420c2480c2a6 228 char *location_0;
john135x 19:420c2480c2a6 229 char *location_1;
john135x 19:420c2480c2a6 230 char *location_2;
joon874 17:ca0b0402a4fe 231
john135x 19:420c2480c2a6 232 char loca_0[2];
john135x 19:420c2480c2a6 233 char loca_1[2];
john135x 19:420c2480c2a6 234 char loca_2[2];
john135x 19:420c2480c2a6 235
john135x 19:420c2480c2a6 236 int INT_location_0[2];
john135x 19:420c2480c2a6 237 int INT_location_1[2];
john135x 19:420c2480c2a6 238 int INT_location_2[2];
john135x 19:420c2480c2a6 239
john135x 19:420c2480c2a6 240 int S_location_0;
john135x 19:420c2480c2a6 241 int S_location_1;
john135x 19:420c2480c2a6 242 int S_location_2;
john135x 19:420c2480c2a6 243
john135x 19:420c2480c2a6 244 printf("\n<<< locationNo1 >>>\n");
john135x 19:420c2480c2a6 245
john135x 19:420c2480c2a6 246 location_0 = strstr(buffer_0, "<locationNo1>");
john135x 19:420c2480c2a6 247 printf("330 => %.2s\n", location_0+13);
john135x 19:420c2480c2a6 248
john135x 19:420c2480c2a6 249 location_1 = strstr(buffer_1, "<locationNo1>");
john135x 19:420c2480c2a6 250 printf("350 => %.2s\n", location_1+13);
john135x 19:420c2480c2a6 251
john135x 19:420c2480c2a6 252 location_2 = strstr(buffer_2, "<locationNo1>");
john135x 19:420c2480c2a6 253 printf("380 => %.2s\n", location_1+13);
john135x 19:420c2480c2a6 254
joon874 17:ca0b0402a4fe 255
john135x 19:420c2480c2a6 256 //330 display
john135x 19:420c2480c2a6 257 for(int i=0; i<2; i++)
john135x 19:420c2480c2a6 258 {
john135x 19:420c2480c2a6 259 loca_0[i] = (location_0[i+13]);
john135x 19:420c2480c2a6 260 INT_location_0[i] = loca_0[i]-'0';
john135x 19:420c2480c2a6 261 }
john135x 19:420c2480c2a6 262
john135x 19:420c2480c2a6 263 printf("\n<<< Remaining station >>>\n");
john135x 19:420c2480c2a6 264
john135x 19:420c2480c2a6 265 if(INT_location_0[1]==12)
john135x 19:420c2480c2a6 266 {
john135x 19:420c2480c2a6 267 printf("330 => %d\n",INT_location_0[0]);
john135x 19:420c2480c2a6 268 S_location_0 = INT_location_0[0];
john135x 19:420c2480c2a6 269 }
john135x 19:420c2480c2a6 270 else
john135x 19:420c2480c2a6 271 {
john135x 19:420c2480c2a6 272 printf("330 => %d\n",INT_location_0[0]*10+INT_location_0[1]);
john135x 19:420c2480c2a6 273 S_location_0 = INT_location_0[0]*10+INT_location_0[1];
john135x 19:420c2480c2a6 274 }
john135x 19:420c2480c2a6 275
john135x 19:420c2480c2a6 276 //330 position sign
john135x 19:420c2480c2a6 277 //if(S_location_0>=5)
john135x 19:420c2480c2a6 278 //{
john135x 19:420c2480c2a6 279 // rled=0;bled=1;gled=1;
john135x 19:420c2480c2a6 280 //}
john135x 19:420c2480c2a6 281 //else if (S_location_0==4)
john135x 19:420c2480c2a6 282 //{
john135x 19:420c2480c2a6 283 // rled=1;bled=0;gled=0;
john135x 19:420c2480c2a6 284 //}
john135x 19:420c2480c2a6 285 //else if (S_location_0==3)
john135x 19:420c2480c2a6 286 if (S_location_0>=4)
john135x 19:420c2480c2a6 287 {
john135x 19:420c2480c2a6 288 //rled=1;bled=1;gled=0;
john135x 19:420c2480c2a6 289 busled_00=0;busled_01=0;busled_02=0;busled_03=1;
john135x 19:420c2480c2a6 290 }
john135x 19:420c2480c2a6 291 else if (S_location_0==3)
john135x 19:420c2480c2a6 292 {
john135x 19:420c2480c2a6 293 //rled=1;bled=0;gled=1;
john135x 19:420c2480c2a6 294 busled_00=0;busled_01=0;busled_02=1;busled_03=0;
john135x 19:420c2480c2a6 295 }
john135x 19:420c2480c2a6 296 else if (S_location_0==2)
john135x 19:420c2480c2a6 297 {
john135x 19:420c2480c2a6 298 //rled=0;bled=0;gled=0;
john135x 19:420c2480c2a6 299 busled_00=0;busled_01=1;busled_02=0;busled_03=0;
john135x 19:420c2480c2a6 300 }
john135x 19:420c2480c2a6 301 else if (S_location_0==1)
john135x 19:420c2480c2a6 302 {
john135x 19:420c2480c2a6 303 //rled=1;bled=1;gled=1;
john135x 19:420c2480c2a6 304 busled_00=1;busled_01=0;busled_02=0;busled_03=0;
john135x 19:420c2480c2a6 305 }
john135x 19:420c2480c2a6 306 else
john135x 19:420c2480c2a6 307 {
john135x 19:420c2480c2a6 308 busled_00=0;busled_01=0;busled_02=0;busled_03=0;
john135x 19:420c2480c2a6 309 }
john135x 19:420c2480c2a6 310
john135x 19:420c2480c2a6 311
john135x 19:420c2480c2a6 312 //350 display
john135x 19:420c2480c2a6 313 for(int i=0; i<2; i++)
john135x 19:420c2480c2a6 314 {
john135x 19:420c2480c2a6 315 loca_1[i] = (location_1[i+13]);
john135x 19:420c2480c2a6 316 INT_location_1[i] = loca_1[i]-'0';
john135x 19:420c2480c2a6 317 }
john135x 19:420c2480c2a6 318
john135x 19:420c2480c2a6 319 if(INT_location_1[1]==12)
john135x 19:420c2480c2a6 320 {
john135x 19:420c2480c2a6 321 printf("350 => %d\n",INT_location_1[0]);
john135x 19:420c2480c2a6 322 S_location_1 = INT_location_1[0];
john135x 19:420c2480c2a6 323 }
john135x 19:420c2480c2a6 324 else
john135x 19:420c2480c2a6 325 {
john135x 19:420c2480c2a6 326 printf("350 => %d\n",INT_location_1[0]*10+INT_location_1[1]);
john135x 19:420c2480c2a6 327 S_location_1 = INT_location_1[0]*10+INT_location_1[1];
joon874 18:a02a73acd3c8 328 }
john135x 19:420c2480c2a6 329
john135x 19:420c2480c2a6 330 //350 position sign
john135x 19:420c2480c2a6 331 if (S_location_1>=4)
john135x 19:420c2480c2a6 332 {
john135x 19:420c2480c2a6 333 //rled=1;bled=1;gled=0;
john135x 19:420c2480c2a6 334 busled_10=0;busled_11=0;busled_12=0;busled_13=1;
john135x 19:420c2480c2a6 335 }
john135x 19:420c2480c2a6 336 else if (S_location_1==3)
john135x 19:420c2480c2a6 337 {
john135x 19:420c2480c2a6 338 //rled=1;bled=0;gled=1;
john135x 19:420c2480c2a6 339 busled_10=0;busled_11=0;busled_12=1;busled_13=0;
john135x 19:420c2480c2a6 340 }
john135x 19:420c2480c2a6 341 else if (S_location_1==2)
john135x 19:420c2480c2a6 342 {
john135x 19:420c2480c2a6 343 //rled=0;bled=0;gled=0;
john135x 19:420c2480c2a6 344 busled_10=0;busled_11=1;busled_12=0;busled_13=0;
john135x 19:420c2480c2a6 345 }
john135x 19:420c2480c2a6 346 else if (S_location_1==1)
john135x 19:420c2480c2a6 347 {
john135x 19:420c2480c2a6 348 //rled=1;bled=1;gled=1;
john135x 19:420c2480c2a6 349 busled_10=1;busled_11=0;busled_12=0;busled_13=0;
john135x 19:420c2480c2a6 350 }
john135x 19:420c2480c2a6 351 else
john135x 19:420c2480c2a6 352 {
john135x 19:420c2480c2a6 353 busled_10=0;busled_11=0;busled_12=0;busled_13=0;
john135x 19:420c2480c2a6 354 }
john135x 19:420c2480c2a6 355
john135x 19:420c2480c2a6 356
john135x 19:420c2480c2a6 357 //380 display
john135x 19:420c2480c2a6 358 for(int i=0; i<2; i++)
john135x 19:420c2480c2a6 359 {
john135x 19:420c2480c2a6 360 loca_2[i] = (location_2[i+13]);
john135x 19:420c2480c2a6 361 INT_location_2[i] = loca_2[i]-'0';
john135x 19:420c2480c2a6 362 }
donatien 0:bb128f0e952f 363
john135x 19:420c2480c2a6 364 if(INT_location_2[1]==12)
john135x 19:420c2480c2a6 365 {
john135x 19:420c2480c2a6 366 printf("380 => %d\n",INT_location_2[0]);
john135x 19:420c2480c2a6 367 S_location_2 = INT_location_2[0];
john135x 19:420c2480c2a6 368 }
john135x 19:420c2480c2a6 369 else
john135x 19:420c2480c2a6 370 {
john135x 19:420c2480c2a6 371 printf("380 => %d\n",INT_location_2[0]*10+INT_location_2[1]);
john135x 19:420c2480c2a6 372 S_location_2 = INT_location_2[0]*10+INT_location_2[1];
john135x 19:420c2480c2a6 373 }
donatien 5:01f6c3e112af 374
john135x 19:420c2480c2a6 375 //380 position sign
john135x 19:420c2480c2a6 376 if (S_location_2>=4)
john135x 19:420c2480c2a6 377 {
john135x 19:420c2480c2a6 378 //rled=1;bled=1;gled=0;
john135x 19:420c2480c2a6 379 busled_20=0;busled_21=0;busled_22=0;busled_23=1;
john135x 19:420c2480c2a6 380 }
john135x 19:420c2480c2a6 381 else if (S_location_2==3)
john135x 19:420c2480c2a6 382 {
john135x 19:420c2480c2a6 383 //rled=1;bled=0;gled=1;
john135x 19:420c2480c2a6 384 busled_20=0;busled_21=0;busled_22=1;busled_23=0;
john135x 19:420c2480c2a6 385 }
john135x 19:420c2480c2a6 386 else if (S_location_2==2)
john135x 19:420c2480c2a6 387 {
john135x 19:420c2480c2a6 388 //rled=0;bled=0;gled=0;
john135x 19:420c2480c2a6 389 busled_20=0;busled_21=1;busled_22=0;busled_23=0;
john135x 19:420c2480c2a6 390 }
john135x 19:420c2480c2a6 391 else if (S_location_2==1)
john135x 19:420c2480c2a6 392 {
john135x 19:420c2480c2a6 393 //rled=1;bled=1;gled=1;
john135x 19:420c2480c2a6 394 busled_20=1;busled_21=0;busled_22=0;busled_23=0;
john135x 19:420c2480c2a6 395 }
john135x 19:420c2480c2a6 396 else
john135x 19:420c2480c2a6 397 {
john135x 19:420c2480c2a6 398 busled_20=0;busled_21=0;busled_22=0;busled_23=0;
john135x 19:420c2480c2a6 399 }
john135x 19:420c2480c2a6 400
john135x 19:420c2480c2a6 401
john135x 19:420c2480c2a6 402 sock_wea.close();
john135x 19:420c2480c2a6 403 sock_0.close();
john135x 19:420c2480c2a6 404 sock_1.close();
john135x 19:420c2480c2a6 405 sock_2.close();
john135x 19:420c2480c2a6 406
john135x 19:420c2480c2a6 407 eth.disconnect();
john135x 19:420c2480c2a6 408 printf("\nSocket disconnected\n\n");
john135x 19:420c2480c2a6 409
john135x 19:420c2480c2a6 410 wait(12);
joon874 17:ca0b0402a4fe 411 };
joon874 17:ca0b0402a4fe 412
joon874 17:ca0b0402a4fe 413 }