Skip to content

Commit

Permalink
allow setting APN (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
DomAmato authored Apr 27, 2021
1 parent e205937 commit bacbf38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Hologram/Network/Modem/BG96.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def set_network_registration_status(self):
def _set_up_pdp_context(self):
if self._is_pdp_context_active(): return True
self.logger.info('Setting up PDP context')
self.set('+QICSGP', '1,1,\"hologram\",\"\",\"\",1')
self.set('+QICSGP', f'1,1,\"{self._apn}\",\"\",\"\",1')
ok, _ = self.set('+QIACT', '1', timeout=30)
if ok != ModemResult.OK:
self.logger.error('PDP Context setup failed')
Expand Down
13 changes: 11 additions & 2 deletions Hologram/Network/Modem/Modem.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(self, device_name=None, baud_rate='9600',
self.result = ModemResult.OK
self.debug_out = ''
self.in_ext = False
self._apn = 'hologram'

self._initialize_device_name(device_name)

Expand Down Expand Up @@ -711,7 +712,7 @@ def _is_pdp_context_active(self):
def _set_up_pdp_context(self):
if self._is_pdp_context_active(): return True
self.logger.info('Setting up PDP context')
self.set('+UPSD', '0,1,\"hologram\"')
self.set('+UPSD', f'0,1,\"{self._apn}\"')
self.set('+UPSD', '0,7,\"0.0.0.0\"')
ok, _ = self.set('+UPSDA', '0,3', timeout=30)
if ok != ModemResult.OK:
Expand Down Expand Up @@ -913,11 +914,19 @@ def remoteIPAddress(self):
else:
return None


@property
def version(self):
raise NotImplementedError('This modem does not support this property')

@property
def imei(self):
return self._basic_command('+GSN')

@property
def apn(self):
return self._apn

@apn.setter
def apn(self, apn):
self._apn = apn
return self.set('+CGDCONT', f'1,"IP","{self._apn}"')

0 comments on commit bacbf38

Please sign in to comment.