* @brief This function is an application I/F function which is used to send the data for other then TCP mode. * Unlike TCP transmission, The peer's destination address and the port is needed. * * @return This function return send data size for success else -1. */
| 202 | * @return This function return send data size for success else -1. |
| 203 | */ |
| 204 | uint16_t sendto(SOCKET s, const uint8_t *buf, uint16_t len, uint8_t *addr, uint16_t port) |
| 205 | { |
| 206 | uint16_t ret=0; |
| 207 | |
| 208 | if (len > w5500.SSIZE) ret = w5500.SSIZE; // check size not to exceed MAX size. |
| 209 | else ret = len; |
| 210 | |
| 211 | if |
| 212 | ( |
| 213 | ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || |
| 214 | ((port == 0x00)) ||(ret == 0) |
| 215 | ) |
| 216 | { |
| 217 | /* +2008.01 [bj] : added return value */ |
| 218 | ret = 0; |
| 219 | } |
| 220 | else |
| 221 | { |
| 222 | w5500.writeSnDIPR(s, addr); |
| 223 | w5500.writeSnDPORT(s, port); |
| 224 | |
| 225 | // copy data |
| 226 | w5500.send_data_processing(s, (uint8_t *)buf, ret); |
| 227 | w5500.execCmdSn(s, Sock_SEND); |
| 228 | |
| 229 | /* +2008.01 bj */ |
| 230 | while ( (w5500.readSnIR(s) & SnIR::SEND_OK) != SnIR::SEND_OK ) |
| 231 | { |
| 232 | if (w5500.readSnIR(s) & SnIR::TIMEOUT) |
| 233 | { |
| 234 | /* +2008.01 [bj]: clear interrupt */ |
| 235 | w5500.writeSnIR(s, (SnIR::SEND_OK | SnIR::TIMEOUT)); /* clear SEND_OK & TIMEOUT */ |
| 236 | return 0; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | /* +2008.01 bj */ |
| 241 | w5500.writeSnIR(s, SnIR::SEND_OK); |
| 242 | } |
| 243 | return ret; |
| 244 | } |
| 245 | |
| 246 | |
| 247 | /** |
nothing calls this directly
no test coverage detected