aclec / expo-zebra-scanner

14 stars 6 forks source link

Added support for sending broadcasts to Datawedge API #18

Closed Shadic78 closed 3 months ago

Shadic78 commented 3 months ago

Added sendActionCommand() and sendBroadcast() functions.

With these functions you can send messages to Datawedge API to do things like create and configure profiles with code.

An example is available in the readme and example folder.

The code is a port of react-native-datawedge-intents done with minimum effort.

Tested with a Zebra TC21 and MC33

aclec commented 3 months ago

Thank you for this great PR!

I was wondering, wouldn't it be better to expose a function like createDataWedgeProfile() that, with default parameters, would allow us to create profiles much more quickly instead of rewriting everything each time?

Shadic78 commented 3 months ago

@aclec I didn't thought about that, it's a great idea to avoid boilerplate code. Already commited it.

aclec commented 3 months ago

Great!
One more question: shouldn't we add some additional parameters to the function to configure it directly, such as barcode type, UPDATE/NEW Profile, etc.?
By using proper TypeScript types?
Not necessarily the complete JSON objects, but just the parameters, and we can generate the JSONs with the basic parameters. Otherwise, they would generate their own function.

Shadic78 commented 3 months ago

There a lot of decoders you can choose

I don't want to make types for that, maybe you could do it if you want after the next commit I'll do later.

Shadic78 commented 3 months ago

Hi @aclec I added support for custom decoders when you create a intent profile and a new example, check it out.

Update: I just realized some things like package name and other things aren't right in the example, I'll fix it tomorrow.

aclec commented 3 months ago

There a lot of decoders you can choose

I don't want to make types for that, maybe you could do it if you want after the next commit I'll do later.

I will make types later

aclec commented 3 months ago

Hi @aclec I added support for custom decoders when you create a intent profile and a new example, check it out.

Update: I just realized some things like package name and other things aren't right in the example, I'll fix it tomorrow.

Tell me when it's ok and I will merge the PR.

Shadic78 commented 3 months ago

@aclec Alright, I rewrote the example to show how to use the package with expo router and how to change settings on the fly. There are a lot of things that can be improved and added but I think the package now provides enough functionality to satisfy my needs and other people's for basic usage of datawedge with Expo SDK 50+.

I think I'm done with what I wanted to implement, check it out, I'll listen if you have suggestions. Maybe I'll improve profile creation to avoid resetting settings but that can be in other PR.

Example app Example app