npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-rfid-chainway-c72

v0.2.0

Published

handled module for chainway c72

Readme

react-native-rfid-chainway-c72

handled module for chainway c72

Installation

npm install react-native-rfid-chainway-c72

Usage

import React from 'react';
import {
  StyleSheet,
  Text,
  View,
  Alert,
  Button,
  TextInput,
} from 'react-native';

import {
  deInitializeReader,
  readPower,
  readSingleTag,
  startReadingTags,
  stopReadingTags,
  initializeReader,
  powerListener,
  tagListener,
  writeDataIntoEpc,
} from 'react-native-rfid-chainway-c72';
const App = () => {
  const [isReading, setIsReading] = React.useState();
  const [powerState, setPowerState] = React.useState('');
  const [tags, setTags] = React.useState([]);
  const [value, setValue] = React.useState("123456789012345678901234");

  const showAlert = (title: string, data: string | undefined) => {
    Alert.alert(
      title,
      data,
      [{ text: 'OK', onPress: () => console.log('OK Pressed') }],
      { cancelable: false }
    );
  };

  const eventListenerPower = (data: React.SetStateAction<string>) => {
    console.log(data);
    setPowerState(data);
  };

  const eventListenerTag = (data: any[]) => {
    console.log('tag', data);
    setTags((tags) => tags.concat(data[0]));
  };

  React.useEffect(() => {
    loadData();

    return () => deInitializeReader();
  }, []);

  const loadData = async () => {
    console.log('loadData');
    await initializeReader();
    powerListener(eventListenerPower);
    tagListener(eventListenerTag);
  };

  const handlerReadPower = async () => {
    try {
      let result = await readPower();
      showAlert('SUCCESS', `The result is ${result}`);
      console.log(result);
    } catch (error) {
      showAlert('FAILED', error.message);
    }
  };

  const handlerScanSingleTag = async () => {
    try {
      let result = await readSingleTag();
      showAlert('SUCCESS', `The result is ${result}`);
      console.log(result);
    } catch (error) {
      showAlert('FAILED', error.message);
    }
  };

  const handlerStartReading = () => {
    startReadingTags(function success(message) {
      console.log({ tags, message });
      setIsReading(message);
    });
  };

  const handlerStopReading = () => {
    stopReadingTags(function success(message) {
      console.log({ message })
      setIsReading(false);
    });

    /**
     * When I stop scanning I immediately return the tags in my state
     * (You could render a view or do whatever you want with the data)
     */
    console.log({ tags });
  };

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <View>
        <Text>{powerState}</Text>
      </View>

      <View style={{ marginVertical: 20 }}>
        <Button
          style={{ margin: 10 }}
          onPress={() => handlerReadPower()}
          title="Read Power"
        />
      </View>

      <View style={{ marginVertical: 20 }}>
        <Button
          style={{ margin: 10 }}
          onPress={() => handlerScanSingleTag()}
          title="Read Single Tag"
        />
      </View>

      <View style={{ marginVertical: 20 }}>
        <Button
          disabled={isReading}
          style={{ margin: 10 }}
          onPress={() => handlerStartReading()}
          title="Start Bulk Scan"
        />
      </View>

      <View style={{ marginVertical: 20 }}>
        <Button
          disabled={!isReading}
          style={{ margin: 10 }}
          onPress={() => handlerStopReading()}
          title="Stop Bulk Scan"
        />
      </View>

      <TextInput
        style={styles.input}
        onChangeText={value => setValue(value)}
        maxLength={24}
        value={value}
        placeholder="Digite aqui..."
      />

      <View style={{ marginVertical: 20 }}>
        <Button
          style={{ margin: 10 }}
          onPress={() => writeDataIntoEpc(value)}
          title="Write Data"
        />
      </View>

    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    padding: 20,
    backgroundColor: '#f0f0f0',
  },
  input: {
    height: 40,
    width: 250,
    borderColor: '#ccc',
    borderWidth: 1,
    borderRadius: 5,
    paddingHorizontal: 10,
    backgroundColor: '#fff',
  },
});

export default App;

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library