Select Git revision
filetransfer.c
Forked from
card10 / firmware
Source project has a limited visibility.
-
Hauke Mehrtens authored
Replace printf with LOG_ERR. Signed-off-by:
Hauke Mehrtens <hauke@hauke-m.de>
Hauke Mehrtens authoredReplace printf with LOG_ERR. Signed-off-by:
Hauke Mehrtens <hauke@hauke-m.de>
filetransfer.c 10.02 KiB
/*
* BLE (Bluetooth Low energy) file transfer service.
*
* This file provides a BLE service and a characteristic which allows to
* write the content of the mytest.py file over BLE into the file system.
* We haven't found any existing BLE service which provides such a
* functionality so we implemented our own service.
* The service uses the UUID in fileTransSvc
* The characteristic uses the UUID in attTxChConfigUuid
* BLE point to point links use a pretty small MTU (min 23 bytes, max 244
* bytes) which is negotiated between the central and the peripheral (card10).
*
* The first byte of each message is the type of message being send,
* different types are supported and based on this type the next bytes
* have different meaning.
*
* TODOs:
* * File deletion
* * File read
* * Directory creation
* * Directory listing
*/
#include "wsf_types.h"
#include "wsf_os.h"
#include "wsf_buf.h"
#include "wsf_timer.h"
#include "wsf_trace.h"
#include "app_ui.h"
#include "fit/fit_api.h"
#include "hci_vs.h"
#include <epicardium.h>
#include "modules/log.h"
#include "util/bstream.h"
#include "att_api.h"
#include "FreeRTOS.h"
#include "crc32.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <machine/endian.h>
/*!< \brief Service start handle. */
#define FILE_TRANS_START_HDL 0x820
/*!< \brief Service end handle. */
#define FILE_TRANS_END_HDL (FILE_TRANS_MAX_HDL - 1)
#define FILE_TRANS_UUID_SUFFIX \
0x42, 0x23, 0x42, 0x23, 0x42, 0x23, 0x42, 0x23, 0x42, 0x23, 0x42, 0x23
#define FILE_TRANS_UUID_PREFIX 0x01, 0x23, 0x42
/*
* This has to match in order and number of members to the functions
* called in fileTransAddGroupDyn() otherwise the stack breaks.
*/
enum {
/*!< \brief File transfer service declaration */
FILE_TRANS_SVC_HDL = FILE_TRANS_START_HDL,
/*!< \brief File transfer Central tx characteristic */
FILE_TRANS_CENTRAL_TX_CH_HDL,
/*!< \brief File transfer Central tx value */
FILE_TRANS_CENTRAL_TX_VAL_HDL,
/*!< \brief File transfer Central rx characteristic */