Exemplo n.º 1
0
        //---------------------------------------------------------------------
        //---------------------------------------------------------------------
        //
        //---------------------------------------------------------------------
        //---------------------------------------------------------------------
        //Manifest FakeManifest;
        public static Manifest myFakeManifest()
        {
            Manifest pm = new Manifest();

            //
            pm.app_size = 0;

            /*
            --manifest.json-- file
            {
                "manifest": {
                    "application": {
                    }
                }
            }
            */

            pm.bootloader = null;  //  NO Bootloader <- "manifest": { "application":
            pm.softdevice = null;  //  NO Softdevice <- "manifest": { "application":
            pm.softdevice_bootloader = null;  //  NO Softdevice_Bootloader <- "manifest": { "application":

            pm.application = new Firmware();// &FakeApplication;
            //

            //
            pm.application.bin_file = "dfu_temp.bin";  //"nrf51422_xxac_s110.bin";
            pm.application.dat_file = "dfu_temp.dat"; //"nrf51422_xxac_s110.dat";
            pm.application.init_packet_data = new InitPacketData();
            pm.application.bl_size = 0;
            pm.application.sd_size = 0;
            //

            //
            //        "init_packet_data": {

            //            "application_version": 0,             -> uint32_t application_version = 0x00000000;
            pm.application.init_packet_data.application_version = 0x00000000;

            //            "device_revision": 0,                 --> uint16_t hardware_revision   = 0x0000;
            pm.application.init_packet_data.device_revision = 0x0000;

            //            "device_type": 0,                     --> uint16_t hardware_version    = 0x0000;
            pm.application.init_packet_data.device_type = 0x0000;

            //            "firmware_crc16": 6302,               --> uint16_t image_crc           = 0x189e; --> decimal 6302
            pm.application.init_packet_data.firmware_crc16 = 0x189e;
            //            "softdevice_req": [                   --> uint16_t softdevice_len      = 0x0001; --> one entry in the array
            //                65534                             --> uint16_t softdevice_array    = 0xFFFE;
            pm.application.init_packet_data.softdevice_req[0] = 0xFFFE;
            pm.application.init_packet_data.softdevice_req[1] = 0;
            //            ]
            //        }
            pm.application.init_packet_data.compression_type = 0;
            pm.application.init_packet_data.firmware_hash = "";
            pm.application.init_packet_data.packet_version = 0;

            //

            return (pm);
        }
Exemplo n.º 2
0
        //__init__(this, zip_file_path, dfu_transport):
        //---------------------------------------------------------------------
        // This overload takes the ".bin" and ".dat" files rather than the "package"
        // This is only for programming the application, for which a fake manifest
        // is created
        public Dfu(String binFileName, String datFileName, DfuTransport dfu_transport)
        {
            /*
             * Initializes the dfu upgrade, unpacks zip and registers callbacks.
             *
             * @param zip_file_path: Path to the zip file with the firmware to upgrade
             * @type zip_file_path: str
             * @param dfu_transport: Transport backend to use to upgrade
             * @type dfu_transport: nordicsemi.dfu.dfu_transport.DfuTransport
             * @return
             */

            this.zip_file_path = "Unused zip_file_path";
            this.ready_to_send = true;
            this.response_opcode_received = 0;//None;
            #if false
            this.temp_dir = "TODO"; //tempfile.mkdtemp(prefix="nrf_dfu_");
            this.unpacked_zip_path = "TODO"; //os.path.join(this.temp_dir, 'unpacked_zip');
            this.manifest = null;//"TODO"; //Package.unpack_package(this.zip_file_path, this.unpacked_zip_path);
            #else
            this.temp_dir = "./";
            this.unpacked_zip_path = "./";
            //this.manifest = FakeManifest.myFakeManifest();//"TODO"; //Package.unpack_package(this.zip_file_path, this.unpacked_zip_path);
            this.manifest = FakeManifest.myFakeManifest_fromFiles(binFileName, datFileName);//"TODO"; //Package.unpack_package(this.zip_file_path, this.unpacked_zip_path);
            #endif

            if (dfu_transport != null)
                this.dfu_transport = dfu_transport;

            this.dfu_transport.register_events_callback(DfuEvent.TIMEOUT_EVENT, this.timeout_event_handler);
            this.dfu_transport.register_events_callback(DfuEvent.ERROR_EVENT, this.error_event_handler);
        }
Exemplo n.º 3
0
        /*
        --manifest.json-- file
        {
            "manifest": {
                "application": {
                    "bin_file": "nrf51422_xxac_s110.bin",
                    "dat_file": "nrf51422_xxac_s110.dat",
                    "init_packet_data": {
                        "application_version": 0,             --> uint32_t application_version = 0x00000000;
                        "device_revision": 0,                 --> uint16_t hardware_revision   = 0x0000;
                        "device_type": 0,                     --> uint16_t hardware_version    = 0x0000;
                        "firmware_crc16": 6302,               --> uint16_t image_crc           = 0x189e; --> decimal 6302
                        "softdevice_req": [                   --> uint16_t softdevice_len      = 0x0001; --> one entry in the array
                            65534                             --> uint16_t softdevice_array    = 0xFFFE;
                        ]
                    }
                }
            }
        }
        */
        //---------------------------------------------------------------------
        //---------------------------------------------------------------------
        //
        //---------------------------------------------------------------------
        //---------------------------------------------------------------------
        public static Manifest myFakeManifest_fromFiles(String binFileName, String datFileName)
        {
            Manifest pm = new Manifest();

            pm = myFakeManifest();

            pm.application.bin_file = binFileName; // "dfu_temp.bin";  //"nrf51422_xxac_s110.bin";
            pm.application.dat_file = datFileName; // "dfu_temp.dat"; //"nrf51422_xxac_s110.dat";

            return(pm);
        }