SNIC UART Interface library: Serial to Wi-Fi library for Murata TypeYD Wi-Fi module. For more information about TypeYD: http://www.murata.co.jp/products/microwave/module/lbwb1zzydz/index.html
Dependents: SNIC-xively-jumpstart-demo SNIC-FluentLogger-example TCPEchoServer murataDemo ... more
Fork of YDwifiInterface by
Revision 34:8c3527b8f44e, committed 2014-06-09
- Comitter:
- kishino
- Date:
- Mon Jun 09 08:28:07 2014 +0000
- Parent:
- 33:33f1bc919486
- Child:
- 35:e4e7f86fd975
- Commit message:
- [Refactoring] ; Changed how to define of buffer for TCP socket.; About setting IP address, changed to using common function for convert to binary array from decimal.
Changed in this revision
--- a/SNIC/SNIC_UartMsgUtil.h Tue Jun 03 08:53:07 2014 +0000
+++ b/SNIC/SNIC_UartMsgUtil.h Mon Jun 09 08:28:07 2014 +0000
@@ -135,6 +135,8 @@
friend class C_SNIC_Core;
friend class C_SNIC_WifiInterface;
friend class UDPSocket;
+friend class TCPSocketConnection;
+friend class Socket;
private:
C_SNIC_UartMsgUtil();
--- a/Socket/Socket.cpp Tue Jun 03 08:53:07 2014 +0000
+++ b/Socket/Socket.cpp Mon Jun 09 08:28:07 2014 +0000
@@ -134,10 +134,7 @@
if( bind != 0 )
{
// set ip addr ( byte order )
- req.local_addr[0] = ( (local_addr & 0xFF000000) >> 24 );
- req.local_addr[1] = ( (local_addr & 0xFF0000) >> 16 );
- req.local_addr[2] = ( (local_addr & 0xFF00) >> 8 );
- req.local_addr[3] = (local_addr & 0xFF);
+ C_SNIC_UartMsgUtil::convertIntToByteAdday( local_addr, (char *)req.local_addr );
req.local_port[0] = ( (port & 0xFF00) >> 8 );
req.local_port[1] = (port & 0xFF);
--- a/Socket/TCPSocketConnection.cpp Tue Jun 03 08:53:07 2014 +0000
+++ b/Socket/TCPSocketConnection.cpp Mon Jun 09 08:28:07 2014 +0000
@@ -80,16 +80,7 @@
req.socket_id = mSocketID;
// set ip addr ( byte order )
- req.remote_addr[0] = ((ip_addr & 0xFF000000) >> 24 );
- req.remote_addr[1] = ((ip_addr & 0xFF0000) >> 16 );
- req.remote_addr[2] = ((ip_addr & 0xFF00) >> 8 );
- req.remote_addr[3] = ( ip_addr & 0xFF);
-/*
- req.remote_addr[0] = 0xD8;
- req.remote_addr[1] = 0x34;
- req.remote_addr[2] = 0xE9;
- req.remote_addr[3] = 0x78;
-*/
+ C_SNIC_UartMsgUtil::convertIntToByteAdday( ip_addr, (char *)req.remote_addr );
req.remote_port[0] = ( (port & 0xFF00) >> 8 );
req.remote_port[1] = (port & 0xFF);
req.recv_bufsize[0] = ( (SNIC_UART_RECVBUF_SIZE & 0xFF00) >> 8 );
@@ -145,7 +136,6 @@
return con_info_p->is_connected;
}
-unsigned char gTCP_SEND_BUF[2048];
int TCPSocketConnection::send(char* data_p, int length)
{
C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance();
@@ -168,14 +158,15 @@
req.payload_len[0]= ( (length & 0xFF00) >> 8 );
req.payload_len[1]= (length & 0xFF);
- int req_size = sizeof(C_SNIC_Core::tagSNIC_TCP_SEND_FROM_SOCKET_REQ_T);
- memcpy( gTCP_SEND_BUF, &req, req_size );
- memcpy( &gTCP_SEND_BUF[req_size], data_p, length );
+ int req_size = sizeof(C_SNIC_Core::tagSNIC_TCP_SEND_FROM_SOCKET_REQ_T);
+ char *send_buf_p = getSocketSendBuf();
+ memcpy( send_buf_p, &req, req_size );
+ memcpy( &send_buf_p[req_size], data_p, length );
unsigned char *command_array = snic_core_p->getCommandBuf();
unsigned int command_len;
// Preparation of command
- command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_SNIC, req.cmd_sid, gTCP_SEND_BUF
+ command_len = snic_core_p->preparationSendCommand( UART_CMD_ID_SNIC, req.cmd_sid, (unsigned char *)send_buf_p
, req_size + length, payload_buf->buf, command_array );
// Send uart command request
muRata

Murata TypeYD