void DJI_Pro_Test_Setup(void) { activation_msg.app_id =1002242; activation_msg.app_api_level = 2; activation_msg.app_ver = 1; memcpy(activation_msg.app_bundle_id,"1234567890123456789012", 32); key = "be8631fb6d726c96f5b935df3cc64510dd9e74febe60400192e0b8608593828e"; Pro_Config_Comm_Encrypt_Key(key); Pro_Link_Setup(); }
void Test_Pro_Link(void) { unsigned char buf[16]; ProSendParameter param; const char key[32] = {"this is key"}; //set the communication Pro_Config_Comm_Encrypt_Key(key); //session 0 buf[0] = 0x11; buf[1] = 0x22; param.pkg_type = 0; param.length = 2; param.buf = buf; param.need_encrypt = 1; Pro_Send_Interface(¶m); //session 1 buf[0] = 0x33; buf[1] = 0x44; param.pkg_type = 1; param.length = 2; param.ack_callback = Test_ACK_Callback; param.buf = buf; param.need_encrypt = 1; Pro_Send_Interface(¶m); //session 2~31 buf[0] = 0x55; buf[1] = 0x66; param.pkg_type = 2; param.length = 2; param.ack_timeout = 1000; //unit is ms param.ack_callback = Test_ACK_Callback; param.retry_time = 1; param.buf = buf; param.need_encrypt = 1; Pro_Send_Interface(¶m); //session 2~31 buf[0] = 0x77; buf[1] = 0x88; param.pkg_type = 2; param.length = 2; param.ack_timeout = 1000; //unit is ms param.ack_callback = Test_ACK_Callback; param.retry_time = 1; param.buf = buf; param.need_encrypt = 1; Pro_Send_Interface(¶m); }
/* * test activation */ void test_activation_ack_cmd_callback(ProHeader *header) { /* #define ACTIVATION_SUCCESS 0x0000 #define PARAM_ERROR 0x0001 #define DATA_ENC_ERROR 0x0002 #define NEW_DEVICE_TRY_AGAIN 0x0003 #define DJI_APP_TIMEOUT 0x0004 #define DJI_APP_NO_INTERNET 0x0005 #define SERVER_REFUSED 0x0006 #define LEVEL_ERROR 0x0007 */ unsigned short ack_data; printf("Sdk_ack_cmd0_callback,sequence_number=%d,session_id=%d,data_len=%d\n", header->sequence_number, header->session_id, header->length - EXC_DATA_SIZE); memcpy((unsigned char *)&ack_data,(unsigned char *)&header->magic, (header->length - EXC_DATA_SIZE)); if( is_sys_error(ack_data)) { printf("[DEBUG] SDK_SYS_ERROR!!! \n"); } else { char result[][50]={{"ACTIVATION_SUCCESS"},{"PARAM_ERROR"},{"DATA_ENC_ERROR"},{"NEW_DEVICE_TRY_AGAIN"},{"DJI_APP_TIMEOUT"},{" DJI_APP_NO_INTERNET"},{"SERVER_REFUSED"},{"LEVEL_ERROR"}}; printf("[ACTIVATION] Activation result: %s \n", *(result+ack_data)); activation_status_s = (unsigned char)ack_data; if(ack_data == 0) { Pro_Config_Comm_Encrypt_Key(key); printf("[ACTIVATION] set key %s\n",key); } else if(ack_data == 3) { /* new device, try again when activation is failed */ alarm(2); } } }