Angular, Ionic and the Texas Instrument SensorTag

Hello everybody, I’m trying to create an app to manage Ti SensorTag 2.
Ti Sensor Tag is a cheap module with a lot of sensor:

It can be used for beacon, temperature, tilt detection, light etc etc etc…
You can manage the sensor using a js library created by Evothing,

This is the HTML sample app provided by Evothing:

I’m trying to create a module to manage the sensor inside Angular and so with Ionic.

I have this code:

angular.module('sensor', [])

.run( (evothings, sensor) => {

.factory( 'evothings', ()=> {
  // fake global deps
  return {
    tisensortag: {
      createInstance: angular.noop,
      ble: {
        status: {},
    scriptsLoaded: ref => ref()

.factory( 'sensor', evothings => {
  let sensortag
  let currentDisplayStatus = ''
  let currentAccelerometerValues = {}
  function statusHandler(status) {
		if (evothings.tisensortag.ble.status.SENSORTAG_ONLINE === status) {
			// displaySprite()
  function errorHandler(error) {
    if (evothings.easyble.error.DISCONNECTED === error)
			// sprite.hide()
			setDisplayStatus('Error: ' + error)
  function accelerometerHandler(data) {
    var values = sensortag.getAccelerometerValues(data)
    currentAccelerometerValues = {
      rawX: values.x,
      rawY: values.y,
      degreeX: values.x/ 10*90,
      degreeY: values.y/ 10*90
  function setDisplayStatus(status){
    currentDisplayStatus = status
  return {
    get displayStatus() {
      return currentDisplayStatus
    get accelerometerValues() {
      return currentAccelerometerValues
    initialise() {
      // Create SensorTag CC2650 instance.
		  sensortag = evothings.tisensortag
  		// Set up callbacks and sensors.
			  .accelerometerCallback(accelerometerHandler, 200)
    connect() {
    disconnect() {

I cannot understand how to save in the scope the callbacks, for example the connection status and the accelerometer value.

Can you help me?


Nice to see that you’re using Evothings libraries!

I tried running your code but have some troubles getting it parsed correctly, as I haven’t worked with ECMAScript 6 before. Please supply a fully working example including all dependencies and I’ll be able to try to help you.


I’m refactoring the code using javascript!

@robypez did you get this to work? I’m trying to do the same thing and I’m struggling to convert the evothings code to an angular module