|
@@ -574,3 +574,58 @@ void shellmatta_ymodem_disable(void)
|
|
|
{
|
|
|
ymodem_is_enabled = false;
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief starts the ymodem receive module
|
|
|
+ * @param[in] handle shellmatta instance handle
|
|
|
+ * @param[in] buffer pointer to where the received data is stored
|
|
|
+ * @param[in] fileSize pointer to where the file size is stored
|
|
|
+ * @param[in] packetSize pointer to where the packet size is stored
|
|
|
+ * @param[in] callbacks callback functions for ymodem module
|
|
|
+ * @note disables the transport layer if active
|
|
|
+*/
|
|
|
+uint8_t shellmatta_ymodem( shellmatta_handle_t handle,
|
|
|
+ uint8_t* buffer,
|
|
|
+ uint32_t* fileSize,
|
|
|
+ uint16_t* packetSize,
|
|
|
+ shellmatta_ymodem_callbacks_t callbacks)
|
|
|
+{
|
|
|
+#ifdef SHELLMATTA_TRANSPORT
|
|
|
+ /* disable transport layer so control symbols won't be caught by it */
|
|
|
+ ((shellmatta_instance_t*)handle)->transportEnabled = false;
|
|
|
+#endif
|
|
|
+ shellmatta_ymodem_init(handle, buffer, fileSize, packetSize, callbacks);
|
|
|
+
|
|
|
+ /* send initial ymodem symbol to start transmission */
|
|
|
+ shellmatta_ymodem_control(handle, YMODEM_CRC);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Resets the ymodem module
|
|
|
+ * @param[in] doCancel Set this flag to execute the cancel-callback function within the ymodem-reset function
|
|
|
+ * @note call this function after file transmission is done or cancelled
|
|
|
+*/
|
|
|
+void shellmatta_ymodem_end(shellmatta_handle_t handle, bool doCancel)
|
|
|
+{
|
|
|
+ shellmatta_ymodem_reset(handle, doCancel);
|
|
|
+ /* clear any possibly leftover inputs */
|
|
|
+ utils_clearInput((shellmatta_instance_t*)handle);
|
|
|
+}
|
|
|
+
|
|
|
+void shellmatta_ymodem_set_enable(bool doEnable)
|
|
|
+{
|
|
|
+ if (doEnable)
|
|
|
+ {
|
|
|
+ shellmatta_ymodem_enable();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ shellmatta_ymodem_disable();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+bool shellmatta_ymodem_is_active(void)
|
|
|
+{
|
|
|
+ return shellmatta_ymodem_get_current_datatype() != YMODEM_NONE;
|
|
|
+}
|