bluetooth LE MVC architecture - model-view-controller

I am developing an Android app that connects to a device and send command to get its information such as version number.
I am building it using the Bluetooth LE sample code which has DeviceScanActivity, DeviceControlActivity and BluetoothLeService.
I am trying to understand the structure so I can make the code separate from GUI and low level operations.
Is DeviceControlActivity equivalent to View + Control in MVC model? Is BluetoothLeService equivalent to Model?
I want to have a class separate from GUI that has functions to operate the device. eg. contains a function called getVersion(). Does this class belong to Model as well? How should I implement this class along with BluetoothLeService?
Basically I want to have a hierarchy as UI->a Class of functions->Bluetooth rx & tx.

I created an instance of the class of functions and I derived command data from it.
Then I sent this command to BluetoothLeService.

Related

How can i set the api version on a generic controller when loading a plugin?

I have some plugin's which are basically input and output type definitions. I have a generic controller which i can add to the mvc pipeline. All works fine.
but I'm having trouble setting the api version on this generic controller. I know you can set this based upon an attribute on top of the controller class. But since you can't have this dynamic (attribute) don't allow it, i have no way to set the version for each instance of the generic controller.
Currently i just compile the controller for each instance on runtime and register i using the roslyn compiler.
is there a way to set the api-version somewhere in the pipeline of registering controllers in the mvc pipeline and endup with different api versions endpoints.
This can be achieved by using the Conventions API. It was designed to support this exact type of scenario:
https://github.com/microsoft/aspnet-api-versioning/wiki/API-Version-Conventions
This will only work on closed-generics, but it shouldn't be too much work to make that happen. Here's a couple of basic examples:
// typed, closed generic
options.Conventions.Controller<GenericController<PlugIn1>>().HasApiVersion(1,0);
// untyped, closed generic
var controllerType = typeof(GenericController<>).MakeGenericType(new []{typeof(PlugIn1)});
options.Conventions.Controller(controllerType).HasApiVersion(1,0);
You can also author your own custom conventions a la IControllerConvention. This approach could be used to version all controllers that inherit from GenericController<>. Then you just need to add it to the conventions like this:
options.Conventions.Add(new PlugInControllerConvention());
Hopefully that's enough to get you started. Feel free to ask more questions.

How to add google map and map pins using Xamarin cross platform

I'm new to the Xamarin. I need to create a small application to make use phone resources and google map.
For resources access like, call, sms, flash on/off you can make use these
phoneDialer.MakePhoneCall(phoneNo);
smsMessenger.SendSms(phoneNo, smsMessage);
CrossLamp.Current.TurnOn();
CrossLamp.Current.TurnOff();
I think this will help you get some idea. You can also create a utility class where you can create a function and make use these for all platform and you can call the corresponding functions whenever it is necessary.

How to implement global VB6 error handler?

The global VB6 error handler product referred to in the following link claims to "install a small callback hook into the VBE6 debugger":
http://www.everythingaccess.com/simplyvba/globalerrorhandler/howitworks.htm
I would like to implement this product myself because I would like more control over what it is doing. How is the above product likely to be achieving what it does?
The product you are looking at is a COM component. From the documentation that is available on the web site, it sounds like the COM component implements particular component classes. The first thing to do, if you already have the product, would be to fire up SysInternals procmon, run regsvr32 on the DLL, and figure out what component classes are implemented from the registry entries that are created. Once you know this, MSDN may be able to tell you what interfaces correspond to those component classes.
Microsoft developed a framework called Active Scripting that allows you to host a script engine and inject debugging capabilities. If one assumes that VB6 produces an exe that ties into that framework, you might be able to do:
Create a COM component that implements IApplicationDebugger
Implement IApplicationDebugger::onHandleBreakPoint to be able to respond to errors in the VB code
Read MSDN KB Q222966 to find out how to call back to VB from onHandleBreakPoint
It looks like the product injects the ErrEx class using IActiveScript::AddNamedItem. To provide the same behaviour, Implement IActiveScriptSite::GetItemInfo on the same COM component to return a pointer to an instance of (and the associated TypeInfo for) a COM component that implements the same interface as ErrEx. In your implementation of ErrEx.EnableGlobalErrorHandler you would do the following:
CoCreateInstance inproc Process Debug Manager
Cast reference to IRemoteDebugApplication
Register an instance of your IApplicationDebugger component using IRemoteDebugApplication::ConnectDebugger
I glossed over calling IActiveScript::AddNamedItem because I have no idea how you get a pointer to IActiveScript from a running process. Also, I don't know if creating a new instance of the Process Debug Manager will work, or if you somehow have to hook into an existing instance.
I apologize for the confusing explanation, missing information, and glossing over large parts of the process, but this is going waaay back...
You will want to read the Active Scripting APIs article at MSDN.

Emulate Motion API on an emulator

I am developing an app which uses a accelerometer + compass sensor and I would like to run it the emulator. The problem with that is that Mango only allow to emulate Acceleromter, but it doesn't to emulate Motion.
I thought of creating a Mock object using the same base class as Motion does (SensorBase - abstract class), however it's constructor is internal and I can't inherit from it :/
Any ideas how to overcome it?
I have solved it by wrapping a Motion service inside an object which exposes the functionality of the motion service using ReactiveExtensions.
So in the end I would simple have to emulate a sequence of numbers.

Are there MVC embedded system GUI examples?

I'd like to apply the MVC pattern to a GUI we are developing for an embedded system. In this case my understanding is we would need to provide the underlying framework for listener/event actions between the Controller and View. Also, I have seen some examples where the Model send an event to the View, but perhaps that is not correct. Does that seem correct?
Does anyone know of a framework targeted to embedded devices that may have this capability?
If your embedded device supports Java, eRCP would be the best GUI framework in that case.
Check out: http://www.eclipse.org/ercp/
Model sends event to view is a way to notify the view updated about things has been changed in model. It's normal communication between M & V in MVC. However, the "view" here should be a generic view which is bound via an "observable" interface, not a concrete one.
For example:
Abstract View: Clock (generic interface)
Concrete View: Digital Clock, Analog Clock <--implementation of Clock
Model: Time <-- "knows" Clock but not Digital or Analog...
I could suggest the Qt Toolkit. But you don't give any mention of your platform capabilities.
If you are working on a linux platform. Try Enlightenment the best GUI I have ever seen.....

Resources