How to generate QR code for every prediction? - flutter

I've created a mobile app with Flutter framework that can predict laptop prices. Now, I want to add a special functionality: for every prediction the user does, I want the app to generate a QR Code with the price, so that another user scan it, and it will automatically fill his characteristics like the other user.

Your QR code generator string must contain all characteristics that the creator entered
Ex.:
User x created a computer with 16GB ram & Core i7 7700HQ etc..
the generator string should be
{"ram":"16gb","cpu":"i7 7700hq",...}
you can use a Map<String, String> for the entered characteristics and use jsonEncode(yourMap) to convert it to string and pass it the the QR Code generator
when the receiver scan the QR Code, he will get {"ram":"16gb","cpu":"i7 7700hq",...}, use jsonDecode(yourMap) to reconvert the string to Map<String, String> characteristics in your receiver's device, predict the price according to what you got in the map

there is a package called qr_flutter you can throw data to it and it will generate a QR code for the user
package : https://pub.dev/packages/qr_flutter

Related

How to save models in pytorch from tpu to cpu

I am training a Neural Network model with pytorch.
Since this model is very complicated, I made use of the pytorch_xla package to use TPU. I finished training the model and now I want to save the weight so I will be able to use them from any envrionment.
I tried to save the data like so
file_name = "model_params"
torch.save(model.state_dict(), file_name)
and when I tried to load them (from environment which does not support TPU)
model.load_state_dict(torch.load(file name))
I got the following error
NotImplementedError: Could not run 'aten::empty_strided' with arguments from the 'XLA' backend. This could be because the operator doesn't exist for this backend, or was omitted during the selective/custom build process (if using custom build). If you are a Facebook employee using PyTorch on mobile, please visit https://fburl.com/ptmfixes for possible resolutions. 'aten::empty_strided' is only available for these backends: [CPU, Meta, BackendSelect, Named, ADInplaceOrView, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, UNKNOWN_TENSOR_TYPE_ID, AutogradMLC, AutogradHPU, AutogradNestedTensor, AutogradPrivateUse1, AutogradPrivateUse2, AutogradPrivateUse3, Tracer, Autocast, Batched, VmapMode].
Is there a way to do what I want?

Reading Dogbone (Magnus 3) sensor tags with Zebra RFD8500

I'am trying to read the new sensor tags Dogbone, (with Magnus S3 IC) but I don't have luck.
I'am using Zebra RFD8500 and programming with the Zebra SDK for Android.
I want to read the RSSI or the temperature values, but it seems the problem is with the Select command.
In either case, it is a two step procedure : 1) select command to match a specific tag pattern in a specific pointer address at the MEMORY_USER_BANK. Then the IC detect that have to store
the solicited value in a specific address at the MEMORY_RESERVED_BANK and 2) read the value, from the specific address at the MEMORY_RESERVED_BANK.
For the Select command (C1G2) I tried with Access-filters and Pre-Filters, but although the tag is matched, the IC doesn't store a value in the RESERVED Bank.
Somebody knows if Zebra APIs support the reading of this newers tags ? Or suggest me any other test?
Thanks a lot for your help
Regards.
It's possible to read the RSSI value with EPC Gen2 tags, so if the tag you're referring to supports this standard it should work.
Try downloading the Zebra RFID sample app > Perform inventory > If the tag is found it should display the RSSI. The sample app code can be found here
As for the temperature values try reading the USER memory in the sample app as well to see if you can get it.
I suggest using the SLS smartSLED; it has built-in functionality for the Magnus (Axzon) chip family (both S2 and S3).

Flutter Bluetooth printing to Zebra

