Beispiel #1
0
 def setAdvertising(self, enabled):
     """
         Enable/ disable the advertising
         :param enabled: Boolean
         :return:
     """
     self._send(UartWrapper(UartTxType.ENABLE_ADVERTISEMENT, self._getPayload(enabled)).getPacket())
Beispiel #2
0
 def toggleVoltageChannelPin(self):
     """
         Select the measurement pin for the voltage sensing
         :param pin: int [0 .. 255]
         :return:
     """
     self._send(UartWrapper(UartTxType.ADC_CONFIG_VOLTAGE_PIN, []).getPacket())
Beispiel #3
0
 def setSendFilteredCurrentSamples(self, enabled):
     """
         Enable/ disable the sending of the filtered current sample buffer.
         :param enabled: Boolean
         :return:
     """
     self._send(UartWrapper(UartTxType.POWER_LOG_FILTERED_CURRENT, self._getPayload(enabled)).getPacket())
 def toggleRelay(self, isOn):
     val = 0
     if isOn:
         val = 1
     switchPacket = ControlPacket(
         ControlType.RELAY).loadUInt8(val).getPacket()
     self._send(UartWrapper(UartTxType.CONTROL, switchPacket).getPacket())
Beispiel #5
0
 def setDifferentialModeVoltage(self, enabled):
     """
         Enable/disable differential mode on the voltage sensing
         :param enabled: Boolean
         :return:
     """
     self._send(UartWrapper(UartTxType.ADC_CONFIG_DIFFERENTIAL_VOLTAGE, self._getPayload(enabled)).getPacket())
Beispiel #6
0
 def setMeshing(self, enabled):
     """
         Enable/ disable the Meshing
         :param enabled: Boolean
         :return:
     """
     self._send(UartWrapper(UartTxType.ENABLE_MESH, self._getPayload(enabled)).getPacket())
Beispiel #7
0
 def setDifferentialModeCurrent(self, enabled):
     """
         Enable/disable differential mode on the current sensing
         :param enabled: Boolean
         :return:
     """
     self._send(UartWrapper(UartTxType.ADC_CONFIG_DIFFERENTIAL_CURRENT, self._getPayload(enabled)).getPacket())
Beispiel #8
0
 def setSendFilteredVoltageSamples(self, enabled):
     """
         Enable/ disable the sending of the filtered voltage sample buffer.
         :param enabled: Boolean
         :return:
     """
     self._send(UartWrapper(UartTxType.POWER_LOG_FILTERED_VOLTAGE, self._getPayload(enabled)).getPacket())
Beispiel #9
0
 def setSendCalculatedSamples(self, enabled):
     """
         Enable/ disable the sending of the calculated power samples.
         :param enabled: Boolean
         :return:
     """
     self._send(UartWrapper(UartTxType.POWER_LOG_CALCULATED_POWER, self._getPayload(enabled)).getPacket())
 def toggleIGBTs(self, isOn):
     val = 0
     if isOn:
         val = 100
     switchPacket = ControlPacket(
         ControlType.PWM).loadUInt8(val).getPacket()
     self._send(UartWrapper(UartTxType.CONTROL, switchPacket).getPacket())
Beispiel #11
0
 def resetCrownstone(self):
     """
         Reset the Crownstone
         :return:
     """
     resetPacket = ControlPacket(ControlType.RESET).getPacket()
     self._send(UartWrapper(UartTxType.CONTROL, resetPacket).getPacket())
 def toggleAllowDimming(self, isOn):
     val = 0
     if isOn:
         val = 1
     instructionPacket = ControlPacket(
         ControlType.ALLOW_DIMMING).loadUInt8(val).getPacket()
     self._send(
         UartWrapper(UartTxType.CONTROL, instructionPacket).getPacket())
 def decreaseCurrentRange(self):
     """
         Decrease the GAIN on the current sensing
         :return:
     """
     self._send(
         UartWrapper(UartTxType.ADC_CONFIG_DEC_RANGE_CURRENT,
                     []).getPacket())
 def decreaseVoltageRange(self):
     """
         Decrease the GAIN on the voltage sensing
         :return:
     """
     self._send(
         UartWrapper(UartTxType.ADC_CONFIG_DEC_RANGE_VOLTAGE,
                     []).getPacket())
Beispiel #15
0
    def uartEcho(self, payloadString):
        # wrap that in a control packet
        controlPacket = ControlPacket(ControlType.UART_MESSAGE).loadString(payloadString).getPacket()
    
        # finally wrap it in an Uart packet
        uartPacket = UartWrapper(UartTxType.CONTROL, controlPacket).getPacket()

        # send over uart
        BluenetEventBus.emit(SystemTopics.uartWriteData, uartPacket)
Beispiel #16
0
 def setUartMode(self, mode):
     """
         Set UART mode.
         :param mode: : 0=none 1=RX only, 2=TX only, 3=TX and RX
         :return:
     """
     if ((mode < 0) or (mode > 3)):
         return
     controlPacket = ControlStateSetPacket(StateType.UART_ENABLED).loadUInt8(mode).getPacket()
     self._send(UartWrapper(UartTxType.CONTROL, controlPacket).getPacket())
Beispiel #17
0
    def __switchCrownstone(self, crownstoneId, value):
        """
        :param crownstoneId:
        :param value: 0 .. 1
        :return:
        """

        # forcibly map the input from [any .. any] to [0 .. 1]
        correctedValue = min(1,max(0,value))

        # create a stone switch state packet to go into the multi switch
        stoneSwitchPacket     = StoneMultiSwitchPacket(crownstoneId, correctedValue, 0, IntentType.MANUAL)

        # wrap it in a mesh multi switch packet
        meshMultiSwitchPacket = MeshMultiSwitchPacket(MeshMultiSwitchType.SIMPLE_LIST, [stoneSwitchPacket]).getPacket()

        # wrap that in a control packet
        controlPacket         = ControlPacket(ControlType.MESH_MULTI_SWITCH).loadByteArray(meshMultiSwitchPacket).getPacket()

        # finally wrap it in an Uart packet
        uartPacket            = UartWrapper(UartTxType.CONTROL, controlPacket).getPacket()

        # send over uart
        BluenetEventBus.emit(SystemTopics.uartWriteData, uartPacket)
Beispiel #18
0
 def requestMacAddress(self):
     """
         Request the MAC address ID.
         :return:
     """
     self._send(UartWrapper(UartTxType.GET_MAC_ADDRESS, []).getPacket())
Beispiel #19
0
 def requestCrownstoneId(self):
     """
         Request the Crownstone ID. This is a uint16
         :return:
     """
     self._send(UartWrapper(UartTxType.GET_CROWNSTONE_ID, []).getPacket())