Skip to content
Snippets Groups Projects
Select Git revision
  • d29f8f95f5757a795464524341a1d2f6e3e944f1
  • master default protected
  • genofire/ble-rewrite
  • koalo/bhi160
  • rahix/simple_menu
  • ch3/splashscreen
  • koalo/bhi160-works-but-dirty
  • ios-workarounds
  • koalo/wip/i2c-for-python
  • renze/safe_mode
  • renze/hatchery_apps
  • schneider/fundamental-test
  • koalo/factory-reset
  • msgctl/gfx_rle
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • schneider/bonding
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • rahix/bma
  • rahix/bhi
  • v1.3
  • v1.2
  • v1.1
  • v1.0
  • release-1
  • bootloader-v1
  • v0.0
28 results

filetransfer.c

Blame
  • Forked from card10 / firmware
    Source project has a limited visibility.
    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 */