Merge "Thread HAL: support dynamic radio URLs" into main
This commit is contained in:
commit
db7bab9eba
3 changed files with 22 additions and 19 deletions
|
@ -26,24 +26,29 @@
|
|||
using aidl::android::hardware::threadnetwork::IThreadChip;
|
||||
using aidl::android::hardware::threadnetwork::ThreadChip;
|
||||
|
||||
namespace {
|
||||
void addThreadChip(int id, const char* url) {
|
||||
binder_status_t status;
|
||||
const std::string serviceName(std::string() + IThreadChip::descriptor + "/chip" +
|
||||
std::to_string(id));
|
||||
|
||||
ALOGI("ServiceName: %s, Url: %s", serviceName.c_str(), url);
|
||||
|
||||
auto threadChip = ndk::SharedRefBase::make<ThreadChip>(url);
|
||||
|
||||
CHECK_NE(threadChip, nullptr);
|
||||
|
||||
status = AServiceManager_addService(threadChip->asBinder().get(), serviceName.c_str());
|
||||
CHECK_EQ(status, STATUS_OK);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
CHECK_GT(argc, 1);
|
||||
std::vector<std::shared_ptr<ThreadChip>> threadChips;
|
||||
aidl::android::hardware::threadnetwork::Service service;
|
||||
|
||||
for (int id = 0; id < argc - 1; id++) {
|
||||
binder_status_t status;
|
||||
const std::string serviceName(std::string() + IThreadChip::descriptor + "/chip" +
|
||||
std::to_string(id));
|
||||
auto threadChip = ndk::SharedRefBase::make<ThreadChip>(argv[id + 1]);
|
||||
|
||||
CHECK_NE(threadChip, nullptr);
|
||||
|
||||
status = AServiceManager_addService(threadChip->asBinder().get(), serviceName.c_str());
|
||||
CHECK_EQ(status, STATUS_OK);
|
||||
|
||||
ALOGI("ServiceName: %s, Url: %s", serviceName.c_str(), argv[id + 1]);
|
||||
threadChips.push_back(std::move(threadChip));
|
||||
addThreadChip(id, argv[id + 1]);
|
||||
}
|
||||
|
||||
ALOGI("Thread Network HAL is running");
|
||||
|
|
|
@ -32,11 +32,9 @@ namespace android {
|
|||
namespace hardware {
|
||||
namespace threadnetwork {
|
||||
|
||||
ThreadChip::ThreadChip(char* url) : mUrl(), mRxFrameBuffer(), mCallback(nullptr) {
|
||||
ThreadChip::ThreadChip(const char* url) : mUrl(url), mRxFrameBuffer(), mCallback(nullptr) {
|
||||
const char* interfaceName;
|
||||
|
||||
CHECK_EQ(mUrl.Init(url), 0);
|
||||
|
||||
interfaceName = mUrl.GetProtocol();
|
||||
CHECK_NE(interfaceName, nullptr);
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#include <aidl/android/hardware/threadnetwork/IThreadChipCallback.h>
|
||||
|
||||
#include "lib/spinel/spinel_interface.hpp"
|
||||
#include "lib/url/url.hpp"
|
||||
#include "mainloop.hpp"
|
||||
#include "radio_url.hpp"
|
||||
|
||||
#include <android/binder_auto_utils.h>
|
||||
#include <android/binder_ibinder.h>
|
||||
|
@ -34,7 +34,7 @@ namespace threadnetwork {
|
|||
|
||||
class ThreadChip : public BnThreadChip, ot::Posix::Mainloop::Source {
|
||||
public:
|
||||
ThreadChip(char* url);
|
||||
ThreadChip(const char* url);
|
||||
~ThreadChip() {}
|
||||
|
||||
ndk::ScopedAStatus open(const std::shared_ptr<IThreadChipCallback>& in_callback) override;
|
||||
|
@ -55,7 +55,7 @@ class ThreadChip : public BnThreadChip, ot::Posix::Mainloop::Source {
|
|||
ndk::ScopedAStatus initChip(const std::shared_ptr<IThreadChipCallback>& in_callback);
|
||||
ndk::ScopedAStatus deinitChip();
|
||||
|
||||
ot::Url::Url mUrl;
|
||||
ot::Posix::RadioUrl mUrl;
|
||||
std::shared_ptr<ot::Spinel::SpinelInterface> mSpinelInterface;
|
||||
ot::Spinel::SpinelInterface::RxFrameBuffer mRxFrameBuffer;
|
||||
std::shared_ptr<IThreadChipCallback> mCallback;
|
||||
|
|
Loading…
Reference in a new issue