/** * \brief Send the chip ID information. * * \param name Not used. * \param recv_buf Receive buffer. * \param recv_len Receive buffer length. * * \return 0. */ static int cgi_chipInfo(struct netconn *client, const char *name, char *recv_buf, size_t recv_len) { (void)recv_buf; (void)recv_len; (void)name; /* Protect tx_buf buffer from concurrent access. */ sys_arch_sem_wait(&cgi_sem, 0); sprintf((char *)tx_buf, "{\"core_name\":\"%s\",\"arch_name\":\"%s\",\"sram_size\":\"%s\",\"flash_size\":\"%s\"}", chipid_eproc_name(CHIPID_EPRCOC), chipid_archnames(CHIPID_ARCH), chipid_sramsize(CHIPID_SRAMSIZ), chipid_nvpsize(CHIPID_NVPSIZ)); /* Send answer. */ http_sendOk(client, HTTP_CONTENT_JSON); /* Use NETCONN_COPY to avoid corrupting the buffer after releasing the semaphore. */ netconn_write(client, tx_buf, strlen((char *)tx_buf), NETCONN_COPY); /* Release semaphore to allow further use of tx_buf. */ sys_sem_signal(&cgi_sem); return 0; }
/** * \brief Send the chip ID information. * * \param name Not used. * \param recv_buf Receive buffer. * \param recv_len Receive buffer length. * * \return 0. */ static int cgi_chipInfo(const char *name, char *recv_buf, size_t recv_len) { UNUSED(recv_buf); UNUSED(recv_len); UNUSED(name); sprintf((char *)tx_buf, "{ \"core_name\":\"%s\", \"arch_name\":\"%s\", \"sram_size\":\"%s\",\"flash_size\":\"%s\", \"mem_boot_type\":\"%s\" }", chipid_eproc_name(CHIPID_EPRCOC), chipid_archnames(CHIPID_ARCH), chipid_sramsize(CHIPID_SRAMSIZ), chipid_nvpsize(CHIPID_NVPSIZ), chipid_nvptype(CHIPID_NVTYP)); http_sendOk(HTTP_CONTENT_JSON); http_write((const char *)tx_buf, strlen((char *)tx_buf)); return 0; }