Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 8 months ago.
set mac address of Ethernet shield by using FRDM kl25z
I am not able to set mac address of Ethernet shield by using FRDM kl25z. I checked my output over the tera term and i also added the image of output at end.
my code is:-
- include "mbed.h"
- include "WIZnetInterface.h"
unsigned char MAC_Addr[6] = {0xDE,0x01,0xBE,0xEF,0xFE,0xEE}; int motionfront; char* Update_Key = "DUKIIHPI784HV24M";
Serial pc(USBTX, USBRX); SPI spi(PTD2,PTD3,PTD1); WIZnetInterface ethernet(&spi,PTD0,PTA20);
DigitalIn motion_front(PTB0, PullUp);
int main() { Set serial port baudrate speed: 19200 pc.baud(9600); pc.printf("Start\r\n");
while(1) {
motionfront=motion_front.read(); wait(0.2); pc.printf("motion = %d\n\r", motionfront);
int ret = ethernet.init(MAC_Addr);
if (!ret) { pc.printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress()); ret = ethernet.connect(); if (!ret) { pc.printf("IP: %s, MASK: %s, GW: %s\r\n", ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway()); } else { pc.printf("Error ethernet.connect() - ret = %d\r\n", ret); exit(0); } } else { pc.printf("Error ethernet.init() - ret = %d\r\n", ret); exit(0); }
TCPSocketConnection sock; sock.connect("184.106.153.149", 80); if(sock.is_connected()) pc.printf("Socket Connected\n\r"); else pc.printf("Socket NoT Connected\n\r");
char buffer[300]; int ret_t;
char http_cmd[256]; sprintf(http_cmd,"GET/update?key=DUKIIHPI784HV24M&field1=%d HTTP/1.0\n\n",motionfront); printf("Running - %s\r\n",http_cmd); sock.send_all(http_cmd, sizeof(http_cmd)-1);
ret_t = sock.receive(buffer, sizeof(buffer)-1); buffer[ret_t] = '\0'; printf("Received %d chars from server:\n%s\r\n", ret_t, buffer);
sock.close();
ethernet.disconnect(); printf("Socket Closed");
while(1);
} }