I need to add printing functionality on a zebra zq520 bluetooth thermal printer.
I manage to do so using the flutter_blue plugin but I am not happy with the implementation.
I hate to break the string to smaller chunks in order to pass through bluetooth (and wait!!!!!).
I was wondering if there is a better approach, like the one we used in the (good?) old days of java for android using the android.bluetooth.BluetoothAdapter class
Thanks.
I ended up creating my own plugin.
source code
EDIT: 2021/11/29 integrate some comments from comments section
This code is not limited to zpl. In theory it can support every printer language that sends clear text to bluetooth serial
It is only for Android
For this source code to works as is:
You have to pair a bluetooth printer with name that starts with "zebra"
You have to send the zpl commands as string.
The easiest way to check that your zpl command is valid, is by using the ultra useful labelary viewer. The easiest way to test a label layout (font size, images, barcodes etc) is by using the above free service. in fact all you have to do, is to create the layout you need in labelary and the just copy the entire string from first ^XA to last ^XZ to FlutterCblue.printToBT. For example if you send this
printToBT("^XA
^FX Top section with logo, name and address.
^CF0,60
^FO50,50^GB100,100,100^FS
^FO75,75^FR^GB100,100,100^FS
^FO93,93^GB40,40,40^FS
^FO220,50^FDIntershipping, Inc.^FS
^CF0,30
^FO220,115^FD1000 Shipping Lane^FS
^FO220,155^FDShelbyville TN 38102^FS
^FO220,195^FDUnited States (USA)^FS
^FO50,250^GB700,3,3^FS
^FX Second section with recipient address and permit information.
^CFA,30
^FO50,300^FDJohn Doe^FS
^FO50,340^FD100 Main Street^FS
^FO50,380^FDSpringfield TN 39021^FS
^FO50,420^FDUnited States (USA)^FS
^CFA,15
^FO600,300^GB150,150,3^FS
^FO638,340^FDPermit^FS
^FO638,390^FD123456^FS
^FO50,500^GB700,3,3^FS
^FX Third section with bar code.
^BY5,2,270
^FO100,550^BC^FD12345678^FS
^FX Fourth section (the two boxes on the bottom).
^FO50,900^GB700,250,3^FS
^FO400,900^GB3,250,3^FS
^CF0,40
^FO100,960^FDCtr. X34B-1^FS
^FO100,1010^FDREF1 F00B47^FS
^FO100,1060^FDREF2 BL4H8^FS
^CF0,190
^FO470,955^FDCA^FS
^XZ")
You will get this:
One more thing: keep in mind that if you want to print special language characters (I need to print Greek) you have to find the correct font that is installed in your printer. For example: In order to print Greek characters I have to integrate this
^CWN,E:TT0003M_.FNT
just after the first ^XA. Then I use the N font in order to print Greek. It is very flexible if you understand the basics
Hope it helps

Creating Sample Data in Blend Expressions

I been watching TechDays 2010 Understanding MVVM and at one point he talks about blend and creating sample data but instead of generating it in blend he makes the data in C# code.
I am wondering if you create sample data(from sample class,new sample data and etc) does it save it somewhere in the project(ie I give my project to someone else will they see the same data in blend when they load up the project)? Can you switch from sample data and live data easily?
Sample data is just an xaml (not just xml) file defining your object graph that is marked with the build types DesignData or DesignDataWithDesignTimeCreatableTypes. The docs are sparse on MSDN, but this document about its use in the Silverlight designer is essentially the same in any xaml designer in 2012.
There is no "live data" when using these types of samples. All the values are set in the xaml file. You can't change the data for, say, a particular text box within the designer. Nor can you easily switch between different samples.
There are two ways to create the sample data--you can build it by hand (if you know your types and if you are comfortable writing xaml), or you can spin up a simple console application, build your object graph, then use the XamlServices class to serialize your graph to a string (or just rewrite to drop it to a stream instead). Here's some C# pseudocode that may or may not work as written:
public string Serialize(object toSerialize)
{
var sb = new StringBuilder();
var writer = XmlWriter.Create(sb);
XamlServices.Save(writer, toSerialize);
writer.Flush();
writer.Close();
return sb.ToString();
}
You just create a new file, give it an .xaml extension, drop the result in that file, save it to your solution, and set its Build Action to DesignData (the designer mocks the structure of your types) or DesignTimeDataWithDesignTimeCreatableTypes (the latter if your graph can be deserialized with XamlServices, doesn't throw any exceptions when used in the designer, etc).

iOS: How to build a table from a JSON Query?

I got a JSON response with a lot of data.
(e.g.: Private Messages).
How to display them into a table?
I mean in C#.net I normaly would have a class (PM) with a lot of Properties (sender, reciever, subject, text) and make a database-query (here JSON) and fill it in a list of my class (List pmList = new pmLIst();).
How to do it in Objective C for iPhone?
Have a look at SBJson. The TweetStream example project shows how to fetch data over an HTTP connection and parse it. If the data contains a list of objects you'll find those in an NSArray in your parsed data; at that point it's simply a matter of using a UITableView to display the data.
Have a look at restkit. It's a nice framework for parsing JSON and putting it into the right structure. The examples provided there should get you started.