1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- //
- // DialogOTATool.h
- // Aibrush
- //
- // Created by steven wu on 2020/8/12.
- // Copyright © 2020 taolei. All rights reserved.
- //
-
- #import <Foundation/Foundation.h>
- #import <CoreBluetooth/CoreBluetooth.h>
-
- //OTA专用的服务UUID,连接上外设后读取peripheral.services数组包含这个UUID,就支持OTA升级
- #define OTA_SERVICE_UUID 0xFEF5
- ///如下5个特征值都是OTA升级不同阶段,用来向蓝牙写数据使用的
- #define OTA_MEM_DEV_UUID @"8082CAA8-41A6-4021-91C6-56F9B954CC34"
- #define OTA_GPIO_MAP_UUID @"724249F0-5EC3-4B5F-8804-42345AF08651"
- #define OTA_PATCH_LEN_UUID @"9D84B9A3-000C-49D8-9183-855B673FDA31"
- #define OTA_PATCH_DATA_UUID @"457871E8-D516-4CA1-9116-57D0B17B9CB2"
- ///Dialog有2种OTA升级模式,好牙使用SPOTA,下面这个是SPOTA-Notify特征值
- #define OTA_SERV_STATUS_UUID @"5F78DF94-798C-46F5-990A-B3EB6A065C88"
- //Dialog的另一种SUOTA升级Notify特征值,好牙暂未使用
- //#define OTA_MEM_INFO_UUID @"6C53DB25-47A1-45FE-A022-7C92FB334FD4"
-
-
- #define memoryType 0x13
- #define memoryBank 0
- #define spiMOSIAddress 0x06
- #define spiMISOAddress 0x05
- #define spiCSAddress 0X03
- #define spiSCKAddress 0x00
-
- typedef enum {
- // Value zero must not be used !! Notifications are sent when status changes.
- AiBrush_SRV_STARTED = 0x01, // Valid memory device has been configured by initiator. No sleep state while in this mode
- AiBrush_CMP_OK = 0x02, // SPOTA process completed successfully.
- AiBrush_SRV_EXIT = 0x03, // Forced exit of SPOTAR service.
- AiBrush_CRC_ERR = 0x04, // Overall Patch Data CRC failed
- AiBrush_PATCH_LEN_ERR = 0x05, // Received patch Length not equal to PATCH_LEN characteristic value
- AiBrush_EXT_MEM_WRITE_ERR= 0x06, // External Mem Error (Writing to external device failed)
- AiBrush_INT_MEM_ERR = 0x07, // Internal Mem Error (not enough space for Patch)
- AiBrush_INVAL_MEM_TYPE = 0x08, // Invalid memory device
- AiBrush_APP_ERROR = 0x09, // Application error
-
- // SUOTAR application specific error codes
- AiBrush_IMG_STARTED = 0x10, // SPOTA started for downloading image (SUOTA application)
- AiBrush_INVAL_IMG_BANK = 0x11, // Invalid image bank
- AiBrush_INVAL_IMG_HDR = 0x12, // Invalid image header
- AiBrush_INVAL_IMG_SIZE = 0x13, // Invalid image size
- AiBrush_INVAL_PRODUCT_HDR= 0x14, // Invalid product header
- AiBrush_SAME_IMG_ERR = 0x15, // Same Image Error
- AiBrush_EXT_MEM_READ_ERR = 0x16, // Failed to read from external memory device
-
- } AiBrush_STATUS_VALUES;
-
-
- @protocol DialogOTAToolDelegate <NSObject>
-
- /*
- *返回升级进度至主界面
- return update progress to mainscreen
- 如果progress=1;则写入失败
- */
- - (void)returnUpdateProgress:(double)progress;
- /*
- *返回升级结果至主界面
- */
- - (void)returnUpdateResult:(BOOL)isSuccess errorMsg:(NSString*)errorMsg ;
- @end
-
-
-
- @interface DialogOTATool : NSObject
-
- + (instancetype)shared;
-
- @property (nonatomic, weak) id <DialogOTAToolDelegate> delegate;
-
- - (void)OTAupdate:(NSString *)fileStr;
- - (void)rebootDevice;
-
- ///如下4个方法:在你的蓝牙中心管理者中调用,用法请参考“好牙”App
- @property (nonatomic, weak) CBPeripheral *peripheral;
- - (void)analyzeBleValueForCharacteristic:(CBCharacteristic *)characteristic;
- - (void)judgeIfDoStepForOTA;
- //- (void)judgeIfOTAService:(CBService *)service andOpenOTANotifyForPeripheral:(CBPeripheral *)peripheral;
- - (void)judgeIfOTACharacteristics:(NSArray *)characteristics andOpenOTANotifyForPeripheral:(CBPeripheral *)peripheral;
-
- @end
|