int start() { ALOGD("[WIFI HAL]Set significant wifi change config"); WifiRequest request(familyId(), ifaceId()); int result = createSetupRequest(request); if (result < 0) { return result; } result = requestResponse(request); if (result < 0) { ALOGE("failed to set significant wifi change config %d", result); return result; } ALOGI("successfully set significant wifi change config"); result = createFeatureRequest(request, GSCAN_SUBCMD_ENABLE_GSCAN, 1); if (result < 0) { return result; } registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS); result = requestResponse(request); if (result < 0) { ALOGE("failed to start scan; result = %d", result); unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS); return result; } ALOGI("successfully restarted the scan"); return result; }
int start() { ALOGD("1) GScan Setting configuration: "); WifiRequest request(familyId(), ifaceId()); int result = createSetupRequest(request); if (result != WIFI_SUCCESS) { ALOGE("failed to create setup request; result = %d", result); return result; } result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("failed to configure setup; result = %d", result); return result; } request.destroy(); result = createScanConfigRequest(request); if (result != WIFI_SUCCESS) { ALOGE("failed to create scan config request; result = %d", result); return result; } result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("failed to configure scan; result = %d", result); return result; } ALOGD("2) Enable GScan: "); result = createStartRequest(request); if (result != WIFI_SUCCESS) { ALOGE("failed to create start request; result = %d", result); return result; } registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE); registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_COMPLETE_SCAN); result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("failed to start scan; result = %d", result); registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_COMPLETE_SCAN); unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE); return result; } result = enableFullScanResultsIfRequired(); return result; }
int Alltrax::readTemp() { //This function returns the tempurature in celcius that the controller reports //Pre: none //Post: Celcius value of controller is returned as a float //byte array initialization byte* returnArray; //send command to controller byte tempArray[7] = {0x5B,0x04,0x2C,0x00,0x00,0x00,0x75}; returnArray = requestResponse(tempArray); if (returnArray[0] == 0) { return -1; } //I think this will work. //This should correctly convert the returned value to Celcius //This math might be slightly incorrect as well, one source says that there is 2.048 counts per degree celcius with a offset at 0 degrees celcius = 559 counts int temp = ((returnArray[4])*16*16)+(returnArray[3]); temp = temp - 559; int val = .5*temp; return val; //End return }
bool QNearFieldTagType3Symbian::hasNdefMessage() { #if 0 BEGIN bool hasNdef = false; QList<quint16> blockList; // first block blockList.append(0); // NDEF service quint16 serviceCode = 0x0B; QMap<quint16, QList<quint16> > serviceBlockList; serviceBlockList.insert(serviceCode, blockList); QNearFieldTarget::RequestId id = check(serviceBlockList); if (_waitForRequestCompletedNoSignal(id)) { QMap<quint16, QByteArray> result = requestResponse(id).value<QMap<quint16, QByteArray> >(); if (result.contains(serviceCode)) { const QByteArray& lens = result.value(serviceCode); if (!lens.isEmpty()) { hasNdef = (lens.at(0) > 0); } } } END return hasNdef; #endif return _hasNdefMessage(); }
int execute() { WifiRequest request(familyId(), ifaceId()); ALOGD("retrieving %d scan results", mMax); for (int i = 0; i < 10 && mRetrieved < mMax; i++) { int result = createRequest(request, (mMax - mRetrieved), mFlush); if (result < 0) { ALOGE("failed to create request"); return result; } int prev_retrieved = mRetrieved; result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("failed to retrieve scan results; result = %d", result); return result; } if (mRetrieved == prev_retrieved || mCompleted) { /* no more items left to retrieve */ break; } request.destroy(); } ALOGD("GetScanResults read %d results", mRetrieved); *mNum = mRetrieved; return WIFI_SUCCESS; }
quint8 QNearFieldTagType4Symbian::version() { BEGIN quint8 result = 0; QByteArray resp; resp.append(char(0x90)); resp.append(char(0x00)); QNearFieldTarget::RequestId id = selectNdefApplication(); if (_waitForRequestCompletedNoSignal(id)) { if (requestResponse(id).toByteArray().right(2) == resp) { // response is ok // select cc LOG("select cc"); QNearFieldTarget::RequestId id1 = selectCC(); if (_waitForRequestCompletedNoSignal(id1)) { if (requestResponse(id1).toBool()) { // response is ok // read cc LOG("read cc"); QNearFieldTarget::RequestId id2 = read(0x0001,0x0002); if (_waitForRequestCompletedNoSignal(id2)) { if (requestResponse(id2).toByteArray().right(2) == resp) { // response is ok result = requestResponse(id2).toByteArray().at(0); } } } } } } LOG("version is "<<result); END return result; }
int start() { // ALOGD("Start debug command"); WifiRequest request(familyId(), ifaceId()); int result = createRequest(request); if (result != WIFI_SUCCESS) { ALOGE("Failed to create debug request; result = %d", result); return result; } result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("Failed to register debug response; result = %d", result); } return result; }
int start() { ALOGD("[WIFI HAL]Executing hotlist setup request, num = %d", mParams.num_ap); WifiRequest request(familyId(), ifaceId()); int result = createSetupRequest(request); if (result < 0) { return result; } result = requestResponse(request); if (result < 0) { ALOGI("Failed to execute hotlist setup request, result = %d", result); //unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_FOUND); //unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST); return result; } ALOGI("Successfully set %d APs in the hotlist", mParams.num_ap); result = createFeatureRequest(request, GSCAN_SUBCMD_ENABLE_GSCAN, 1); if (result < 0) { return result; } registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_FOUND); registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST); result = requestResponse(request); if (result < 0) { ALOGE("failed to start scan; result = %d", result); unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_FOUND); unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST); return result; } ALOGI("successfully restarted the scan"); return result; }
int start() { ALOGD("Start memory dump command"); WifiRequest request(familyId(), ifaceId()); int result = request.create(GOOGLE_OUI, LOGGER_TRIGGER_MEM_DUMP); if (result != WIFI_SUCCESS) { ALOGE("Failed to create trigger fw memory dump request; result = %d", result); return result; } result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("Failed to register trigger memory dump response; result = %d", result); } return result; }
int start() { ALOGD("Start get packet fate command\n"); WifiRequest request(familyId(), ifaceId()); int result = createRequest(request); if (result < 0) { ALOGE("Failed to create get pkt fate request; result = %d\n", result); return result; } result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("Failed to register get pkt fate response; result = %d\n", result); } return result; }
virtual int cancel() { ALOGD("Disabling Full scan results"); WifiRequest request(familyId(), ifaceId()); int result = createRequest(request, GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS, 0); if (result != WIFI_SUCCESS) { ALOGE("failed to create request; result = %d", result); } else { result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("failed to disable full scan results;result = %d", result); } } unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS); return WIFI_SUCCESS; }
byte Alltrax::readShutdown() { //checks to see if the controller is shutdown //returns 1 if there is an error, 0 if not //Pre: none //Post: 1 if error, -1 if transmition error, 0 if the controller is fine //byte array initialization byte* returnArray; //send command to controller byte tempArray[7] = {0x5B,0x04,0x3B,0x00,0x00,0x00,0x66}; returnArray = requestResponse(tempArray); if (returnArray[0] == 0) { return -1; } return returnArray[3]; }
float Alltrax::readCurrent() { //returns the output Current //Pre: None //Post: returns the Output current as a float // -1 if there was an error //byte array initialization byte* returnArray; //send command to controller byte tempArray[7] = {0x5B,0x04,0x60,0x00,0x00,0x00,0x41}; returnArray = requestResponse(tempArray); if (returnArray[0] == 0) { return -1; } float val = ((returnArray[4])*16*16)+(returnArray[3]); return val; }
int Alltrax::readTopSpeed() { //returns the Top Speed Percent //Pre: None //Post: returns the Top Speed Percent as a int // -1 if there was an error //byte array initialization byte* returnArray; //send command to controller byte tempArray[7] = {0x5B,0x02,0x38,0x00,0x00,0x00,0x6b}; returnArray = requestResponse(tempArray); if (returnArray[0] == 0) { return -1; } int val = (returnArray[4]); return val; }
int Alltrax::readMaxCurrent() { //returns the Max output current percentage //Pre: None //Post: returns the Output current as a int // -1 if there was an error //byte array initialization byte* returnArray; //send command to controller byte tempArray[7] = {0x5B,0x02,0x04,0x00,0x00,0x00,0x9f}; returnArray = requestResponse(tempArray); if (returnArray[0] == 0) { return -1; } int val = (returnArray[4]); return val; }
virtual int cancel() { /* unregister event handler */ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_FOUND); unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST); /* create set hotlist message with empty hotlist */ WifiRequest request(familyId(), ifaceId()); int result = createTeardownRequest(request); if (result < 0) { return result; } result = requestResponse(request); if (result < 0) { return result; } ALOGI("Successfully reset APs in current hotlist"); return result; }
float Alltrax::readVoltage() { //returns the battery Voltage //Pre: None //Post: Battery Voltage as a float // -1 if there was an error //byte array initialization byte* returnArray; //send command to controller byte tempArray[7] = {0x5B,0x04,0x39,0x00,0x00,0x00,0x68}; returnArray = requestResponse(tempArray); if (returnArray[0] == 0) { return -1; } float val = ((returnArray[4])*16*16)+(returnArray[3]); float voltage = val * .1025; return voltage; }
int start() { WifiRequest request(familyId(), ifaceId()); int result = createRequest(request, GSCAN_SUBCMD_ENABLE_FULL_SCAN_RESULTS, 1); if (result != WIFI_SUCCESS) { ALOGE("failed to create request; result = %d", result); return result; } registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS); result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("failed to enable full scan results; result = %d", result); unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS); return result; } return result; }
virtual int cancel() { /* unregister event handler */ unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SIGNIFICANT_CHANGE_RESULTS); /* create set significant change monitor message with empty hotlist */ WifiRequest request(familyId(), ifaceId()); int result = createTeardownRequest(request); if (result < 0) { return result; } result = requestResponse(request); if (result < 0) { return result; } ALOGI("successfully reset significant wifi change config"); return result; }
virtual int cancel() { ALOGD("Stopping scan"); WifiRequest request(familyId(), ifaceId()); int result = createStopRequest(request); if (result != WIFI_SUCCESS) { ALOGE("failed to create stop request; result = %d", result); } else { result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("failed to stop scan; result = %d", result); } } unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_COMPLETE_SCAN); unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE); disableFullScanResultsIfRequired(); return WIFI_SUCCESS; }
int Alltrax::readThrottle() { //This function returns the throttle position from 0 to 255 //to get a percentage divide this number by 2.55 //Pre: none //Post: throttle position is reported as an int between 0 and 255 // -1 if there was an error //byte array initialization byte* returnArray ; //send command to controller byte tempArray[7] = {0x5B,0x04,0x20,0x00,0x00,0x00,0x81}; returnArray = requestResponse(tempArray); if (returnArray[0] == 0) { return -1; } //The returned value by the controller will be a position on a scale of 0 through 255 int throttlePos = returnArray[3]; return throttlePos; //return 0; }
virtual int cancel() { /* Send a command to driver to stop generating logging events */ ALOGV("Clear loghandler"); /* unregister event handler */ unregisterVendorHandler(GOOGLE_OUI, GOOGLE_DEBUG_RING_EVENT); WifiRequest request(familyId(), ifaceId()); int result = request.create(GOOGLE_OUI, LOGGER_RESET_LOGGING); if (result != WIFI_SUCCESS) { ALOGE("failed to create reset request; result = %d", result); return result; } result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("failed to request reset; result = %d", result); return result; } ALOGD("Success to clear loghandler"); return WIFI_SUCCESS; }
virtual int handleEvent(WifiEvent& event) { wifi_ring_buffer_id ring_id; char *buffer = NULL; int buffer_size = 0; nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = event.get_vendor_data_len(); int event_id = event.get_vendor_subcmd(); ALOGI("Got event: %d", event_id); if (vendor_data == NULL || len == 0) { ALOGE("No Debug data found"); return NL_SKIP; } if (event_id == GOOGLE_DEBUG_MEM_DUMP_EVENT) { for (nl_iterator it(vendor_data); it.has_next(); it.next()) { if (it.get_type() == LOGGER_ATTRIBUTE_FW_DUMP_LEN) { mBuffSize = it.get_u32(); } else if (it.get_type() == LOGGER_ATTRIBUTE_RING_DATA) { buffer_size = it.get_len(); buffer = (char *)it.get_data(); /* } else if (it.get_type() == LOGGER_ATTRIBUTE_FW_ERR_CODE) { mErrCode = it.get_u32(); */ } else { ALOGW("Ignoring invalid attribute type = %d, size = %d", it.get_type(), it.get_len()); } } if (mBuffSize) { ALOGD("dump size: %d meta data size: %d", mBuffSize, buffer_size); if (mBuff) free(mBuff); mBuff = (char *)malloc(mBuffSize + buffer_size); if (!mBuff) { ALOGE("Buffer allocation failed"); return NL_SKIP; } memcpy(mBuff, buffer, buffer_size); WifiRequest request(familyId(), ifaceId()); int result = request.create(GOOGLE_OUI, LOGGER_GET_MEM_DUMP); if (result != WIFI_SUCCESS) { ALOGE("Failed to create get memory dump request; result = %d", result); free(mBuff); return NL_SKIP; } nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); result = request.put_u32(LOGGER_ATTRIBUTE_FW_DUMP_LEN, mBuffSize); if (result != WIFI_SUCCESS) { ALOGE("Failed to put get memory dump request; result = %d", result); return result; } result = request.put_u64(LOGGER_ATTRIBUTE_FW_DUMP_DATA, (uint64_t)(mBuff+buffer_size)); if (result != WIFI_SUCCESS) { ALOGE("Failed to put get memory dump request; result = %d", result); return result; } request.attr_end(data); mBuffSize += buffer_size; result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("Failed to register get momory dump response; result = %d", result); } } else { ALOGE("dump event missing dump length attribute"); return NL_SKIP; } } return NL_OK; }
virtual int handleResponse(WifiEvent& reply) { ALOGD("In MemoryDumpCommand::handleResponse"); if (reply.get_cmd() != NL80211_CMD_VENDOR) { ALOGD("Ignoring reply with cmd = %d", reply.get_cmd()); return NL_SKIP; } nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = reply.get_vendor_data_len(); ALOGD("len = %d", len); if (vendor_data == NULL || len == 0) { ALOGE("no vendor data in memory dump response; ignoring it"); return NL_SKIP; } for (nl_iterator it(vendor_data); it.has_next(); it.next()) { if (it.get_type() == LOGGER_ATTRIBUTE_FW_DUMP_LEN) { mBuffSize = it.get_u32(); if (mBuff) free(mBuff); mBuff = (char *)malloc(mBuffSize); if (!mBuff) { ALOGE("Buffer allocation failed"); return NL_SKIP; } WifiRequest request(familyId(), ifaceId()); int result = request.create(GOOGLE_OUI, LOGGER_GET_MEM_DUMP); if (result != WIFI_SUCCESS) { ALOGE("Failed to create get memory dump request; result = %d", result); free(mBuff); return NL_SKIP; } nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); result = request.put_u32(LOGGER_ATTRIBUTE_FW_DUMP_LEN, mBuffSize); if (result != WIFI_SUCCESS) { ALOGE("Failed to put get memory dump request; result = %d", result); return result; } result = request.put_u64(LOGGER_ATTRIBUTE_FW_DUMP_DATA, (uint64_t)mBuff); if (result != WIFI_SUCCESS) { ALOGE("Failed to put get memory dump request; result = %d", result); return result; } request.attr_end(data); result = requestResponse(request); if (result != WIFI_SUCCESS) { ALOGE("Failed to register get momory dump response; result = %d", result); } } else if (it.get_type() == LOGGER_ATTRIBUTE_FW_DUMP_DATA) { ALOGI("Initiating memory dump callback"); if (mHandler.on_firmware_memory_dump) { (*mHandler.on_firmware_memory_dump)(mBuff, mBuffSize); } if (mBuff) { free(mBuff); mBuff = NULL; } } else { ALOGW("Ignoring invalid attribute type = %d, size = %d", it.get_type(), it.get_len()); } } return NL_OK; }