void ARCONTROLLER_Network_Delete (ARCONTROLLER_Network_t **networkController) { // -- Delete the Network Controller -- if (networkController != NULL) { if ((*networkController) != NULL) { (*networkController)->state = ARCONTROLLER_NETWORK_STATE_STOPPED; ARSAL_Mutex_Destroy (&((*networkController)->mutex)); // Check if the device has video if ((*networkController)->hasVideo) { ARCONTROLLER_Stream_Delete (&((*networkController)->videoController)); } //NO else ; device has not video ARCONTROLLER_Network_StopReaderThreads (*networkController); //TODO read error !!!!!!!!!! ARCONTROLLER_Network_StopNetworkThreads (*networkController); //TODO read error !!!!!!!!!! ARNETWORK_Manager_Delete(&((*networkController)->networkManager)); ARDISCOVERY_Device_DeleteARNetworkAL ((*networkController)->discoveryDevice, &((*networkController)->networkALManager)); //TODO read error !!!!!!!!!! ARDISCOVERY_Device_Delete (&((*networkController)->discoveryDevice)); free (*networkController); (*networkController) = NULL; } } }
void stopNetwork (BD_MANAGER_t *deviceManager) { int failed = 0; eARNETWORK_ERROR netError = ARNETWORK_OK; eARNETWORKAL_ERROR netAlError = ARNETWORKAL_OK; int pingDelay = 0; // 0 means default, -1 means no ping ARSAL_PRINT(ARSAL_PRINT_INFO, TAG, "- Stop ARNetwork"); // ARNetwork cleanup if (deviceManager->netManager != NULL) { printf("Stop Manager Network !! \n"); ARNETWORK_Manager_Stop(deviceManager->netManager); if (deviceManager->rxThread != NULL) { printf("Detruit le thread rx !! \n"); ARSAL_Thread_Join(deviceManager->rxThread, NULL); ARSAL_Thread_Destroy(&(deviceManager->rxThread)); deviceManager->rxThread = NULL; } if (deviceManager->txThread != NULL) { printf("Detruit le thread tx !! \n"); ARSAL_Thread_Join(deviceManager->txThread, NULL); ARSAL_Thread_Destroy(&(deviceManager->txThread)); deviceManager->txThread = NULL; } } if (deviceManager->alManager != NULL) { printf("Arrête le manager Networkal et ferme la connexion wifi !! \n"); ARNETWORKAL_Manager_Unlock(deviceManager->alManager); ARNETWORKAL_Manager_CloseWifiNetwork(deviceManager->alManager); } printf("Supprime les managers\n"); ARNETWORK_Manager_Delete(&(deviceManager->netManager)); ARNETWORKAL_Manager_Delete(&(deviceManager->alManager)); }
int ARSTREAM_Reader_TestBenchMain (int argc, char *argv[]) { int retVal = 0; appName = argv[0]; if (argc > 3) { ARSTREAM_ReaderTb_printUsage (); return 1; } char *ip = __IP; char *outPath = NULL; if (argc >= 2) { ip = argv[1]; } if (argc >= 3) { outPath = argv[2]; } ARSAL_PRINT (ARSAL_PRINT_WARNING, __TAG__, "IP = %s", ip); int nbInBuff = 1; ARNETWORK_IOBufferParam_t inParams; ARSTREAM_Reader_InitStreamAckBuffer (&inParams, ACK_BUFFER_ID); int nbOutBuff = 1; ARNETWORK_IOBufferParam_t outParams; ARSTREAM_Reader_InitStreamDataBuffer (&outParams, DATA_BUFFER_ID, ARSTREAM_TB_FRAG_SIZE, ARSTREAM_TB_MAX_NB_FRAG); eARNETWORK_ERROR error; eARNETWORKAL_ERROR specificError = ARNETWORKAL_OK; ARNETWORKAL_Manager_t *osspecificManagerPtr = ARNETWORKAL_Manager_New(&specificError); if(specificError == ARNETWORKAL_OK) { specificError = ARNETWORKAL_Manager_InitWifiNetwork(osspecificManagerPtr, ip, SENDING_PORT, READING_PORT, 1000); } else { ARSAL_PRINT (ARSAL_PRINT_ERROR, __TAG__, "Error during ARNETWORKAL_Manager_New call : %s", ARNETWORKAL_Error_ToString(specificError)); } if(specificError == ARNETWORKAL_OK) { g_Manager = ARNETWORK_Manager_New(osspecificManagerPtr, nbInBuff, &inParams, nbOutBuff, &outParams, READER_PING_DELAY, NULL, NULL, &error); } else { ARSAL_PRINT (ARSAL_PRINT_ERROR, __TAG__, "Error during ARNETWORKAL_Manager_InitWifiNetwork call : %s", ARNETWORKAL_Error_ToString(specificError)); error = ARNETWORK_ERROR; } if ((g_Manager == NULL) || (error != ARNETWORK_OK)) { ARSAL_PRINT (ARSAL_PRINT_ERROR, __TAG__, "Error during ARNETWORK_Manager_New call : %s", ARNETWORK_Error_ToString(error)); return 1; } pthread_t netsend, netread; pthread_create (&netsend, NULL, ARNETWORK_Manager_SendingThreadRun, g_Manager); pthread_create (&netread, NULL, ARNETWORK_Manager_ReceivingThreadRun, g_Manager); retVal = ARSTREAM_ReaderTb_StartStreamTest (g_Manager, outPath); ARNETWORK_Manager_Stop (g_Manager); pthread_join (netread, NULL); pthread_join (netsend, NULL); ARNETWORK_Manager_Delete (&g_Manager); ARNETWORKAL_Manager_CloseWifiNetwork(osspecificManagerPtr); ARNETWORKAL_Manager_Delete(&osspecificManagerPtr); return retVal; }